add Disable fiat mode
Serhii committed
Nov 4, 2022 at 13:58 UTC
d4c7004a3cd7785d5f452cbc96089d7d0712cb4e
11 files changed
+76
-32
lib/entities/default_settings_migration.dart
+1
@@ -61,6 +61,7 @@ Future defaultSettingsMigration(
61
await sharedPreferences.setInt(
62
PreferencesKey.currentBalanceDisplayModeKey,
63
BalanceDisplayMode.availableBalance.raw);
64
+ await sharedPreferences.setBool('disable_fiat', false);
65
await sharedPreferences.setBool('save_recipient_address', true);
66
await resetToDefault(nodes);
67
await changeMoneroCurrentNodeToDefault(
lib/entities/preferences_key.dart
+1
@@ -9,6 +9,7 @@ class PreferencesKey {
9
static const currentTransactionPriorityKeyLegacy = 'current_fee_priority';
10
static const currentBalanceDisplayModeKey = 'current_balance_display_mode';
11
static const shouldSaveRecipientAddressKey = 'save_recipient_address';
12
+ static const shouldDisableFiatKey = 'disable_fiat';
13
static const allowBiometricalAuthenticationKey =
14
'allow_biometrical_authentication';
15
static const currentTheme = 'current_theme';
lib/reactions/fiat_rate_update.dart
+3
-1
@@ -27,7 +27,9 @@ Future<void> startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore,
27
if (appStore.wallet!.type == WalletType.haven) {
28
await updateHavenRate(fiatConversionStore);
29
} else {
30
- fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice(
30
+ fiatConversionStore.prices[appStore.wallet!.currency] =
31
+ settingsStore.shouldDisableFiat ? 0.0
32
+ : await FiatConversionService.fetchPrice(
33
appStore.wallet!.currency, settingsStore.fiatCurrency);
34
}
35
} catch(e) {
lib/src/screens/dashboard/widgets/transactions_page.dart
+3
-1
@@ -57,7 +57,9 @@ class TransactionsPage extends StatelessWidget {
57
formattedDate: DateFormat('HH:mm')
58
.format(transaction.date),
59
formattedAmount: item.formattedCryptoAmount,
60
- formattedFiatAmount: item.formattedFiatAmount,
60
+ formattedFiatAmount:
61
+ dashboardViewModel.balanceViewModel.disableFiat
62
+ ? '' : item.formattedFiatAmount,
63
isPending: transaction.isPending));
64
}
65
lib/src/screens/exchange_trade/exchange_trade_page.dart
+8
-3
@@ -74,9 +74,12 @@ class ExchangeTradePage extends BasePage {
74
}
75
76
class ExchangeTradeForm extends StatefulWidget {
77
- ExchangeTradeForm(this.exchangeTradeViewModel);
77
+ ExchangeTradeForm(this.exchangeTradeViewModel)
78
+ : disableFiat =
79
+ exchangeTradeViewModel.sendViewModel.balanceViewModel.disableFiat;
80
81
final ExchangeTradeViewModel exchangeTradeViewModel;
82
+ final bool disableFiat;
83
84
@override
85
ExchangeTradeState createState() => ExchangeTradeState();
@@ -378,9 +381,11 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
381
});
382
},
383
actionLeftButton: () => Navigator.of(context).pop(),
381
- feeFiatAmount: widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount
384
+ feeFiatAmount: widget.disableFiat ? ''
385
+ : widget.exchangeTradeViewModel.sendViewModel.pendingTransactionFeeFiatAmount
386
+ ' ' + widget.exchangeTradeViewModel.sendViewModel.fiat.title,
383
- fiatAmountValue: widget.exchangeTradeViewModel.sendViewModel
387
+ fiatAmountValue: widget.disableFiat ? ''
388
+ : widget.exchangeTradeViewModel.sendViewModel
389
.pendingTransactionFiatAmount +
390
' ' +
391
widget.exchangeTradeViewModel.sendViewModel.fiat.title,
lib/src/screens/send/send_page.dart
+6
-8
@@ -386,16 +386,14 @@ class SendPage extends BasePage {
386
amount: S.of(context).send_amount,
387
amountValue:
388
sendViewModel.pendingTransaction!.amountFormatted,
389
- fiatAmountValue:
390
- sendViewModel.pendingTransactionFiatAmount +
391
- ' ' +
392
- sendViewModel.fiat.title,
389
+ fiatAmountValue: sendViewModel.balanceViewModel.disableFiat
390
+ ? '' : sendViewModel.pendingTransactionFiatAmount +
391
+ ' ' + sendViewModel.fiat.title,
392
fee: S.of(context).send_fee,
393
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
395
- feeFiatAmount:
396
- sendViewModel.pendingTransactionFeeFiatAmount +
397
- ' ' +
398
- sendViewModel.fiat.title,
394
+ feeFiatAmount: sendViewModel.balanceViewModel.disableFiat
395
+ ? '' : sendViewModel.pendingTransactionFeeFiatAmount +
396
+ ' ' + sendViewModel.fiat.title,
397
outputs: sendViewModel.outputs,
398
rightButtonText: S.of(context).ok,
399
leftButtonText: S.of(context).cancel,
lib/src/screens/send/widgets/send_card.dart
+4
-2
@@ -332,6 +332,8 @@ class SendCardState extends State<SendCard>
332
],
333
),
334
)),
335
+ sendViewModel.balanceViewModel.disableFiat ?
336
+ Container () :
337
Padding(
338
padding: const EdgeInsets.only(top: 20),
339
child: BaseTextFormField(
@@ -438,8 +440,8 @@ class SendCardState extends State<SendCard>
440
Padding(
441
padding:
442
EdgeInsets.only(top: 5),
441
- child: Text(
442
- output
443
+ child: sendViewModel.balanceViewModel.disableFiat ?
444
+ Container () : Text(output
445
.estimatedFeeFiatAmount
446
+ ' ' +
447
sendViewModel
lib/src/screens/settings/settings.dart
+8
-5
@@ -29,18 +29,20 @@ class SettingsPage extends BasePage {
29
@override
30
Widget body(BuildContext context) {
31
// FIX-ME: Added `context` it was not used here before, maby bug ?
32
- return SectionStandardList(
32
+ return Observer(builder: (_) {
33
+ final sections = settingsViewModel.getSections();
34
+ return SectionStandardList(
35
context: context,
34
- sectionCount: settingsViewModel.sections.length,
36
+ sectionCount: sections.length,
37
itemCounter: (int sectionIndex) {
36
- if (sectionIndex < settingsViewModel.sections.length) {
37
- return settingsViewModel.sections[sectionIndex].length;
38
+ if (sectionIndex < sections.length) {
39
+ return sections[sectionIndex].length;
40
}
41
42
return 0;
43
},
44
itemBuilder: (_, sectionIndex, itemIndex) {
43
- final item = settingsViewModel.sections[sectionIndex][itemIndex];
45
+ final item = sections[sectionIndex][itemIndex];
46
47
if (item is PickerListItem) {
48
return Observer(builder: (_) {
@@ -94,5 +96,6 @@ class SettingsPage extends BasePage {
96
97
return Container();
98
});
99
+ });
100
}
101
}
lib/store/settings_store.dart
+14
@@ -29,6 +29,7 @@ abstract class SettingsStoreBase with Store {
29
required FiatCurrency initialFiatCurrency,
30
required BalanceDisplayMode initialBalanceDisplayMode,
31
required bool initialSaveRecipientAddress,
32
+ required bool initialDisableFiat,
33
required bool initialAllowBiometricalAuthentication,
34
required ThemeBase initialTheme,
35
required int initialPinLength,
@@ -46,6 +47,7 @@ abstract class SettingsStoreBase with Store {
47
fiatCurrency = initialFiatCurrency,
48
balanceDisplayMode = initialBalanceDisplayMode,
49
shouldSaveRecipientAddress = initialSaveRecipientAddress,
50
+ shouldDisableFiat = initialDisableFiat,
51
allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
52
currentTheme = initialTheme,
53
pinCodeLength = initialPinLength,
@@ -87,6 +89,12 @@ abstract class SettingsStoreBase with Store {
89
PreferencesKey.shouldSaveRecipientAddressKey,
90
shouldSaveRecipientAddress));
91
92
+ reaction(
93
+ (_) => shouldDisableFiat,
94
+ (bool shouldDisableFiat) => sharedPreferences.setBool(
95
+ PreferencesKey.shouldDisableFiatKey,
96
+ shouldDisableFiat));
97
+
98
reaction(
99
(_) => currentTheme,
100
(ThemeBase theme) =>
@@ -140,6 +148,9 @@ abstract class SettingsStoreBase with Store {
148
@observable
149
bool shouldSaveRecipientAddress;
150
151
+ @observable
152
+ bool shouldDisableFiat;
153
+
154
@observable
155
bool allowBiometricalAuthentication;
156
@@ -218,6 +229,8 @@ abstract class SettingsStoreBase with Store {
229
// FIX-ME: Check for which default value we should have here
230
final shouldSaveRecipientAddress =
231
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? false;
232
+ final shouldDisableFiat =
233
+ sharedPreferences.getBool(PreferencesKey.shouldDisableFiatKey) ?? false;
234
final allowBiometricalAuthentication = sharedPreferences
235
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
236
false;
@@ -283,6 +296,7 @@ abstract class SettingsStoreBase with Store {
296
initialFiatCurrency: currentFiatCurrency,
297
initialBalanceDisplayMode: currentBalanceDisplayMode,
298
initialSaveRecipientAddress: shouldSaveRecipientAddress,
299
+ initialDisableFiat: shouldDisableFiat,
300
initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
301
initialTheme: savedTheme,
302
actionlistDisplayMode: actionListDisplayMode,
lib/view_model/dashboard/balance_view_model.dart
+11
-8
@@ -71,6 +71,9 @@ abstract class BalanceViewModelBase with Store {
71
@computed
72
BalanceDisplayMode get savedDisplayMode => settingsStore.balanceDisplayMode;
73
74
+ @computed
75
+ bool get disableFiat => settingsStore.shouldDisableFiat;
76
+
77
@computed
78
String get asset {
79
final typeFormatted = walletTypeToString(appStore.wallet!.type);
@@ -180,8 +183,8 @@ abstract class BalanceViewModelBase with Store {
183
return MapEntry(key, BalanceRecord(
184
availableBalance: '---',
185
additionalBalance: '---',
183
- fiatAdditionalBalance: '---',
184
- fiatAvailableBalance: '---',
186
+ fiatAdditionalBalance: disableFiat ? '' : '---',
187
+ fiatAvailableBalance: disableFiat ? '' : '---',
188
asset: key,
189
formattedAssetTitle: _formatterAsset(key)));
190
}
@@ -192,17 +195,17 @@ abstract class BalanceViewModelBase with Store {
195
// throw Exception('Price is null for: $key');
196
// }
197
195
- final additionalFiatBalance = fiatCurrency.toString()
196
- + ' '
198
+ final additionalFiatBalance = disableFiat ? '' : (fiatCurrency.toString()
199
+ + ' '
200
+ _getFiatBalance(
201
price: price,
199
- cryptoAmount: value.formattedAdditionalBalance);
202
+ cryptoAmount: value.formattedAdditionalBalance));
203
201
- final availableFiatBalance = fiatCurrency.toString()
202
- + ' '
204
+ final availableFiatBalance = disableFiat ? '' : (fiatCurrency.toString()
205
+ + ' '
206
+ _getFiatBalance(
207
price: price,
205
- cryptoAmount: value.formattedAvailableBalance);
208
+ cryptoAmount: value.formattedAvailableBalance));
209
210
return MapEntry(key, BalanceRecord(
211
availableBalance: value.formattedAvailableBalance,
lib/view_model/settings/settings_view_model.dart
+17
-4
@@ -61,7 +61,6 @@ abstract class SettingsViewModelBase with Store {
61
: itemHeaders = {},
62
_walletType = wallet.type,
63
_biometricAuth = BiometricAuth(),
64
- sections = <List<SettingsListItem>>[],
64
currentVersion = '' {
65
PackageInfo.fromPlatform().then(
66
(PackageInfo packageInfo) => currentVersion = packageInfo.version);
@@ -98,7 +97,7 @@ abstract class SettingsViewModelBase with Store {
97
//}
98
99
101
- sections = [
100
+ getSections = () => [
101
[
102
SwitcherListItem(
103
title: S.current.settings_display_balance,
@@ -111,7 +110,7 @@ abstract class SettingsViewModelBase with Store {
110
}
111
},
112
),
114
- if (!isHaven)
113
+ if (!isHaven && !shouldDisableFiat)
114
PickerListItem(
115
title: S.current.settings_currency,
116
searchHintText: S.current.search_currency,
@@ -183,6 +182,11 @@ abstract class SettingsViewModelBase with Store {
182
return LanguageService.list[code]?.toLowerCase().contains(searchText) ?? false;
183
},
184
),
185
+ SwitcherListItem(
186
+ title: 'S.current.disable_fiat',
187
+ value: () => shouldDisableFiat,
188
+ onValueChange: (_, bool value) =>
189
+ setShouldDisableFiat(value)),
190
SwitcherListItem(
191
title: S.current.settings_allow_biometrical_authentication,
192
value: () => allowBiometricalAuthentication,
@@ -208,6 +212,7 @@ abstract class SettingsViewModelBase with Store {
212
setAllowBiometricalAuthentication(value);
213
}
214
}),
215
+
216
ChoicesListItem(
217
title: S.current.color_theme,
218
items: ThemeList.all,
@@ -275,6 +280,10 @@ abstract class SettingsViewModelBase with Store {
280
bool get shouldSaveRecipientAddress =>
281
_settingsStore.shouldSaveRecipientAddress;
282
283
+ @computed
284
+ bool get shouldDisableFiat =>
285
+ _settingsStore.shouldDisableFiat;
286
+
287
@computed
288
bool get allowBiometricalAuthentication =>
289
_settingsStore.allowBiometricalAuthentication;
@@ -285,7 +294,7 @@ abstract class SettingsViewModelBase with Store {
294
bool get isBitcoinBuyEnabled => _settingsStore.isBitcoinBuyEnabled;
295
296
final Map<String, String> itemHeaders;
288
- List<List<SettingsListItem>> sections;
297
+ late List<List<SettingsListItem>> Function() getSections;
298
final SettingsStore _settingsStore;
299
final YatStore _yatStore;
300
final WalletType _walletType;
@@ -303,6 +312,10 @@ abstract class SettingsViewModelBase with Store {
312
void setShouldSaveRecipientAddress(bool value) =>
313
_settingsStore.shouldSaveRecipientAddress = value;
314
315
+ @action
316
+ void setShouldDisableFiat(bool value) =>
317
+ _settingsStore.shouldDisableFiat = value;
318
+
319
@action
320
void setAllowBiometricalAuthentication(bool value) =>
321
_settingsStore.allowBiometricalAuthentication = value;