Add toggle for disabling service bulletin (#1347)

* Add toggle for disabling service bulletin

* Make the toggle functional

* Fix + add toggle to Advanced Settings

* Remove unused variable

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
tuxsudo
2024-03-25 20:28:45 +02:00
committed by GitHub
co-authored by Omar Hatem
parent bca59ad5e4
commit 4520f583a6
34 changed files with 78 additions and 2 deletions
+1
View File
@@ -20,6 +20,7 @@ class PreferencesKey {
static const isAppSecureKey = 'is_app_secure';
static const disableBuyKey = 'disable_buy';
static const disableSellKey = 'disable_sell';
static const disableBulletinKey = 'disable_bulletin';
static const defaultBuyProvider = 'default_buy_provider';
static const walletListOrder = 'wallet_list_order';
static const walletListAscending = 'wallet_list_ascending';
+10 -1
View File
@@ -103,7 +103,16 @@ class _DashboardPageView extends BasePage {
Widget get endDrawer => MenuWidget(dashboardViewModel);
@override
Widget leading(BuildContext context) => ServicesUpdatesWidget(dashboardViewModel.getServicesStatus());
Widget leading(BuildContext context) {
return Observer(
builder: (context) {
if (dashboardViewModel.isEnabledBulletinAction) {
return ServicesUpdatesWidget(dashboardViewModel.getServicesStatus());
}
return const SizedBox();
},
);
}
@override
Widget middle(BuildContext context) {
@@ -100,6 +100,12 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
Observer(builder: (_) {
return Column(
children: [
SettingsSwitcherCell(
title: S.current.disable_bulletin,
value: widget.privacySettingsViewModel.disableBulletin,
onValueChange: (BuildContext _, bool value) {
widget.privacySettingsViewModel.setDisableBulletin(value);
}),
SettingsSwitcherCell(
title: S.current.add_custom_node,
value: widget.privacySettingsViewModel.addCustomNode,
@@ -80,6 +80,12 @@ class PrivacyPage extends BasePage {
onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setDisableSell(value);
}),
SettingsSwitcherCell(
title: S.current.disable_bulletin,
value: _privacySettingsViewModel.disableBulletin,
onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setDisableBulletin(value);
}),
if (_privacySettingsViewModel.canUseEtherscan)
SettingsSwitcherCell(
title: S.current.etherscan_history,
+13
View File
@@ -59,6 +59,7 @@ abstract class SettingsStoreBase with Store {
required bool initialAppSecure,
required bool initialDisableBuy,
required bool initialDisableSell,
required bool initialDisableBulletin,
required WalletListOrderType initialWalletListOrder,
required bool initialWalletListAscending,
required FiatApiMode initialFiatMode,
@@ -130,6 +131,7 @@ abstract class SettingsStoreBase with Store {
isAppSecure = initialAppSecure,
disableBuy = initialDisableBuy,
disableSell = initialDisableSell,
disableBulletin = initialDisableBulletin,
walletListOrder = initialWalletListOrder,
walletListAscending = initialWalletListAscending,
shouldShowMarketPlaceInDashboard = initialShouldShowMarketPlaceInDashboard,
@@ -291,6 +293,11 @@ abstract class SettingsStoreBase with Store {
(bool disableSell) =>
sharedPreferences.setBool(PreferencesKey.disableSellKey, disableSell));
reaction(
(_) => disableBulletin,
(bool disableBulletin) =>
sharedPreferences.setBool(PreferencesKey.disableBulletinKey, disableBulletin));
reaction(
(_) => walletListOrder,
(WalletListOrderType walletListOrder) =>
@@ -553,6 +560,9 @@ abstract class SettingsStoreBase with Store {
@observable
bool disableSell;
@observable
bool disableBulletin;
@observable
WalletListOrderType walletListOrder;
@@ -777,6 +787,7 @@ abstract class SettingsStoreBase with Store {
final isAppSecure = sharedPreferences.getBool(PreferencesKey.isAppSecureKey) ?? false;
final disableBuy = sharedPreferences.getBool(PreferencesKey.disableBuyKey) ?? false;
final disableSell = sharedPreferences.getBool(PreferencesKey.disableSellKey) ?? false;
final disableBulletin = sharedPreferences.getBool(PreferencesKey.disableBulletinKey) ?? false;
final walletListOrder =
WalletListOrderType.values[sharedPreferences.getInt(PreferencesKey.walletListOrder) ?? 0];
final walletListAscending =
@@ -1029,6 +1040,7 @@ abstract class SettingsStoreBase with Store {
initialAppSecure: isAppSecure,
initialDisableBuy: disableBuy,
initialDisableSell: disableSell,
initialDisableBulletin: disableBulletin,
initialWalletListOrder: walletListOrder,
initialWalletListAscending: walletListAscending,
initialFiatMode: currentFiatApiMode,
@@ -1147,6 +1159,7 @@ abstract class SettingsStoreBase with Store {
isAppSecure = sharedPreferences.getBool(PreferencesKey.isAppSecureKey) ?? isAppSecure;
disableBuy = sharedPreferences.getBool(PreferencesKey.disableBuyKey) ?? disableBuy;
disableSell = sharedPreferences.getBool(PreferencesKey.disableSellKey) ?? disableSell;
disableBulletin = sharedPreferences.getBool(PreferencesKey.disableBulletinKey) ?? disableBulletin;
walletListOrder =
WalletListOrderType.values[sharedPreferences.getInt(PreferencesKey.walletListOrder) ?? 0];
walletListAscending = sharedPreferences.getBool(PreferencesKey.walletListAscending) ?? true;
@@ -20,6 +20,9 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
@computed
FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode;
@computed
bool get disableBulletin => _settingsStore.disableBulletin;
@observable
bool _addCustomNode = false;
@@ -64,6 +67,9 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
@action
void setExchangeApiMode(ExchangeApiMode value) => _settingsStore.exchangeStatus = value;
@action
void setDisableBulletin(bool value) => _settingsStore.disableBulletin = value;
@action
void toggleAddCustomNode() => _addCustomNode = !_addCustomNode;
@@ -355,6 +355,9 @@ abstract class DashboardViewModelBase with Store {
@observable
bool hasSellAction;
@computed
bool get isEnabledBulletinAction => !settingsStore.disableBulletin;
ReactionDisposer? _onMoneroAccountChangeReaction;
ReactionDisposer? _onMoneroBalanceChangeReaction;
@@ -59,6 +59,9 @@ abstract class PrivacySettingsViewModelBase with Store {
@computed
bool get disableSell => _settingsStore.disableSell;
@computed
bool get disableBulletin => _settingsStore.disableBulletin;
@computed
bool get useEtherscan => _settingsStore.useEtherscan;
@@ -106,6 +109,9 @@ abstract class PrivacySettingsViewModelBase with Store {
@action
void setDisableSell(bool value) => _settingsStore.disableSell = value;
@action
void setDisableBulletin(bool value) => _settingsStore.disableBulletin = value;
@action
void setLookupsTwitter(bool value) => _settingsStore.lookupsTwitter = value;