From 1800070fc182e39ef25d8d8c38178566cdddc1c6 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Tue, 29 Sep 2020 11:45:35 +0300 Subject: [PATCH] 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 --- .../dashboard/widgets/balance_page.dart | 80 +++++++++++-------- lib/utils/show_pop_up.dart | 4 +- .../dashboard/balance_view_model.dart | 18 ++++- pubspec.lock | 31 +++---- 4 files changed, 76 insertions(+), 57 deletions(-) diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index 4410fc3ff..5470c859d 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; +import 'package:auto_size_text/auto_size_text.dart'; class BalancePage extends StatelessWidget { BalancePage({@required this.dashboardViewModel}); @@ -11,42 +12,57 @@ class BalancePage extends StatelessWidget { Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(24), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Observer(builder: (_) { - return Text( - dashboardViewModel.balanceViewModel.currency.toString(), - style: TextStyle( - fontSize: 40, - fontWeight: FontWeight.bold, - color: Theme.of(context).indicatorColor, - height: 1), - ); - }), - SizedBox(height: 10), - Observer(builder: (_) { - return Text(dashboardViewModel.balanceViewModel.cryptoBalance, + child: GestureDetector( + onTapUp: (_) => dashboardViewModel.balanceViewModel.isReversing = false, + onTapDown: (_) => dashboardViewModel.balanceViewModel.isReversing = true, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Observer(builder: (_) { + return Text( + dashboardViewModel.balanceViewModel.currency.toString(), style: TextStyle( - fontSize: 54, + fontSize: 40, fontWeight: FontWeight.bold, - color: Colors.white, - height: 1), - textAlign: TextAlign.center); - }), - SizedBox(height: 10), - Observer(builder: (_) { - return Text(dashboardViewModel.balanceViewModel.fiatBalance, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w500, color: Theme.of(context).indicatorColor, height: 1), - textAlign: TextAlign.center); - }), - ], - ), + ); + }), + Observer(builder: (_) { + return Text( + dashboardViewModel.balanceViewModel.displayMode.toString(), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Theme.of(context).indicatorColor, + height: 1), + ); + }), + SizedBox(height: 10), + Observer(builder: (_) { + return AutoSizeText(dashboardViewModel.balanceViewModel.cryptoBalance, + style: TextStyle( + fontSize: 54, + fontWeight: FontWeight.bold, + color: Colors.white, + height: 1), + maxLines: 1, + textAlign: TextAlign.center); + }), + SizedBox(height: 10), + Observer(builder: (_) { + return Text(dashboardViewModel.balanceViewModel.fiatBalance, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, + color: Theme.of(context).indicatorColor, + height: 1), + textAlign: TextAlign.center); + }), + ], + ), + ) ); } } diff --git a/lib/utils/show_pop_up.dart b/lib/utils/show_pop_up.dart index a97fb3762..280bcff3c 100644 --- a/lib/utils/show_pop_up.dart +++ b/lib/utils/show_pop_up.dart @@ -14,8 +14,8 @@ Future showPopUp({ context: context, builder: builder, barrierDismissible: barrierDismissible, - barrierColor: barrierColor, - useSafeArea: useSafeArea, + //barrierColor: barrierColor, + //useSafeArea: useSafeArea, useRootNavigator: useRootNavigator, routeSettings: routeSettings, child: child); diff --git a/lib/view_model/dashboard/balance_view_model.dart b/lib/view_model/dashboard/balance_view_model.dart index 58978c946..37f6e5247 100644 --- a/lib/view_model/dashboard/balance_view_model.dart +++ b/lib/view_model/dashboard/balance_view_model.dart @@ -1,5 +1,4 @@ import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart'; -import 'package:cake_wallet/core/wallet_base.dart'; import 'package:cake_wallet/entities/crypto_currency.dart'; import 'package:cake_wallet/monero/monero_wallet.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart'; @@ -20,19 +19,31 @@ abstract class BalanceViewModelBase with Store { @required this.appStore, @required this.settingsStore, @required this.fiatConvertationStore - }); + }) : isReversing = false; final AppStore appStore; final SettingsStore settingsStore; final FiatConversionStore fiatConvertationStore; + @observable + bool isReversing; + + @computed + BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode; + + @computed + BalanceDisplayMode get displayMode => isReversing + ? (savedDisplayMode == BalanceDisplayMode.availableBalance + ? BalanceDisplayMode.fullBalance + : BalanceDisplayMode.availableBalance) + : savedDisplayMode; + @computed double get price => fiatConvertationStore.price; @computed String get cryptoBalance { final walletBalance = _walletBalance; - final displayMode = settingsStore.balanceDisplayMode; var balance = '---'; if (displayMode == BalanceDisplayMode.availableBalance) { @@ -49,7 +60,6 @@ abstract class BalanceViewModelBase with Store { @computed String get fiatBalance { final walletBalance = _walletBalance; - final displayMode = settingsStore.balanceDisplayMode; final fiatCurrency = settingsStore.fiatCurrency; var balance = '---'; diff --git a/pubspec.lock b/pubspec.lock index f9bbbbd26..7d3081850 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.4.1" auto_size_text: dependency: "direct main" description: @@ -210,7 +210,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.14.12" connectivity: dependency: "direct main" description: @@ -252,7 +252,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.1.4" csslib: dependency: transitive description: @@ -330,13 +330,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" ffi: dependency: transitive description: @@ -505,7 +498,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.18" + version: "2.1.12" intl: dependency: "direct main" description: @@ -554,7 +547,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.6" meta: dependency: transitive description: @@ -624,7 +617,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.6.4" path_drawing: dependency: transitive description: @@ -687,7 +680,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "3.0.4" + version: "2.4.0" platform: dependency: transitive description: @@ -867,7 +860,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.9.3" stream_channel: dependency: transitive description: @@ -902,7 +895,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.15" time: dependency: transitive description: @@ -923,7 +916,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.6" url_launcher: dependency: "direct main" description: @@ -1014,7 +1007,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "3.6.1" yaml: dependency: "direct main" description: @@ -1023,5 +1016,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.7.0 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0"