feat: Haven removal flow, should go back to the previous screen/wallet if it is triggered within the app

This commit is contained in:
Blazebrain 2023-10-03 15:03:02 +01:00
parent 04b9ebb366
commit bb159a5c7c
8 changed files with 298 additions and 305 deletions

View file

@ -0,0 +1,14 @@
import 'package:cake_wallet/view_model/haven_removal_view_model.dart';
import 'package:cw_core/wallet_base.dart';
class HavenRemovalFlowParameters {
final WalletBase wallet;
final bool isFromRemoveHavenAppStartFlow;
final HavenRemovalViewModel? havenRemovalViewModel;
HavenRemovalFlowParameters(
this.wallet,
this.isFromRemoveHavenAppStartFlow,
this.havenRemovalViewModel,
);
}

View file

@ -4,6 +4,7 @@ import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart';
import 'package:cake_wallet/buy/onramper/onramper_buy_provider.dart'; import 'package:cake_wallet/buy/onramper/onramper_buy_provider.dart';
import 'package:cake_wallet/buy/payfura/payfura_buy_provider.dart'; import 'package:cake_wallet/buy/payfura/payfura_buy_provider.dart';
import 'package:cake_wallet/buy/robinhood/robinhood_buy_provider.dart'; import 'package:cake_wallet/buy/robinhood/robinhood_buy_provider.dart';
import 'package:cake_wallet/core/haven_removal_flow_parameters.dart';
import 'package:cake_wallet/core/yat_service.dart'; import 'package:cake_wallet/core/yat_service.dart';
import 'package:cake_wallet/entities/background_tasks.dart'; import 'package:cake_wallet/entities/background_tasks.dart';
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart'; import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
@ -855,9 +856,8 @@ Future<void> setup({
getIt.registerFactory(() => SupportPage(getIt.get<SupportViewModel>())); getIt.registerFactory(() => SupportPage(getIt.get<SupportViewModel>()));
getIt.registerFactory(() => getIt.registerFactory(() => SupportChatPage(getIt.get<SupportViewModel>(),
SupportChatPage( secureStorage: getIt.get<FlutterSecureStorage>()));
getIt.get<SupportViewModel>(), secureStorage: getIt.get<FlutterSecureStorage>()));
getIt.registerFactory(() => SupportOtherLinksPage(getIt.get<SupportViewModel>())); getIt.registerFactory(() => SupportOtherLinksPage(getIt.get<SupportViewModel>()));
@ -1059,12 +1059,20 @@ Future<void> setup({
walletInfoSource: _walletInfoSource, walletInfoSource: _walletInfoSource,
walletLoadingService: getIt.get<WalletLoadingService>())); walletLoadingService: getIt.get<WalletLoadingService>()));
getIt.registerFactoryParam<HavenRemovalNoticePage, WalletBase, void>( getIt.registerFactoryParam<HavenRemovalNoticePage, WalletBase, bool>(
(wallet, _) => HavenRemovalNoticePage(wallet, getIt.get<HavenRemovalViewModel>()), (wallet, isFromHavenRemovalAtStartFlow) {
final params = HavenRemovalFlowParameters(
wallet,
isFromHavenRemovalAtStartFlow,
getIt.get<HavenRemovalViewModel>(),
); );
getIt.registerFactoryParam<HavenRemovalSeedPage, WalletBase, HavenRemovalViewModel>( return HavenRemovalNoticePage(params);
(wallet, viewModel) => HavenRemovalSeedPage(wallet, viewModel), },
);
getIt.registerFactoryParam<HavenRemovalSeedPage, HavenRemovalFlowParameters, void>(
(params, _) => HavenRemovalSeedPage(params),
); );
_isSetupFinished = true; _isSetupFinished = true;

View file

@ -44,11 +44,8 @@ Future<void> _navigateBasedOnWalletType(
final wallet = appStore.wallet!; final wallet = appStore.wallet!;
if (wallet.type == WalletType.haven) { if (wallet.type == WalletType.haven) {
await navigatorKey.currentState!.pushNamedAndRemoveUntil( await navigatorKey.currentState!
Routes.havenRemovalNoticePage, .pushNamed(Routes.havenRemovalNoticePage, arguments: [wallet, true]);
(route) => false,
arguments: wallet,
);
return; return;
} else { } else {
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false); await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);

View file

@ -1,5 +1,6 @@
import 'package:cake_wallet/anonpay/anonpay_info_base.dart'; import 'package:cake_wallet/anonpay/anonpay_info_base.dart';
import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart'; import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart';
import 'package:cake_wallet/core/haven_removal_flow_parameters.dart';
import 'package:cake_wallet/core/totp_request_details.dart'; import 'package:cake_wallet/core/totp_request_details.dart';
import 'package:cake_wallet/entities/contact_record.dart'; import 'package:cake_wallet/entities/contact_record.dart';
import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/buy/order.dart';
@ -115,10 +116,11 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.newWalletFromWelcome: case Routes.newWalletFromWelcome:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => getIt.get<SetupPinCodePage>( builder: (_) =>
param1: (PinCodeState<PinCodeWidget> context, dynamic _) { getIt.get<SetupPinCodePage>(param1: (PinCodeState<PinCodeWidget> context, dynamic _) {
if (availableWalletTypes.length == 1) { if (availableWalletTypes.length == 1) {
Navigator.of(context.context).pushNamed(Routes.newWallet, arguments: availableWalletTypes.first); Navigator.of(context.context)
.pushNamed(Routes.newWallet, arguments: availableWalletTypes.first);
} else { } else {
Navigator.of(context.context).pushNamed(Routes.newWalletType); Navigator.of(context.context).pushNamed(Routes.newWalletType);
} }
@ -129,22 +131,19 @@ Route<dynamic> createRoute(RouteSettings settings) {
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => getIt.get<NewWalletTypePage>( builder: (_) => getIt.get<NewWalletTypePage>(
param1: (BuildContext context, WalletType type) => param1: (BuildContext context, WalletType type) =>
Navigator.of(context) Navigator.of(context).pushNamed(Routes.newWallet, arguments: type)));
.pushNamed(Routes.newWallet, arguments: type)));
case Routes.newWallet: case Routes.newWallet:
final type = settings.arguments as WalletType; final type = settings.arguments as WalletType;
final walletNewVM = getIt.get<WalletNewVM>(param1: type); final walletNewVM = getIt.get<WalletNewVM>(param1: type);
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => NewWalletPage(walletNewVM));
builder: (_) => NewWalletPage(walletNewVM));
case Routes.setupPin: case Routes.setupPin:
Function(PinCodeState<PinCodeWidget>, String)? callback; Function(PinCodeState<PinCodeWidget>, String)? callback;
if (settings.arguments is Function(PinCodeState<PinCodeWidget>, String)) { if (settings.arguments is Function(PinCodeState<PinCodeWidget>, String)) {
callback = callback = settings.arguments as Function(PinCodeState<PinCodeWidget>, String);
settings.arguments as Function(PinCodeState<PinCodeWidget>, String);
} }
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
@ -154,8 +153,7 @@ Route<dynamic> createRoute(RouteSettings settings) {
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => getIt.get<NewWalletTypePage>( builder: (_) => getIt.get<NewWalletTypePage>(
param1: (BuildContext context, WalletType type) => param1: (BuildContext context, WalletType type) =>
Navigator.of(context) Navigator.of(context).pushNamed(Routes.restoreWallet, arguments: type),
.pushNamed(Routes.restoreWallet, arguments: type),
param2: false)); param2: false));
case Routes.restoreOptions: case Routes.restoreOptions:
@ -176,60 +174,51 @@ Route<dynamic> createRoute(RouteSettings settings) {
.pushNamed(Routes.restoreWallet, arguments: availableWalletTypes.first); .pushNamed(Routes.restoreWallet, arguments: availableWalletTypes.first);
} }
return Navigator.pushNamed( return Navigator.pushNamed(context.context, Routes.restoreWalletType);
context.context, Routes.restoreWalletType);
}), }),
fullscreenDialog: true); fullscreenDialog: true);
} else if (isSingleCoin) { } else if (isSingleCoin) {
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => getIt.get<WalletRestorePage>( builder: (_) => getIt.get<WalletRestorePage>(param1: availableWalletTypes.first));
param1: availableWalletTypes.first
));
} else { } else {
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => getIt.get<NewWalletTypePage>( builder: (_) => getIt.get<NewWalletTypePage>(
param1: (BuildContext context, WalletType type) => param1: (BuildContext context, WalletType type) =>
Navigator.of(context) Navigator.of(context).pushNamed(Routes.restoreWallet, arguments: type),
.pushNamed(Routes.restoreWallet, arguments: type),
param2: false)); param2: false));
} }
case Routes.seed: case Routes.seed:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true,
builder: (_) => builder: (_) => getIt.get<WalletSeedPage>(param1: settings.arguments as bool));
getIt.get<WalletSeedPage>(param1: settings.arguments as bool));
case Routes.restoreWallet: case Routes.restoreWallet:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => getIt.get<WalletRestorePage>( builder: (_) => getIt.get<WalletRestorePage>(param1: settings.arguments as WalletType));
param1: settings.arguments as WalletType));
case Routes.sweepingWalletPage: case Routes.sweepingWalletPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<SweepingWalletPage>());
builder: (_) => getIt.get<SweepingWalletPage>());
case Routes.dashboard: case Routes.dashboard:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
settings: settings, settings: settings, builder: (_) => getIt.get<DashboardPage>());
builder: (_) => getIt.get<DashboardPage>());
case Routes.send: case Routes.send:
final initialPaymentRequest = settings.arguments as PaymentRequest?; final initialPaymentRequest = settings.arguments as PaymentRequest?;
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, builder: (_) => getIt.get<SendPage>( fullscreenDialog: true,
builder: (_) => getIt.get<SendPage>(
param1: initialPaymentRequest, param1: initialPaymentRequest,
)); ));
case Routes.sendTemplate: case Routes.sendTemplate:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<SendTemplatePage>());
builder: (_) => getIt.get<SendTemplatePage>());
case Routes.receive: case Routes.receive:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<ReceivePage>());
builder: (_) => getIt.get<ReceivePage>());
case Routes.addressPage: case Routes.addressPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
@ -238,20 +227,18 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.transactionDetails: case Routes.transactionDetails:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true,
builder: (_) => getIt.get<TransactionDetailsPage>( builder: (_) =>
param1: settings.arguments as TransactionInfo)); getIt.get<TransactionDetailsPage>(param1: settings.arguments as TransactionInfo));
case Routes.newSubaddress: case Routes.newSubaddress:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => builder: (_) => getIt.get<AddressEditOrCreatePage>(param1: settings.arguments));
getIt.get<AddressEditOrCreatePage>(param1: settings.arguments));
case Routes.disclaimer: case Routes.disclaimer:
return CupertinoPageRoute<void>(builder: (_) => DisclaimerPage()); return CupertinoPageRoute<void>(builder: (_) => DisclaimerPage());
case Routes.readDisclaimer: case Routes.readDisclaimer:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => DisclaimerPage(isReadOnly: true));
builder: (_) => DisclaimerPage(isReadOnly: true));
case Routes.seedLanguage: case Routes.seedLanguage:
final args = settings.arguments as List<dynamic>; final args = settings.arguments as List<dynamic>;
@ -260,8 +247,8 @@ Route<dynamic> createRoute(RouteSettings settings) {
return CupertinoPageRoute<void>(builder: (_) { return CupertinoPageRoute<void>(builder: (_) {
return SeedLanguage( return SeedLanguage(
onConfirm: (context, lang) => Navigator.of(context) onConfirm: (context, lang) =>
.popAndPushNamed(redirectRoute, arguments: [type, lang])); Navigator.of(context).popAndPushNamed(redirectRoute, arguments: [type, lang]));
}); });
case Routes.walletList: case Routes.walletList:
@ -271,15 +258,13 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.walletEdit: case Routes.walletEdit:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true,
builder: (_) => getIt.get<WalletEditPage>( builder: (_) => getIt.get<WalletEditPage>(param1: settings.arguments as List<dynamic>));
param1: settings.arguments as List<dynamic>));
case Routes.auth: case Routes.auth:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true,
builder: (_) => getIt.get<AuthPage>( builder: (_) => getIt.get<AuthPage>(
param1: settings.arguments as OnAuthenticationFinished, param1: settings.arguments as OnAuthenticationFinished, param2: true));
param2: true));
case Routes.totpAuthCodePage: case Routes.totpAuthCodePage:
final args = settings.arguments as TotpAuthArgumentsModel; final args = settings.arguments as TotpAuthArgumentsModel;
@ -306,43 +291,34 @@ Route<dynamic> createRoute(RouteSettings settings) {
fullscreenDialog: true, fullscreenDialog: true,
builder: (_) => WillPopScope( builder: (_) => WillPopScope(
child: getIt.get<AuthPage>( child: getIt.get<AuthPage>(
param1: settings.arguments as OnAuthenticationFinished, param1: settings.arguments as OnAuthenticationFinished, param2: false),
param2: false),
onWillPop: () async => false)); onWillPop: () async => false));
case Routes.connectionSync: case Routes.connectionSync:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<ConnectionSyncPage>());
builder: (_) => getIt.get<ConnectionSyncPage>());
case Routes.securityBackupPage: case Routes.securityBackupPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<SecurityBackupPage>());
builder: (_) => getIt.get<SecurityBackupPage>());
case Routes.privacyPage: case Routes.privacyPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<PrivacyPage>());
builder: (_) => getIt.get<PrivacyPage>());
case Routes.displaySettingsPage: case Routes.displaySettingsPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<DisplaySettingsPage>());
builder: (_) => getIt.get<DisplaySettingsPage>());
case Routes.otherSettingsPage: case Routes.otherSettingsPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<OtherSettingsPage>());
builder: (_) => getIt.get<OtherSettingsPage>());
case Routes.newNode: case Routes.newNode:
final args = settings.arguments as Map<String, dynamic>?; final args = settings.arguments as Map<String, dynamic>?;
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => getIt.get<NodeCreateOrEditPage>( builder: (_) => getIt.get<NodeCreateOrEditPage>(
param1: args?['editingNode'] as Node?, param1: args?['editingNode'] as Node?, param2: args?['isSelected'] as bool?));
param2: args?['isSelected'] as bool?));
case Routes.accountCreation: case Routes.accountCreation:
return CupertinoPageRoute<String>( return CupertinoPageRoute<String>(
@ -351,8 +327,7 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.addressBook: case Routes.addressBook:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<ContactListPage>());
builder: (_) => getIt.get<ContactListPage>());
case Routes.pickerAddressBook: case Routes.pickerAddressBook:
final selectedCurrency = settings.arguments as CryptoCurrency?; final selectedCurrency = settings.arguments as CryptoCurrency?;
@ -361,31 +336,26 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.addressBookAddContact: case Routes.addressBookAddContact:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => getIt.get<ContactPage>( builder: (_) => getIt.get<ContactPage>(param1: settings.arguments as ContactRecord?));
param1: settings.arguments as ContactRecord?));
case Routes.showKeys: case Routes.showKeys:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => getIt.get<WalletKeysPage>(), fullscreenDialog: true); builder: (_) => getIt.get<WalletKeysPage>(), fullscreenDialog: true);
case Routes.exchangeTrade: case Routes.exchangeTrade:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<ExchangeTradePage>());
builder: (_) => getIt.get<ExchangeTradePage>());
case Routes.exchangeConfirm: case Routes.exchangeConfirm:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(builder: (_) => getIt.get<ExchangeConfirmPage>());
builder: (_) => getIt.get<ExchangeConfirmPage>());
case Routes.tradeDetails: case Routes.tradeDetails:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true,
builder: (_) => builder: (_) => getIt.get<TradeDetailsPage>(param1: settings.arguments as Trade));
getIt.get<TradeDetailsPage>(param1: settings.arguments as Trade));
case Routes.orderDetails: case Routes.orderDetails:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => builder: (_) => getIt.get<OrderDetailsPage>(param1: settings.arguments as Order));
getIt.get<OrderDetailsPage>(param1: settings.arguments as Order));
case Routes.buy: case Routes.buy:
return MaterialPageRoute<void>(builder: (_) => getIt.get<BuyOptionsPage>()); return MaterialPageRoute<void>(builder: (_) => getIt.get<BuyOptionsPage>());
@ -394,18 +364,14 @@ Route<dynamic> createRoute(RouteSettings settings) {
final args = settings.arguments as List; final args = settings.arguments as List;
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<BuyWebViewPage>(param1: args));
builder: (_) =>
getIt.get<BuyWebViewPage>(param1: args));
case Routes.exchange: case Routes.exchange:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<ExchangePage>());
builder: (_) => getIt.get<ExchangePage>());
case Routes.exchangeTemplate: case Routes.exchangeTemplate:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<ExchangeTemplatePage>());
builder: (_) => getIt.get<ExchangeTemplatePage>());
case Routes.rescan: case Routes.rescan:
return MaterialPageRoute<void>(builder: (_) => getIt.get<RescanPage>()); return MaterialPageRoute<void>(builder: (_) => getIt.get<RescanPage>());
@ -415,51 +381,41 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.preSeed: case Routes.preSeed:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => builder: (_) => getIt.get<PreSeedPage>(param1: settings.arguments as WalletType));
getIt.get<PreSeedPage>(param1: settings.arguments as WalletType));
case Routes.backup: case Routes.backup:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, builder: (_) => getIt.get<BackupPage>()); fullscreenDialog: true, builder: (_) => getIt.get<BackupPage>());
case Routes.editBackupPassword: case Routes.editBackupPassword:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<EditBackupPasswordPage>());
builder: (_) => getIt.get<EditBackupPasswordPage>());
case Routes.restoreFromBackup: case Routes.restoreFromBackup:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<RestoreFromBackupPage>());
builder: (_) => getIt.get<RestoreFromBackupPage>());
case Routes.support: case Routes.support:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<SupportPage>());
builder: (_) => getIt.get<SupportPage>());
case Routes.supportLiveChat: case Routes.supportLiveChat:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<SupportChatPage>());
builder: (_) => getIt.get<SupportChatPage>());
case Routes.supportOtherLinks: case Routes.supportOtherLinks:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
fullscreenDialog: true, fullscreenDialog: true, builder: (_) => getIt.get<SupportOtherLinksPage>());
builder: (_) => getIt.get<SupportOtherLinksPage>());
case Routes.unspentCoinsList: case Routes.unspentCoinsList:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(builder: (_) => getIt.get<UnspentCoinsListPage>());
builder: (_) => getIt.get<UnspentCoinsListPage>());
case Routes.unspentCoinsDetails: case Routes.unspentCoinsDetails:
final args = settings.arguments as List; final args = settings.arguments as List;
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => builder: (_) => getIt.get<UnspentCoinsDetailsPage>(param1: args));
getIt.get<UnspentCoinsDetailsPage>(
param1: args));
case Routes.fullscreenQR: case Routes.fullscreenQR:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => builder: (_) => getIt.get<FullscreenQRPage>(
getIt.get<FullscreenQRPage>(
param1: settings.arguments as QrViewData, param1: settings.arguments as QrViewData,
)); ));
@ -470,26 +426,27 @@ Route<dynamic> createRoute(RouteSettings settings) {
); );
case Routes.ioniaLoginPage: case Routes.ioniaLoginPage:
return CupertinoPageRoute<void>( builder: (_) => getIt.get<IoniaLoginPage>()); return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaLoginPage>());
case Routes.ioniaCreateAccountPage: case Routes.ioniaCreateAccountPage:
return CupertinoPageRoute<void>( builder: (_) => getIt.get<IoniaCreateAccountPage>()); return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaCreateAccountPage>());
case Routes.ioniaManageCardsPage: case Routes.ioniaManageCardsPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaManageCardsPage>());
builder: (_) => getIt.get<IoniaManageCardsPage>());
case Routes.ioniaBuyGiftCardPage: case Routes.ioniaBuyGiftCardPage:
final args = settings.arguments as List; final args = settings.arguments as List;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaBuyGiftCardPage>(param1: args)); return CupertinoPageRoute<void>(
builder: (_) => getIt.get<IoniaBuyGiftCardPage>(param1: args));
case Routes.ioniaBuyGiftCardDetailPage: case Routes.ioniaBuyGiftCardDetailPage:
final args = settings.arguments as List; final args = settings.arguments as List;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaBuyGiftCardDetailPage>(param1: args)); return CupertinoPageRoute<void>(
builder: (_) => getIt.get<IoniaBuyGiftCardDetailPage>(param1: args));
case Routes.ioniaVerifyIoniaOtpPage: case Routes.ioniaVerifyIoniaOtpPage:
final args = settings.arguments as List; final args = settings.arguments as List;
return CupertinoPageRoute<void>(builder: (_) =>getIt.get<IoniaVerifyIoniaOtp>(param1: args)); return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaVerifyIoniaOtp>(param1: args));
case Routes.ioniaDebitCardPage: case Routes.ioniaDebitCardPage:
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaDebitCardPage>()); return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaDebitCardPage>());
@ -505,35 +462,37 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.ioniaCustomTipPage: case Routes.ioniaCustomTipPage:
final args = settings.arguments as List; final args = settings.arguments as List;
return CupertinoPageRoute<void>(builder: (_) =>getIt.get<IoniaCustomTipPage>(param1: args)); return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaCustomTipPage>(param1: args));
case Routes.ioniaGiftCardDetailPage: case Routes.ioniaGiftCardDetailPage:
final args = settings.arguments as List; final args = settings.arguments as List;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaGiftCardDetailPage>(param1: args.first)); return CupertinoPageRoute<void>(
builder: (_) => getIt.get<IoniaGiftCardDetailPage>(param1: args.first));
case Routes.ioniaCustomRedeemPage: case Routes.ioniaCustomRedeemPage:
final args = settings.arguments as List; final args = settings.arguments as List;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaCustomRedeemPage>(param1: args)); return CupertinoPageRoute<void>(
builder: (_) => getIt.get<IoniaCustomRedeemPage>(param1: args));
case Routes.ioniaMoreOptionsPage: case Routes.ioniaMoreOptionsPage:
final args = settings.arguments as List; final args = settings.arguments as List;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaMoreOptionsPage>(param1: args)); return CupertinoPageRoute<void>(
builder: (_) => getIt.get<IoniaMoreOptionsPage>(param1: args));
case Routes.ioniaPaymentStatusPage: case Routes.ioniaPaymentStatusPage:
final args = settings.arguments as List; final args = settings.arguments as List;
final paymentInfo = args.first as IoniaAnyPayPaymentInfo; final paymentInfo = args.first as IoniaAnyPayPaymentInfo;
final commitedInfo = args[1] as AnyPayPaymentCommittedInfo; final commitedInfo = args[1] as AnyPayPaymentCommittedInfo;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaPaymentStatusPage>( return CupertinoPageRoute<void>(
param1: paymentInfo, builder: (_) =>
param2: commitedInfo)); getIt.get<IoniaPaymentStatusPage>(param1: paymentInfo, param2: commitedInfo));
case Routes.webViewPage: case Routes.webViewPage:
final args = settings.arguments as List; final args = settings.arguments as List;
final title = args.first as String; final title = args.first as String;
final url = args[1] as Uri; final url = args[1] as Uri;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<WebViewPage>( return CupertinoPageRoute<void>(
param1: title, builder: (_) => getIt.get<WebViewPage>(param1: title, param2: url));
param2: url));
case Routes.advancedPrivacySettings: case Routes.advancedPrivacySettings:
final type = settings.arguments as WalletType; final type = settings.arguments as WalletType;
@ -546,16 +505,17 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.anonPayInvoicePage: case Routes.anonPayInvoicePage:
final args = settings.arguments as List; final args = settings.arguments as List;
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => getIt.get<AnonPayInvoicePage>(param1: args));
builder: (_) => getIt.get<AnonPayInvoicePage>(param1: args));
case Routes.anonPayReceivePage: case Routes.anonPayReceivePage:
final anonInvoiceViewData = settings.arguments as AnonpayInfoBase; final anonInvoiceViewData = settings.arguments as AnonpayInfoBase;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<AnonPayReceivePage>(param1: anonInvoiceViewData)); return CupertinoPageRoute<void>(
builder: (_) => getIt.get<AnonPayReceivePage>(param1: anonInvoiceViewData));
case Routes.anonPayDetailsPage: case Routes.anonPayDetailsPage:
final anonInvoiceViewData = settings.arguments as AnonpayInvoiceInfo; final anonInvoiceViewData = settings.arguments as AnonpayInvoiceInfo;
return CupertinoPageRoute<void>(builder: (_) => getIt.get<AnonpayDetailsPage>(param1: anonInvoiceViewData)); return CupertinoPageRoute<void>(
builder: (_) => getIt.get<AnonpayDetailsPage>(param1: anonInvoiceViewData));
case Routes.desktop_actions: case Routes.desktop_actions:
return PageRouteBuilder( return PageRouteBuilder(
@ -564,12 +524,10 @@ Route<dynamic> createRoute(RouteSettings settings) {
); );
case Routes.desktop_settings_page: case Routes.desktop_settings_page:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(builder: (_) => DesktopSettingsPage());
builder: (_) => DesktopSettingsPage());
case Routes.empty_no_route: case Routes.empty_no_route:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(builder: (_) => SizedBox.shrink());
builder: (_) => SizedBox.shrink());
case Routes.transactionsPage: case Routes.transactionsPage:
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
@ -609,24 +567,25 @@ Route<dynamic> createRoute(RouteSettings settings) {
return MaterialPageRoute<void>(builder: (_) => getIt.get<ManageNodesPage>()); return MaterialPageRoute<void>(builder: (_) => getIt.get<ManageNodesPage>());
case Routes.havenRemovalNoticePage: case Routes.havenRemovalNoticePage:
final args = settings.arguments as List;
final wallet = args.first as WalletBase;
final isFromHavenRemovalAtStartFlow = args[1];
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => getIt.get<HavenRemovalNoticePage>(param1: settings.arguments as WalletBase), builder: (_) => getIt.get<HavenRemovalNoticePage>(param1: wallet, param2: isFromHavenRemovalAtStartFlow),
); );
case Routes.havenRemovalSeedPage: case Routes.havenRemovalSeedPage:
final args = settings.arguments as List; final args = settings.arguments as HavenRemovalFlowParameters;
final wallet = args.first as WalletBase;
final havenRemovalViewModel = args[1] as HavenRemovalViewModel;
return CupertinoPageRoute<void>( return CupertinoPageRoute<void>(
builder: (_) => builder: (_) => getIt.get<HavenRemovalSeedPage>(param1: args),
getIt.get<HavenRemovalSeedPage>(param1: wallet, param2: havenRemovalViewModel),
); );
default: default:
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (_) => Scaffold( builder: (_) => Scaffold(
body: Center( body: Center(child: Text(S.current.router_no_route(settings.name ?? 'No route')))));
child: Text(S.current.router_no_route(settings.name ?? 'No route')))));
} }
} }

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/core/haven_removal_flow_parameters.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart'; import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart';
@ -5,20 +6,17 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/view_model/haven_removal_view_model.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class HavenRemovalNoticePage extends BasePage { class HavenRemovalNoticePage extends BasePage {
HavenRemovalNoticePage(this.wallet, this.viewModel) HavenRemovalNoticePage(this.params)
: imageLight = Image.asset('assets/images/pre_seed_light.png'), : imageLight = Image.asset('assets/images/pre_seed_light.png'),
imageDark = Image.asset('assets/images/pre_seed_dark.png'); imageDark = Image.asset('assets/images/pre_seed_dark.png');
final Image imageDark; final Image imageDark;
final Image imageLight; final Image imageLight;
final WalletBase wallet; final HavenRemovalFlowParameters params;
final HavenRemovalViewModel viewModel;
@override @override
Widget? leading(BuildContext context) => null; Widget? leading(BuildContext context) => null;
@ -30,9 +28,7 @@ class HavenRemovalNoticePage extends BasePage {
Widget body(BuildContext context) { Widget body(BuildContext context) {
final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight; final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight;
return WillPopScope( return Container(
onWillPop: () async => false,
child: Container(
alignment: Alignment.center, alignment: Alignment.center,
padding: EdgeInsets.all(24), padding: EdgeInsets.all(24),
child: ConstrainedBox( child: ConstrainedBox(
@ -70,7 +66,7 @@ class HavenRemovalNoticePage extends BasePage {
), ),
PrimaryButton( PrimaryButton(
onPressed: () => Navigator.of(context) onPressed: () => Navigator.of(context)
.pushNamed(Routes.havenRemovalSeedPage, arguments: [wallet, viewModel]), .popAndPushNamed(Routes.havenRemovalSeedPage, arguments: params),
text: S.of(context).pre_seed_button_text, text: S.of(context).pre_seed_button_text,
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
textColor: Colors.white, textColor: Colors.white,
@ -78,7 +74,6 @@ class HavenRemovalNoticePage extends BasePage {
], ],
), ),
), ),
),
); );
} }
} }

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/core/haven_removal_flow_parameters.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart'; import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/extensions/pin_code_theme.dart'; import 'package:cake_wallet/themes/extensions/pin_code_theme.dart';
import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/themes/theme_base.dart';
@ -17,12 +18,18 @@ import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart'; import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class HavenRemovalSeedPage extends BasePage { class HavenRemovalSeedPage extends BasePage {
HavenRemovalSeedPage(this.wallet, this.havenRemovalViewModel); HavenRemovalSeedPage(this.params)
: wallet = params.wallet,
isFromRemoveHavenAppStartFlow = params.isFromRemoveHavenAppStartFlow,
havenRemovalViewModel = params.havenRemovalViewModel!;
final imageLight = Image.asset('assets/images/crypto_lock_light.png'); final imageLight = Image.asset('assets/images/crypto_lock_light.png');
final imageDark = Image.asset('assets/images/crypto_lock.png'); final imageDark = Image.asset('assets/images/crypto_lock.png');
final HavenRemovalFlowParameters params;
final WalletBase wallet; final WalletBase wallet;
final bool isFromRemoveHavenAppStartFlow;
final HavenRemovalViewModel havenRemovalViewModel; final HavenRemovalViewModel havenRemovalViewModel;
@override @override
@ -30,7 +37,7 @@ class HavenRemovalSeedPage extends BasePage {
@override @override
void onClose(BuildContext context) async { void onClose(BuildContext context) async {
await showPopUp<bool>( final shouldPopBack = await showPopUp<bool>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertWithTwoActions( return AlertWithTwoActions(
@ -39,12 +46,17 @@ class HavenRemovalSeedPage extends BasePage {
leftButtonText: S.of(context).seed_alert_back, leftButtonText: S.of(context).seed_alert_back,
rightButtonText: S.of(context).seed_alert_yes, rightButtonText: S.of(context).seed_alert_yes,
actionLeftButton: () => Navigator.of(context).pop(false), actionLeftButton: () => Navigator.of(context).pop(false),
actionRightButton: () async => await havenRemovalViewModel.onSeedsCopiedConfirmed(), actionRightButton: () async =>
await havenRemovalViewModel.onSeedsCopiedConfirmed(isFromRemoveHavenAppStartFlow),
); );
}, },
) ?? ) ??
false; false;
if (shouldPopBack) {
Navigator.of(context).pop();
}
return; return;
} }
@ -80,9 +92,7 @@ class HavenRemovalSeedPage extends BasePage {
Widget body(BuildContext context) { Widget body(BuildContext context) {
final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight; final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight;
return WillPopScope( return Container(
onWillPop: () async => false,
child: Container(
padding: EdgeInsets.all(24), padding: EdgeInsets.all(24),
alignment: Alignment.center, alignment: Alignment.center,
child: ConstrainedBox( child: ConstrainedBox(
@ -129,9 +139,8 @@ class HavenRemovalSeedPage extends BasePage {
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
color: Theme.of(context) color:
.extension<TransactionTradeTheme>()! Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
.detailsTitlesColor,
), ),
), ),
), ),
@ -178,7 +187,6 @@ class HavenRemovalSeedPage extends BasePage {
], ],
), ),
), ),
),
); );
} }
} }

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/core/haven_removal_flow_parameters.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart'; import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/core/auth_service.dart'; import 'package:cake_wallet/core/auth_service.dart';
import 'package:cake_wallet/themes/extensions/receive_page_theme.dart'; import 'package:cake_wallet/themes/extensions/receive_page_theme.dart';
@ -286,7 +287,7 @@ class WalletListBodyState extends State<WalletListBody> {
changeProcessText(S.of(context).wallet_list_loading_wallet(walletListItem.name)); changeProcessText(S.of(context).wallet_list_loading_wallet(walletListItem.name));
final wallet = await widget.walletListViewModel.loadWalletWithoutChanging(walletListItem); final wallet = await widget.walletListViewModel.loadWalletWithoutChanging(walletListItem);
await hideProgressText(); await hideProgressText();
await Navigator.pushNamed(context, Routes.havenRemovalNoticePage, arguments: wallet); await Navigator.pushNamed(context, Routes.havenRemovalNoticePage, arguments: [wallet, false]);
} }
void changeProcessText(String text) { void changeProcessText(String text) {

View file

@ -18,10 +18,15 @@ class HavenRemovalViewModel {
final Box<WalletInfo> walletInfoSource; final Box<WalletInfo> walletInfoSource;
final WalletLoadingService walletLoadingService; final WalletLoadingService walletLoadingService;
Future<void> onSeedsCopiedConfirmed() async { Future<bool> onSeedsCopiedConfirmed(bool isFromStart) async {
if (walletInfoSource.length == 1) { if (walletInfoSource.length == 1) {
_navigateToWelcomePage(); _navigateToWelcomePage();
return; return false;
}
if (!isFromStart) {
goBack();
return true;
} }
final walletInfo = _getFirstNonHavenWallet(); final walletInfo = _getFirstNonHavenWallet();
@ -31,6 +36,8 @@ class HavenRemovalViewModel {
_changeWallet(wallet); _changeWallet(wallet);
await _navigateToDashboardPage(); await _navigateToDashboardPage();
return false;
} }
WalletInfo _getFirstNonHavenWallet() { WalletInfo _getFirstNonHavenWallet() {
@ -56,4 +63,8 @@ class HavenRemovalViewModel {
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.welcome, (route) => false); await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.welcome, (route) => false);
return; return;
} }
void goBack() {
navigatorKey.currentState!.pop(true);
}
} }