mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 09:47:35 +00:00
add Disable fiat mode
This commit is contained in:
parent
289f382eda
commit
d4c7004a3c
11 changed files with 76 additions and 32 deletions
|
@ -61,6 +61,7 @@ Future defaultSettingsMigration(
|
|||
await sharedPreferences.setInt(
|
||||
PreferencesKey.currentBalanceDisplayModeKey,
|
||||
BalanceDisplayMode.availableBalance.raw);
|
||||
await sharedPreferences.setBool('disable_fiat', false);
|
||||
await sharedPreferences.setBool('save_recipient_address', true);
|
||||
await resetToDefault(nodes);
|
||||
await changeMoneroCurrentNodeToDefault(
|
||||
|
|
|
@ -9,6 +9,7 @@ class PreferencesKey {
|
|||
static const currentTransactionPriorityKeyLegacy = 'current_fee_priority';
|
||||
static const currentBalanceDisplayModeKey = 'current_balance_display_mode';
|
||||
static const shouldSaveRecipientAddressKey = 'save_recipient_address';
|
||||
static const shouldDisableFiatKey = 'disable_fiat';
|
||||
static const allowBiometricalAuthenticationKey =
|
||||
'allow_biometrical_authentication';
|
||||
static const currentTheme = 'current_theme';
|
||||
|
|
|
@ -27,7 +27,9 @@ Future<void> startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore,
|
|||
if (appStore.wallet!.type == WalletType.haven) {
|
||||
await updateHavenRate(fiatConversionStore);
|
||||
} else {
|
||||
fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice(
|
||||
fiatConversionStore.prices[appStore.wallet!.currency] =
|
||||
settingsStore.shouldDisableFiat ? 0.0
|
||||
: await FiatConversionService.fetchPrice(
|
||||
appStore.wallet!.currency, settingsStore.fiatCurrency);
|
||||
}
|
||||
} catch(e) {
|
||||
|
|
|
@ -57,7 +57,9 @@ class TransactionsPage extends StatelessWidget {
|
|||
formattedDate: DateFormat('HH:mm')
|
||||
.format(transaction.date),
|
||||
formattedAmount: item.formattedCryptoAmount,
|
||||
formattedFiatAmount: item.formattedFiatAmount,
|
||||
formattedFiatAmount:
|
||||
dashboardViewModel.balanceViewModel.disableFiat
|
||||
? '' : item.formattedFiatAmount,
|
||||
isPending: transaction.isPending));
|
||||
}
|
||||
|
||||
|
|
|
@ -74,9 +74,12 @@ class ExchangeTradePage extends BasePage {
|
|||
}
|
||||
|
||||
class ExchangeTradeForm extends StatefulWidget {
|
||||
ExchangeTradeForm(this.exchangeTradeViewModel);
|
||||
ExchangeTradeForm(this.exchangeTradeViewModel)
|
||||
: disableFiat =
|
||||
exchangeTradeViewModel.sendViewModel.balanceViewModel.disableFiat;
|
||||
|
||||
final ExchangeTradeViewModel exchangeTradeViewModel;
|
||||
final bool disableFiat;
|
||||
|
||||
@override
|
||||
ExchangeTradeState createState() => ExchangeTradeState();
|
||||
|
@ -378,9 +381,11 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
});
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(context).pop(),
|
||||
feeFiatAmount: widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount
|
||||
feeFiatAmount: widget.disableFiat ? ''
|
||||
: widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount
|
||||
+ ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title,
|
||||
fiatAmountValue: widget.exchangeTradeViewModel.sendViewModel
|
||||
fiatAmountValue: widget.disableFiat ? ''
|
||||
: widget.exchangeTradeViewModel.sendViewModel
|
||||
.pendingTransactionFiatAmount +
|
||||
' ' +
|
||||
widget.exchangeTradeViewModel.sendViewModel.fiat.title,
|
||||
|
|
|
@ -386,16 +386,14 @@ class SendPage extends BasePage {
|
|||
amount: S.of(context).send_amount,
|
||||
amountValue:
|
||||
sendViewModel.pendingTransaction!.amountFormatted,
|
||||
fiatAmountValue:
|
||||
sendViewModel.pendingTransactionFiatAmount +
|
||||
' ' +
|
||||
sendViewModel.fiat.title,
|
||||
fiatAmountValue: sendViewModel.balanceViewModel.disableFiat
|
||||
? '' : sendViewModel.pendingTransactionFiatAmount +
|
||||
' ' + sendViewModel.fiat.title,
|
||||
fee: S.of(context).send_fee,
|
||||
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
|
||||
feeFiatAmount:
|
||||
sendViewModel.pendingTransactionFeeFiatAmount +
|
||||
' ' +
|
||||
sendViewModel.fiat.title,
|
||||
feeFiatAmount: sendViewModel.balanceViewModel.disableFiat
|
||||
? '' : sendViewModel.pendingTransactionFeeFiatAmount +
|
||||
' ' + sendViewModel.fiat.title,
|
||||
outputs: sendViewModel.outputs,
|
||||
rightButtonText: S.of(context).ok,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
|
|
|
@ -332,6 +332,8 @@ class SendCardState extends State<SendCard>
|
|||
],
|
||||
),
|
||||
)),
|
||||
sendViewModel.balanceViewModel.disableFiat ?
|
||||
Container () :
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: BaseTextFormField(
|
||||
|
@ -438,8 +440,8 @@ class SendCardState extends State<SendCard>
|
|||
Padding(
|
||||
padding:
|
||||
EdgeInsets.only(top: 5),
|
||||
child: Text(
|
||||
output
|
||||
child: sendViewModel.balanceViewModel.disableFiat ?
|
||||
Container () : Text(output
|
||||
.estimatedFeeFiatAmount
|
||||
+ ' ' +
|
||||
sendViewModel
|
||||
|
|
|
@ -29,18 +29,20 @@ class SettingsPage extends BasePage {
|
|||
@override
|
||||
Widget body(BuildContext context) {
|
||||
// FIX-ME: Added `context` it was not used here before, maby bug ?
|
||||
return SectionStandardList(
|
||||
return Observer(builder: (_) {
|
||||
final sections = settingsViewModel.getSections();
|
||||
return SectionStandardList(
|
||||
context: context,
|
||||
sectionCount: settingsViewModel.sections.length,
|
||||
sectionCount: sections.length,
|
||||
itemCounter: (int sectionIndex) {
|
||||
if (sectionIndex < settingsViewModel.sections.length) {
|
||||
return settingsViewModel.sections[sectionIndex].length;
|
||||
if (sectionIndex < sections.length) {
|
||||
return sections[sectionIndex].length;
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
itemBuilder: (_, sectionIndex, itemIndex) {
|
||||
final item = settingsViewModel.sections[sectionIndex][itemIndex];
|
||||
final item = sections[sectionIndex][itemIndex];
|
||||
|
||||
if (item is PickerListItem) {
|
||||
return Observer(builder: (_) {
|
||||
|
@ -94,5 +96,6 @@ class SettingsPage extends BasePage {
|
|||
|
||||
return Container();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ abstract class SettingsStoreBase with Store {
|
|||
required FiatCurrency initialFiatCurrency,
|
||||
required BalanceDisplayMode initialBalanceDisplayMode,
|
||||
required bool initialSaveRecipientAddress,
|
||||
required bool initialDisableFiat,
|
||||
required bool initialAllowBiometricalAuthentication,
|
||||
required ThemeBase initialTheme,
|
||||
required int initialPinLength,
|
||||
|
@ -46,6 +47,7 @@ abstract class SettingsStoreBase with Store {
|
|||
fiatCurrency = initialFiatCurrency,
|
||||
balanceDisplayMode = initialBalanceDisplayMode,
|
||||
shouldSaveRecipientAddress = initialSaveRecipientAddress,
|
||||
shouldDisableFiat = initialDisableFiat,
|
||||
allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
|
||||
currentTheme = initialTheme,
|
||||
pinCodeLength = initialPinLength,
|
||||
|
@ -87,6 +89,12 @@ abstract class SettingsStoreBase with Store {
|
|||
PreferencesKey.shouldSaveRecipientAddressKey,
|
||||
shouldSaveRecipientAddress));
|
||||
|
||||
reaction(
|
||||
(_) => shouldDisableFiat,
|
||||
(bool shouldDisableFiat) => sharedPreferences.setBool(
|
||||
PreferencesKey.shouldDisableFiatKey,
|
||||
shouldDisableFiat));
|
||||
|
||||
reaction(
|
||||
(_) => currentTheme,
|
||||
(ThemeBase theme) =>
|
||||
|
@ -140,6 +148,9 @@ abstract class SettingsStoreBase with Store {
|
|||
@observable
|
||||
bool shouldSaveRecipientAddress;
|
||||
|
||||
@observable
|
||||
bool shouldDisableFiat;
|
||||
|
||||
@observable
|
||||
bool allowBiometricalAuthentication;
|
||||
|
||||
|
@ -218,6 +229,8 @@ abstract class SettingsStoreBase with Store {
|
|||
// FIX-ME: Check for which default value we should have here
|
||||
final shouldSaveRecipientAddress =
|
||||
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? false;
|
||||
final shouldDisableFiat =
|
||||
sharedPreferences.getBool(PreferencesKey.shouldDisableFiatKey) ?? false;
|
||||
final allowBiometricalAuthentication = sharedPreferences
|
||||
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
|
||||
false;
|
||||
|
@ -283,6 +296,7 @@ abstract class SettingsStoreBase with Store {
|
|||
initialFiatCurrency: currentFiatCurrency,
|
||||
initialBalanceDisplayMode: currentBalanceDisplayMode,
|
||||
initialSaveRecipientAddress: shouldSaveRecipientAddress,
|
||||
initialDisableFiat: shouldDisableFiat,
|
||||
initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
|
||||
initialTheme: savedTheme,
|
||||
actionlistDisplayMode: actionListDisplayMode,
|
||||
|
|
|
@ -71,6 +71,9 @@ abstract class BalanceViewModelBase with Store {
|
|||
@computed
|
||||
BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode;
|
||||
|
||||
@computed
|
||||
bool get disableFiat => settingsStore.shouldDisableFiat;
|
||||
|
||||
@computed
|
||||
String get asset {
|
||||
final typeFormatted = walletTypeToString(appStore.wallet!.type);
|
||||
|
@ -180,8 +183,8 @@ abstract class BalanceViewModelBase with Store {
|
|||
return MapEntry(key, BalanceRecord(
|
||||
availableBalance: '---',
|
||||
additionalBalance: '---',
|
||||
fiatAdditionalBalance: '---',
|
||||
fiatAvailableBalance: '---',
|
||||
fiatAdditionalBalance: disableFiat ? '' : '---',
|
||||
fiatAvailableBalance: disableFiat ? '' : '---',
|
||||
asset: key,
|
||||
formattedAssetTitle: _formatterAsset(key)));
|
||||
}
|
||||
|
@ -192,17 +195,17 @@ abstract class BalanceViewModelBase with Store {
|
|||
// throw Exception('Price is null for: $key');
|
||||
// }
|
||||
|
||||
final additionalFiatBalance = fiatCurrency.toString()
|
||||
+ ' '
|
||||
final additionalFiatBalance = disableFiat ? '' : (fiatCurrency.toString()
|
||||
+ ' '
|
||||
+ _getFiatBalance(
|
||||
price: price,
|
||||
cryptoAmount: value.formattedAdditionalBalance);
|
||||
cryptoAmount: value.formattedAdditionalBalance));
|
||||
|
||||
final availableFiatBalance = fiatCurrency.toString()
|
||||
+ ' '
|
||||
final availableFiatBalance = disableFiat ? '' : (fiatCurrency.toString()
|
||||
+ ' '
|
||||
+ _getFiatBalance(
|
||||
price: price,
|
||||
cryptoAmount: value.formattedAvailableBalance);
|
||||
cryptoAmount: value.formattedAvailableBalance));
|
||||
|
||||
return MapEntry(key, BalanceRecord(
|
||||
availableBalance: value.formattedAvailableBalance,
|
||||
|
|
|
@ -61,7 +61,6 @@ abstract class SettingsViewModelBase with Store {
|
|||
: itemHeaders = {},
|
||||
_walletType = wallet.type,
|
||||
_biometricAuth = BiometricAuth(),
|
||||
sections = <List<SettingsListItem>>[],
|
||||
currentVersion = '' {
|
||||
PackageInfo.fromPlatform().then(
|
||||
(PackageInfo packageInfo) => currentVersion = packageInfo.version);
|
||||
|
@ -98,7 +97,7 @@ abstract class SettingsViewModelBase with Store {
|
|||
//}
|
||||
|
||||
|
||||
sections = [
|
||||
getSections = () => [
|
||||
[
|
||||
SwitcherListItem(
|
||||
title: S.current.settings_display_balance,
|
||||
|
@ -111,7 +110,7 @@ abstract class SettingsViewModelBase with Store {
|
|||
}
|
||||
},
|
||||
),
|
||||
if (!isHaven)
|
||||
if (!isHaven && !shouldDisableFiat)
|
||||
PickerListItem(
|
||||
title: S.current.settings_currency,
|
||||
searchHintText: S.current.search_currency,
|
||||
|
@ -183,6 +182,11 @@ abstract class SettingsViewModelBase with Store {
|
|||
return LanguageService.list[code]?.toLowerCase().contains(searchText) ?? false;
|
||||
},
|
||||
),
|
||||
SwitcherListItem(
|
||||
title: 'S.current.disable_fiat',
|
||||
value: () => shouldDisableFiat,
|
||||
onValueChange: (_, bool value) =>
|
||||
setShouldDisableFiat(value)),
|
||||
SwitcherListItem(
|
||||
title: S.current.settings_allow_biometrical_authentication,
|
||||
value: () => allowBiometricalAuthentication,
|
||||
|
@ -208,6 +212,7 @@ abstract class SettingsViewModelBase with Store {
|
|||
setAllowBiometricalAuthentication(value);
|
||||
}
|
||||
}),
|
||||
|
||||
ChoicesListItem(
|
||||
title: S.current.color_theme,
|
||||
items: ThemeList.all,
|
||||
|
@ -275,6 +280,10 @@ abstract class SettingsViewModelBase with Store {
|
|||
bool get shouldSaveRecipientAddress =>
|
||||
_settingsStore.shouldSaveRecipientAddress;
|
||||
|
||||
@computed
|
||||
bool get shouldDisableFiat =>
|
||||
_settingsStore.shouldDisableFiat;
|
||||
|
||||
@computed
|
||||
bool get allowBiometricalAuthentication =>
|
||||
_settingsStore.allowBiometricalAuthentication;
|
||||
|
@ -285,7 +294,7 @@ abstract class SettingsViewModelBase with Store {
|
|||
bool get isBitcoinBuyEnabled => _settingsStore.isBitcoinBuyEnabled;
|
||||
|
||||
final Map<String, String> itemHeaders;
|
||||
List<List<SettingsListItem>> sections;
|
||||
late List<List<SettingsListItem>> Function() getSections;
|
||||
final SettingsStore _settingsStore;
|
||||
final YatStore _yatStore;
|
||||
final WalletType _walletType;
|
||||
|
@ -303,6 +312,10 @@ abstract class SettingsViewModelBase with Store {
|
|||
void setShouldSaveRecipientAddress(bool value) =>
|
||||
_settingsStore.shouldSaveRecipientAddress = value;
|
||||
|
||||
@action
|
||||
void setShouldDisableFiat(bool value) =>
|
||||
_settingsStore.shouldDisableFiat = value;
|
||||
|
||||
@action
|
||||
void setAllowBiometricalAuthentication(bool value) =>
|
||||
_settingsStore.allowBiometricalAuthentication = value;
|
||||
|
|
Loading…
Reference in a new issue