Add Fiat API mode to advanced privacy settings page

OmarHatem committed Mar 2, 2023 at 19:13 UTC de629873386403c29b2d5f64462193c5ac81702e
2 files changed +36 -50
lib/src/screens/new_wallet/advanced_privacy_settings_page.dart
+32 -36
@@ -52,39 +52,37 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
52 content: Column(
53 crossAxisAlignment: CrossAxisAlignment.center,
54 children: [
55 - Observer(
56 - builder: (_) {
57 - return SettingsSwitcherCell(
55 + Observer(builder: (_) {
56 + return SettingsChoicesCell(
57 + ChoicesListItem<FiatApiMode>(
58 title: S.current.disable_fiat,
59 - value: widget.privacySettingsViewModel.fiatApi == FiatApiMode.disabled,
60 - onValueChange: (BuildContext context, bool value) {
61 - widget.privacySettingsViewModel.setFiatMode(value);
62 - });
63 - }
64 - ),
65 - Observer(
66 - builder: (_) {
67 - return SettingsChoicesCell(
68 - ChoicesListItem<ExchangeApiMode>(
69 - title: S.current.exchange,
70 - items: ExchangeApiMode.all,
71 - selectedItem: widget.privacySettingsViewModel.exchangeStatus,
72 - onItemSelected: (ExchangeApiMode mode) =>
73 - widget.privacySettingsViewModel.setExchangeApiMode(mode),
59 + items: FiatApiMode.all,
60 + selectedItem: widget.privacySettingsViewModel.fiatApiMode,
61 + onItemSelected: (FiatApiMode mode) =>
62 + widget.privacySettingsViewModel.setFiatApiMode(mode),
63 + ),
64 + );
65 + }),
66 + Observer(builder: (_) {
67 + return SettingsChoicesCell(
68 + ChoicesListItem<ExchangeApiMode>(
69 + title: S.current.exchange,
70 + items: ExchangeApiMode.all,
71 + selectedItem: widget.privacySettingsViewModel.exchangeStatus,
72 + onItemSelected: (ExchangeApiMode mode) =>
73 + widget.privacySettingsViewModel.setExchangeApiMode(mode),
74 + ),
75 + );
76 + }),
77 + Observer(builder: (_) {
78 + return Column(
79 + children: [
80 + SettingsSwitcherCell(
81 + title: S.current.add_custom_node,
82 + value: widget.privacySettingsViewModel.addCustomNode,
83 + onValueChange: (_, __) => widget.privacySettingsViewModel.toggleAddCustomNode(),
84 ),
75 - );
76 - }
77 - ),
78 - Observer(
79 - builder: (_) {
80 - return Column(
81 - children: [
82 - SettingsSwitcherCell(
83 - title: S.current.add_custom_node,
84 - value: widget.privacySettingsViewModel.addCustomNode,
85 - onValueChange: (_, __) => widget.privacySettingsViewModel.toggleAddCustomNode(),
86 - ),
87 - if (widget.privacySettingsViewModel.addCustomNode)
85 + if (widget.privacySettingsViewModel.addCustomNode)
86 Padding(
87 padding: EdgeInsets.only(left: 24, right: 24, top: 24),
88 child: NodeForm(
@@ -92,11 +90,9 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
90 nodeViewModel: widget.nodeViewModel,
91 ),
92 )
95 - ],
96 - );
97 - }
98 - ),
99 -
93 + ],
94 + );
95 + }),
96 ],
97 ),
98 bottomSectionPadding: EdgeInsets.all(24),
lib/view_model/advanced_privacy_settings_view_model.dart
+4 -14
@@ -16,7 +16,7 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
16 ExchangeApiMode get exchangeStatus => _settingsStore.exchangeStatus;
17
18 @computed
19 - FiatApiMode get fiatApi => _settingsStore.fiatApiMode;
19 + FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode;
20
21 @observable
22 bool _addCustomNode = false;
@@ -29,21 +29,11 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
29 bool get addCustomNode => _addCustomNode;
30
31 @action
32 - void setFiatMode(bool value) {
33 - if (value) {
34 - _settingsStore.fiatApiMode = FiatApiMode.disabled;
35 - return;
36 - }
37 - _settingsStore.fiatApiMode = FiatApiMode.enabled;
38 - }
32 + void setFiatApiMode(FiatApiMode fiatApiMode) => _settingsStore.fiatApiMode = fiatApiMode;
33
34 @action
41 - void setExchangeApiMode(ExchangeApiMode value) {
42 - _settingsStore.exchangeStatus = value;
43 - }
35 + void setExchangeApiMode(ExchangeApiMode value) => _settingsStore.exchangeStatus = value;
36
37 @action
46 - void toggleAddCustomNode() {
47 - _addCustomNode = !_addCustomNode;
48 - }
38 + void toggleAddCustomNode() => _addCustomNode = !_addCustomNode;
39 }