CW-370-add-options-to-enable-disable-buy-and-sell-actions (#920)

* feat: In the privacy settings screen, add 2 options to Enable/Disable Buy and Sell actions

* fix: add strings

* fix: add the rest of the strings

* fix: disable instead of hide buy & sell buttons

* fix: use disableSell

* fix: main actions able to be onTapped even when disabled
This commit is contained in:
Rafael Saes
2023-05-15 15:26:56 +03:00
committed by GitHub
parent 0f44bc094f
commit 7fa7c45c0c
30 changed files with 175 additions and 56 deletions
@@ -46,9 +46,7 @@ abstract class DashboardViewModelBase with Store {
required this.anonpayTransactionsStore})
: isOutdatedElectrumWallet = false,
hasSellAction = false,
isEnabledSellAction = false,
hasBuyAction = false,
isEnabledBuyAction = false,
hasExchangeAction = false,
isShowFirstYatIntroduction = false,
isShowSecondYatIntroduction = false,
@@ -287,14 +285,19 @@ abstract class DashboardViewModelBase with Store {
@observable
bool hasExchangeAction;
@observable
bool isEnabledBuyAction;
@computed
bool get isEnabledBuyAction =>
!settingsStore.disableBuy && wallet.type != WalletType.haven;
@observable
bool hasBuyAction;
@observable
bool isEnabledSellAction;
@computed
bool get isEnabledSellAction =>
!settingsStore.disableSell &&
wallet.type != WalletType.haven &&
wallet.type != WalletType.monero &&
wallet.type != WalletType.litecoin;
@observable
bool hasSellAction;
@@ -398,11 +401,7 @@ abstract class DashboardViewModelBase with Store {
void updateActions() {
hasExchangeAction = !isHaven;
isEnabledBuyAction = wallet.type != WalletType.haven;
hasBuyAction = !isHaven;
isEnabledSellAction = wallet.type != WalletType.haven
&& wallet.type != WalletType.monero
&& wallet.type != WalletType.litecoin;
hasSellAction = !isHaven;
}
}
@@ -24,6 +24,12 @@ abstract class PrivacySettingsViewModelBase with Store {
@computed
bool get isAppSecure => _settingsStore.isAppSecure;
@computed
bool get disableBuy => _settingsStore.disableBuy;
@computed
bool get disableSell => _settingsStore.disableSell;
@action
void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value;
@@ -36,4 +42,10 @@ abstract class PrivacySettingsViewModelBase with Store {
@action
void setIsAppSecure(bool value) => _settingsStore.isAppSecure = value;
@action
void setDisableBuy(bool value) => _settingsStore.disableBuy = value;
@action
void setDisableSell(bool value) => _settingsStore.disableSell = value;
}