[skip ci] change fiat api UI to swich mode
Serhii committed
Dec 7, 2022 at 15:31 UTC
37ca7957560c6b30efa717bd990152cd2aeda867
2 files changed
+14
-9
lib/src/screens/settings/privacy_page.dart
+5
-7
@@ -24,14 +24,12 @@ class PrivacyPage extends BasePage {
24
return Column(
25
mainAxisSize: MainAxisSize.min,
26
children: [
27
- SettingsChoicesCell(
28
- ChoicesListItem<FiatApiMode>(
27
+ SettingsSwitcherCell(
28
title: S.current.fiat_api,
30
- items: FiatApiMode.all,
31
- selectedItem: _privacySettingsViewModel.fiatApiMode,
32
- onItemSelected: (FiatApiMode mode) => _privacySettingsViewModel.setFiatMode(mode),
33
- ),
34
- ),
29
+ value: _privacySettingsViewModel.fiatApiMode,
30
+ onValueChange: (BuildContext context, bool value) {
31
+ _privacySettingsViewModel.setFiatMode(value);
32
+ }),
33
SettingsSwitcherCell(
34
title: S.current.disable_exchange,
35
value: _privacySettingsViewModel.disableExchange,
lib/view_model/settings/privacy_settings_view_model.dart
+9
-2
@@ -18,7 +18,7 @@ abstract class PrivacySettingsViewModelBase with Store {
18
bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress;
19
20
@computed
21
- FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode;
21
+ bool get fiatApiMode => _settingsStore.fiatApiMode == FiatApiMode.disabled;
22
23
@action
24
void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value;
@@ -27,5 +27,12 @@ abstract class PrivacySettingsViewModelBase with Store {
27
void setEnableExchange(bool value) => _settingsStore.disableExchange = value;
28
29
@action
30
- void setFiatMode(FiatApiMode mode) => _settingsStore.fiatApiMode = mode;
30
+ void setFiatMode(bool value) {
31
+ if (value) {
32
+ _settingsStore.fiatApiMode = FiatApiMode.disabled;
33
+ return;
34
+ }
35
+ _settingsStore.fiatApiMode = FiatApiMode.enabled;
36
+ }
37
+
38
}