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]
This commit is contained in:
Adegoke David 2023-04-16 14:45:35 +01:00 committed by GitHub
parent 77ab6b49f4
commit 4a203a43c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 124 additions and 42 deletions

View file

@ -39,4 +39,5 @@ class PreferencesKey {
static const exchangeProvidersSelection = 'exchange-providers-selection'; static const exchangeProvidersSelection = 'exchange-providers-selection';
static const clearnetDonationLink = 'clearnet_donation_link'; static const clearnetDonationLink = 'clearnet_donation_link';
static const onionDonationLink = 'onion_donation_link'; static const onionDonationLink = 'onion_donation_link';
static const shouldShowMarketPlaceInDashboard = 'should_show_marketplace_in_dashboard';
} }

View file

@ -109,14 +109,29 @@ class _DashboardPageView extends BasePage {
final DashboardViewModel dashboardViewModel; final DashboardViewModel dashboardViewModel;
final WalletAddressListViewModel addressListViewModel; final WalletAddressListViewModel addressListViewModel;
final controller = PageController(initialPage: 1); int get initialPage => dashboardViewModel.shouldShowMarketPlaceInDashboard ? 1 : 0;
ObservableList<Widget> pages = ObservableList<Widget>();
var pages = <Widget>[];
bool _isEffectsInstalled = false; bool _isEffectsInstalled = false;
StreamSubscription<bool>? _onInactiveSub; StreamSubscription<bool>? _onInactiveSub;
@override @override
Widget body(BuildContext context) { Widget body(BuildContext context) {
final controller = PageController(initialPage: initialPage);
reaction((_) => dashboardViewModel.shouldShowMarketPlaceInDashboard, (bool value) {
if (!dashboardViewModel.shouldShowMarketPlaceInDashboard) {
controller.jumpToPage(0);
}
pages.clear();
_isEffectsInstalled = false;
_setEffects(context);
if (value) {
controller.jumpToPage(1);
} else {
controller.jumpToPage(0);
}
});
_setEffects(context); _setEffects(context);
return SafeArea( return SafeArea(
@ -125,23 +140,28 @@ class _DashboardPageView extends BasePage {
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: PageView.builder( child: Observer(builder: (context) {
controller: controller, return PageView.builder(
itemCount: pages.length, controller: controller,
itemBuilder: (context, index) => pages[index])), itemCount: pages.length,
itemBuilder: (context, index) => pages[index]);
})),
Padding( Padding(
padding: EdgeInsets.only(bottom: 24, top: 10), padding: EdgeInsets.only(bottom: 24, top: 10),
child: SmoothPageIndicator( child: Observer(builder: (context) {
controller: controller, return SmoothPageIndicator(
count: pages.length, controller: controller,
effect: ColorTransitionEffect( count: pages.length,
spacing: 6.0, effect: ColorTransitionEffect(
radius: 6.0, spacing: 6.0,
dotWidth: 6.0, radius: 6.0,
dotHeight: 6.0, dotWidth: 6.0,
dotColor: Theme.of(context).indicatorColor, dotHeight: 6.0,
activeDotColor: dotColor: Theme.of(context).indicatorColor,
Theme.of(context).accentTextTheme!.headline4!.backgroundColor!), activeDotColor:
Theme.of(context).accentTextTheme!.headline4!.backgroundColor!),
);
}
)), )),
Observer(builder: (_) { Observer(builder: (_) {
return ClipRect( return ClipRect(
@ -201,7 +221,9 @@ class _DashboardPageView extends BasePage {
if (_isEffectsInstalled) { if (_isEffectsInstalled) {
return; return;
} }
pages.add(MarketPlacePage(dashboardViewModel: dashboardViewModel)); if (dashboardViewModel.shouldShowMarketPlaceInDashboard) {
pages.add(MarketPlacePage(dashboardViewModel: dashboardViewModel));
}
pages.add(balancePage); pages.add(balancePage);
pages.add(TransactionsPage(dashboardViewModel: dashboardViewModel)); pages.add(TransactionsPage(dashboardViewModel: dashboardViewModel));
_isEffectsInstalled = true; _isEffectsInstalled = true;

View file

@ -34,6 +34,13 @@ class DisplaySettingsPage extends BasePage {
onValueChange: (_, bool value) { onValueChange: (_, bool value) {
_displaySettingsViewModel.setShouldDisplayBalance(value); _displaySettingsViewModel.setShouldDisplayBalance(value);
}), }),
SettingsSwitcherCell(
title: S.current.show_market_place,
value: _displaySettingsViewModel.shouldShowMarketPlaceInDashboard,
onValueChange: (_, bool value) {
_displaySettingsViewModel.setShouldShowMarketPlaceInDashbaord(value);
},
),
//if (!isHaven) it does not work correctly //if (!isHaven) it does not work correctly
if(!_displaySettingsViewModel.disabledFiatApiMode) if(!_displaySettingsViewModel.disabledFiatApiMode)
SettingsPickerCell<FiatCurrency>( SettingsPickerCell<FiatCurrency>(

View file

@ -27,6 +27,7 @@ class SettingsStore = SettingsStoreBase with _$SettingsStore;
abstract class SettingsStoreBase with Store { abstract class SettingsStoreBase with Store {
SettingsStoreBase( SettingsStoreBase(
{required SharedPreferences sharedPreferences, {required SharedPreferences sharedPreferences,
required bool initialShouldShowMarketPlaceInDashboard,
required FiatCurrency initialFiatCurrency, required FiatCurrency initialFiatCurrency,
required BalanceDisplayMode initialBalanceDisplayMode, required BalanceDisplayMode initialBalanceDisplayMode,
required bool initialSaveRecipientAddress, required bool initialSaveRecipientAddress,
@ -54,6 +55,7 @@ abstract class SettingsStoreBase with Store {
shouldSaveRecipientAddress = initialSaveRecipientAddress, shouldSaveRecipientAddress = initialSaveRecipientAddress,
fiatApiMode = initialFiatMode, fiatApiMode = initialFiatMode,
allowBiometricalAuthentication = initialAllowBiometricalAuthentication, allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
shouldShowMarketPlaceInDashboard = initialShouldShowMarketPlaceInDashboard,
exchangeStatus = initialExchangeStatus, exchangeStatus = initialExchangeStatus,
currentTheme = initialTheme, currentTheme = initialTheme,
pinCodeLength = initialPinLength, pinCodeLength = initialPinLength,
@ -133,6 +135,11 @@ abstract class SettingsStoreBase with Store {
PreferencesKey.allowBiometricalAuthenticationKey, PreferencesKey.allowBiometricalAuthenticationKey,
biometricalAuthentication)); biometricalAuthentication));
reaction(
(_) => shouldShowMarketPlaceInDashboard,
(bool value) =>
sharedPreferences.setBool(PreferencesKey.shouldShowMarketPlaceInDashboard, value));
reaction( reaction(
(_) => pinCodeLength, (_) => pinCodeLength,
(int pinLength) => sharedPreferences.setInt( (int pinLength) => sharedPreferences.setInt(
@ -177,6 +184,9 @@ abstract class SettingsStoreBase with Store {
@observable @observable
bool shouldShowYatPopup; bool shouldShowYatPopup;
@observable
bool shouldShowMarketPlaceInDashboard;
@observable @observable
ObservableList<ActionListDisplayMode> actionlistDisplayMode; ObservableList<ActionListDisplayMode> actionlistDisplayMode;
@ -285,6 +295,8 @@ abstract class SettingsStoreBase with Store {
final allowBiometricalAuthentication = sharedPreferences final allowBiometricalAuthentication = sharedPreferences
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ?? .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
false; false;
final shouldShowMarketPlaceInDashboard =
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ?? true;
final exchangeStatus = ExchangeApiMode.deserialize( final exchangeStatus = ExchangeApiMode.deserialize(
raw: sharedPreferences raw: sharedPreferences
.getInt(PreferencesKey.exchangeStatusKey) ?? ExchangeApiMode.enabled.raw); .getInt(PreferencesKey.exchangeStatusKey) ?? ExchangeApiMode.enabled.raw);
@ -348,6 +360,7 @@ abstract class SettingsStoreBase with Store {
return SettingsStore( return SettingsStore(
sharedPreferences: sharedPreferences, sharedPreferences: sharedPreferences,
initialShouldShowMarketPlaceInDashboard: shouldShowMarketPlaceInDashboard,
nodes: nodes, nodes: nodes,
appVersion: packageInfo.version, appVersion: packageInfo.version,
isBitcoinBuyEnabled: isBitcoinBuyEnabled, isBitcoinBuyEnabled: isBitcoinBuyEnabled,
@ -402,6 +415,9 @@ abstract class SettingsStoreBase with Store {
allowBiometricalAuthentication = sharedPreferences allowBiometricalAuthentication = sharedPreferences
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ?? .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
allowBiometricalAuthentication; allowBiometricalAuthentication;
shouldShowMarketPlaceInDashboard =
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ??
shouldShowMarketPlaceInDashboard;
exchangeStatus = ExchangeApiMode.deserialize( exchangeStatus = ExchangeApiMode.deserialize(
raw: sharedPreferences raw: sharedPreferences
.getInt(PreferencesKey.exchangeStatusKey) ?? ExchangeApiMode.enabled.raw); .getInt(PreferencesKey.exchangeStatusKey) ?? ExchangeApiMode.enabled.raw);

View file

@ -213,6 +213,11 @@ abstract class DashboardViewModelBase with Store {
@computed @computed
BalanceDisplayMode get balanceDisplayMode => BalanceDisplayMode get balanceDisplayMode =>
appStore.settingsStore.balanceDisplayMode; appStore.settingsStore.balanceDisplayMode;
@computed
bool get shouldShowMarketPlaceInDashboard {
return appStore.settingsStore.shouldShowMarketPlaceInDashboard;
}
@computed @computed
List<TradeListItem> get trades => tradesStore.trades List<TradeListItem> get trades => tradesStore.trades

View file

@ -28,6 +28,9 @@ abstract class DisplaySettingsViewModelBase with Store {
@computed @computed
bool get shouldDisplayBalance => balanceDisplayMode == BalanceDisplayMode.displayableBalance; bool get shouldDisplayBalance => balanceDisplayMode == BalanceDisplayMode.displayableBalance;
@computed
bool get shouldShowMarketPlaceInDashboard => _settingsStore.shouldShowMarketPlaceInDashboard;
@computed @computed
ThemeBase get theme => _settingsStore.currentTheme; ThemeBase get theme => _settingsStore.currentTheme;
@ -58,4 +61,9 @@ abstract class DisplaySettingsViewModelBase with Store {
@action @action
void setFiatCurrency(FiatCurrency value) => _settingsStore.fiatCurrency = value; void setFiatCurrency(FiatCurrency value) => _settingsStore.fiatCurrency = value;
@action
void setShouldShowMarketPlaceInDashbaord(bool value) {
_settingsStore.shouldShowMarketPlaceInDashboard = value;
}
} }

View file

@ -696,5 +696,6 @@
"clearnet_link": "رابط Clearnet", "clearnet_link": "رابط Clearnet",
"onion_link": "رابط البصل", "onion_link": "رابط البصل",
"settings": "إعدادات", "settings": "إعدادات",
"sell_monero_com_alert_content": "بيع Monero غير مدعوم حتى الآن" "sell_monero_com_alert_content": "بيع Monero غير مدعوم حتى الآن",
"show_market_place": "إظهار السوق"
} }

View file

@ -697,5 +697,6 @@
"optional_name": "Незадължително име на получател", "optional_name": "Незадължително име на получател",
"clearnet_link": "Clearnet връзка", "clearnet_link": "Clearnet връзка",
"onion_link": "Лукова връзка", "onion_link": "Лукова връзка",
"sell_monero_com_alert_content": "Продажбата на Monero все още не се поддържа" "sell_monero_com_alert_content": "Продажбата на Monero все още не се поддържа",
"show_market_place":"Покажи пазар"
} }

View file

@ -697,5 +697,6 @@
"optional_name": "Volitelné jméno příjemce", "optional_name": "Volitelné jméno příjemce",
"clearnet_link": "Odkaz na Clearnet", "clearnet_link": "Odkaz na Clearnet",
"onion_link": "Cibulový odkaz", "onion_link": "Cibulový odkaz",
"sell_monero_com_alert_content": "Prodej Monero zatím není podporován" "sell_monero_com_alert_content": "Prodej Monero zatím není podporován",
"show_market_place": "Zobrazit trh"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "Clearnet-Link", "clearnet_link": "Clearnet-Link",
"onion_link": "Zwiebel-Link", "onion_link": "Zwiebel-Link",
"settings": "Einstellungen", "settings": "Einstellungen",
"sell_monero_com_alert_content": "Der Verkauf von Monero wird noch nicht unterstützt" "sell_monero_com_alert_content": "Der Verkauf von Monero wird noch nicht unterstützt",
"show_market_place": "Marktplatz anzeigen"
} }

View file

@ -698,5 +698,6 @@
"decimal_places_error": "Too many decimal places", "decimal_places_error": "Too many decimal places",
"edit_node": "Edit Node", "edit_node": "Edit Node",
"settings": "Settings", "settings": "Settings",
"sell_monero_com_alert_content": "Selling Monero is not supported yet" "sell_monero_com_alert_content": "Selling Monero is not supported yet",
"show_market_place" :"Show Marketplace"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "enlace Clearnet", "clearnet_link": "enlace Clearnet",
"onion_link": "Enlace de cebolla", "onion_link": "Enlace de cebolla",
"settings": "Configuraciones", "settings": "Configuraciones",
"sell_monero_com_alert_content": "Aún no se admite la venta de Monero" "sell_monero_com_alert_content": "Aún no se admite la venta de Monero",
"show_market_place": "Mostrar mercado"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "Lien Clearnet", "clearnet_link": "Lien Clearnet",
"settings": "Paramètres", "settings": "Paramètres",
"onion_link": "Lien .onion", "onion_link": "Lien .onion",
"sell_monero_com_alert_content": "La vente de Monero n'est pas encore prise en charge" "sell_monero_com_alert_content": "La vente de Monero n'est pas encore prise en charge",
"show_market_place" :"Afficher la place de marché"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "क्लियरनेट लिंक", "clearnet_link": "क्लियरनेट लिंक",
"onion_link": "प्याज का लिंक", "onion_link": "प्याज का लिंक",
"settings": "समायोजन", "settings": "समायोजन",
"sell_monero_com_alert_content": "मोनेरो बेचना अभी तक समर्थित नहीं है" "sell_monero_com_alert_content": "मोनेरो बेचना अभी तक समर्थित नहीं है",
"show_market_place":"बाज़ार दिखाएँ"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "Clearnet veza", "clearnet_link": "Clearnet veza",
"onion_link": "Poveznica luka", "onion_link": "Poveznica luka",
"settings": "Postavke", "settings": "Postavke",
"sell_monero_com_alert_content": "Prodaja Monera još nije podržana" "sell_monero_com_alert_content": "Prodaja Monera još nije podržana",
"show_market_place" : "Prikaži tržište"
} }

View file

@ -679,5 +679,6 @@
"optional_name": "Nama penerima opsional", "optional_name": "Nama penerima opsional",
"clearnet_link": "Tautan clearnet", "clearnet_link": "Tautan clearnet",
"onion_link": "Tautan bawang", "onion_link": "Tautan bawang",
"sell_monero_com_alert_content": "Menjual Monero belum didukung" "sell_monero_com_alert_content": "Menjual Monero belum didukung",
"show_market_place": "Tampilkan Pasar"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "Collegamento Clearnet", "clearnet_link": "Collegamento Clearnet",
"onion_link": "Collegamento a cipolla", "onion_link": "Collegamento a cipolla",
"settings": "Impostazioni", "settings": "Impostazioni",
"sell_monero_com_alert_content": "La vendita di Monero non è ancora supportata" "sell_monero_com_alert_content": "La vendita di Monero non è ancora supportata",
"show_market_place":"Mostra mercato"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "クリアネット リンク", "clearnet_link": "クリアネット リンク",
"onion_link": "オニオンリンク", "onion_link": "オニオンリンク",
"settings": "設定", "settings": "設定",
"sell_monero_com_alert_content": "モネロの販売はまだサポートされていません" "sell_monero_com_alert_content": "モネロの販売はまだサポートされていません",
"show_market_place":"マーケットプレイスを表示"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "클리어넷 링크", "clearnet_link": "클리어넷 링크",
"onion_link": "양파 링크", "onion_link": "양파 링크",
"settings": "설정", "settings": "설정",
"sell_monero_com_alert_content": "지원되지 않습니다." "sell_monero_com_alert_content": "지원되지 않습니다.",
"show_market_place":"마켓플레이스 표시"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "Clearnet လင့်ခ်", "clearnet_link": "Clearnet လင့်ခ်",
"onion_link": "ကြက်သွန်လင့်", "onion_link": "ကြက်သွန်လင့်",
"settings": "ဆက်တင်များ", "settings": "ဆက်တင်များ",
"sell_monero_com_alert_content": "Monero ရောင်းချခြင်းကို မပံ့ပိုးရသေးပါ။" "sell_monero_com_alert_content": "Monero ရောင်းချခြင်းကို မပံ့ပိုးရသေးပါ။",
"show_market_place":"စျေးကွက်ကိုပြသပါ။"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "Clearnet-link", "clearnet_link": "Clearnet-link",
"onion_link": "Ui koppeling", "onion_link": "Ui koppeling",
"settings": "Instellingen", "settings": "Instellingen",
"sell_monero_com_alert_content": "Het verkopen van Monero wordt nog niet ondersteund" "sell_monero_com_alert_content": "Het verkopen van Monero wordt nog niet ondersteund",
"show_market_place":"Toon Marktplaats"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "łącze Clearnet", "clearnet_link": "łącze Clearnet",
"onion_link": "Łącznik cebulowy", "onion_link": "Łącznik cebulowy",
"settings": "Ustawienia", "settings": "Ustawienia",
"sell_monero_com_alert_content": "Sprzedaż Monero nie jest jeszcze obsługiwana" "sell_monero_com_alert_content": "Sprzedaż Monero nie jest jeszcze obsługiwana",
"show_market_place" : "Pokaż rynek"
} }

View file

@ -697,5 +697,6 @@
"clearnet_link": "link clear net", "clearnet_link": "link clear net",
"onion_link": "ligação de cebola", "onion_link": "ligação de cebola",
"settings": "Configurações", "settings": "Configurações",
"sell_monero_com_alert_content": "A venda de Monero ainda não é suportada" "sell_monero_com_alert_content": "A venda de Monero ainda não é suportada",
"show_market_place":"Mostrar mercado"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "Клирнет ссылка", "clearnet_link": "Клирнет ссылка",
"onion_link": "Луковая ссылка", "onion_link": "Луковая ссылка",
"settings": "Настройки", "settings": "Настройки",
"sell_monero_com_alert_content": "Продажа Monero пока не поддерживается" "sell_monero_com_alert_content": "Продажа Monero пока не поддерживается",
"show_market_place":"Показать торговую площадку"
} }

View file

@ -696,5 +696,6 @@
"clearnet_link": "ลิงค์เคลียร์เน็ต", "clearnet_link": "ลิงค์เคลียร์เน็ต",
"onion_link": "ลิงค์หัวหอม", "onion_link": "ลิงค์หัวหอม",
"settings": "การตั้งค่า", "settings": "การตั้งค่า",
"sell_monero_com_alert_content": "ยังไม่รองรับการขาย Monero" "sell_monero_com_alert_content": "ยังไม่รองรับการขาย Monero",
"show_market_place":"แสดงตลาดกลาง"
} }

View file

@ -698,5 +698,6 @@
"clearnet_link": "Net bağlantı", "clearnet_link": "Net bağlantı",
"onion_link": "soğan bağlantısı", "onion_link": "soğan bağlantısı",
"settings": "ayarlar", "settings": "ayarlar",
"sell_monero_com_alert_content": "Monero satışı henüz desteklenmiyor" "sell_monero_com_alert_content": "Monero satışı henüz desteklenmiyor",
"show_market_place":"Pazar Yerini Göster"
} }

View file

@ -697,5 +697,6 @@
"clearnet_link": "Посилання Clearnet", "clearnet_link": "Посилання Clearnet",
"onion_link": "Посилання на цибулю", "onion_link": "Посилання на цибулю",
"settings": "Налаштування", "settings": "Налаштування",
"sell_monero_com_alert_content": "Продаж Monero ще не підтримується" "sell_monero_com_alert_content": "Продаж Monero ще не підтримується",
"show_market_place":"Шоу Ринок"
} }

View file

@ -698,5 +698,6 @@
"optional_name": "اختیاری وصول کنندہ کا نام", "optional_name": "اختیاری وصول کنندہ کا نام",
"clearnet_link": "کلیرنیٹ لنک", "clearnet_link": "کلیرنیٹ لنک",
"onion_link": "پیاز کا لنک", "onion_link": "پیاز کا لنک",
"sell_monero_com_alert_content": "Monero فروخت کرنا ابھی تک تعاون یافتہ نہیں ہے۔" "sell_monero_com_alert_content": "Monero فروخت کرنا ابھی تک تعاون یافتہ نہیں ہے۔",
"show_market_place":"بازار دکھائیں۔"
} }

View file

@ -697,5 +697,6 @@
"clearnet_link": "明网链接", "clearnet_link": "明网链接",
"onion_link": "洋葱链接", "onion_link": "洋葱链接",
"settings": "设置", "settings": "设置",
"sell_monero_com_alert_content": "尚不支持出售门罗币" "sell_monero_com_alert_content": "尚不支持出售门罗币",
"show_market_place" :"显示市场"
} }