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: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: <Widget>[
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: <Widget>[
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);
}),
],
),
)
);
}
}

View file

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

View file

@ -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 = '---';

View file

@ -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"