[skip ci] change fiat api UI to swich mode

This commit is contained in:
Serhii 2022-12-07 15:31:33 +02:00
parent 228e157b39
commit 37ca795756
2 changed files with 14 additions and 9 deletions

View file

@ -24,14 +24,12 @@ class PrivacyPage extends BasePage {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SettingsChoicesCell(
ChoicesListItem<FiatApiMode>(
SettingsSwitcherCell(
title: S.current.fiat_api,
items: FiatApiMode.all,
selectedItem: _privacySettingsViewModel.fiatApiMode,
onItemSelected: (FiatApiMode mode) => _privacySettingsViewModel.setFiatMode(mode),
),
),
value: _privacySettingsViewModel.fiatApiMode,
onValueChange: (BuildContext context, bool value) {
_privacySettingsViewModel.setFiatMode(value);
}),
SettingsSwitcherCell(
title: S.current.disable_exchange,
value: _privacySettingsViewModel.disableExchange,

View file

@ -18,7 +18,7 @@ abstract class PrivacySettingsViewModelBase with Store {
bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress;
@computed
FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode;
bool get fiatApiMode => _settingsStore.fiatApiMode == FiatApiMode.disabled;
@action
void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value;
@ -27,5 +27,12 @@ abstract class PrivacySettingsViewModelBase with Store {
void setEnableExchange(bool value) => _settingsStore.disableExchange = value;
@action
void setFiatMode(FiatApiMode mode) => _settingsStore.fiatApiMode = mode;
void setFiatMode(bool value) {
if (value) {
_settingsStore.fiatApiMode = FiatApiMode.disabled;
return;
}
_settingsStore.fiatApiMode = FiatApiMode.enabled;
}
}