mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01:00
Fix issues from code review
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
||||
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -12,7 +13,7 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
|
||||
AdvancedPrivacySettingsViewModelBase(this.type, this._settingsStore) : _addCustomNode = false;
|
||||
|
||||
@computed
|
||||
FiatApiMode get exchangeStatus => _settingsStore.exchangeStatus;
|
||||
ExchangeApiMode get exchangeStatus => _settingsStore.exchangeStatus;
|
||||
|
||||
@computed
|
||||
FiatApiMode get fiatApi => _settingsStore.fiatApiMode;
|
||||
@@ -28,12 +29,16 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
|
||||
bool get addCustomNode => _addCustomNode;
|
||||
|
||||
@action
|
||||
void setFiatMode(FiatApiMode value) {
|
||||
_settingsStore.fiatApiMode = value;
|
||||
void setFiatMode(bool value) {
|
||||
if (value) {
|
||||
_settingsStore.fiatApiMode = FiatApiMode.disabled;
|
||||
return;
|
||||
}
|
||||
_settingsStore.fiatApiMode = FiatApiMode.enabled;
|
||||
}
|
||||
|
||||
@action
|
||||
void setEnableExchange(FiatApiMode value) {
|
||||
void setEnableExchange(ExchangeApiMode value) {
|
||||
_settingsStore.exchangeStatus = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ abstract class ExchangeViewModelBase with Store {
|
||||
isDepositAddressEnabled = false,
|
||||
isReceiveAddressEnabled = false,
|
||||
isReceiveAmountEditable = false,
|
||||
_providerUseTorOnly = false,
|
||||
receiveCurrencies = <CryptoCurrency>[],
|
||||
depositCurrencies = <CryptoCurrency>[],
|
||||
limits = Limits(min: 0, max: 0),
|
||||
@@ -65,6 +66,7 @@ abstract class ExchangeViewModelBase with Store {
|
||||
depositCurrency = wallet.currency,
|
||||
providerList = [],
|
||||
selectedProviders = ObservableList<ExchangeProvider>() {
|
||||
_providerUseTorOnly = _settingsStore.exchangeStatus == FiatApiMode.torOnly;
|
||||
_setProviders();
|
||||
const excludeDepositCurrencies = [CryptoCurrency.btt, CryptoCurrency.nano];
|
||||
const excludeReceiveCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp,
|
||||
@@ -121,18 +123,18 @@ abstract class ExchangeViewModelBase with Store {
|
||||
_calculateBestRate();
|
||||
});
|
||||
}
|
||||
|
||||
bool _providerUseTorOnly;
|
||||
final WalletBase wallet;
|
||||
final Box<Trade> trades;
|
||||
final ExchangeTemplateStore _exchangeTemplateStore;
|
||||
final TradesStore tradesStore;
|
||||
final SharedPreferences sharedPreferences;
|
||||
|
||||
final _allProviders = [
|
||||
List<ExchangeProvider> get _allProviders => [
|
||||
ChangeNowExchangeProvider(),
|
||||
SideShiftExchangeProvider(),
|
||||
SimpleSwapExchangeProvider(),
|
||||
TrocadorExchangeProvider(),
|
||||
TrocadorExchangeProvider(useTorOnly: _providerUseTorOnly),
|
||||
];
|
||||
|
||||
@observable
|
||||
@@ -695,7 +697,7 @@ abstract class ExchangeViewModelBase with Store {
|
||||
|
||||
void _setProviders(){
|
||||
if (_settingsStore.exchangeStatus == FiatApiMode.torOnly) {
|
||||
providerList = _allProviders.where((provider) => provider.shouldUseOnionAddress).toList();
|
||||
providerList = _allProviders.where((provider) => provider.supportsOnionAddress).toList();
|
||||
} else {
|
||||
providerList = _allProviders;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
||||
@@ -12,23 +13,27 @@ abstract class PrivacySettingsViewModelBase with Store {
|
||||
final SettingsStore _settingsStore;
|
||||
|
||||
@computed
|
||||
FiatApiMode get exchangeStatus => _settingsStore.exchangeStatus;
|
||||
ExchangeApiMode get exchangeStatus => _settingsStore.exchangeStatus;
|
||||
|
||||
@computed
|
||||
bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress;
|
||||
|
||||
@computed
|
||||
FiatApiMode get fiatApi => _settingsStore.fiatApiMode;
|
||||
bool get isFiatDisabled => _settingsStore.fiatApiMode == FiatApiMode.disabled;
|
||||
|
||||
@action
|
||||
void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value;
|
||||
|
||||
@action
|
||||
void setEnableExchange(FiatApiMode value) => _settingsStore.exchangeStatus = value;
|
||||
void setEnableExchange(ExchangeApiMode value) => _settingsStore.exchangeStatus = value;
|
||||
|
||||
@action
|
||||
void setFiatMode(FiatApiMode value) {
|
||||
_settingsStore.fiatApiMode = value;
|
||||
void setFiatMode(bool value) {
|
||||
if (value) {
|
||||
_settingsStore.fiatApiMode = FiatApiMode.disabled;
|
||||
return;
|
||||
}
|
||||
_settingsStore.fiatApiMode = FiatApiMode.enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user