From 19120dfbc4c089782314ec285024333b12d3ea47 Mon Sep 17 00:00:00 2001 From: Blazebrain Date: Tue, 3 Oct 2023 14:04:15 +0100 Subject: [PATCH] feat: Haven removal --- .../on_authentication_state_change.dart | 18 +++++++++++------- .../haven_removal_notice_page.dart | 2 +- .../haven_removal/haven_removal_seed_page.dart | 4 ---- .../screens/wallet_list/wallet_list_page.dart | 3 +++ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/reactions/on_authentication_state_change.dart b/lib/reactions/on_authentication_state_change.dart index 96e22a7ce..e6e846376 100644 --- a/lib/reactions/on_authentication_state_change.dart +++ b/lib/reactions/on_authentication_state_change.dart @@ -27,6 +27,7 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore, if (state == AuthenticationState.allowed) { await _navigateBasedOnWalletType(navigatorKey, appStore); + return; } }, ); @@ -43,17 +44,20 @@ Future _loadCurrentWallet() async { Future _navigateBasedOnWalletType( GlobalKey navigatorKey, AppStore appStore) async { - final typeRaw = getIt.get().getInt(PreferencesKey.currentWalletType) ?? 0; - final type = deserializeFromInt(typeRaw); - - if (type == WalletType.haven) { - final wallet = appStore.wallet; - - await navigatorKey.currentState!.pushNamed(Routes.havenRemovalNoticePage, arguments: wallet); + final wallet = appStore.wallet!; + if (wallet.type == WalletType.haven) { + await navigatorKey.currentState!.pushNamedAndRemoveUntil( + Routes.havenRemovalNoticePage, + (route) => false, + arguments: wallet, + ); return; } else { await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false); return; } + + // await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false); + // return; } diff --git a/lib/src/screens/haven_removal/haven_removal_notice_page.dart b/lib/src/screens/haven_removal/haven_removal_notice_page.dart index 52fb5a620..96d9bfc43 100644 --- a/lib/src/screens/haven_removal/haven_removal_notice_page.dart +++ b/lib/src/screens/haven_removal/haven_removal_notice_page.dart @@ -70,7 +70,7 @@ class HavenRemovalNoticePage extends BasePage { ), PrimaryButton( onPressed: () => Navigator.of(context) - .popAndPushNamed(Routes.havenRemovalSeedPage, arguments: [wallet, viewModel]), + .pushNamed(Routes.havenRemovalSeedPage, arguments: [wallet, viewModel]), text: S.of(context).pre_seed_button_text, color: Theme.of(context).primaryColor, textColor: Colors.white, diff --git a/lib/src/screens/haven_removal/haven_removal_seed_page.dart b/lib/src/screens/haven_removal/haven_removal_seed_page.dart index 17b2d9357..b62378cd5 100644 --- a/lib/src/screens/haven_removal/haven_removal_seed_page.dart +++ b/lib/src/screens/haven_removal/haven_removal_seed_page.dart @@ -45,10 +45,6 @@ class HavenRemovalSeedPage extends BasePage { ) ?? false; - // if (confirmed) { - // await havenRemovalViewModel.onSeedsCopiedConfirmed(); - // } - return; } diff --git a/lib/src/screens/wallet_list/wallet_list_page.dart b/lib/src/screens/wallet_list/wallet_list_page.dart index 13f4d5447..3ecefb2c1 100644 --- a/lib/src/screens/wallet_list/wallet_list_page.dart +++ b/lib/src/screens/wallet_list/wallet_list_page.dart @@ -270,6 +270,7 @@ class WalletListBodyState extends State { if (ResponsiveLayoutUtil.instance.shouldRenderMobileUI()) { WidgetsBinding.instance.addPostFrameCallback((_) { Navigator.of(context).pop(); + return; }); } } catch (e) { @@ -283,7 +284,9 @@ class WalletListBodyState extends State { } Future _onHavenWalletSelected(WalletListItem walletListItem) async { + changeProcessText(S.of(context).wallet_list_loading_wallet(walletListItem.name)); final wallet = await widget.walletListViewModel.loadWalletWithoutChanging(walletListItem); + await hideProgressText(); await Navigator.pushNamed(context, Routes.havenRemovalNoticePage, arguments: wallet); }