mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
Fix issues from code review
This commit is contained in:
parent
63df8c6b6f
commit
3acbfbae79
10 changed files with 94 additions and 192 deletions
23
lib/di.dart
23
lib/di.dart
|
@ -123,7 +123,6 @@ import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_v
|
||||||
import 'package:cake_wallet/view_model/monero_account_list/monero_account_edit_or_create_view_model.dart';
|
import 'package:cake_wallet/view_model/monero_account_list/monero_account_edit_or_create_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/monero_account_list/monero_account_list_view_model.dart';
|
import 'package:cake_wallet/view_model/monero_account_list/monero_account_list_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/send/send_view_model.dart';
|
import 'package:cake_wallet/view_model/send/send_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
|
||||||
import 'package:cake_wallet/view_model/wallet_keys_view_model.dart';
|
import 'package:cake_wallet/view_model/wallet_keys_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
|
import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/wallet_restore_view_model.dart';
|
import 'package:cake_wallet/view_model/wallet_restore_view_model.dart';
|
||||||
|
@ -385,8 +384,7 @@ Future setup(
|
||||||
_transactionDescriptionBox));
|
_transactionDescriptionBox));
|
||||||
|
|
||||||
getIt.registerFactory(
|
getIt.registerFactory(
|
||||||
() => SendPage(sendViewModel: getIt.get<SendViewModel>(),
|
() => SendPage(sendViewModel: getIt.get<SendViewModel>()));
|
||||||
settingsViewModel: getIt.get<SettingsViewModel>()));
|
|
||||||
|
|
||||||
getIt.registerFactory(() => SendTemplatePage(
|
getIt.registerFactory(() => SendTemplatePage(
|
||||||
sendTemplateViewModel: getIt.get<SendTemplateViewModel>()));
|
sendTemplateViewModel: getIt.get<SendTemplateViewModel>()));
|
||||||
|
@ -442,29 +440,19 @@ Future setup(
|
||||||
getIt.get<MoneroAccountEditOrCreateViewModel>(param1: account)));
|
getIt.get<MoneroAccountEditOrCreateViewModel>(param1: account)));
|
||||||
|
|
||||||
getIt.registerFactory(() {
|
getIt.registerFactory(() {
|
||||||
final appStore = getIt.get<AppStore>();
|
return DisplaySettingsViewModel(getIt.get<SettingsStore>());
|
||||||
final yatStore = getIt.get<YatStore>();
|
|
||||||
return SettingsViewModel(appStore.settingsStore, yatStore, appStore.wallet!);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
getIt.registerFactory(() {
|
getIt.registerFactory(() {
|
||||||
final appStore = getIt.get<AppStore>();
|
return PrivacySettingsViewModel(getIt.get<SettingsStore>());
|
||||||
return DisplaySettingsViewModel(appStore.settingsStore);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
getIt.registerFactory(() {
|
getIt.registerFactory(() {
|
||||||
final appStore = getIt.get<AppStore>();
|
return OtherSettingsViewModel(getIt(), getIt());
|
||||||
return PrivacySettingsViewModel(appStore.settingsStore);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
getIt.registerFactory(() {
|
getIt.registerFactory(() {
|
||||||
final appStore = getIt.get<AppStore>();
|
return SecuritySettingsViewModel(getIt.get<SettingsStore>());
|
||||||
return OtherSettingsViewModel(appStore.settingsStore, appStore.wallet!);
|
|
||||||
});
|
|
||||||
|
|
||||||
getIt.registerFactory(() {
|
|
||||||
final appStore = getIt.get<AppStore>();
|
|
||||||
return SecuritySettingsViewModel(appStore.settingsStore);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
getIt
|
getIt
|
||||||
|
@ -530,7 +518,6 @@ Future setup(
|
||||||
getIt.get<TradesStore>(),
|
getIt.get<TradesStore>(),
|
||||||
getIt.get<AppStore>().settingsStore,
|
getIt.get<AppStore>().settingsStore,
|
||||||
getIt.get<SharedPreferences>(),
|
getIt.get<SharedPreferences>(),
|
||||||
getIt.get<SettingsViewModel>(),
|
|
||||||
));
|
));
|
||||||
|
|
||||||
getIt.registerFactory(() => ExchangeTradeViewModel(
|
getIt.registerFactory(() => ExchangeTradeViewModel(
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import 'dart:ui';
|
|
||||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||||
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart';
|
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart';
|
||||||
import 'package:cake_wallet/src/screens/send/widgets/send_card.dart';
|
import 'package:cake_wallet/src/screens/send/widgets/send_card.dart';
|
||||||
|
@ -6,8 +5,6 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||||
import 'package:cake_wallet/src/widgets/picker.dart';
|
import 'package:cake_wallet/src/widgets/picker.dart';
|
||||||
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
||||||
import 'package:cake_wallet/view_model/send/output.dart';
|
import 'package:cake_wallet/view_model/send/output.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
@ -28,13 +25,11 @@ import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
||||||
import 'package:cw_core/crypto_currency.dart';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
|
|
||||||
class SendPage extends BasePage {
|
class SendPage extends BasePage {
|
||||||
SendPage({required this.sendViewModel,required this.settingsViewModel }) : _formKey = GlobalKey<FormState>(),fiatFromSettings = settingsViewModel.fiatCurrency;
|
SendPage({required this.sendViewModel}) : _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
final SendViewModel sendViewModel;
|
final SendViewModel sendViewModel;
|
||||||
final SettingsViewModel settingsViewModel;
|
|
||||||
final GlobalKey<FormState> _formKey;
|
final GlobalKey<FormState> _formKey;
|
||||||
final controller = PageController(initialPage: 0);
|
final controller = PageController(initialPage: 0);
|
||||||
final FiatCurrency fiatFromSettings ;
|
|
||||||
|
|
||||||
bool _effectsInstalled = false;
|
bool _effectsInstalled = false;
|
||||||
|
|
||||||
|
@ -55,7 +50,7 @@ class SendPage extends BasePage {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose(BuildContext context) {
|
void onClose(BuildContext context) {
|
||||||
settingsViewModel.setFiatCurrency(fiatFromSettings);
|
sendViewModel.onClose();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +231,7 @@ class SendPage extends BasePage {
|
||||||
if(template.isCurrencySelected){
|
if(template.isCurrencySelected){
|
||||||
output.setCryptoAmount(template.amount);
|
output.setCryptoAmount(template.amount);
|
||||||
}else{
|
}else{
|
||||||
settingsViewModel.setFiatCurrency(fiatFromTemplate);
|
sendViewModel.setFiatCurrency(fiatFromTemplate);
|
||||||
output.setFiatAmount(template.amountFiat);
|
output.setFiatAmount(template.amountFiat);
|
||||||
}
|
}
|
||||||
output.resetParsedAddress();
|
output.resetParsedAddress();
|
||||||
|
|
|
@ -14,12 +14,12 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
|
||||||
class DisplaySettingsPage extends BasePage {
|
class DisplaySettingsPage extends BasePage {
|
||||||
DisplaySettingsPage(this.settingsViewModel);
|
DisplaySettingsPage(this._displaySettingsViewModel);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get title => S.current.display_settings;
|
String get title => S.current.display_settings;
|
||||||
|
|
||||||
final DisplaySettingsViewModel settingsViewModel;
|
final DisplaySettingsViewModel _displaySettingsViewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
|
@ -30,17 +30,17 @@ class DisplaySettingsPage extends BasePage {
|
||||||
children: [
|
children: [
|
||||||
SettingsSwitcherCell(
|
SettingsSwitcherCell(
|
||||||
title: S.current.settings_display_balance,
|
title: S.current.settings_display_balance,
|
||||||
value: settingsViewModel.shouldDisplayBalance,
|
value: _displaySettingsViewModel.shouldDisplayBalance,
|
||||||
onValueChange: (_, bool value) {
|
onValueChange: (_, bool value) {
|
||||||
settingsViewModel.setShouldDisplayBalance(value);
|
_displaySettingsViewModel.setShouldDisplayBalance(value);
|
||||||
}),
|
}),
|
||||||
if (!isHaven)
|
if (!isHaven)
|
||||||
SettingsPickerCell<FiatCurrency>(
|
SettingsPickerCell<FiatCurrency>(
|
||||||
title: S.current.settings_currency,
|
title: S.current.settings_currency,
|
||||||
searchHintText: S.current.search_currency,
|
searchHintText: S.current.search_currency,
|
||||||
items: FiatCurrency.all,
|
items: FiatCurrency.all,
|
||||||
selectedItem: settingsViewModel.fiatCurrency,
|
selectedItem: _displaySettingsViewModel.fiatCurrency,
|
||||||
onItemSelected: (FiatCurrency currency) => settingsViewModel.setFiatCurrency(currency),
|
onItemSelected: (FiatCurrency currency) => _displaySettingsViewModel.setFiatCurrency(currency),
|
||||||
images: FiatCurrency.all.map((e) => Image.asset("assets/images/flags/${e.countryCode}.png")).toList(),
|
images: FiatCurrency.all.map((e) => Image.asset("assets/images/flags/${e.countryCode}.png")).toList(),
|
||||||
isGridView: true,
|
isGridView: true,
|
||||||
matchingCriteria: (FiatCurrency currency, String searchText) {
|
matchingCriteria: (FiatCurrency currency, String searchText) {
|
||||||
|
@ -55,8 +55,8 @@ class DisplaySettingsPage extends BasePage {
|
||||||
displayItem: (dynamic code) {
|
displayItem: (dynamic code) {
|
||||||
return LanguageService.list[code] ?? '';
|
return LanguageService.list[code] ?? '';
|
||||||
},
|
},
|
||||||
selectedItem: settingsViewModel.languageCode,
|
selectedItem: _displaySettingsViewModel.languageCode,
|
||||||
onItemSelected: settingsViewModel.onLanguageSelected,
|
onItemSelected: _displaySettingsViewModel.onLanguageSelected,
|
||||||
images: LanguageService.list.keys
|
images: LanguageService.list.keys
|
||||||
.map((e) => Image.asset("assets/images/flags/${LanguageService.localeCountryCode[e]}.png"))
|
.map((e) => Image.asset("assets/images/flags/${LanguageService.localeCountryCode[e]}.png"))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
@ -68,8 +68,8 @@ class DisplaySettingsPage extends BasePage {
|
||||||
ChoicesListItem<ThemeBase>(
|
ChoicesListItem<ThemeBase>(
|
||||||
title: S.current.color_theme,
|
title: S.current.color_theme,
|
||||||
items: ThemeList.all,
|
items: ThemeList.all,
|
||||||
selectedItem: settingsViewModel.theme,
|
selectedItem: _displaySettingsViewModel.theme,
|
||||||
onItemSelected: (ThemeBase theme) => settingsViewModel.setTheme(theme),
|
onItemSelected: (ThemeBase theme) => _displaySettingsViewModel.setTheme(theme),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -11,12 +11,12 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
|
||||||
class OtherSettingsPage extends BasePage {
|
class OtherSettingsPage extends BasePage {
|
||||||
OtherSettingsPage(this._settingsViewModel);
|
OtherSettingsPage(this._otherSettingsViewModel);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get title => S.current.other_settings;
|
String get title => S.current.other_settings;
|
||||||
|
|
||||||
final OtherSettingsViewModel _settingsViewModel;
|
final OtherSettingsViewModel _otherSettingsViewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
|
@ -26,10 +26,10 @@ class OtherSettingsPage extends BasePage {
|
||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
SettingsPickerCell(
|
SettingsPickerCell(
|
||||||
title: S.current.settings_fee_priority,
|
title: S.current.settings_fee_priority,
|
||||||
items: priorityForWalletType(_settingsViewModel.walletType),
|
items: priorityForWalletType(_otherSettingsViewModel.walletType),
|
||||||
displayItem: _settingsViewModel.getDisplayPriority,
|
displayItem: _otherSettingsViewModel.getDisplayPriority,
|
||||||
selectedItem: _settingsViewModel.transactionPriority,
|
selectedItem: _otherSettingsViewModel.transactionPriority,
|
||||||
onItemSelected: _settingsViewModel.onDisplayPrioritySelected,
|
onItemSelected: _otherSettingsViewModel.onDisplayPrioritySelected,
|
||||||
),
|
),
|
||||||
SettingsCellWithArrow(
|
SettingsCellWithArrow(
|
||||||
title: S.current.settings_terms_and_conditions,
|
title: S.current.settings_terms_and_conditions,
|
||||||
|
@ -37,7 +37,7 @@ class OtherSettingsPage extends BasePage {
|
||||||
),
|
),
|
||||||
StandardListSeparator(padding: EdgeInsets.symmetric(horizontal: 24)),
|
StandardListSeparator(padding: EdgeInsets.symmetric(horizontal: 24)),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
SettingsVersionCell(title: S.of(context).version(_settingsViewModel.currentVersion))
|
SettingsVersionCell(title: S.of(context).version(_otherSettingsViewModel.currentVersion))
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,24 +6,37 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
|
||||||
class PrivacyPage extends BasePage {
|
class PrivacyPage extends BasePage {
|
||||||
PrivacyPage(this.settingsViewModel);
|
PrivacyPage(this._privacySettingsViewModel);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get title => S.current.privacy_settings;
|
String get title => S.current.privacy_settings;
|
||||||
|
|
||||||
final PrivacySettingsViewModel settingsViewModel;
|
final PrivacySettingsViewModel _privacySettingsViewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(top: 10),
|
padding: EdgeInsets.only(top: 10),
|
||||||
child: Observer(builder: (_) {
|
child: Observer(builder: (_) {
|
||||||
return SettingsSwitcherCell(
|
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,
|
title: S.current.settings_save_recipient_address,
|
||||||
value: settingsViewModel.shouldSaveRecipientAddress,
|
value: _privacySettingsViewModel.shouldSaveRecipientAddress,
|
||||||
onValueChange: (BuildContext _, bool value) {
|
onValueChange: (BuildContext _, bool value) {
|
||||||
settingsViewModel.setShouldSaveRecipientAddress(value);
|
_privacySettingsViewModel.setShouldSaveRecipientAddress(value);
|
||||||
});
|
})
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,16 @@ import 'package:cake_wallet/src/screens/settings/widgets/settings_cell_with_arro
|
||||||
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
|
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
|
||||||
import 'package:cake_wallet/src/widgets/standard_list.dart';
|
import 'package:cake_wallet/src/widgets/standard_list.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/security_settings_view_model.dart';
|
import 'package:cake_wallet/view_model/settings/security_settings_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
|
||||||
class SecurityBackupPage extends BasePage {
|
class SecurityBackupPage extends BasePage {
|
||||||
SecurityBackupPage(this.settingsViewModel);
|
SecurityBackupPage(this._securitySettingsViewModel);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get title => S.current.security_and_backup;
|
String get title => S.current.security_and_backup;
|
||||||
|
|
||||||
final SecuritySettingsViewModel settingsViewModel;
|
final SecuritySettingsViewModel _securitySettingsViewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
|
@ -59,23 +58,23 @@ class SecurityBackupPage extends BasePage {
|
||||||
Observer(builder: (_) {
|
Observer(builder: (_) {
|
||||||
return SettingsSwitcherCell(
|
return SettingsSwitcherCell(
|
||||||
title: S.current.settings_allow_biometrical_authentication,
|
title: S.current.settings_allow_biometrical_authentication,
|
||||||
value: settingsViewModel.allowBiometricalAuthentication,
|
value: _securitySettingsViewModel.allowBiometricalAuthentication,
|
||||||
onValueChange: (BuildContext context, bool value) {
|
onValueChange: (BuildContext context, bool value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
Navigator.of(context).pushNamed(Routes.auth,
|
Navigator.of(context).pushNamed(Routes.auth,
|
||||||
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) async {
|
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) async {
|
||||||
if (isAuthenticatedSuccessfully) {
|
if (isAuthenticatedSuccessfully) {
|
||||||
if (await settingsViewModel.biometricAuthenticated()) {
|
if (await _securitySettingsViewModel.biometricAuthenticated()) {
|
||||||
settingsViewModel.setAllowBiometricalAuthentication(isAuthenticatedSuccessfully);
|
_securitySettingsViewModel.setAllowBiometricalAuthentication(isAuthenticatedSuccessfully);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settingsViewModel.setAllowBiometricalAuthentication(isAuthenticatedSuccessfully);
|
_securitySettingsViewModel.setAllowBiometricalAuthentication(isAuthenticatedSuccessfully);
|
||||||
}
|
}
|
||||||
|
|
||||||
auth.close();
|
auth.close();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
settingsViewModel.setAllowBiometricalAuthentication(value);
|
_securitySettingsViewModel.setAllowBiometricalAuthentication(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -6,8 +6,8 @@ import 'package:cake_wallet/entities/preferences_key.dart';
|
||||||
import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart';
|
import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart';
|
||||||
import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart';
|
import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart';
|
||||||
import 'package:cake_wallet/exchange/simpleswap/simpleswap_exchange_provider.dart';
|
import 'package:cake_wallet/exchange/simpleswap/simpleswap_exchange_provider.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
|
||||||
import 'package:cake_wallet/exchange/simpleswap/simpleswap_request.dart';
|
import 'package:cake_wallet/exchange/simpleswap/simpleswap_request.dart';
|
||||||
|
import 'package:cw_core/transaction_priority.dart';
|
||||||
import 'package:cw_core/wallet_base.dart';
|
import 'package:cw_core/wallet_base.dart';
|
||||||
import 'package:cw_core/crypto_currency.dart';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
import 'package:cw_core/sync_status.dart';
|
import 'package:cw_core/sync_status.dart';
|
||||||
|
@ -42,7 +42,7 @@ class ExchangeViewModel = ExchangeViewModelBase with _$ExchangeViewModel;
|
||||||
|
|
||||||
abstract class ExchangeViewModelBase with Store {
|
abstract class ExchangeViewModelBase with Store {
|
||||||
ExchangeViewModelBase(this.wallet, this.trades, this._exchangeTemplateStore,
|
ExchangeViewModelBase(this.wallet, this.trades, this._exchangeTemplateStore,
|
||||||
this.tradesStore, this._settingsStore, this.sharedPreferences, this._settingsViewModel)
|
this.tradesStore, this._settingsStore, this.sharedPreferences)
|
||||||
: _cryptoNumberFormat = NumberFormat(),
|
: _cryptoNumberFormat = NumberFormat(),
|
||||||
isReverse = false,
|
isReverse = false,
|
||||||
isFixedRateMode = false,
|
isFixedRateMode = false,
|
||||||
|
@ -189,6 +189,19 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
ObservableList<ExchangeTemplate> get templates =>
|
ObservableList<ExchangeTemplate> get templates =>
|
||||||
_exchangeTemplateStore.templates;
|
_exchangeTemplateStore.templates;
|
||||||
|
|
||||||
|
|
||||||
|
@computed
|
||||||
|
TransactionPriority get transactionPriority {
|
||||||
|
final priority = _settingsStore.priority[wallet.type];
|
||||||
|
|
||||||
|
if (priority == null) {
|
||||||
|
throw Exception('Unexpected type ${wallet.type.toString()}');
|
||||||
|
}
|
||||||
|
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool get hasAllAmount =>
|
bool get hasAllAmount =>
|
||||||
wallet.type == WalletType.bitcoin && depositCurrency == wallet.currency;
|
wallet.type == WalletType.bitcoin && depositCurrency == wallet.currency;
|
||||||
|
|
||||||
|
@ -198,11 +211,11 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
switch (wallet.type) {
|
switch (wallet.type) {
|
||||||
case WalletType.monero:
|
case WalletType.monero:
|
||||||
case WalletType.haven:
|
case WalletType.haven:
|
||||||
return _settingsViewModel.transactionPriority == monero!.getMoneroTransactionPrioritySlow();
|
return transactionPriority == monero!.getMoneroTransactionPrioritySlow();
|
||||||
case WalletType.bitcoin:
|
case WalletType.bitcoin:
|
||||||
return _settingsViewModel.transactionPriority == bitcoin!.getBitcoinTransactionPrioritySlow();
|
return transactionPriority == bitcoin!.getBitcoinTransactionPrioritySlow();
|
||||||
case WalletType.litecoin:
|
case WalletType.litecoin:
|
||||||
return _settingsViewModel.transactionPriority == bitcoin!.getLitecoinTransactionPrioritySlow();
|
return transactionPriority == bitcoin!.getLitecoinTransactionPrioritySlow();
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -220,8 +233,6 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
|
|
||||||
final SettingsStore _settingsStore;
|
final SettingsStore _settingsStore;
|
||||||
|
|
||||||
final SettingsViewModel _settingsViewModel;
|
|
||||||
|
|
||||||
double _bestRate = 0.0;
|
double _bestRate = 0.0;
|
||||||
|
|
||||||
late Timer bestRateSync;
|
late Timer bestRateSync;
|
||||||
|
|
|
@ -42,7 +42,8 @@ abstract class SendViewModelBase with Store {
|
||||||
: state = InitialExecutionState(),
|
: state = InitialExecutionState(),
|
||||||
currencies = _wallet.balance.keys.toList(),
|
currencies = _wallet.balance.keys.toList(),
|
||||||
selectedCryptoCurrency = _wallet.currency,
|
selectedCryptoCurrency = _wallet.currency,
|
||||||
outputs = ObservableList<Output>() {
|
outputs = ObservableList<Output>(),
|
||||||
|
fiatFromSettings = _settingsStore.fiatCurrency {
|
||||||
final priority = _settingsStore.priority[_wallet.type];
|
final priority = _settingsStore.priority[_wallet.type];
|
||||||
final priorities = priorityForWalletType(_wallet.type);
|
final priorities = priorityForWalletType(_wallet.type);
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
outputs.add(Output(_wallet, _settingsStore, _fiatConversationStore, () => selectedCryptoCurrency));
|
outputs.add(Output(_wallet, _settingsStore, _fiatConversationStore, () => selectedCryptoCurrency));
|
||||||
}
|
}
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
ExecutionState state;
|
ExecutionState state;
|
||||||
|
|
||||||
|
@ -133,11 +134,13 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
Validator get textValidator => TextValidator();
|
Validator get textValidator => TextValidator();
|
||||||
|
|
||||||
|
final FiatCurrency fiatFromSettings;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
PendingTransaction? pendingTransaction;
|
PendingTransaction? pendingTransaction;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
String get balance => balanceViewModel.availableBalance ?? '0.0';
|
String get balance => balanceViewModel.availableBalance;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
|
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
|
||||||
|
@ -166,6 +169,9 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
bool get hasCurrecyChanger => walletType == WalletType.haven;
|
bool get hasCurrecyChanger => walletType == WalletType.haven;
|
||||||
|
|
||||||
|
@computed
|
||||||
|
FiatCurrency get fiatCurrency => _settingsStore.fiatCurrency;
|
||||||
|
|
||||||
final WalletBase _wallet;
|
final WalletBase _wallet;
|
||||||
final SettingsStore _settingsStore;
|
final SettingsStore _settingsStore;
|
||||||
final SendTemplateViewModel sendTemplateViewModel;
|
final SendTemplateViewModel sendTemplateViewModel;
|
||||||
|
@ -208,7 +214,7 @@ abstract class SendViewModelBase with Store {
|
||||||
state = TransactionCommitting();
|
state = TransactionCommitting();
|
||||||
await pendingTransaction!.commit();
|
await pendingTransaction!.commit();
|
||||||
|
|
||||||
if (pendingTransaction!.id?.isNotEmpty ?? false) {
|
if (pendingTransaction!.id.isNotEmpty) {
|
||||||
_settingsStore.shouldSaveRecipientAddress
|
_settingsStore.shouldSaveRecipientAddress
|
||||||
? await transactionDescriptionBox.add(TransactionDescription(
|
? await transactionDescriptionBox.add(TransactionDescription(
|
||||||
id: pendingTransaction!.id,
|
id: pendingTransaction!.id,
|
||||||
|
@ -283,4 +289,12 @@ abstract class SendViewModelBase with Store {
|
||||||
|
|
||||||
bool _isEqualCurrency(String currency) =>
|
bool _isEqualCurrency(String currency) =>
|
||||||
currency.toLowerCase() == _wallet.currency.title.toLowerCase();
|
currency.toLowerCase() == _wallet.currency.title.toLowerCase();
|
||||||
|
|
||||||
|
@action
|
||||||
|
void onClose() =>
|
||||||
|
_settingsStore.fiatCurrency = fiatFromSettings;
|
||||||
|
|
||||||
|
@action
|
||||||
|
void setFiatCurrency(FiatCurrency fiat) =>
|
||||||
|
_settingsStore.fiatCurrency = fiat;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ abstract class PrivacySettingsViewModelBase with Store {
|
||||||
|
|
||||||
final SettingsStore _settingsStore;
|
final SettingsStore _settingsStore;
|
||||||
|
|
||||||
|
@computed
|
||||||
|
bool get disableExchange => _settingsStore.disableExchange;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
bool get shouldSaveRecipientAddress =>
|
bool get shouldSaveRecipientAddress =>
|
||||||
_settingsStore.shouldSaveRecipientAddress;
|
_settingsStore.shouldSaveRecipientAddress;
|
||||||
|
@ -18,4 +21,8 @@ abstract class PrivacySettingsViewModelBase with Store {
|
||||||
@action
|
@action
|
||||||
void setShouldSaveRecipientAddress(bool value) =>
|
void setShouldSaveRecipientAddress(bool value) =>
|
||||||
_settingsStore.shouldSaveRecipientAddress = value;
|
_settingsStore.shouldSaveRecipientAddress = value;
|
||||||
|
|
||||||
|
@action
|
||||||
|
void setEnableExchange(bool value) =>
|
||||||
|
_settingsStore.disableExchange = value;
|
||||||
}
|
}
|
|
@ -1,124 +0,0 @@
|
||||||
import 'package:cake_wallet/entities/priority_for_wallet_type.dart';
|
|
||||||
import 'package:cake_wallet/store/yat/yat_store.dart';
|
|
||||||
import 'package:mobx/mobx.dart';
|
|
||||||
import 'package:cw_core/wallet_base.dart';
|
|
||||||
import 'package:cake_wallet/store/settings_store.dart';
|
|
||||||
import 'package:cw_core/wallet_type.dart';
|
|
||||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
|
||||||
import 'package:cake_wallet/entities/action_list_display_mode.dart';
|
|
||||||
import 'package:cw_core/transaction_history.dart';
|
|
||||||
import 'package:cw_core/balance.dart';
|
|
||||||
import 'package:cw_core/transaction_info.dart';
|
|
||||||
import 'package:cw_core/transaction_priority.dart';
|
|
||||||
import 'package:cake_wallet/themes/theme_base.dart';
|
|
||||||
|
|
||||||
part 'settings_view_model.g.dart';
|
|
||||||
|
|
||||||
class SettingsViewModel = SettingsViewModelBase with _$SettingsViewModel;
|
|
||||||
|
|
||||||
abstract class SettingsViewModelBase with Store {
|
|
||||||
SettingsViewModelBase(
|
|
||||||
this._settingsStore,
|
|
||||||
this._yatStore,
|
|
||||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
|
||||||
TransactionInfo>
|
|
||||||
wallet)
|
|
||||||
: itemHeaders = {},
|
|
||||||
walletType = wallet.type,
|
|
||||||
_wallet = wallet{
|
|
||||||
|
|
||||||
final priority = _settingsStore.priority[wallet.type];
|
|
||||||
final priorities = priorityForWalletType(wallet.type);
|
|
||||||
|
|
||||||
if (!priorities.contains(priority)) {
|
|
||||||
_settingsStore.priority[wallet.type] = priorities.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
//var connectYatUrl = YatLink.baseUrl + YatLink.signInSuffix;
|
|
||||||
//final connectYatUrlParameters =
|
|
||||||
// _yatStore.defineQueryParameters();
|
|
||||||
|
|
||||||
//if (connectYatUrlParameters.isNotEmpty) {
|
|
||||||
// connectYatUrl += YatLink.queryParameter + connectYatUrlParameters;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//var manageYatUrl = YatLink.baseUrl + YatLink.managePath;
|
|
||||||
//final manageYatUrlParameters =
|
|
||||||
// _yatStore.defineQueryParameters();
|
|
||||||
|
|
||||||
//if (manageYatUrlParameters.isNotEmpty) {
|
|
||||||
// manageYatUrl += YatLink.queryParameter + manageYatUrlParameters;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//var createNewYatUrl = YatLink.startFlowUrl;
|
|
||||||
//final createNewYatUrlParameters =
|
|
||||||
// _yatStore.defineQueryParameters();
|
|
||||||
|
|
||||||
//if (createNewYatUrlParameters.isNotEmpty) {
|
|
||||||
// createNewYatUrl += '?sub1=' + createNewYatUrlParameters;
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@computed
|
|
||||||
FiatCurrency get fiatCurrency => _settingsStore.fiatCurrency;
|
|
||||||
|
|
||||||
@computed
|
|
||||||
ObservableList<ActionListDisplayMode> get actionlistDisplayMode =>
|
|
||||||
_settingsStore.actionlistDisplayMode;
|
|
||||||
|
|
||||||
@computed
|
|
||||||
TransactionPriority get transactionPriority {
|
|
||||||
final priority = _settingsStore.priority[walletType];
|
|
||||||
|
|
||||||
if (priority == null) {
|
|
||||||
throw Exception('Unexpected type ${walletType.toString()}');
|
|
||||||
}
|
|
||||||
|
|
||||||
return priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
@computed
|
|
||||||
ThemeBase get theme => _settingsStore.currentTheme;
|
|
||||||
|
|
||||||
bool get isBitcoinBuyEnabled => _settingsStore.isBitcoinBuyEnabled;
|
|
||||||
|
|
||||||
final Map<String, String> itemHeaders;
|
|
||||||
final SettingsStore _settingsStore;
|
|
||||||
final YatStore _yatStore;
|
|
||||||
final WalletType walletType;
|
|
||||||
final WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
|
||||||
TransactionInfo> _wallet;
|
|
||||||
|
|
||||||
@action
|
|
||||||
void setFiatCurrency(FiatCurrency value) =>
|
|
||||||
_settingsStore.fiatCurrency = value;
|
|
||||||
|
|
||||||
@action
|
|
||||||
void toggleTransactionsDisplay() =>
|
|
||||||
actionlistDisplayMode.contains(ActionListDisplayMode.transactions)
|
|
||||||
? _hideTransaction()
|
|
||||||
: _showTransaction();
|
|
||||||
|
|
||||||
@action
|
|
||||||
void toggleTradesDisplay() =>
|
|
||||||
actionlistDisplayMode.contains(ActionListDisplayMode.trades)
|
|
||||||
? _hideTrades()
|
|
||||||
: _showTrades();
|
|
||||||
|
|
||||||
@action
|
|
||||||
void _hideTransaction() =>
|
|
||||||
actionlistDisplayMode.remove(ActionListDisplayMode.transactions);
|
|
||||||
|
|
||||||
@action
|
|
||||||
void _hideTrades() =>
|
|
||||||
actionlistDisplayMode.remove(ActionListDisplayMode.trades);
|
|
||||||
|
|
||||||
@action
|
|
||||||
void _showTransaction() =>
|
|
||||||
actionlistDisplayMode.add(ActionListDisplayMode.transactions);
|
|
||||||
|
|
||||||
@action
|
|
||||||
void _showTrades() => actionlistDisplayMode.add(ActionListDisplayMode.trades);
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue