@@ -13,47 +13,27 @@ class IzlyQrcodeWidget extends StatelessWidget {
13
13
const IzlyQrcodeWidget ({super .key});
14
14
15
15
Color calculateWarningColor (BuildContext context) {
16
- if (context
17
- .read <IzlyCubit >()
18
- .state
19
- .paymentList
20
- .isEmpty) {
21
- if (context
22
- .read <IzlyCubit >()
23
- .state
24
- .izlyClient != null &&
25
- context
26
- .read <IzlyCubit >()
27
- .state
28
- .status == IzlyStatus .loaded) {
16
+ if (context.read <IzlyCubit >().state.paymentList.isEmpty) {
17
+ if (context.read <IzlyCubit >().state.izlyClient != null &&
18
+ context.read <IzlyCubit >().state.status == IzlyStatus .loaded) {
29
19
context.read <IzlyCubit >().loadPaymentHistory ();
30
20
}
31
21
return Colors .transparent;
32
22
}
33
23
34
24
double average = 0.0 ;
35
- for (var i in context
36
- .read <IzlyCubit >()
37
- .state
38
- .paymentList) {
25
+ for (var i in context.read <IzlyCubit >().state.paymentList) {
39
26
if (i.amountSpent < 0 ) {
40
27
average += - i.amountSpent;
41
28
}
42
29
}
43
- average /= context
44
- .read <IzlyCubit >()
45
- .state
46
- .paymentList
47
- .length;
30
+ average /= context.read <IzlyCubit >().state.paymentList.length;
48
31
49
32
final green = 5 * average; //5 times the average should display green
50
33
final red = 2 * average; //2 times the average should display red
51
34
//do a linear interpolation between green and red
52
35
double interpolation =
53
- (context
54
- .read <IzlyCubit >()
55
- .state
56
- .balance - red) / (green - red);
36
+ (context.read <IzlyCubit >().state.balance - red) / (green - red);
57
37
return HSVColor .fromAHSV (1 , (120 * interpolation).clamp (0 , 120 ), 1 , 1 )
58
38
.toColor ();
59
39
}
@@ -118,9 +98,7 @@ class IzlyQrcodeWidget extends StatelessWidget {
118
98
color: Colors .white,
119
99
),
120
100
Text (
121
- AppLocalizations
122
- .of (context)
123
- .unHideQrCode,
101
+ AppLocalizations .of (context).unHideQrCode,
124
102
textAlign: TextAlign .center,
125
103
style: const TextStyle (color: Colors .white),
126
104
),
0 commit comments