CAKE-79 | added ability to flip balance on dashboard page; added isReversing, displayMode and savedDisplayMode to balance_view_model; added display mode to balance page

OleksandrSobol committed Sep 29, 2020 at 11:45 UTC 1800070fc182e39ef25d8d8c38178566cdddc1c6
4 files changed +74 -55
lib/src/screens/dashboard/widgets/balance_page.dart
+46 -30
@@ -1,6 +1,7 @@
1 import 'package:flutter/material.dart';
2 import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
3 import 'package:flutter_mobx/flutter_mobx.dart';
4 +import 'package:auto_size_text/auto_size_text.dart';
5
6 class BalancePage extends StatelessWidget {
7 BalancePage({@required this.dashboardViewModel});
@@ -11,42 +12,57 @@ class BalancePage extends StatelessWidget {
12 Widget build(BuildContext context) {
13 return Container(
14 padding: EdgeInsets.all(24),
14 - child: Column(
15 - mainAxisAlignment: MainAxisAlignment.center,
16 - crossAxisAlignment: CrossAxisAlignment.center,
17 - children: <Widget>[
18 - Observer(builder: (_) {
19 - return Text(
20 - dashboardViewModel.balanceViewModel.currency.toString(),
21 - style: TextStyle(
22 - fontSize: 40,
23 - fontWeight: FontWeight.bold,
24 - color: Theme.of(context).indicatorColor,
25 - height: 1),
26 - );
27 - }),
28 - SizedBox(height: 10),
29 - Observer(builder: (_) {
30 - return Text(dashboardViewModel.balanceViewModel.cryptoBalance,
15 + child: GestureDetector(
16 + onTapUp: (_) => dashboardViewModel.balanceViewModel.isReversing = false,
17 + onTapDown: (_) => dashboardViewModel.balanceViewModel.isReversing = true,
18 + child: Column(
19 + mainAxisAlignment: MainAxisAlignment.center,
20 + crossAxisAlignment: CrossAxisAlignment.center,
21 + children: <Widget>[
22 + Observer(builder: (_) {
23 + return Text(
24 + dashboardViewModel.balanceViewModel.currency.toString(),
25 style: TextStyle(
32 - fontSize: 54,
26 + fontSize: 40,
27 fontWeight: FontWeight.bold,
34 - color: Colors.white,
28 + color: Theme.of(context).indicatorColor,
29 height: 1),
36 - textAlign: TextAlign.center);
37 - }),
38 - SizedBox(height: 10),
39 - Observer(builder: (_) {
40 - return Text(dashboardViewModel.balanceViewModel.fiatBalance,
30 + );
31 + }),
32 + Observer(builder: (_) {
33 + return Text(
34 + dashboardViewModel.balanceViewModel.displayMode.toString(),
35 style: TextStyle(
42 - fontSize: 18,
43 - fontWeight: FontWeight.w500,
36 + fontSize: 12,
37 + fontWeight: FontWeight.w600,
38 color: Theme.of(context).indicatorColor,
39 height: 1),
46 - textAlign: TextAlign.center);
47 - }),
48 - ],
49 - ),
40 + );
41 + }),
42 + SizedBox(height: 10),
43 + Observer(builder: (_) {
44 + return AutoSizeText(dashboardViewModel.balanceViewModel.cryptoBalance,
45 + style: TextStyle(
46 + fontSize: 54,
47 + fontWeight: FontWeight.bold,
48 + color: Colors.white,
49 + height: 1),
50 + maxLines: 1,
51 + textAlign: TextAlign.center);
52 + }),
53 + SizedBox(height: 10),
54 + Observer(builder: (_) {
55 + return Text(dashboardViewModel.balanceViewModel.fiatBalance,
56 + style: TextStyle(
57 + fontSize: 18,
58 + fontWeight: FontWeight.w500,
59 + color: Theme.of(context).indicatorColor,
60 + height: 1),
61 + textAlign: TextAlign.center);
62 + }),
63 + ],
64 + ),
65 + )
66 );
67 }
68 }
lib/utils/show_pop_up.dart
+2 -2
@@ -14,8 +14,8 @@ Future<T> showPopUp<T>({
14 context: context,
15 builder: builder,
16 barrierDismissible: barrierDismissible,
17 - barrierColor: barrierColor,
18 - useSafeArea: useSafeArea,
17 + //barrierColor: barrierColor,
18 + //useSafeArea: useSafeArea,
19 useRootNavigator: useRootNavigator,
20 routeSettings: routeSettings,
21 child: child);
lib/view_model/dashboard/balance_view_model.dart
+14 -4
@@ -1,5 +1,4 @@
1 import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
2 -import 'package:cake_wallet/core/wallet_base.dart';
2 import 'package:cake_wallet/entities/crypto_currency.dart';
3 import 'package:cake_wallet/monero/monero_wallet.dart';
4 import 'package:cake_wallet/entities/balance_display_mode.dart';
@@ -20,19 +19,31 @@ abstract class BalanceViewModelBase with Store {
19 @required this.appStore,
20 @required this.settingsStore,
21 @required this.fiatConvertationStore
23 - });
22 + }) : isReversing = false;
23
24 final AppStore appStore;
25 final SettingsStore settingsStore;
26 final FiatConversionStore fiatConvertationStore;
27
28 + @observable
29 + bool isReversing;
30 +
31 + @computed
32 + BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode;
33 +
34 + @computed
35 + BalanceDisplayMode get displayMode => isReversing
36 + ? (savedDisplayMode == BalanceDisplayMode.availableBalance
37 + ? BalanceDisplayMode.fullBalance
38 + : BalanceDisplayMode.availableBalance)
39 + : savedDisplayMode;
40 +
41 @computed
42 double get price => fiatConvertationStore.price;
43
44 @computed
45 String get cryptoBalance {
46 final walletBalance = _walletBalance;
35 - final displayMode = settingsStore.balanceDisplayMode;
47 var balance = '---';
48
49 if (displayMode == BalanceDisplayMode.availableBalance) {
@@ -49,7 +60,6 @@ abstract class BalanceViewModelBase with Store {
60 @computed
61 String get fiatBalance {
62 final walletBalance = _walletBalance;
52 - final displayMode = settingsStore.balanceDisplayMode;
63 final fiatCurrency = settingsStore.fiatCurrency;
64 var balance = '---';
65
pubspec.lock
+12 -19
@@ -42,7 +42,7 @@ packages:
42 name: async
43 url: "https://pub.dartlang.org"
44 source: hosted
45 - version: "2.4.2"
45 + version: "2.4.1"
46 auto_size_text:
47 dependency: "direct main"
48 description:
@@ -210,7 +210,7 @@ packages:
210 name: collection
211 url: "https://pub.dartlang.org"
212 source: hosted
213 - version: "1.14.13"
213 + version: "1.14.12"
214 connectivity:
215 dependency: "direct main"
216 description:
@@ -252,7 +252,7 @@ packages:
252 name: crypto
253 url: "https://pub.dartlang.org"
254 source: hosted
255 - version: "2.1.5"
255 + version: "2.1.4"
256 csslib:
257 dependency: transitive
258 description:
@@ -330,13 +330,6 @@ packages:
330 url: "https://pub.dartlang.org"
331 source: hosted
332 version: "1.0.2"
333 - fake_async:
334 - dependency: transitive
335 - description:
336 - name: fake_async
337 - url: "https://pub.dartlang.org"
338 - source: hosted
339 - version: "1.1.0"
333 ffi:
334 dependency: transitive
335 description:
@@ -505,7 +498,7 @@ packages:
498 name: image
499 url: "https://pub.dartlang.org"
500 source: hosted
508 - version: "2.1.18"
501 + version: "2.1.12"
502 intl:
503 dependency: "direct main"
504 description:
@@ -554,7 +547,7 @@ packages:
547 name: matcher
548 url: "https://pub.dartlang.org"
549 source: hosted
557 - version: "0.12.8"
550 + version: "0.12.6"
551 meta:
552 dependency: transitive
553 description:
@@ -624,7 +617,7 @@ packages:
617 name: path
618 url: "https://pub.dartlang.org"
619 source: hosted
627 - version: "1.7.0"
620 + version: "1.6.4"
621 path_drawing:
622 dependency: transitive
623 description:
@@ -687,7 +680,7 @@ packages:
680 name: petitparser
681 url: "https://pub.dartlang.org"
682 source: hosted
690 - version: "3.0.4"
683 + version: "2.4.0"
684 platform:
685 dependency: transitive
686 description:
@@ -867,7 +860,7 @@ packages:
860 name: stack_trace
861 url: "https://pub.dartlang.org"
862 source: hosted
870 - version: "1.9.5"
863 + version: "1.9.3"
864 stream_channel:
865 dependency: transitive
866 description:
@@ -902,7 +895,7 @@ packages:
895 name: test_api
896 url: "https://pub.dartlang.org"
897 source: hosted
905 - version: "0.2.17"
898 + version: "0.2.15"
899 time:
900 dependency: transitive
901 description:
@@ -923,7 +916,7 @@ packages:
916 name: typed_data
917 url: "https://pub.dartlang.org"
918 source: hosted
926 - version: "1.2.0"
919 + version: "1.1.6"
920 url_launcher:
921 dependency: "direct main"
922 description:
@@ -1014,7 +1007,7 @@ packages:
1007 name: xml
1008 url: "https://pub.dartlang.org"
1009 source: hosted
1017 - version: "4.5.1"
1010 + version: "3.6.1"
1011 yaml:
1012 dependency: "direct main"
1013 description:
@@ -1023,5 +1016,5 @@ packages:
1016 source: hosted
1017 version: "2.2.1"
1018 sdks:
1026 - dart: ">=2.9.0-14.0.dev <3.0.0"
1019 + dart: ">=2.7.0 <3.0.0"
1020 flutter: ">=1.12.13+hotfix.5 <2.0.0"