diff --git a/lib/di.dart b/lib/di.dart index 49fafb357..dd1001858 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -50,6 +50,7 @@ import 'package:cake_wallet/src/screens/settings/connection_sync_page.dart'; import 'package:cake_wallet/src/screens/settings/trocador_providers_page.dart'; import 'package:cake_wallet/src/screens/settings/tor_page.dart'; import 'package:cake_wallet/src/screens/setup_2fa/modify_2fa_page.dart'; +import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa_info_page.dart'; import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa_qr_page.dart'; import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa.dart'; import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa_enter_code_page.dart'; @@ -133,7 +134,7 @@ import 'package:cake_wallet/src/screens/rescan/rescan_page.dart'; import 'package:cake_wallet/src/screens/restore/restore_from_backup_page.dart'; import 'package:cake_wallet/src/screens/restore/restore_options_page.dart'; import 'package:cake_wallet/src/screens/restore/wallet_restore_page.dart'; -import 'package:cake_wallet/src/screens/seed/warning_page.dart'; +import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart'; import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart'; import 'package:cake_wallet/src/screens/send/send_template_page.dart'; import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.dart'; @@ -524,6 +525,8 @@ Future setup({ getIt.registerFactory( () => TransactionsPage(dashboardViewModel: getIt.get())); + getIt.registerFactory(() => Setup2FAInfoPage()); + getIt.registerFactory( () => Setup2FAPage(setup2FAViewModel: getIt.get())); @@ -915,9 +918,9 @@ Future setup({ getIt.registerFactoryParam( (param1, isCreate) => NewWalletTypePage(onTypeSelected: param1, isCreate: isCreate ?? true)); - getIt.registerFactoryParam( + getIt.registerFactoryParam( (seedPhraseLength, _) - => WarningPage(seedPhraseLength)); + => PreSeedPage(seedPhraseLength)); getIt.registerFactoryParam((trade, _) => TradeDetailsViewModel( diff --git a/lib/router.dart b/lib/router.dart index 5148e2d16..b7b7c9a8e 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -42,11 +42,12 @@ import 'package:cake_wallet/src/screens/order_details/order_details_page.dart'; import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart'; import 'package:cake_wallet/src/screens/restore/restore_from_backup_page.dart'; import 'package:cake_wallet/src/screens/restore/wallet_restore_page.dart'; -import 'package:cake_wallet/src/screens/seed/warning_page.dart'; +import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart'; import 'package:cake_wallet/src/screens/settings/connection_sync_page.dart'; import 'package:cake_wallet/src/screens/settings/trocador_providers_page.dart'; import 'package:cake_wallet/src/screens/settings/tor_page.dart'; import 'package:cake_wallet/src/screens/setup_2fa/modify_2fa_page.dart'; +import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa_info_page.dart'; import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa_qr_page.dart'; import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa.dart'; import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa_enter_code_page.dart'; @@ -414,10 +415,10 @@ Route createRoute(RouteSettings settings) { case Routes.faq: return MaterialPageRoute(builder: (_) => getIt.get()); - case Routes.warningPage: + case Routes.preSeedPage: return MaterialPageRoute( - builder: (_) => getIt.get( - param1: settings.arguments as int?)); + builder: (_) => getIt.get( + param1: settings.arguments as int)); case Routes.backup: return CupertinoPageRoute( @@ -580,6 +581,9 @@ Route createRoute(RouteSettings settings) { case Routes.modify2FAPage: return MaterialPageRoute(builder: (_) => getIt.get()); + case Routes.setup2faInfoPage: + return MaterialPageRoute(builder: (_) => getIt.get()); + case Routes.homeSettings: return CupertinoPageRoute( builder: (_) => getIt.get(param1: settings.arguments), diff --git a/lib/routes.dart b/lib/routes.dart index 06bf7d5fa..7ad5c70bc 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -47,7 +47,7 @@ class Routes { static const exchangeTemplate = '/exchange_template'; static const restoreWalletType = '/restore_wallet_type'; static const restoreWallet = '/restore_wallet'; - static const warningPage = '/warning_page'; + static const preSeedPage = '/pre_seed_page'; static const backup = '/backup'; static const editBackupPassword = '/edit_backup_passowrd'; static const restoreFromBackup = '/restore_from_backup'; @@ -96,6 +96,7 @@ class Routes { static const setup_2faQRPage = '/setup_2fa_qr_page'; static const totpAuthCodePage = '/totp_auth_code_page'; static const modify2FAPage = '/modify_2fa_page'; + static const setup2faInfoPage = '/setup_2fa_info_page'; static const homeSettings = '/home_settings'; static const editToken = '/edit_token'; static const manageNodes = '/manage_nodes'; diff --git a/lib/src/screens/InfoPage.dart b/lib/src/screens/InfoPage.dart new file mode 100644 index 000000000..5398df22c --- /dev/null +++ b/lib/src/screens/InfoPage.dart @@ -0,0 +1,83 @@ +import 'package:cake_wallet/src/screens/base_page.dart'; +import 'package:cake_wallet/src/widgets/primary_button.dart'; +import 'package:cake_wallet/themes/extensions/cake_text_theme.dart'; +import 'package:cake_wallet/themes/theme_base.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; +import 'package:flutter/material.dart'; + +abstract class InfoPage extends BasePage { + InfoPage({ + this.imageLightPath = 'assets/images/pre_seed_light.png', + this.imageDarkPath = 'assets/images/pre_seed_dark.png', + }); + + final String imageLightPath; + final String imageDarkPath; + + Image get imageLight => Image.asset(imageLightPath); + Image get imageDark => Image.asset(imageDarkPath); + + bool get onWillPop => true; + String get pageTitle; + String get pageDescription; + String get buttonText; + void Function(BuildContext) get onPressed; + + @override + Widget? leading(BuildContext context) => null; + + @override + String get title => pageTitle; + + @override + Widget body(BuildContext context) { + final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight; + + return WillPopScope( + onWillPop: () async => onWillPop, + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.all(24), + child: ConstrainedBox( + constraints: BoxConstraints( + maxWidth: ResponsiveLayoutUtilBase.kDesktopMaxWidthConstraint), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: MediaQuery.of(context).size.height * 0.3), + child: AspectRatio(aspectRatio: 1, child: image), + ), + ), + Expanded( + child: Padding( + padding: EdgeInsets.all(10), + child: Text( + pageDescription, + textAlign: TextAlign.center, + style: TextStyle( + height: 1.7, + fontSize: 14, + fontWeight: FontWeight.normal, + color: Theme.of(context) + .extension()! + .secondaryTextColor, + ), + ), + ), + ), + PrimaryButton( + onPressed: () => onPressed(context), + text: buttonText, + color: Theme.of(context).primaryColor, + textColor: Colors.white, + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/src/screens/new_wallet/new_wallet_page.dart b/lib/src/screens/new_wallet/new_wallet_page.dart index 9d37e22eb..499e5feff 100644 --- a/lib/src/screens/new_wallet/new_wallet_page.dart +++ b/lib/src/screens/new_wallet/new_wallet_page.dart @@ -73,7 +73,7 @@ class _WalletNameFormState extends State { _stateReaction ??= reaction((_) => _walletNewVM.state, (ExecutionState state) async { if (state is ExecutedSuccessfullyState) { Navigator.of(navigatorKey.currentContext!) - .pushNamed(Routes.warningPage, arguments: _walletNewVM.seedPhraseWordsLength); + .pushNamed(Routes.preSeedPage, arguments: _walletNewVM.seedPhraseWordsLength); } if (state is FailureState) { diff --git a/lib/src/screens/seed/pre_seed_page.dart b/lib/src/screens/seed/pre_seed_page.dart new file mode 100644 index 000000000..730dfa5f8 --- /dev/null +++ b/lib/src/screens/seed/pre_seed_page.dart @@ -0,0 +1,27 @@ +import 'package:cake_wallet/generated/i18n.dart'; +import 'package:cake_wallet/routes.dart'; +import 'package:cake_wallet/src/screens/InfoPage.dart'; +import 'package:flutter/cupertino.dart'; + +class PreSeedPage extends InfoPage { + PreSeedPage(this.seedPhraseLength); + + final int seedPhraseLength; + + @override + bool get onWillPop => false; + + @override + String get pageTitle => S.current.pre_seed_title; + + @override + String get pageDescription => + S.current.pre_seed_description(seedPhraseLength.toString()); + + @override + String get buttonText => S.current.pre_seed_button_text; + + @override + void Function(BuildContext) get onPressed => (BuildContext context) => + Navigator.of(context).popAndPushNamed(Routes.seed, arguments: true); +} diff --git a/lib/src/screens/seed/warning_page.dart b/lib/src/screens/seed/warning_page.dart deleted file mode 100644 index 18b9b6248..000000000 --- a/lib/src/screens/seed/warning_page.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'package:cake_wallet/utils/responsive_layout_util.dart'; -import 'package:cake_wallet/themes/extensions/cake_text_theme.dart'; -import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart'; -import 'package:cw_core/wallet_type.dart'; -import 'package:cake_wallet/src/screens/base_page.dart'; -import 'package:cake_wallet/src/widgets/primary_button.dart'; -import 'package:cake_wallet/generated/i18n.dart'; -import 'package:cake_wallet/routes.dart'; -import 'package:cake_wallet/themes/theme_base.dart'; -import 'package:flutter/material.dart'; - -class WarningPage extends BasePage { - WarningPage(this.seedPhraseLength) - : isPreSeedPage = seedPhraseLength != null, - imageLight = Image.asset('assets/images/pre_seed_light.png'), - imageDark = Image.asset('assets/images/pre_seed_dark.png'); - - final Image imageDark; - final Image imageLight; - final int? seedPhraseLength; - final bool isPreSeedPage; - - @override - Widget? leading(BuildContext context) => - isPreSeedPage ? null : super.leading(context); - - @override - String? get title => S.current.pre_seed_title; - - @override - Widget body(BuildContext context) { - final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight; - - return WillPopScope( - onWillPop: () async => !isPreSeedPage, - child: Container( - alignment: Alignment.center, - padding: EdgeInsets.all(24), - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: ResponsiveLayoutUtilBase.kDesktopMaxWidthConstraint), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: ConstrainedBox( - constraints: BoxConstraints( - maxHeight: MediaQuery.of(context).size.height * 0.3), - child: AspectRatio(aspectRatio: 1, child: image), - ), - ), - Expanded( - child: Padding( - padding: EdgeInsets.all(10), - child: Text( - isPreSeedPage - ? S.of(context).pre_seed_description( - seedPhraseLength.toString()) - : S.of(context).setup_warning_2fa_text, - textAlign: TextAlign.center, - style: TextStyle( - height: 1.7, - fontSize: 14, - fontWeight: FontWeight.normal, - color: Theme.of(context) - .extension()! - .secondaryTextColor)), - ), - ), - PrimaryButton( - onPressed: () => isPreSeedPage - ? Navigator.of(context) - .popAndPushNamed(Routes.seed, arguments: true) - : Navigator.of(context) - .popAndPushNamed(Routes.setup_2faPage), - text: isPreSeedPage - ? S.of(context).pre_seed_button_text - : S.of(context).understand, - color: Theme.of(context).primaryColor, - textColor: Colors.white) - ], - ), - ), - )); - } -} diff --git a/lib/src/screens/settings/security_backup_page.dart b/lib/src/screens/settings/security_backup_page.dart index c6fa939de..56ba049ba 100644 --- a/lib/src/screens/settings/security_backup_page.dart +++ b/lib/src/screens/settings/security_backup_page.dart @@ -108,7 +108,7 @@ class SecurityBackupPage extends BasePage { context, route: _securitySettingsViewModel.useTotp2FA ? Routes.modify2FAPage - : Routes.warningPage, + : Routes.setup2faInfoPage, conditionToDetermineIfToUse2FA: _securitySettingsViewModel .shouldRequireTOTP2FAForAllSecurityAndBackupSettings, ), diff --git a/lib/src/screens/setup_2fa/setup_2fa_info_page.dart b/lib/src/screens/setup_2fa/setup_2fa_info_page.dart new file mode 100644 index 000000000..ff6187665 --- /dev/null +++ b/lib/src/screens/setup_2fa/setup_2fa_info_page.dart @@ -0,0 +1,20 @@ +import 'package:cake_wallet/generated/i18n.dart'; +import 'package:cake_wallet/routes.dart'; +import 'package:cake_wallet/src/screens/InfoPage.dart'; +import 'package:flutter/cupertino.dart'; + +class Setup2FAInfoPage extends InfoPage { + + @override + String get pageTitle => S.current.pre_seed_title; + + @override + String get pageDescription => S.current.setup_warning_2fa_text; + + @override + String get buttonText => S.current.understand; + + @override + void Function(BuildContext) get onPressed => (BuildContext context) => + Navigator.of(context).popAndPushNamed(Routes.setup_2faPage); +}