CAKE-288 | added possibility to see available and additional balance by pressing on hidden balance (balance_page.dart); fixed switch of display mode on order_list_item.dart and trade_list_item.dart

OleksandrSobol committed Mar 31, 2021 at 19:18 UTC 3da9eb38aa11542ca327ba0dda1e51fcda459914
6 files changed +113 -100
lib/src/screens/dashboard/widgets/balance_page.dart
+92 -84
@@ -13,97 +13,105 @@ class BalancePage extends StatelessWidget {
13 return Container(
14 color: Colors.transparent,
15 padding: EdgeInsets.all(24),
16 - child: Column(
17 - mainAxisAlignment: MainAxisAlignment.center,
18 - crossAxisAlignment: CrossAxisAlignment.center,
19 - children: <Widget>[
20 - Observer(builder: (_) {
21 - return Text(
22 - dashboardViewModel.balanceViewModel.currency.toString(),
23 - style: TextStyle(
24 - fontSize: 40,
25 - fontWeight: FontWeight.bold,
26 - color: Theme.of(context)
27 - .accentTextTheme
28 - .display2
29 - .backgroundColor,
30 - height: 1),
31 - );
32 - }),
33 - SizedBox(height: 10),
34 - Observer(builder: (_) {
35 - return Row(
36 - children: [
37 - Expanded(
38 - child: Text(
39 - '${dashboardViewModel.balanceViewModel.availableBalanceLabel} (${dashboardViewModel.balanceViewModel.availableFiatBalance.toString()})',
40 - textAlign: TextAlign.center,
41 - style: TextStyle(
42 - fontSize: 12,
43 - fontWeight: FontWeight.w600,
44 - color: Theme.of(context)
45 - .accentTextTheme
46 - .display2
47 - .backgroundColor,
48 - height: 1),
49 - )
50 - )
51 - ],
52 - );
53 - }),
54 - SizedBox(height: 10),
55 - Observer(builder: (_) {
56 - return AutoSizeText(
57 - dashboardViewModel.balanceViewModel.availableBalance,
16 + child: GestureDetector(
17 + onLongPress: () =>
18 + dashboardViewModel.balanceViewModel.isReversing =
19 + !dashboardViewModel.balanceViewModel.isReversing,
20 + onLongPressUp: () =>
21 + dashboardViewModel.balanceViewModel.isReversing =
22 + !dashboardViewModel.balanceViewModel.isReversing,
23 + child: Column(
24 + mainAxisAlignment: MainAxisAlignment.center,
25 + crossAxisAlignment: CrossAxisAlignment.center,
26 + children: <Widget>[
27 + Observer(builder: (_) {
28 + return Text(
29 + dashboardViewModel.balanceViewModel.currency.toString(),
30 style: TextStyle(
59 - fontSize: 54,
31 + fontSize: 40,
32 fontWeight: FontWeight.bold,
33 color: Theme.of(context)
34 .accentTextTheme
63 - .display3
35 + .display2
36 .backgroundColor,
37 height: 1),
66 - maxLines: 1,
67 - textAlign: TextAlign.center);
68 - }),
69 - SizedBox(height: 10),
70 - Observer(builder: (_) {
71 - return Row(
72 - children: [
73 - Expanded(
74 - child: Text(
75 - '${dashboardViewModel.balanceViewModel.additionalBalanceLabel} (${dashboardViewModel.balanceViewModel.additionalFiatBalance.toString()})',
76 - textAlign: TextAlign.center,
77 - style: TextStyle(
78 - fontSize: 12,
79 - fontWeight: FontWeight.w600,
80 - color: Theme.of(context)
81 - .accentTextTheme
82 - .display2
83 - .backgroundColor,
84 - height: 1),
38 + );
39 + }),
40 + SizedBox(height: 10),
41 + Observer(builder: (_) {
42 + return Row(
43 + children: [
44 + Expanded(
45 + child: Text(
46 + '${dashboardViewModel.balanceViewModel.availableBalanceLabel} (${dashboardViewModel.balanceViewModel.availableFiatBalance.toString()})',
47 + textAlign: TextAlign.center,
48 + style: TextStyle(
49 + fontSize: 12,
50 + fontWeight: FontWeight.w600,
51 + color: Theme.of(context)
52 + .accentTextTheme
53 + .display2
54 + .backgroundColor,
55 + height: 1),
56 + )
57 )
86 - )
87 - ],
88 - );
89 - }),
90 - SizedBox(height: 10),
91 - Observer(builder: (_) {
92 - return AutoSizeText(
93 - dashboardViewModel.balanceViewModel.additionalBalance
94 - .toString(),
95 - style: TextStyle(
96 - fontSize: 18,
97 - fontWeight: FontWeight.bold,
98 - color: Theme.of(context)
99 - .accentTextTheme
100 - .display3
101 - .backgroundColor,
102 - height: 1),
103 - maxLines: 1,
104 - textAlign: TextAlign.center);
105 - }),
106 - ],
58 + ],
59 + );
60 + }),
61 + SizedBox(height: 10),
62 + Observer(builder: (_) {
63 + return AutoSizeText(
64 + dashboardViewModel.balanceViewModel.availableBalance,
65 + style: TextStyle(
66 + fontSize: 54,
67 + fontWeight: FontWeight.bold,
68 + color: Theme.of(context)
69 + .accentTextTheme
70 + .display3
71 + .backgroundColor,
72 + height: 1),
73 + maxLines: 1,
74 + textAlign: TextAlign.center);
75 + }),
76 + SizedBox(height: 10),
77 + Observer(builder: (_) {
78 + return Row(
79 + children: [
80 + Expanded(
81 + child: Text(
82 + '${dashboardViewModel.balanceViewModel.additionalBalanceLabel} (${dashboardViewModel.balanceViewModel.additionalFiatBalance.toString()})',
83 + textAlign: TextAlign.center,
84 + style: TextStyle(
85 + fontSize: 12,
86 + fontWeight: FontWeight.w600,
87 + color: Theme.of(context)
88 + .accentTextTheme
89 + .display2
90 + .backgroundColor,
91 + height: 1),
92 + )
93 + )
94 + ],
95 + );
96 + }),
97 + SizedBox(height: 10),
98 + Observer(builder: (_) {
99 + return AutoSizeText(
100 + dashboardViewModel.balanceViewModel.additionalBalance
101 + .toString(),
102 + style: TextStyle(
103 + fontSize: 18,
104 + fontWeight: FontWeight.bold,
105 + color: Theme.of(context)
106 + .accentTextTheme
107 + .display3
108 + .backgroundColor,
109 + height: 1),
110 + maxLines: 1,
111 + textAlign: TextAlign.center);
112 + }),
113 + ],
114 + ),
115 ),
116 );
117 }
lib/store/dashboard/orders_store.dart
+1 -1
@@ -41,5 +41,5 @@ abstract class OrdersStoreBase with Store {
41 Future updateOrderList() async => orders =
42 ordersSource.values.map((order) => OrderListItem(
43 order: order,
44 - displayMode: settingsStore.balanceDisplayMode)).toList();
44 + settingsStore: settingsStore)).toList();
45 }
\ No newline at end of file
lib/store/dashboard/trades_store.dart
+1 -2
@@ -1,7 +1,6 @@
1 import 'dart:async';
2 import 'package:cake_wallet/exchange/trade.dart';
3 import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart';
4 -import 'package:flutter/cupertino.dart';
4 import 'package:hive/hive.dart';
5 import 'package:mobx/mobx.dart';
6 import 'package:cake_wallet/store/settings_store.dart';
@@ -37,5 +36,5 @@ abstract class TradesStoreBase with Store {
36 Future updateTradeList() async => trades =
37 tradesSource.values.map((trade) => TradeListItem(
38 trade: trade,
40 - displayMode: settingsStore.balanceDisplayMode)).toList();
39 + settingsStore: settingsStore)).toList();
40 }
\ No newline at end of file
lib/view_model/dashboard/balance_view_model.dart
+7 -7
@@ -69,9 +69,9 @@ abstract class BalanceViewModelBase with Store {
69
70 @computed
71 BalanceDisplayMode get displayMode => isReversing
72 - ? (savedDisplayMode == BalanceDisplayMode.availableBalance
73 - ? BalanceDisplayMode.fullBalance
74 - : BalanceDisplayMode.availableBalance)
72 + ? savedDisplayMode == BalanceDisplayMode.hiddenBalance
73 + ? BalanceDisplayMode.displayableBalance
74 + : savedDisplayMode
75 : savedDisplayMode;
76
77 @computed
@@ -96,7 +96,7 @@ abstract class BalanceViewModelBase with Store {
96 String get availableBalance {
97 final walletBalance = _walletBalance;
98
99 - if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) {
99 + if (displayMode == BalanceDisplayMode.hiddenBalance) {
100 return '---';
101 }
102
@@ -107,7 +107,7 @@ abstract class BalanceViewModelBase with Store {
107 String get additionalBalance {
108 final walletBalance = _walletBalance;
109
110 - if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) {
110 + if (displayMode == BalanceDisplayMode.hiddenBalance) {
111 return '---';
112 }
113
@@ -119,7 +119,7 @@ abstract class BalanceViewModelBase with Store {
119 final walletBalance = _walletBalance;
120 final fiatCurrency = settingsStore.fiatCurrency;
121
122 - if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) {
122 + if (displayMode == BalanceDisplayMode.hiddenBalance) {
123 return '---';
124 }
125
@@ -135,7 +135,7 @@ abstract class BalanceViewModelBase with Store {
135 final walletBalance = _walletBalance;
136 final fiatCurrency = settingsStore.fiatCurrency;
137
138 - if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) {
138 + if (displayMode == BalanceDisplayMode.hiddenBalance) {
139 return '---';
140 }
141
lib/view_model/dashboard/order_list_item.dart
+7 -4
@@ -1,18 +1,21 @@
1 import 'package:cake_wallet/entities/order.dart';
2 +import 'package:cake_wallet/store/settings_store.dart';
3 import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
4 import 'package:cake_wallet/entities/balance_display_mode.dart';
5
6 class OrderListItem extends ActionListItem {
6 - OrderListItem({this.order, this.displayMode});
7 + OrderListItem({this.order, this.settingsStore});
8
9 final Order order;
9 - final BalanceDisplayMode displayMode;
10 + final SettingsStore settingsStore;
11 +
12 + BalanceDisplayMode get displayMode => settingsStore.balanceDisplayMode;
13
14 String get orderFormattedAmount {
15 return order.amount != null
16 ? displayMode == BalanceDisplayMode.hiddenBalance
14 - ? '---'
15 - : order.amountFormatted()
17 + ? '---'
18 + : order.amountFormatted()
19 : order.amount;
20 }
21
lib/view_model/dashboard/trade_list_item.dart
+5 -2
@@ -1,12 +1,15 @@
1 import 'package:cake_wallet/exchange/trade.dart';
2 +import 'package:cake_wallet/store/settings_store.dart';
3 import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
4 import 'package:cake_wallet/entities/balance_display_mode.dart';
5
6 class TradeListItem extends ActionListItem {
6 - TradeListItem({this.trade, this.displayMode});
7 + TradeListItem({this.trade, this.settingsStore});
8
9 final Trade trade;
9 - final BalanceDisplayMode displayMode;
10 + final SettingsStore settingsStore;
11 +
12 + BalanceDisplayMode get displayMode => settingsStore.balanceDisplayMode;
13
14 String get tradeFormattedAmount {
15 return trade.amount != null