mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-20 06:08:34 +02:00
Flutter upgrade
This commit is contained in:
@@ -5,7 +5,7 @@ import 'package:cw_core/sync_status.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:connectivity/connectivity.dart';
|
||||
|
||||
Timer _checkConnectionTimer;
|
||||
Timer? _checkConnectionTimer;
|
||||
|
||||
void startCheckConnectionReaction(
|
||||
WalletBase wallet, SettingsStore settingsStore,
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
|
||||
Timer _timer;
|
||||
Timer? _timer;
|
||||
|
||||
Future<void> startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore,
|
||||
FiatConversionStore fiatConversionStore) async {
|
||||
@@ -14,19 +14,21 @@ Future<void> startFiatRateUpdate(AppStore appStore, SettingsStore settingsStore,
|
||||
return;
|
||||
}
|
||||
|
||||
fiatConversionStore.prices[appStore.wallet.currency] =
|
||||
if (appStore.wallet != null) {
|
||||
fiatConversionStore.prices[appStore.wallet!.currency] =
|
||||
await FiatConversionService.fetchPrice(
|
||||
appStore.wallet.currency, settingsStore.fiatCurrency);
|
||||
appStore.wallet!.currency, settingsStore.fiatCurrency);
|
||||
}
|
||||
|
||||
_timer = Timer.periodic(
|
||||
Duration(seconds: 30),
|
||||
(_) async {
|
||||
try {
|
||||
if (appStore.wallet.type == WalletType.haven) {
|
||||
if (appStore.wallet!.type == WalletType.haven) {
|
||||
await updateHavenRate(fiatConversionStore);
|
||||
} else {
|
||||
fiatConversionStore.prices[appStore.wallet.currency] = await FiatConversionService.fetchPrice(
|
||||
appStore.wallet.currency, settingsStore.fiatCurrency);
|
||||
fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice(
|
||||
appStore.wallet!.currency, settingsStore.fiatCurrency);
|
||||
}
|
||||
} catch(e) {
|
||||
print(e);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/router.dart';
|
||||
import 'package:cake_wallet/entities/load_current_wallet.dart';
|
||||
import 'package:cake_wallet/store/authentication_store.dart';
|
||||
|
||||
ReactionDisposer _onAuthenticationStateChange;
|
||||
ReactionDisposer? _onAuthenticationStateChange;
|
||||
|
||||
dynamic loginError;
|
||||
|
||||
@@ -24,14 +23,12 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
|
||||
}
|
||||
|
||||
if (state == AuthenticationState.allowed) {
|
||||
await navigatorKey.currentState
|
||||
.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
|
||||
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state == AuthenticationState.denied) {
|
||||
await navigatorKey.currentState
|
||||
.pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
|
||||
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.welcome, (_) => false);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,15 +5,19 @@ import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
|
||||
ReactionDisposer _onCurrentFiatCurrencyChangeDisposer;
|
||||
ReactionDisposer? _onCurrentFiatCurrencyChangeDisposer;
|
||||
|
||||
void startCurrentFiatChangeReaction(AppStore appStore,
|
||||
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
|
||||
_onCurrentFiatCurrencyChangeDisposer?.reaction?.dispose();
|
||||
_onCurrentFiatCurrencyChangeDisposer?.reaction.dispose();
|
||||
_onCurrentFiatCurrencyChangeDisposer = reaction(
|
||||
(_) => settingsStore.fiatCurrency, (FiatCurrency fiatCurrency) async {
|
||||
final cryptoCurrency = appStore.wallet.currency;
|
||||
fiatConversionStore.prices[appStore.wallet.currency] =
|
||||
if (appStore.wallet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final cryptoCurrency = appStore.wallet!.currency;
|
||||
fiatConversionStore.prices[appStore.wallet!.currency] =
|
||||
await FiatConversionService.fetchPrice(cryptoCurrency, fiatCurrency);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_core/node.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
|
||||
ReactionDisposer _onCurrentNodeChangeReaction;
|
||||
ReactionDisposer? _onCurrentNodeChangeReaction;
|
||||
|
||||
void startOnCurrentNodeChangeReaction(AppStore appStore) {
|
||||
_onCurrentNodeChangeReaction?.reaction?.dispose();
|
||||
_onCurrentNodeChangeReaction?.reaction.dispose();
|
||||
appStore.settingsStore.nodes.observe((change) async {
|
||||
try {
|
||||
await appStore.wallet.connectToNode(node: change.newValue);
|
||||
await appStore.wallet!.connectToNode(node: change.newValue!);
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
|
||||
@@ -15,17 +15,16 @@ import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/core/fiat_conversion_service.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||
|
||||
ReactionDisposer _onCurrentWalletChangeReaction;
|
||||
ReactionDisposer _onCurrentWalletChangeFiatRateUpdateReaction;
|
||||
ReactionDisposer? _onCurrentWalletChangeReaction;
|
||||
ReactionDisposer? _onCurrentWalletChangeFiatRateUpdateReaction;
|
||||
//ReactionDisposer _onCurrentWalletAddressChangeReaction;
|
||||
|
||||
void startCurrentWalletChangeReaction(AppStore appStore,
|
||||
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
|
||||
_onCurrentWalletChangeReaction?.reaction?.dispose();
|
||||
_onCurrentWalletChangeFiatRateUpdateReaction?.reaction?.dispose();
|
||||
//_onCurrentWalletAddressChangeReaction?.reaction?.dispose();
|
||||
_onCurrentWalletChangeReaction?.reaction.dispose();
|
||||
_onCurrentWalletChangeFiatRateUpdateReaction?.reaction.dispose();
|
||||
//_onCurrentWalletAddressChangeReaction?.reaction?dispose();
|
||||
|
||||
//_onCurrentWalletAddressChangeReaction = reaction((_) => appStore.wallet.walletAddresses.address,
|
||||
//(String address) async {
|
||||
@@ -49,9 +48,13 @@ void startCurrentWalletChangeReaction(AppStore appStore,
|
||||
//});
|
||||
|
||||
_onCurrentWalletChangeReaction = reaction((_) => appStore.wallet, (WalletBase<
|
||||
Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>
|
||||
Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>?
|
||||
wallet) async {
|
||||
try {
|
||||
if (wallet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final node = settingsStore.getCurrentNode(wallet.type);
|
||||
startWalletSyncStatusChangeReaction(wallet, fiatConversionStore);
|
||||
startCheckConnectionReaction(wallet, settingsStore);
|
||||
@@ -81,9 +84,13 @@ void startCurrentWalletChangeReaction(AppStore appStore,
|
||||
|
||||
_onCurrentWalletChangeFiatRateUpdateReaction =
|
||||
reaction((_) => appStore.wallet, (WalletBase<Balance,
|
||||
TransactionHistoryBase<TransactionInfo>, TransactionInfo>
|
||||
TransactionHistoryBase<TransactionInfo>, TransactionInfo>?
|
||||
wallet) async {
|
||||
try {
|
||||
if (wallet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
fiatConversionStore.prices[wallet.currency] = 0;
|
||||
fiatConversionStore.prices[wallet.currency] =
|
||||
await FiatConversionService.fetchPrice(
|
||||
|
||||
@@ -11,14 +11,14 @@ import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cw_core/sync_status.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
ReactionDisposer _onWalletSyncStatusChangeReaction;
|
||||
ReactionDisposer? _onWalletSyncStatusChangeReaction;
|
||||
|
||||
void startWalletSyncStatusChangeReaction(
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||
TransactionInfo> wallet,
|
||||
FiatConversionStore fiatConversionStore) {
|
||||
final _wakeLock = getIt.get<WakeLock>();
|
||||
_onWalletSyncStatusChangeReaction?.reaction?.dispose();
|
||||
_onWalletSyncStatusChangeReaction?.reaction.dispose();
|
||||
_onWalletSyncStatusChangeReaction =
|
||||
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
||||
if (status is ConnectedSyncStatus) {
|
||||
|
||||
Reference in New Issue
Block a user