Balance card fixes (#1933)
tuxsudo committed
Jan 4, 2025 at 01:50 UTC
cee3abcb7230669c35b7e8f0a4a5c3f7205caf2f
2 files changed
+160
-197
lib/src/screens/dashboard/pages/balance/balance_row_widget.dart
+155
-192
@@ -78,15 +78,13 @@ class BalanceRowWidget extends StatelessWidget {
78
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
79
),
80
child: TextButton(
81
- onPressed: () =>
82
- Fluttertoast.showToast(
83
- msg: S.current.show_balance_toast,
84
- backgroundColor: Color.fromRGBO(0, 0, 0, 0.85),
85
- ),
81
+ onPressed: () => Fluttertoast.showToast(
82
+ msg: S.current.show_balance_toast,
83
+ backgroundColor: Color.fromRGBO(0, 0, 0, 0.85),
84
+ ),
85
onLongPress: () => dashboardViewModel.balanceViewModel.switchBalanceValue(),
86
style: TextButton.styleFrom(
88
- shape: RoundedRectangleBorder(
89
- borderRadius: BorderRadius.circular(30)),
87
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
88
),
89
child: Container(
90
margin: const EdgeInsets.only(top: 10, left: 12, right: 12, bottom: 10),
@@ -103,11 +101,8 @@ class BalanceRowWidget extends StatelessWidget {
101
GestureDetector(
102
behavior: HitTestBehavior.opaque,
103
onTap: hasAdditionalBalance
106
- ? () =>
107
- _showBalanceDescription(
108
- context, S
109
- .of(context)
110
- .available_balance_description)
104
+ ? () => _showBalanceDescription(
105
+ context, S.of(context).available_balance_description)
106
: null,
107
child: Row(
108
children: [
@@ -150,16 +145,14 @@ class BalanceRowWidget extends StatelessWidget {
145
textAlign: TextAlign.start),
146
SizedBox(height: 6),
147
if (isTestnet)
153
- Text(S
154
- .of(context)
155
- .testnet_coins_no_value,
148
+ Text(S.of(context).testnet_coins_no_value,
149
textAlign: TextAlign.center,
150
style: TextStyle(
151
fontSize: 14,
152
fontFamily: 'Lato',
153
fontWeight: FontWeight.w400,
154
color:
162
- Theme.of(context).extension<BalancePageTheme>()!.textColor,
155
+ Theme.of(context).extension<BalancePageTheme>()!.textColor,
156
height: 1)),
157
if (!isTestnet)
158
Text('${availableFiatBalance}',
@@ -169,7 +162,7 @@ class BalanceRowWidget extends StatelessWidget {
162
fontFamily: 'Lato',
163
fontWeight: FontWeight.w500,
164
color:
172
- Theme.of(context).extension<BalancePageTheme>()!.textColor,
165
+ Theme.of(context).extension<BalancePageTheme>()!.textColor,
166
height: 1)),
167
],
168
),
@@ -218,123 +211,98 @@ class BalanceRowWidget extends StatelessWidget {
211
),
212
//),
213
if (frozenBalance.isNotEmpty)
221
- GestureDetector(
222
- behavior: HitTestBehavior.opaque,
223
- onTap: hasAdditionalBalance
224
- ? () =>
225
- _showBalanceDescription(
226
- context, S
227
- .of(context)
228
- .unavailable_balance_description)
229
- : null,
230
- child: Column(
231
- crossAxisAlignment: CrossAxisAlignment.start,
232
- children: [
233
- SizedBox(height: 26),
234
- Row(
235
- children: [
236
- Text(
237
- S
238
- .of(context)
239
- .unavailable_balance,
240
- textAlign: TextAlign.center,
241
- style: TextStyle(
242
- fontSize: 12,
243
- fontFamily: 'Lato',
244
- fontWeight: FontWeight.w400,
245
- color:
246
- Theme.of(context).extension<BalancePageTheme>()!.labelTextColor,
247
- height: 1,
248
- ),
249
- ),
250
- Padding(
251
- padding: const EdgeInsets.symmetric(horizontal: 4),
252
- child: Icon(Icons.help_outline,
253
- size: 16,
254
- color: Theme.of(context)
255
- .extension<BalancePageTheme>()!
256
- .labelTextColor),
257
- ),
258
- ],
259
- ),
260
- SizedBox(height: 8),
261
- AutoSizeText(
262
- frozenBalance,
263
- style: TextStyle(
264
- fontSize: 20,
265
- fontFamily: 'Lato',
266
- fontWeight: FontWeight.w400,
267
- color:
268
- Theme.of(context).extension<BalancePageTheme>()!.balanceAmountColor,
269
- height: 1,
270
- ),
271
- maxLines: 1,
272
- textAlign: TextAlign.center,
273
- ),
274
- SizedBox(height: 4),
275
- if (!isTestnet)
214
+ Column(
215
+ crossAxisAlignment: CrossAxisAlignment.start,
216
+ children: [
217
+ SizedBox(height: 26),
218
+ Row(
219
+ children: [
220
Text(
277
- frozenFiatBalance,
221
+ S.of(context).frozen_balance,
222
textAlign: TextAlign.center,
223
style: TextStyle(
224
fontSize: 12,
225
fontFamily: 'Lato',
226
fontWeight: FontWeight.w400,
283
- color: Theme.of(context).extension<BalancePageTheme>()!.textColor,
227
+ color:
228
+ Theme.of(context).extension<BalancePageTheme>()!.labelTextColor,
229
height: 1,
230
),
231
),
287
- ],
288
- ),
289
- ),
290
- if (hasAdditionalBalance)
291
- GestureDetector(
292
- onTap: () => dashboardViewModel.balanceViewModel.switchBalanceValue(),
293
- child: Column(
294
- crossAxisAlignment: CrossAxisAlignment.start,
295
- children: [
296
- SizedBox(height: 24),
232
+ ],
233
+ ),
234
+ SizedBox(height: 8),
235
+ AutoSizeText(
236
+ frozenBalance,
237
+ style: TextStyle(
238
+ fontSize: 20,
239
+ fontFamily: 'Lato',
240
+ fontWeight: FontWeight.w400,
241
+ color:
242
+ Theme.of(context).extension<BalancePageTheme>()!.balanceAmountColor,
243
+ height: 1,
244
+ ),
245
+ maxLines: 1,
246
+ textAlign: TextAlign.center,
247
+ ),
248
+ SizedBox(height: 4),
249
+ if (!isTestnet)
250
Text(
298
- '${additionalBalanceLabel}',
251
+ frozenFiatBalance,
252
textAlign: TextAlign.center,
253
style: TextStyle(
254
fontSize: 12,
255
fontFamily: 'Lato',
256
fontWeight: FontWeight.w400,
304
- color: Theme.of(context).extension<BalancePageTheme>()!
305
- .labelTextColor,
257
+ color: Theme.of(context).extension<BalancePageTheme>()!.textColor,
258
height: 1,
259
),
260
),
309
- SizedBox(height: 8),
310
- AutoSizeText(
311
- additionalBalance,
261
+ ],
262
+ ),
263
+ if (hasAdditionalBalance)
264
+ Column(
265
+ crossAxisAlignment: CrossAxisAlignment.start,
266
+ children: [
267
+ SizedBox(height: 24),
268
+ Text(
269
+ '${additionalBalanceLabel}',
270
+ textAlign: TextAlign.center,
271
+ style: TextStyle(
272
+ fontSize: 12,
273
+ fontFamily: 'Lato',
274
+ fontWeight: FontWeight.w400,
275
+ color: Theme.of(context).extension<BalancePageTheme>()!.labelTextColor,
276
+ height: 1,
277
+ ),
278
+ ),
279
+ SizedBox(height: 8),
280
+ AutoSizeText(
281
+ additionalBalance,
282
+ style: TextStyle(
283
+ fontSize: 20,
284
+ fontFamily: 'Lato',
285
+ fontWeight: FontWeight.w400,
286
+ color: Theme.of(context).extension<BalancePageTheme>()!.assetTitleColor,
287
+ height: 1,
288
+ ),
289
+ maxLines: 1,
290
+ textAlign: TextAlign.center,
291
+ ),
292
+ SizedBox(height: 4),
293
+ if (!isTestnet)
294
+ Text(
295
+ '${additionalFiatBalance}',
296
+ textAlign: TextAlign.center,
297
style: TextStyle(
313
- fontSize: 20,
298
+ fontSize: 12,
299
fontFamily: 'Lato',
300
fontWeight: FontWeight.w400,
316
- color: Theme.of(context).extension<BalancePageTheme>()!
317
- .assetTitleColor,
301
+ color: Theme.of(context).extension<BalancePageTheme>()!.textColor,
302
height: 1,
303
),
320
- maxLines: 1,
321
- textAlign: TextAlign.center,
304
),
323
- SizedBox(height: 4),
324
- if (!isTestnet)
325
- Text(
326
- '${additionalFiatBalance}',
327
- textAlign: TextAlign.center,
328
- style: TextStyle(
329
- fontSize: 12,
330
- fontFamily: 'Lato',
331
- fontWeight: FontWeight.w400,
332
- color: Theme.of(context).extension<BalancePageTheme>()!.textColor,
333
- height: 1,
334
- ),
335
- ),
336
- ],
337
- ),
305
+ ],
306
),
307
],
308
),
@@ -353,12 +321,20 @@ class BalanceRowWidget extends StatelessWidget {
321
),
322
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
323
),
356
- child: Container(
324
+ child: TextButton(
325
+ onPressed: () => Fluttertoast.showToast(
326
+ msg: S.current.show_balance_toast,
327
+ backgroundColor: Color.fromRGBO(0, 0, 0, 0.85),
328
+ ),
329
+ onLongPress: () => dashboardViewModel.balanceViewModel.switchBalanceValue(),
330
+ style: TextButton.styleFrom(
331
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
332
+ ),
333
child: Column(
334
crossAxisAlignment: CrossAxisAlignment.start,
335
children: [
336
Container(
361
- margin: const EdgeInsets.only(top: 16, left: 24, right: 8, bottom: 16),
337
+ margin: const EdgeInsets.only(top: 10, left: 12, right: 12, bottom: 10),
338
child: Stack(
339
children: [
340
if (currency == CryptoCurrency.ltc)
@@ -366,7 +342,6 @@ class BalanceRowWidget extends StatelessWidget {
342
mainAxisAlignment: MainAxisAlignment.end,
343
children: [
344
Container(
369
- padding: EdgeInsets.only(right: 16, top: 0),
345
child: Column(
346
children: [
347
Container(
@@ -397,81 +372,77 @@ class BalanceRowWidget extends StatelessWidget {
372
],
373
),
374
if (hasSecondAvailableBalance)
400
- GestureDetector(
401
- onTap: () => dashboardViewModel.balanceViewModel.switchBalanceValue(),
402
- child: Row(
403
- children: [
404
- Column(
405
- crossAxisAlignment: CrossAxisAlignment.start,
406
- children: [
407
- GestureDetector(
408
- behavior: HitTestBehavior.opaque,
409
- onTap: () =>
410
- launchUrl(
411
- Uri.parse(
412
- "https://docs.cakewallet.com/cryptos/litecoin.html#mweb"),
413
- mode: LaunchMode.externalApplication,
375
+ Row(
376
+ children: [
377
+ Column(
378
+ crossAxisAlignment: CrossAxisAlignment.start,
379
+ children: [
380
+ GestureDetector(
381
+ behavior: HitTestBehavior.opaque,
382
+ onTap: () => launchUrl(
383
+ Uri.parse(
384
+ "https://docs.cakewallet.com/cryptos/litecoin#mweb"),
385
+ mode: LaunchMode.externalApplication,
386
+ ),
387
+ child: Row(
388
+ children: [
389
+ Text(
390
+ '${secondAvailableBalanceLabel}',
391
+ textAlign: TextAlign.center,
392
+ style: TextStyle(
393
+ fontSize: 12,
394
+ fontFamily: 'Lato',
395
+ fontWeight: FontWeight.w400,
396
+ color: Theme.of(context)
397
+ .extension<BalancePageTheme>()!
398
+ .labelTextColor,
399
+ height: 1,
400
),
415
- child: Row(
416
- children: [
417
- Text(
418
- '${secondAvailableBalanceLabel}',
419
- textAlign: TextAlign.center,
420
- style: TextStyle(
421
- fontSize: 12,
422
- fontFamily: 'Lato',
423
- fontWeight: FontWeight.w400,
401
+ ),
402
+ Padding(
403
+ padding: const EdgeInsets.symmetric(horizontal: 4),
404
+ child: Icon(Icons.help_outline,
405
+ size: 16,
406
color: Theme.of(context)
407
.extension<BalancePageTheme>()!
426
- .labelTextColor,
427
- height: 1,
428
- ),
429
- ),
430
- Padding(
431
- padding: const EdgeInsets.symmetric(horizontal: 4),
432
- child: Icon(Icons.help_outline,
433
- size: 16,
434
- color: Theme.of(context)
435
- .extension<BalancePageTheme>()!
436
- .labelTextColor),
437
- )
438
- ],
439
- ),
408
+ .labelTextColor),
409
+ )
410
+ ],
411
+ ),
412
+ ),
413
+ SizedBox(height: 8),
414
+ AutoSizeText(
415
+ secondAvailableBalance,
416
+ style: TextStyle(
417
+ fontSize: 24,
418
+ fontFamily: 'Lato',
419
+ fontWeight: FontWeight.w900,
420
+ color: Theme.of(context)
421
+ .extension<BalancePageTheme>()!
422
+ .assetTitleColor,
423
+ height: 1,
424
),
441
- SizedBox(height: 8),
442
- AutoSizeText(
443
- secondAvailableBalance,
425
+ maxLines: 1,
426
+ textAlign: TextAlign.center,
427
+ ),
428
+ SizedBox(height: 6),
429
+ if (!isTestnet)
430
+ Text(
431
+ '${secondAvailableFiatBalance}',
432
+ textAlign: TextAlign.center,
433
style: TextStyle(
445
- fontSize: 24,
434
+ fontSize: 16,
435
fontFamily: 'Lato',
447
- fontWeight: FontWeight.w900,
436
+ fontWeight: FontWeight.w500,
437
color: Theme.of(context)
438
.extension<BalancePageTheme>()!
450
- .assetTitleColor,
439
+ .textColor,
440
height: 1,
441
),
453
- maxLines: 1,
454
- textAlign: TextAlign.center,
442
),
456
- SizedBox(height: 6),
457
- if (!isTestnet)
458
- Text(
459
- '${secondAvailableFiatBalance}',
460
- textAlign: TextAlign.center,
461
- style: TextStyle(
462
- fontSize: 16,
463
- fontFamily: 'Lato',
464
- fontWeight: FontWeight.w500,
465
- color: Theme.of(context)
466
- .extension<BalancePageTheme>()!
467
- .textColor,
468
- height: 1,
469
- ),
470
- ),
471
- ],
472
- ),
473
- ],
474
- ),
443
+ ],
444
+ ),
445
+ ],
446
),
447
],
448
),
@@ -539,19 +510,17 @@ class BalanceRowWidget extends StatelessWidget {
510
),
511
IntrinsicHeight(
512
child: Container(
542
- padding: EdgeInsets.symmetric(horizontal: 24),
513
+ padding: EdgeInsets.symmetric(horizontal: 12),
514
child: Row(
515
mainAxisAlignment: MainAxisAlignment.spaceBetween,
516
children: [
517
Expanded(
518
child: Semantics(
548
- label: S
549
- .of(context)
550
- .litecoin_mweb_pegin,
519
+ label: S.of(context).litecoin_mweb_pegin,
520
child: OutlinedButton(
521
onPressed: () {
522
final mwebAddress =
554
- bitcoin!.getUnusedMwebAddress(dashboardViewModel.wallet);
523
+ bitcoin!.getUnusedMwebAddress(dashboardViewModel.wallet);
524
PaymentRequest? paymentRequest = null;
525
if ((mwebAddress?.isNotEmpty ?? false)) {
526
paymentRequest = PaymentRequest.fromUri(
@@ -589,9 +558,7 @@ class BalanceRowWidget extends StatelessWidget {
558
),
559
const SizedBox(width: 8),
560
Text(
592
- S
593
- .of(context)
594
- .litecoin_mweb_pegin,
561
+ S.of(context).litecoin_mweb_pegin,
562
style: TextStyle(
563
color: Theme.of(context)
564
.extension<BalancePageTheme>()!
@@ -607,13 +574,11 @@ class BalanceRowWidget extends StatelessWidget {
574
SizedBox(width: 24),
575
Expanded(
576
child: Semantics(
610
- label: S
611
- .of(context)
612
- .litecoin_mweb_pegout,
577
+ label: S.of(context).litecoin_mweb_pegout,
578
child: OutlinedButton(
579
onPressed: () {
580
final litecoinAddress =
616
- bitcoin!.getUnusedSegwitAddress(dashboardViewModel.wallet);
581
+ bitcoin!.getUnusedSegwitAddress(dashboardViewModel.wallet);
582
PaymentRequest? paymentRequest = null;
583
if ((litecoinAddress?.isNotEmpty ?? false)) {
584
paymentRequest = PaymentRequest.fromUri(
@@ -651,9 +616,7 @@ class BalanceRowWidget extends StatelessWidget {
616
),
617
const SizedBox(width: 8),
618
Text(
654
- S
655
- .of(context)
656
- .litecoin_mweb_pegout,
619
+ S.of(context).litecoin_mweb_pegout,
620
style: TextStyle(
621
color: Theme.of(context)
622
.extension<BalancePageTheme>()!
lib/view_model/dashboard/balance_view_model.dart
+5
-5
@@ -218,13 +218,13 @@ abstract class BalanceViewModelBase with Store {
218
availableBalance: '●●●●●●',
219
additionalBalance: additionalBalance,
220
frozenBalance: '',
221
- secondAvailableBalance: '',
222
- secondAdditionalBalance: '',
223
- fiatAdditionalBalance: isFiatDisabled ? '' : '',
221
+ secondAvailableBalance: '●●●●●●',
222
+ secondAdditionalBalance: '●●●●●●',
223
+ fiatAdditionalBalance: isFiatDisabled ? '' : '${fiatCurrency.toString()} ●●●●●',
224
fiatAvailableBalance: isFiatDisabled ? '' : '${fiatCurrency.toString()} ●●●●●',
225
fiatFrozenBalance: isFiatDisabled ? '' : '',
226
- fiatSecondAvailableBalance: isFiatDisabled ? '' : '',
227
- fiatSecondAdditionalBalance: isFiatDisabled ? '' : '',
226
+ fiatSecondAvailableBalance: isFiatDisabled ? '' : '${fiatCurrency.toString()} ●●●●●',
227
+ fiatSecondAdditionalBalance: isFiatDisabled ? '' : '${fiatCurrency.toString()} ●●●●●',
228
asset: key,
229
formattedAssetTitle: _formatterAsset(key)));
230
}