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 15:45:35 +02:00
committed by GitHub
parent 77ab6b49f4
commit 4a203a43c8
29 changed files with 124 additions and 42 deletions
+1
View File
@@ -39,4 +39,5 @@ class PreferencesKey {
static const exchangeProvidersSelection = 'exchange-providers-selection';
static const clearnetDonationLink = 'clearnet_donation_link';
static const onionDonationLink = 'onion_donation_link';
static const shouldShowMarketPlaceInDashboard = 'should_show_marketplace_in_dashboard';
}
+41 -19
View File
@@ -109,14 +109,29 @@ class _DashboardPageView extends BasePage {
final DashboardViewModel dashboardViewModel;
final WalletAddressListViewModel addressListViewModel;
final controller = PageController(initialPage: 1);
var pages = <Widget>[];
int get initialPage => dashboardViewModel.shouldShowMarketPlaceInDashboard ? 1 : 0;
ObservableList<Widget> pages = ObservableList<Widget>();
bool _isEffectsInstalled = false;
StreamSubscription<bool>? _onInactiveSub;
@override
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);
return SafeArea(
@@ -125,23 +140,28 @@ class _DashboardPageView extends BasePage {
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
child: PageView.builder(
controller: controller,
itemCount: pages.length,
itemBuilder: (context, index) => pages[index])),
child: Observer(builder: (context) {
return PageView.builder(
controller: controller,
itemCount: pages.length,
itemBuilder: (context, index) => pages[index]);
})),
Padding(
padding: EdgeInsets.only(bottom: 24, top: 10),
child: SmoothPageIndicator(
controller: controller,
count: pages.length,
effect: ColorTransitionEffect(
spacing: 6.0,
radius: 6.0,
dotWidth: 6.0,
dotHeight: 6.0,
dotColor: Theme.of(context).indicatorColor,
activeDotColor:
Theme.of(context).accentTextTheme!.headline4!.backgroundColor!),
child: Observer(builder: (context) {
return SmoothPageIndicator(
controller: controller,
count: pages.length,
effect: ColorTransitionEffect(
spacing: 6.0,
radius: 6.0,
dotWidth: 6.0,
dotHeight: 6.0,
dotColor: Theme.of(context).indicatorColor,
activeDotColor:
Theme.of(context).accentTextTheme!.headline4!.backgroundColor!),
);
}
)),
Observer(builder: (_) {
return ClipRect(
@@ -201,7 +221,9 @@ class _DashboardPageView extends BasePage {
if (_isEffectsInstalled) {
return;
}
pages.add(MarketPlacePage(dashboardViewModel: dashboardViewModel));
if (dashboardViewModel.shouldShowMarketPlaceInDashboard) {
pages.add(MarketPlacePage(dashboardViewModel: dashboardViewModel));
}
pages.add(balancePage);
pages.add(TransactionsPage(dashboardViewModel: dashboardViewModel));
_isEffectsInstalled = true;
@@ -34,6 +34,13 @@ class DisplaySettingsPage extends BasePage {
onValueChange: (_, bool 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(!_displaySettingsViewModel.disabledFiatApiMode)
SettingsPickerCell<FiatCurrency>(
+16
View File
@@ -27,6 +27,7 @@ class SettingsStore = SettingsStoreBase with _$SettingsStore;
abstract class SettingsStoreBase with Store {
SettingsStoreBase(
{required SharedPreferences sharedPreferences,
required bool initialShouldShowMarketPlaceInDashboard,
required FiatCurrency initialFiatCurrency,
required BalanceDisplayMode initialBalanceDisplayMode,
required bool initialSaveRecipientAddress,
@@ -54,6 +55,7 @@ abstract class SettingsStoreBase with Store {
shouldSaveRecipientAddress = initialSaveRecipientAddress,
fiatApiMode = initialFiatMode,
allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
shouldShowMarketPlaceInDashboard = initialShouldShowMarketPlaceInDashboard,
exchangeStatus = initialExchangeStatus,
currentTheme = initialTheme,
pinCodeLength = initialPinLength,
@@ -133,6 +135,11 @@ abstract class SettingsStoreBase with Store {
PreferencesKey.allowBiometricalAuthenticationKey,
biometricalAuthentication));
reaction(
(_) => shouldShowMarketPlaceInDashboard,
(bool value) =>
sharedPreferences.setBool(PreferencesKey.shouldShowMarketPlaceInDashboard, value));
reaction(
(_) => pinCodeLength,
(int pinLength) => sharedPreferences.setInt(
@@ -177,6 +184,9 @@ abstract class SettingsStoreBase with Store {
@observable
bool shouldShowYatPopup;
@observable
bool shouldShowMarketPlaceInDashboard;
@observable
ObservableList<ActionListDisplayMode> actionlistDisplayMode;
@@ -285,6 +295,8 @@ abstract class SettingsStoreBase with Store {
final allowBiometricalAuthentication = sharedPreferences
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
false;
final shouldShowMarketPlaceInDashboard =
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ?? true;
final exchangeStatus = ExchangeApiMode.deserialize(
raw: sharedPreferences
.getInt(PreferencesKey.exchangeStatusKey) ?? ExchangeApiMode.enabled.raw);
@@ -348,6 +360,7 @@ abstract class SettingsStoreBase with Store {
return SettingsStore(
sharedPreferences: sharedPreferences,
initialShouldShowMarketPlaceInDashboard: shouldShowMarketPlaceInDashboard,
nodes: nodes,
appVersion: packageInfo.version,
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
@@ -402,6 +415,9 @@ abstract class SettingsStoreBase with Store {
allowBiometricalAuthentication = sharedPreferences
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
allowBiometricalAuthentication;
shouldShowMarketPlaceInDashboard =
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ??
shouldShowMarketPlaceInDashboard;
exchangeStatus = ExchangeApiMode.deserialize(
raw: sharedPreferences
.getInt(PreferencesKey.exchangeStatusKey) ?? ExchangeApiMode.enabled.raw);
@@ -213,6 +213,11 @@ abstract class DashboardViewModelBase with Store {
@computed
BalanceDisplayMode get balanceDisplayMode =>
appStore.settingsStore.balanceDisplayMode;
@computed
bool get shouldShowMarketPlaceInDashboard {
return appStore.settingsStore.shouldShowMarketPlaceInDashboard;
}
@computed
List<TradeListItem> get trades => tradesStore.trades
@@ -28,6 +28,9 @@ abstract class DisplaySettingsViewModelBase with Store {
@computed
bool get shouldDisplayBalance => balanceDisplayMode == BalanceDisplayMode.displayableBalance;
@computed
bool get shouldShowMarketPlaceInDashboard => _settingsStore.shouldShowMarketPlaceInDashboard;
@computed
ThemeBase get theme => _settingsStore.currentTheme;
@@ -58,4 +61,9 @@ abstract class DisplaySettingsViewModelBase with Store {
@action
void setFiatCurrency(FiatCurrency value) => _settingsStore.fiatCurrency = value;
@action
void setShouldShowMarketPlaceInDashbaord(bool value) {
_settingsStore.shouldShowMarketPlaceInDashboard = value;
}
}