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

This commit is contained in:
OleksandrSobol 2020-09-29 11:45:35 +03:00
parent e3678d2cf9
commit 1800070fc1
4 changed files with 76 additions and 57 deletions

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:auto_size_text/auto_size_text.dart';
class BalancePage extends StatelessWidget { class BalancePage extends StatelessWidget {
BalancePage({@required this.dashboardViewModel}); BalancePage({@required this.dashboardViewModel});
@ -11,42 +12,57 @@ class BalancePage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
padding: EdgeInsets.all(24), padding: EdgeInsets.all(24),
child: Column( child: GestureDetector(
mainAxisAlignment: MainAxisAlignment.center, onTapUp: (_) => dashboardViewModel.balanceViewModel.isReversing = false,
crossAxisAlignment: CrossAxisAlignment.center, onTapDown: (_) => dashboardViewModel.balanceViewModel.isReversing = true,
children: <Widget>[ child: Column(
Observer(builder: (_) { mainAxisAlignment: MainAxisAlignment.center,
return Text( crossAxisAlignment: CrossAxisAlignment.center,
dashboardViewModel.balanceViewModel.currency.toString(), children: <Widget>[
style: TextStyle( Observer(builder: (_) {
fontSize: 40, return Text(
fontWeight: FontWeight.bold, dashboardViewModel.balanceViewModel.currency.toString(),
color: Theme.of(context).indicatorColor,
height: 1),
);
}),
SizedBox(height: 10),
Observer(builder: (_) {
return Text(dashboardViewModel.balanceViewModel.cryptoBalance,
style: TextStyle( style: TextStyle(
fontSize: 54, fontSize: 40,
fontWeight: FontWeight.bold, 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, color: Theme.of(context).indicatorColor,
height: 1), 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);
}),
],
),
)
); );
} }
} }

View file

@ -14,8 +14,8 @@ Future<T> showPopUp<T>({
context: context, context: context,
builder: builder, builder: builder,
barrierDismissible: barrierDismissible, barrierDismissible: barrierDismissible,
barrierColor: barrierColor, //barrierColor: barrierColor,
useSafeArea: useSafeArea, //useSafeArea: useSafeArea,
useRootNavigator: useRootNavigator, useRootNavigator: useRootNavigator,
routeSettings: routeSettings, routeSettings: routeSettings,
child: child); child: child);

View file

@ -1,5 +1,4 @@
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart'; 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/entities/crypto_currency.dart';
import 'package:cake_wallet/monero/monero_wallet.dart'; import 'package:cake_wallet/monero/monero_wallet.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart';
@ -20,19 +19,31 @@ abstract class BalanceViewModelBase with Store {
@required this.appStore, @required this.appStore,
@required this.settingsStore, @required this.settingsStore,
@required this.fiatConvertationStore @required this.fiatConvertationStore
}); }) : isReversing = false;
final AppStore appStore; final AppStore appStore;
final SettingsStore settingsStore; final SettingsStore settingsStore;
final FiatConversionStore fiatConvertationStore; 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 @computed
double get price => fiatConvertationStore.price; double get price => fiatConvertationStore.price;
@computed @computed
String get cryptoBalance { String get cryptoBalance {
final walletBalance = _walletBalance; final walletBalance = _walletBalance;
final displayMode = settingsStore.balanceDisplayMode;
var balance = '---'; var balance = '---';
if (displayMode == BalanceDisplayMode.availableBalance) { if (displayMode == BalanceDisplayMode.availableBalance) {
@ -49,7 +60,6 @@ abstract class BalanceViewModelBase with Store {
@computed @computed
String get fiatBalance { String get fiatBalance {
final walletBalance = _walletBalance; final walletBalance = _walletBalance;
final displayMode = settingsStore.balanceDisplayMode;
final fiatCurrency = settingsStore.fiatCurrency; final fiatCurrency = settingsStore.fiatCurrency;
var balance = '---'; var balance = '---';

View file

@ -42,7 +42,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.2" version: "2.4.1"
auto_size_text: auto_size_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -210,7 +210,7 @@ packages:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.13" version: "1.14.12"
connectivity: connectivity:
dependency: "direct main" dependency: "direct main"
description: description:
@ -252,7 +252,7 @@ packages:
name: crypto name: crypto
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.5" version: "2.1.4"
csslib: csslib:
dependency: transitive dependency: transitive
description: description:
@ -330,13 +330,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
@ -505,7 +498,7 @@ packages:
name: image name: image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.18" version: "2.1.12"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
@ -554,7 +547,7 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.8" version: "0.12.6"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -624,7 +617,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.6.4"
path_drawing: path_drawing:
dependency: transitive dependency: transitive
description: description:
@ -687,7 +680,7 @@ packages:
name: petitparser name: petitparser
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.4" version: "2.4.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -867,7 +860,7 @@ packages:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.5" version: "1.9.3"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
@ -902,7 +895,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.17" version: "0.2.15"
time: time:
dependency: transitive dependency: transitive
description: description:
@ -923,7 +916,7 @@ packages:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.1.6"
url_launcher: url_launcher:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1014,7 +1007,7 @@ packages:
name: xml name: xml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.5.1" version: "3.6.1"
yaml: yaml:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1023,5 +1016,5 @@ packages:
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
sdks: 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" flutter: ">=1.12.13+hotfix.5 <2.0.0"