2023-08-29 19:11:51 +03:00
|
|
|
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
|
2023-03-01 23:44:15 +02:00
|
|
|
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
2023-08-04 20:01:49 +03:00
|
|
|
import 'package:cake_wallet/ethereum/ethereum.dart';
|
2023-12-02 03:26:43 +01:00
|
|
|
import 'package:cake_wallet/polygon/polygon.dart';
|
2022-11-23 19:06:41 +02:00
|
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
2023-08-29 19:11:51 +03:00
|
|
|
import 'package:cw_core/balance.dart';
|
|
|
|
import 'package:cw_core/transaction_history.dart';
|
|
|
|
import 'package:cw_core/transaction_info.dart';
|
2023-08-04 20:01:49 +03:00
|
|
|
import 'package:cw_core/wallet_base.dart';
|
|
|
|
import 'package:cw_core/wallet_type.dart';
|
2022-11-23 19:06:41 +02:00
|
|
|
import 'package:mobx/mobx.dart';
|
2022-12-07 01:38:36 +02:00
|
|
|
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
2022-11-23 19:06:41 +02:00
|
|
|
|
|
|
|
part 'privacy_settings_view_model.g.dart';
|
|
|
|
|
2023-12-02 03:26:43 +01:00
|
|
|
class PrivacySettingsViewModel = PrivacySettingsViewModelBase with _$PrivacySettingsViewModel;
|
2022-11-23 19:06:41 +02:00
|
|
|
|
|
|
|
abstract class PrivacySettingsViewModelBase with Store {
|
2023-08-04 20:01:49 +03:00
|
|
|
PrivacySettingsViewModelBase(this._settingsStore, this._wallet);
|
2022-11-23 19:06:41 +02:00
|
|
|
|
|
|
|
final SettingsStore _settingsStore;
|
2023-08-29 19:11:51 +03:00
|
|
|
final WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> _wallet;
|
2022-11-23 19:06:41 +02:00
|
|
|
|
2022-11-25 22:51:07 +02:00
|
|
|
@computed
|
2023-03-01 23:44:15 +02:00
|
|
|
ExchangeApiMode get exchangeStatus => _settingsStore.exchangeStatus;
|
2022-11-25 22:51:07 +02:00
|
|
|
|
2023-08-29 19:11:51 +03:00
|
|
|
@computed
|
|
|
|
bool get isAutoGenerateSubaddressesEnabled =>
|
|
|
|
_settingsStore.autoGenerateSubaddressStatus != AutoGenerateSubaddressStatus.disabled;
|
|
|
|
|
|
|
|
@action
|
|
|
|
void setAutoGenerateSubaddresses(bool value) {
|
|
|
|
_wallet.isEnabledAutoGenerateSubaddress = value;
|
|
|
|
if (value) {
|
|
|
|
_settingsStore.autoGenerateSubaddressStatus = AutoGenerateSubaddressStatus.enabled;
|
|
|
|
} else {
|
|
|
|
_settingsStore.autoGenerateSubaddressStatus = AutoGenerateSubaddressStatus.disabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-23 07:15:24 +02:00
|
|
|
bool get isAutoGenerateSubaddressesVisible =>
|
|
|
|
_wallet.type == WalletType.monero ||
|
|
|
|
_wallet.type == WalletType.bitcoin ||
|
|
|
|
_wallet.type == WalletType.litecoin ||
|
|
|
|
_wallet.type == WalletType.bitcoinCash;
|
2023-08-29 19:11:51 +03:00
|
|
|
|
2024-04-10 03:28:31 +02:00
|
|
|
bool get isMoneroWallet => _wallet.type == WalletType.monero;
|
|
|
|
|
2022-11-23 19:06:41 +02:00
|
|
|
@computed
|
2022-12-01 21:21:51 +02:00
|
|
|
bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress;
|
2022-11-23 19:06:41 +02:00
|
|
|
|
2022-12-07 01:38:36 +02:00
|
|
|
@computed
|
2023-02-28 18:23:21 +02:00
|
|
|
FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode;
|
2022-12-07 01:38:36 +02:00
|
|
|
|
2023-04-20 12:59:59 +03:00
|
|
|
@computed
|
|
|
|
bool get isAppSecure => _settingsStore.isAppSecure;
|
|
|
|
|
2023-05-15 09:26:56 -03:00
|
|
|
@computed
|
|
|
|
bool get disableBuy => _settingsStore.disableBuy;
|
|
|
|
|
|
|
|
@computed
|
|
|
|
bool get disableSell => _settingsStore.disableSell;
|
|
|
|
|
2024-03-25 14:28:45 -04:00
|
|
|
@computed
|
|
|
|
bool get disableBulletin => _settingsStore.disableBulletin;
|
|
|
|
|
2023-08-04 20:01:49 +03:00
|
|
|
@computed
|
|
|
|
bool get useEtherscan => _settingsStore.useEtherscan;
|
|
|
|
|
2023-12-02 03:26:43 +01:00
|
|
|
@computed
|
|
|
|
bool get usePolygonScan => _settingsStore.usePolygonScan;
|
|
|
|
|
2023-11-03 21:23:11 +02:00
|
|
|
@computed
|
|
|
|
bool get lookupTwitter => _settingsStore.lookupsTwitter;
|
|
|
|
|
|
|
|
@computed
|
|
|
|
bool get looksUpMastodon => _settingsStore.lookupsMastodon;
|
|
|
|
|
|
|
|
@computed
|
|
|
|
bool get looksUpYatService => _settingsStore.lookupsYatService;
|
|
|
|
|
|
|
|
@computed
|
|
|
|
bool get looksUpUnstoppableDomains => _settingsStore.lookupsUnstoppableDomains;
|
|
|
|
|
|
|
|
@computed
|
|
|
|
bool get looksUpOpenAlias => _settingsStore.lookupsOpenAlias;
|
|
|
|
|
|
|
|
@computed
|
|
|
|
bool get looksUpENS => _settingsStore.lookupsENS;
|
|
|
|
|
2023-08-04 20:01:49 +03:00
|
|
|
bool get canUseEtherscan => _wallet.type == WalletType.ethereum;
|
|
|
|
|
2023-12-02 03:26:43 +01:00
|
|
|
bool get canUsePolygonScan => _wallet.type == WalletType.polygon;
|
|
|
|
|
2022-11-23 19:06:41 +02:00
|
|
|
@action
|
2023-08-04 20:01:49 +03:00
|
|
|
void setShouldSaveRecipientAddress(bool value) =>
|
|
|
|
_settingsStore.shouldSaveRecipientAddress = value;
|
2022-12-01 21:21:51 +02:00
|
|
|
|
2022-11-25 22:51:07 +02:00
|
|
|
@action
|
2023-03-02 17:13:25 +02:00
|
|
|
void setExchangeApiMode(ExchangeApiMode value) => _settingsStore.exchangeStatus = value;
|
2022-12-07 01:38:36 +02:00
|
|
|
|
|
|
|
@action
|
2023-02-28 18:23:21 +02:00
|
|
|
void setFiatMode(FiatApiMode fiatApiMode) => _settingsStore.fiatApiMode = fiatApiMode;
|
2022-12-07 15:31:33 +02:00
|
|
|
|
2023-04-20 12:59:59 +03:00
|
|
|
@action
|
|
|
|
void setIsAppSecure(bool value) => _settingsStore.isAppSecure = value;
|
|
|
|
|
2023-05-15 09:26:56 -03:00
|
|
|
@action
|
|
|
|
void setDisableBuy(bool value) => _settingsStore.disableBuy = value;
|
|
|
|
|
|
|
|
@action
|
|
|
|
void setDisableSell(bool value) => _settingsStore.disableSell = value;
|
|
|
|
|
2024-03-25 14:28:45 -04:00
|
|
|
@action
|
|
|
|
void setDisableBulletin(bool value) => _settingsStore.disableBulletin = value;
|
|
|
|
|
2023-11-03 21:23:11 +02:00
|
|
|
@action
|
|
|
|
void setLookupsTwitter(bool value) => _settingsStore.lookupsTwitter = value;
|
|
|
|
|
|
|
|
@action
|
|
|
|
void setLookupsMastodon(bool value) => _settingsStore.lookupsMastodon = value;
|
|
|
|
|
|
|
|
@action
|
|
|
|
void setLookupsENS(bool value) => _settingsStore.lookupsENS = value;
|
|
|
|
|
|
|
|
@action
|
|
|
|
void setLookupsYatService(bool value) => _settingsStore.lookupsYatService = value;
|
|
|
|
|
|
|
|
@action
|
|
|
|
void setLookupsUnstoppableDomains(bool value) => _settingsStore.lookupsUnstoppableDomains = value;
|
|
|
|
|
|
|
|
@action
|
|
|
|
void setLookupsOpenAlias(bool value) => _settingsStore.lookupsOpenAlias = value;
|
|
|
|
|
2023-08-04 20:01:49 +03:00
|
|
|
@action
|
|
|
|
void setUseEtherscan(bool value) {
|
|
|
|
_settingsStore.useEtherscan = value;
|
|
|
|
ethereum!.updateEtherscanUsageState(_wallet, value);
|
|
|
|
}
|
2023-12-02 03:26:43 +01:00
|
|
|
|
|
|
|
@action
|
|
|
|
void setUsePolygonScan(bool value) {
|
|
|
|
_settingsStore.usePolygonScan = value;
|
|
|
|
polygon!.updatePolygonScanUsageState(_wallet, value);
|
|
|
|
}
|
2022-12-01 21:21:51 +02:00
|
|
|
}
|