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

This commit is contained in:
OleksandrSobol 2021-03-31 19:18:33 +03:00
parent c0a12c6026
commit 3da9eb38aa
6 changed files with 113 additions and 100 deletions

View file

@ -13,6 +13,13 @@ class BalancePage extends StatelessWidget {
return Container( return Container(
color: Colors.transparent, color: Colors.transparent,
padding: EdgeInsets.all(24), padding: EdgeInsets.all(24),
child: GestureDetector(
onLongPress: () =>
dashboardViewModel.balanceViewModel.isReversing =
!dashboardViewModel.balanceViewModel.isReversing,
onLongPressUp: () =>
dashboardViewModel.balanceViewModel.isReversing =
!dashboardViewModel.balanceViewModel.isReversing,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -105,6 +112,7 @@ class BalancePage extends StatelessWidget {
}), }),
], ],
), ),
),
); );
} }
} }

View file

@ -41,5 +41,5 @@ abstract class OrdersStoreBase with Store {
Future updateOrderList() async => orders = Future updateOrderList() async => orders =
ordersSource.values.map((order) => OrderListItem( ordersSource.values.map((order) => OrderListItem(
order: order, order: order,
displayMode: settingsStore.balanceDisplayMode)).toList(); settingsStore: settingsStore)).toList();
} }

View file

@ -1,7 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart';
import 'package:flutter/cupertino.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/settings_store.dart';
@ -37,5 +36,5 @@ abstract class TradesStoreBase with Store {
Future updateTradeList() async => trades = Future updateTradeList() async => trades =
tradesSource.values.map((trade) => TradeListItem( tradesSource.values.map((trade) => TradeListItem(
trade: trade, trade: trade,
displayMode: settingsStore.balanceDisplayMode)).toList(); settingsStore: settingsStore)).toList();
} }

View file

@ -69,9 +69,9 @@ abstract class BalanceViewModelBase with Store {
@computed @computed
BalanceDisplayMode get displayMode => isReversing BalanceDisplayMode get displayMode => isReversing
? (savedDisplayMode == BalanceDisplayMode.availableBalance ? savedDisplayMode == BalanceDisplayMode.hiddenBalance
? BalanceDisplayMode.fullBalance ? BalanceDisplayMode.displayableBalance
: BalanceDisplayMode.availableBalance) : savedDisplayMode
: savedDisplayMode; : savedDisplayMode;
@computed @computed
@ -96,7 +96,7 @@ abstract class BalanceViewModelBase with Store {
String get availableBalance { String get availableBalance {
final walletBalance = _walletBalance; final walletBalance = _walletBalance;
if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) { if (displayMode == BalanceDisplayMode.hiddenBalance) {
return '---'; return '---';
} }
@ -107,7 +107,7 @@ abstract class BalanceViewModelBase with Store {
String get additionalBalance { String get additionalBalance {
final walletBalance = _walletBalance; final walletBalance = _walletBalance;
if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) { if (displayMode == BalanceDisplayMode.hiddenBalance) {
return '---'; return '---';
} }
@ -119,7 +119,7 @@ abstract class BalanceViewModelBase with Store {
final walletBalance = _walletBalance; final walletBalance = _walletBalance;
final fiatCurrency = settingsStore.fiatCurrency; final fiatCurrency = settingsStore.fiatCurrency;
if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) { if (displayMode == BalanceDisplayMode.hiddenBalance) {
return '---'; return '---';
} }
@ -135,7 +135,7 @@ abstract class BalanceViewModelBase with Store {
final walletBalance = _walletBalance; final walletBalance = _walletBalance;
final fiatCurrency = settingsStore.fiatCurrency; final fiatCurrency = settingsStore.fiatCurrency;
if (settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance) { if (displayMode == BalanceDisplayMode.hiddenBalance) {
return '---'; return '---';
} }

View file

@ -1,12 +1,15 @@
import 'package:cake_wallet/entities/order.dart'; import 'package:cake_wallet/entities/order.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart';
class OrderListItem extends ActionListItem { class OrderListItem extends ActionListItem {
OrderListItem({this.order, this.displayMode}); OrderListItem({this.order, this.settingsStore});
final Order order; final Order order;
final BalanceDisplayMode displayMode; final SettingsStore settingsStore;
BalanceDisplayMode get displayMode => settingsStore.balanceDisplayMode;
String get orderFormattedAmount { String get orderFormattedAmount {
return order.amount != null return order.amount != null

View file

@ -1,12 +1,15 @@
import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/balance_display_mode.dart';
class TradeListItem extends ActionListItem { class TradeListItem extends ActionListItem {
TradeListItem({this.trade, this.displayMode}); TradeListItem({this.trade, this.settingsStore});
final Trade trade; final Trade trade;
final BalanceDisplayMode displayMode; final SettingsStore settingsStore;
BalanceDisplayMode get displayMode => settingsStore.balanceDisplayMode;
String get tradeFormattedAmount { String get tradeFormattedAmount {
return trade.amount != null return trade.amount != null