mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
info page refactoring
This commit is contained in:
parent
a5895e8832
commit
3522561cfc
9 changed files with 148 additions and 96 deletions
|
@ -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<void> setup({
|
|||
getIt.registerFactory<TransactionsPage>(
|
||||
() => TransactionsPage(dashboardViewModel: getIt.get<DashboardViewModel>()));
|
||||
|
||||
getIt.registerFactory<Setup2FAInfoPage>(() => Setup2FAInfoPage());
|
||||
|
||||
getIt.registerFactory<Setup2FAPage>(
|
||||
() => Setup2FAPage(setup2FAViewModel: getIt.get<Setup2FAViewModel>()));
|
||||
|
||||
|
@ -915,9 +918,9 @@ Future<void> setup({
|
|||
getIt.registerFactoryParam<NewWalletTypePage, void Function(BuildContext, WalletType), bool?>(
|
||||
(param1, isCreate) => NewWalletTypePage(onTypeSelected: param1, isCreate: isCreate ?? true));
|
||||
|
||||
getIt.registerFactoryParam<WarningPage, int?, void>(
|
||||
getIt.registerFactoryParam<PreSeedPage, int, void>(
|
||||
(seedPhraseLength, _)
|
||||
=> WarningPage(seedPhraseLength));
|
||||
=> PreSeedPage(seedPhraseLength));
|
||||
|
||||
getIt.registerFactoryParam<TradeDetailsViewModel, Trade, void>((trade, _) =>
|
||||
TradeDetailsViewModel(
|
||||
|
|
|
@ -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<dynamic> createRoute(RouteSettings settings) {
|
|||
case Routes.faq:
|
||||
return MaterialPageRoute<void>(builder: (_) => getIt.get<FaqPage>());
|
||||
|
||||
case Routes.warningPage:
|
||||
case Routes.preSeedPage:
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (_) => getIt.get<WarningPage>(
|
||||
param1: settings.arguments as int?));
|
||||
builder: (_) => getIt.get<PreSeedPage>(
|
||||
param1: settings.arguments as int));
|
||||
|
||||
case Routes.backup:
|
||||
return CupertinoPageRoute<void>(
|
||||
|
@ -580,6 +581,9 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
case Routes.modify2FAPage:
|
||||
return MaterialPageRoute<void>(builder: (_) => getIt.get<Modify2FAPage>());
|
||||
|
||||
case Routes.setup2faInfoPage:
|
||||
return MaterialPageRoute<void>(builder: (_) => getIt.get<Setup2FAInfoPage>());
|
||||
|
||||
case Routes.homeSettings:
|
||||
return CupertinoPageRoute<void>(
|
||||
builder: (_) => getIt.get<HomeSettingsPage>(param1: settings.arguments),
|
||||
|
|
|
@ -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';
|
||||
|
|
83
lib/src/screens/InfoPage.dart
Normal file
83
lib/src/screens/InfoPage.dart
Normal file
|
@ -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: <Widget>[
|
||||
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<CakeTextTheme>()!
|
||||
.secondaryTextColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
PrimaryButton(
|
||||
onPressed: () => onPressed(context),
|
||||
text: buttonText,
|
||||
color: Theme.of(context).primaryColor,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -73,7 +73,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
|||
_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) {
|
||||
|
|
27
lib/src/screens/seed/pre_seed_page.dart
Normal file
27
lib/src/screens/seed/pre_seed_page.dart
Normal file
|
@ -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);
|
||||
}
|
|
@ -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: <Widget>[
|
||||
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<CakeTextTheme>()!
|
||||
.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)
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -108,7 +108,7 @@ class SecurityBackupPage extends BasePage {
|
|||
context,
|
||||
route: _securitySettingsViewModel.useTotp2FA
|
||||
? Routes.modify2FAPage
|
||||
: Routes.warningPage,
|
||||
: Routes.setup2faInfoPage,
|
||||
conditionToDetermineIfToUse2FA: _securitySettingsViewModel
|
||||
.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
||||
),
|
||||
|
|
20
lib/src/screens/setup_2fa/setup_2fa_info_page.dart
Normal file
20
lib/src/screens/setup_2fa/setup_2fa_info_page.dart
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue