[skip ci] format files

This commit is contained in:
Godwin Asuquo 2022-12-01 21:21:51 +02:00
parent 658d4766c6
commit 03748d680a
5 changed files with 58 additions and 80 deletions

View file

@ -19,24 +19,24 @@ class PrivacyPage extends BasePage {
padding: EdgeInsets.only(top: 10),
child: Observer(builder: (_) {
return Observer(builder: (_) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SettingsSwitcherCell(
title: S.current.disable_exchange,
value: _privacySettingsViewModel.disableExchange,
onValueChange: (BuildContext context, bool value) {
_privacySettingsViewModel.setEnableExchange(value);
}),
SettingsSwitcherCell(
title: S.current.settings_save_recipient_address,
value: _privacySettingsViewModel.shouldSaveRecipientAddress,
onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setShouldSaveRecipientAddress(value);
})
],
);
});
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SettingsSwitcherCell(
title: S.current.disable_exchange,
value: _privacySettingsViewModel.disableExchange,
onValueChange: (BuildContext context, bool value) {
_privacySettingsViewModel.setEnableExchange(value);
}),
SettingsSwitcherCell(
title: S.current.settings_save_recipient_address,
value: _privacySettingsViewModel.shouldSaveRecipientAddress,
onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setShouldSaveRecipientAddress(value);
})
],
);
});
}),
);
}

View file

@ -8,10 +8,9 @@ part 'display_settings_view_model.g.dart';
class DisplaySettingsViewModel = DisplaySettingsViewModelBase with _$DisplaySettingsViewModel;
abstract class DisplaySettingsViewModelBase with Store {
DisplaySettingsViewModelBase(
this._settingsStore,
this._settingsStore,
);
final SettingsStore _settingsStore;
@ -22,10 +21,8 @@ abstract class DisplaySettingsViewModelBase with Store {
@computed
String get languageCode => _settingsStore.languageCode;
@computed
BalanceDisplayMode get balanceDisplayMode =>
_settingsStore.balanceDisplayMode;
BalanceDisplayMode get balanceDisplayMode => _settingsStore.balanceDisplayMode;
@computed
bool get shouldDisplayBalance => balanceDisplayMode == BalanceDisplayMode.displayableBalance;
@ -34,30 +31,27 @@ abstract class DisplaySettingsViewModelBase with Store {
ThemeBase get theme => _settingsStore.currentTheme;
@action
void setBalanceDisplayMode(BalanceDisplayMode value) =>
_settingsStore.balanceDisplayMode = value;
void setBalanceDisplayMode(BalanceDisplayMode value) => _settingsStore.balanceDisplayMode = value;
@action
void setShouldDisplayBalance(bool value){
if (value) {
_settingsStore.balanceDisplayMode = BalanceDisplayMode.displayableBalance;
void setShouldDisplayBalance(bool value) {
if (value) {
_settingsStore.balanceDisplayMode = BalanceDisplayMode.displayableBalance;
} else {
_settingsStore.balanceDisplayMode = BalanceDisplayMode.hiddenBalance;
_settingsStore.balanceDisplayMode = BalanceDisplayMode.hiddenBalance;
}
}
@action
void onLanguageSelected (String code) {
void onLanguageSelected(String code) {
_settingsStore.languageCode = code;
}
@action
void setTheme(ThemeBase newTheme){
_settingsStore.currentTheme = newTheme;
void setTheme(ThemeBase newTheme) {
_settingsStore.currentTheme = newTheme;
}
@action
void setFiatCurrency(FiatCurrency value) =>
_settingsStore.fiatCurrency = value;
}
void setFiatCurrency(FiatCurrency value) => _settingsStore.fiatCurrency = value;
}

View file

@ -12,32 +12,26 @@ import 'package:package_info/package_info.dart';
part 'other_settings_view_model.g.dart';
class OtherSettingsViewModel = OtherSettingsViewModelBase
with _$OtherSettingsViewModel;
class OtherSettingsViewModel = OtherSettingsViewModelBase with _$OtherSettingsViewModel;
abstract class OtherSettingsViewModelBase with Store {
OtherSettingsViewModelBase(this._settingsStore, WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
TransactionInfo>
wallet):
walletType = wallet.type,
_wallet = wallet,
currentVersion = ''{
PackageInfo.fromPlatform().then(
(PackageInfo packageInfo) => currentVersion = packageInfo.version);
OtherSettingsViewModelBase(
this._settingsStore, WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet)
: walletType = wallet.type,
_wallet = wallet,
currentVersion = '' {
PackageInfo.fromPlatform().then((PackageInfo packageInfo) => currentVersion = packageInfo.version);
final priority = _settingsStore.priority[wallet.type];
final priorities = priorityForWalletType(wallet.type);
if (!priorities.contains(priority)) {
_settingsStore.priority[wallet.type] = priorities.first;
}
}
}
final WalletType walletType;
final WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
TransactionInfo> _wallet;
final WalletType walletType;
final WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> _wallet;
@observable
String currentVersion;
@ -55,11 +49,10 @@ abstract class OtherSettingsViewModelBase with Store {
return priority;
}
String getDisplayPriority(dynamic priority) {
String getDisplayPriority(dynamic priority) {
final _priority = priority as TransactionPriority;
if (_wallet.type == WalletType.bitcoin
|| _wallet.type == WalletType.litecoin) {
if (_wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin) {
final rate = bitcoin!.getFeeRate(_wallet, _priority);
return bitcoin!.bitcoinTransactionPriorityWithLabel(_priority, rate);
}
@ -67,6 +60,5 @@ abstract class OtherSettingsViewModelBase with Store {
return priority.toString();
}
void onDisplayPrioritySelected(TransactionPriority priority) =>
_settingsStore.priority[_wallet.type] = priority;
}
void onDisplayPrioritySelected(TransactionPriority priority) => _settingsStore.priority[_wallet.type] = priority;
}

View file

@ -3,8 +3,7 @@ import 'package:mobx/mobx.dart';
part 'privacy_settings_view_model.g.dart';
class PrivacySettingsViewModel = PrivacySettingsViewModelBase
with _$PrivacySettingsViewModel;
class PrivacySettingsViewModel = PrivacySettingsViewModelBase with _$PrivacySettingsViewModel;
abstract class PrivacySettingsViewModelBase with Store {
PrivacySettingsViewModelBase(this._settingsStore);
@ -15,14 +14,11 @@ abstract class PrivacySettingsViewModelBase with Store {
bool get disableExchange => _settingsStore.disableExchange;
@computed
bool get shouldSaveRecipientAddress =>
_settingsStore.shouldSaveRecipientAddress;
bool get shouldSaveRecipientAddress => _settingsStore.shouldSaveRecipientAddress;
@action
void setShouldSaveRecipientAddress(bool value) =>
_settingsStore.shouldSaveRecipientAddress = value;
void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value;
@action
void setEnableExchange(bool value) =>
_settingsStore.disableExchange = value;
}
void setEnableExchange(bool value) => _settingsStore.disableExchange = value;
}

View file

@ -4,26 +4,22 @@ import 'package:mobx/mobx.dart';
part 'security_settings_view_model.g.dart';
class SecuritySettingsViewModel = SecuritySettingsViewModelBase
with _$SecuritySettingsViewModel;
class SecuritySettingsViewModel = SecuritySettingsViewModelBase with _$SecuritySettingsViewModel;
abstract class SecuritySettingsViewModelBase with Store {
SecuritySettingsViewModelBase(this._settingsStore): _biometricAuth = BiometricAuth();
SecuritySettingsViewModelBase(this._settingsStore) : _biometricAuth = BiometricAuth();
final BiometricAuth _biometricAuth;
final SettingsStore _settingsStore;
@computed
bool get allowBiometricalAuthentication =>
_settingsStore.allowBiometricalAuthentication;
bool get allowBiometricalAuthentication => _settingsStore.allowBiometricalAuthentication;
@action
Future<bool> biometricAuthenticated()async{
return await _biometricAuth.canCheckBiometrics() && await _biometricAuth.isAuthenticated();
Future<bool> biometricAuthenticated() async {
return await _biometricAuth.canCheckBiometrics() && await _biometricAuth.isAuthenticated();
}
@action
void setAllowBiometricalAuthentication(bool value) =>
_settingsStore.allowBiometricalAuthentication = value;
}
void setAllowBiometricalAuthentication(bool value) => _settingsStore.allowBiometricalAuthentication = value;
}