mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-21 06:18:42 +02:00
info page refactoring
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user