CW-331-Add-option-to-disable-market-place-in-display-settings (#872)

* CW-331-Add-option-to-disable-market-place-in-display-settings [skip ci] * CW-331-Add-option-to-disable-market-place-in-display-settings [skip ci]

Adegoke David committed Apr 16, 2023 at 14:45 UTC 4a203a43c8ca6eb4179321cacf8c3c5155b7200f
29 files changed +124 -42
lib/entities/preferences_key.dart
+1
@@ -39,4 +39,5 @@ class PreferencesKey {
39 static const exchangeProvidersSelection = 'exchange-providers-selection';
40 static const clearnetDonationLink = 'clearnet_donation_link';
41 static const onionDonationLink = 'onion_donation_link';
42 + static const shouldShowMarketPlaceInDashboard = 'should_show_marketplace_in_dashboard';
43 }
lib/src/screens/dashboard/dashboard_page.dart
+41 -19
@@ -109,14 +109,29 @@ class _DashboardPageView extends BasePage {
109
110 final DashboardViewModel dashboardViewModel;
111 final WalletAddressListViewModel addressListViewModel;
112 - final controller = PageController(initialPage: 1);
113 -
114 - var pages = <Widget>[];
112 + int get initialPage => dashboardViewModel.shouldShowMarketPlaceInDashboard ? 1 : 0;
113 + ObservableList<Widget> pages = ObservableList<Widget>();
114 bool _isEffectsInstalled = false;
115 StreamSubscription<bool>? _onInactiveSub;
116
117 @override
118 Widget body(BuildContext context) {
119 + final controller = PageController(initialPage: initialPage);
120 +
121 + reaction((_) => dashboardViewModel.shouldShowMarketPlaceInDashboard, (bool value) {
122 + if (!dashboardViewModel.shouldShowMarketPlaceInDashboard) {
123 + controller.jumpToPage(0);
124 + }
125 + pages.clear();
126 + _isEffectsInstalled = false;
127 + _setEffects(context);
128 +
129 + if (value) {
130 + controller.jumpToPage(1);
131 + } else {
132 + controller.jumpToPage(0);
133 + }
134 + });
135 _setEffects(context);
136
137 return SafeArea(
@@ -125,23 +140,28 @@ class _DashboardPageView extends BasePage {
140 mainAxisSize: MainAxisSize.max,
141 children: <Widget>[
142 Expanded(
128 - child: PageView.builder(
129 - controller: controller,
130 - itemCount: pages.length,
131 - itemBuilder: (context, index) => pages[index])),
143 + child: Observer(builder: (context) {
144 + return PageView.builder(
145 + controller: controller,
146 + itemCount: pages.length,
147 + itemBuilder: (context, index) => pages[index]);
148 + })),
149 Padding(
150 padding: EdgeInsets.only(bottom: 24, top: 10),
134 - child: SmoothPageIndicator(
135 - controller: controller,
136 - count: pages.length,
137 - effect: ColorTransitionEffect(
138 - spacing: 6.0,
139 - radius: 6.0,
140 - dotWidth: 6.0,
141 - dotHeight: 6.0,
142 - dotColor: Theme.of(context).indicatorColor,
143 - activeDotColor:
144 - Theme.of(context).accentTextTheme!.headline4!.backgroundColor!),
151 + child: Observer(builder: (context) {
152 + return SmoothPageIndicator(
153 + controller: controller,
154 + count: pages.length,
155 + effect: ColorTransitionEffect(
156 + spacing: 6.0,
157 + radius: 6.0,
158 + dotWidth: 6.0,
159 + dotHeight: 6.0,
160 + dotColor: Theme.of(context).indicatorColor,
161 + activeDotColor:
162 + Theme.of(context).accentTextTheme!.headline4!.backgroundColor!),
163 + );
164 + }
165 )),
166 Observer(builder: (_) {
167 return ClipRect(
@@ -201,7 +221,9 @@ class _DashboardPageView extends BasePage {
221 if (_isEffectsInstalled) {
222 return;
223 }
204 - pages.add(MarketPlacePage(dashboardViewModel: dashboardViewModel));
224 + if (dashboardViewModel.shouldShowMarketPlaceInDashboard) {
225 + pages.add(MarketPlacePage(dashboardViewModel: dashboardViewModel));
226 + }
227 pages.add(balancePage);
228 pages.add(TransactionsPage(dashboardViewModel: dashboardViewModel));
229 _isEffectsInstalled = true;
lib/src/screens/settings/display_settings_page.dart
+7
@@ -34,6 +34,13 @@ class DisplaySettingsPage extends BasePage {
34 onValueChange: (_, bool value) {
35 _displaySettingsViewModel.setShouldDisplayBalance(value);
36 }),
37 + SettingsSwitcherCell(
38 + title: S.current.show_market_place,
39 + value: _displaySettingsViewModel.shouldShowMarketPlaceInDashboard,
40 + onValueChange: (_, bool value) {
41 + _displaySettingsViewModel.setShouldShowMarketPlaceInDashbaord(value);
42 + },
43 + ),
44 //if (!isHaven) it does not work correctly
45 if(!_displaySettingsViewModel.disabledFiatApiMode)
46 SettingsPickerCell<FiatCurrency>(
lib/store/settings_store.dart
+16
@@ -27,6 +27,7 @@ class SettingsStore = SettingsStoreBase with _$SettingsStore;
27 abstract class SettingsStoreBase with Store {
28 SettingsStoreBase(
29 {required SharedPreferences sharedPreferences,
30 + required bool initialShouldShowMarketPlaceInDashboard,
31 required FiatCurrency initialFiatCurrency,
32 required BalanceDisplayMode initialBalanceDisplayMode,
33 required bool initialSaveRecipientAddress,
@@ -54,6 +55,7 @@ abstract class SettingsStoreBase with Store {
55 shouldSaveRecipientAddress = initialSaveRecipientAddress,
56 fiatApiMode = initialFiatMode,
57 allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
58 + shouldShowMarketPlaceInDashboard = initialShouldShowMarketPlaceInDashboard,
59 exchangeStatus = initialExchangeStatus,
60 currentTheme = initialTheme,
61 pinCodeLength = initialPinLength,
@@ -133,6 +135,11 @@ abstract class SettingsStoreBase with Store {
135 PreferencesKey.allowBiometricalAuthenticationKey,
136 biometricalAuthentication));
137
138 + reaction(
139 + (_) => shouldShowMarketPlaceInDashboard,
140 + (bool value) =>
141 + sharedPreferences.setBool(PreferencesKey.shouldShowMarketPlaceInDashboard, value));
142 +
143 reaction(
144 (_) => pinCodeLength,
145 (int pinLength) => sharedPreferences.setInt(
@@ -177,6 +184,9 @@ abstract class SettingsStoreBase with Store {
184 @observable
185 bool shouldShowYatPopup;
186
187 + @observable
188 + bool shouldShowMarketPlaceInDashboard;
189 +
190 @observable
191 ObservableList<ActionListDisplayMode> actionlistDisplayMode;
192
@@ -285,6 +295,8 @@ abstract class SettingsStoreBase with Store {
295 final allowBiometricalAuthentication = sharedPreferences
296 .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
297 false;
298 + final shouldShowMarketPlaceInDashboard =
299 + sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ?? true;
300 final exchangeStatus = ExchangeApiMode.deserialize(
301 raw: sharedPreferences
302 .getInt(PreferencesKey.exchangeStatusKey) ?? ExchangeApiMode.enabled.raw);
@@ -348,6 +360,7 @@ abstract class SettingsStoreBase with Store {
360
361 return SettingsStore(
362 sharedPreferences: sharedPreferences,
363 + initialShouldShowMarketPlaceInDashboard: shouldShowMarketPlaceInDashboard,
364 nodes: nodes,
365 appVersion: packageInfo.version,
366 isBitcoinBuyEnabled: isBitcoinBuyEnabled,
@@ -402,6 +415,9 @@ abstract class SettingsStoreBase with Store {
415 allowBiometricalAuthentication = sharedPreferences
416 .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
417 allowBiometricalAuthentication;
418 + shouldShowMarketPlaceInDashboard =
419 + sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ??
420 + shouldShowMarketPlaceInDashboard;
421 exchangeStatus = ExchangeApiMode.deserialize(
422 raw: sharedPreferences
423 .getInt(PreferencesKey.exchangeStatusKey) ?? ExchangeApiMode.enabled.raw);
lib/view_model/dashboard/dashboard_view_model.dart
+5
@@ -213,6 +213,11 @@ abstract class DashboardViewModelBase with Store {
213 @computed
214 BalanceDisplayMode get balanceDisplayMode =>
215 appStore.settingsStore.balanceDisplayMode;
216 +
217 + @computed
218 + bool get shouldShowMarketPlaceInDashboard {
219 + return appStore.settingsStore.shouldShowMarketPlaceInDashboard;
220 + }
221
222 @computed
223 List<TradeListItem> get trades => tradesStore.trades
lib/view_model/settings/display_settings_view_model.dart
+8
@@ -28,6 +28,9 @@ abstract class DisplaySettingsViewModelBase with Store {
28 @computed
29 bool get shouldDisplayBalance => balanceDisplayMode == BalanceDisplayMode.displayableBalance;
30
31 + @computed
32 + bool get shouldShowMarketPlaceInDashboard => _settingsStore.shouldShowMarketPlaceInDashboard;
33 +
34 @computed
35 ThemeBase get theme => _settingsStore.currentTheme;
36
@@ -58,4 +61,9 @@ abstract class DisplaySettingsViewModelBase with Store {
61
62 @action
63 void setFiatCurrency(FiatCurrency value) => _settingsStore.fiatCurrency = value;
64 +
65 + @action
66 + void setShouldShowMarketPlaceInDashbaord(bool value) {
67 + _settingsStore.shouldShowMarketPlaceInDashboard = value;
68 + }
69 }
res/values/strings_ar.arb
+2 -1
@@ -696,5 +696,6 @@
696 "clearnet_link": "رابط Clearnet",
697 "onion_link": "رابط البصل",
698 "settings": "إعدادات",
699 - "sell_monero_com_alert_content": "بيع Monero غير مدعوم حتى الآن"
699 + "sell_monero_com_alert_content": "بيع Monero غير مدعوم حتى الآن",
700 + "show_market_place": "إظهار السوق"
701 }
res/values/strings_bg.arb
+2 -1
@@ -697,5 +697,6 @@
697 "optional_name": "Незадължително име на получател",
698 "clearnet_link": "Clearnet връзка",
699 "onion_link": "Лукова връзка",
700 - "sell_monero_com_alert_content": "Продажбата на Monero все още не се поддържа"
700 + "sell_monero_com_alert_content": "Продажбата на Monero все още не се поддържа",
701 + "show_market_place":"Покажи пазар"
702 }
res/values/strings_cs.arb
+2 -1
@@ -697,5 +697,6 @@
697 "optional_name": "Volitelné jméno příjemce",
698 "clearnet_link": "Odkaz na Clearnet",
699 "onion_link": "Cibulový odkaz",
700 - "sell_monero_com_alert_content": "Prodej Monero zatím není podporován"
700 + "sell_monero_com_alert_content": "Prodej Monero zatím není podporován",
701 + "show_market_place": "Zobrazit trh"
702 }
res/values/strings_de.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "Clearnet-Link",
699 "onion_link": "Zwiebel-Link",
700 "settings": "Einstellungen",
701 - "sell_monero_com_alert_content": "Der Verkauf von Monero wird noch nicht unterstützt"
701 + "sell_monero_com_alert_content": "Der Verkauf von Monero wird noch nicht unterstützt",
702 + "show_market_place": "Marktplatz anzeigen"
703 }
res/values/strings_en.arb
+2 -1
@@ -698,5 +698,6 @@
698 "decimal_places_error": "Too many decimal places",
699 "edit_node": "Edit Node",
700 "settings": "Settings",
701 - "sell_monero_com_alert_content": "Selling Monero is not supported yet"
701 + "sell_monero_com_alert_content": "Selling Monero is not supported yet",
702 + "show_market_place" :"Show Marketplace"
703 }
res/values/strings_es.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "enlace Clearnet",
699 "onion_link": "Enlace de cebolla",
700 "settings": "Configuraciones",
701 - "sell_monero_com_alert_content": "Aún no se admite la venta de Monero"
701 + "sell_monero_com_alert_content": "Aún no se admite la venta de Monero",
702 + "show_market_place": "Mostrar mercado"
703 }
res/values/strings_fr.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "Lien Clearnet",
699 "settings": "Paramètres",
700 "onion_link": "Lien .onion",
701 - "sell_monero_com_alert_content": "La vente de Monero n'est pas encore prise en charge"
701 + "sell_monero_com_alert_content": "La vente de Monero n'est pas encore prise en charge",
702 + "show_market_place" :"Afficher la place de marché"
703 }
res/values/strings_hi.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "क्लियरनेट लिंक",
699 "onion_link": "प्याज का लिंक",
700 "settings": "समायोजन",
701 - "sell_monero_com_alert_content": "मोनेरो बेचना अभी तक समर्थित नहीं है"
701 + "sell_monero_com_alert_content": "मोनेरो बेचना अभी तक समर्थित नहीं है",
702 + "show_market_place":"बाज़ार दिखाएँ"
703 }
res/values/strings_hr.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "Clearnet veza",
699 "onion_link": "Poveznica luka",
700 "settings": "Postavke",
701 - "sell_monero_com_alert_content": "Prodaja Monera još nije podržana"
701 + "sell_monero_com_alert_content": "Prodaja Monera još nije podržana",
702 + "show_market_place" : "Prikaži tržište"
703 }
res/values/strings_id.arb
+2 -1
@@ -679,5 +679,6 @@
679 "optional_name": "Nama penerima opsional",
680 "clearnet_link": "Tautan clearnet",
681 "onion_link": "Tautan bawang",
682 - "sell_monero_com_alert_content": "Menjual Monero belum didukung"
682 + "sell_monero_com_alert_content": "Menjual Monero belum didukung",
683 + "show_market_place": "Tampilkan Pasar"
684 }
res/values/strings_it.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "Collegamento Clearnet",
699 "onion_link": "Collegamento a cipolla",
700 "settings": "Impostazioni",
701 - "sell_monero_com_alert_content": "La vendita di Monero non è ancora supportata"
701 + "sell_monero_com_alert_content": "La vendita di Monero non è ancora supportata",
702 + "show_market_place":"Mostra mercato"
703 }
res/values/strings_ja.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "クリアネット リンク",
699 "onion_link": "オニオンリンク",
700 "settings": "設定",
701 - "sell_monero_com_alert_content": "モネロの販売はまだサポートされていません"
701 + "sell_monero_com_alert_content": "モネロの販売はまだサポートされていません",
702 + "show_market_place":"マーケットプレイスを表示"
703 }
res/values/strings_ko.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "클리어넷 링크",
699 "onion_link": "양파 링크",
700 "settings": "설정",
701 - "sell_monero_com_alert_content": "지원되지 않습니다."
701 + "sell_monero_com_alert_content": "지원되지 않습니다.",
702 + "show_market_place":"마켓플레이스 표시"
703 }
res/values/strings_my.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "Clearnet လင့်ခ်",
699 "onion_link": "ကြက်သွန်လင့်",
700 "settings": "ဆက်တင်များ",
701 - "sell_monero_com_alert_content": "Monero ရောင်းချခြင်းကို မပံ့ပိုးရသေးပါ။"
701 + "sell_monero_com_alert_content": "Monero ရောင်းချခြင်းကို မပံ့ပိုးရသေးပါ။",
702 + "show_market_place":"စျေးကွက်ကိုပြသပါ။"
703 }
res/values/strings_nl.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "Clearnet-link",
699 "onion_link": "Ui koppeling",
700 "settings": "Instellingen",
701 - "sell_monero_com_alert_content": "Het verkopen van Monero wordt nog niet ondersteund"
701 + "sell_monero_com_alert_content": "Het verkopen van Monero wordt nog niet ondersteund",
702 + "show_market_place":"Toon Marktplaats"
703 }
res/values/strings_pl.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "łącze Clearnet",
699 "onion_link": "Łącznik cebulowy",
700 "settings": "Ustawienia",
701 - "sell_monero_com_alert_content": "Sprzedaż Monero nie jest jeszcze obsługiwana"
701 + "sell_monero_com_alert_content": "Sprzedaż Monero nie jest jeszcze obsługiwana",
702 + "show_market_place" : "Pokaż rynek"
703 }
res/values/strings_pt.arb
+2 -1
@@ -697,5 +697,6 @@
697 "clearnet_link": "link clear net",
698 "onion_link": "ligação de cebola",
699 "settings": "Configurações",
700 - "sell_monero_com_alert_content": "A venda de Monero ainda não é suportada"
700 + "sell_monero_com_alert_content": "A venda de Monero ainda não é suportada",
701 + "show_market_place":"Mostrar mercado"
702 }
res/values/strings_ru.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "Клирнет ссылка",
699 "onion_link": "Луковая ссылка",
700 "settings": "Настройки",
701 - "sell_monero_com_alert_content": "Продажа Monero пока не поддерживается"
701 + "sell_monero_com_alert_content": "Продажа Monero пока не поддерживается",
702 + "show_market_place":"Показать торговую площадку"
703 }
res/values/strings_th.arb
+2 -1
@@ -696,5 +696,6 @@
696 "clearnet_link": "ลิงค์เคลียร์เน็ต",
697 "onion_link": "ลิงค์หัวหอม",
698 "settings": "การตั้งค่า",
699 - "sell_monero_com_alert_content": "ยังไม่รองรับการขาย Monero"
699 + "sell_monero_com_alert_content": "ยังไม่รองรับการขาย Monero",
700 + "show_market_place":"แสดงตลาดกลาง"
701 }
res/values/strings_tr.arb
+2 -1
@@ -698,5 +698,6 @@
698 "clearnet_link": "Net bağlantı",
699 "onion_link": "soğan bağlantısı",
700 "settings": "ayarlar",
701 - "sell_monero_com_alert_content": "Monero satışı henüz desteklenmiyor"
701 + "sell_monero_com_alert_content": "Monero satışı henüz desteklenmiyor",
702 + "show_market_place":"Pazar Yerini Göster"
703 }
res/values/strings_uk.arb
+2 -1
@@ -697,5 +697,6 @@
697 "clearnet_link": "Посилання Clearnet",
698 "onion_link": "Посилання на цибулю",
699 "settings": "Налаштування",
700 - "sell_monero_com_alert_content": "Продаж Monero ще не підтримується"
700 + "sell_monero_com_alert_content": "Продаж Monero ще не підтримується",
701 + "show_market_place":"Шоу Ринок"
702 }
res/values/strings_ur.arb
+2 -1
@@ -698,5 +698,6 @@
698 "optional_name": "اختیاری وصول کنندہ کا نام",
699 "clearnet_link": "کلیرنیٹ لنک",
700 "onion_link": "پیاز کا لنک",
701 - "sell_monero_com_alert_content": "Monero فروخت کرنا ابھی تک تعاون یافتہ نہیں ہے۔"
701 + "sell_monero_com_alert_content": "Monero فروخت کرنا ابھی تک تعاون یافتہ نہیں ہے۔",
702 + "show_market_place":"بازار دکھائیں۔"
703 }
res/values/strings_zh.arb
+2 -1
@@ -697,5 +697,6 @@
697 "clearnet_link": "明网链接",
698 "onion_link": "洋葱链接",
699 "settings": "设置",
700 - "sell_monero_com_alert_content": "尚不支持出售门罗币"
700 + "sell_monero_com_alert_content": "尚不支持出售门罗币",
701 + "show_market_place" :"显示市场"
702 }