diff --git a/lib/di.dart b/lib/di.dart index 697e40e22..2010a6158 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -195,9 +195,9 @@ Future setup( instanceName: 'login'); getIt - .registerFactoryParam( - (onAuthFinished, _) => AuthPage(getIt.get(), - onAuthenticationFinished: onAuthFinished, closable: false)); + .registerFactoryParam( + (onAuthFinished, closable) => AuthPage(getIt.get(), + onAuthenticationFinished: onAuthFinished, closable: closable ?? false)); getIt.registerFactory(() => DashboardPage( walletViewModel: getIt.get(), diff --git a/lib/router.dart b/lib/router.dart index e7f9330d8..5ae418395 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -215,13 +215,15 @@ class Router { return MaterialPageRoute( fullscreenDialog: true, builder: (_) => getIt.get( - param1: settings.arguments as OnAuthenticationFinished)); + param1: settings.arguments as OnAuthenticationFinished, + param2: true)); case Routes.unlock: return MaterialPageRoute( fullscreenDialog: true, builder: (_) => getIt.get( - param1: settings.arguments as OnAuthenticationFinished)); + param1: settings.arguments as OnAuthenticationFinished, + param2: false)); case Routes.nodeList: return CupertinoPageRoute( diff --git a/lib/src/screens/auth/auth_page.dart b/lib/src/screens/auth/auth_page.dart index 13c74f6e1..37f03f5c3 100644 --- a/lib/src/screens/auth/auth_page.dart +++ b/lib/src/screens/auth/auth_page.dart @@ -27,7 +27,7 @@ class AuthPageState extends State { final _key = GlobalKey(); final _pinCodeKey = GlobalKey(); final _backArrowImageDarkTheme = - Image.asset('assets/images/back_arrow_dark_theme.png'); + Image.asset('assets/images/close_button.png'); ReactionDisposer _reaction; @override @@ -122,9 +122,11 @@ class AuthPageState extends State { key: _key, appBar: CupertinoNavigationBar( leading: widget.closable - ? SizedBox( + ? Container( + padding: EdgeInsets.only(top: 10), + child: SizedBox( height: 37, - width: 20, + width: 37, child: ButtonTheme( minWidth: double.minPositive, child: FlatButton( @@ -134,7 +136,7 @@ class AuthPageState extends State { onPressed: () => Navigator.of(context).pop(), child: _backArrowImageDarkTheme), ), - ) + )) : Container(), backgroundColor: Theme.of(context).backgroundColor, border: null), diff --git a/lib/src/screens/seed/wallet_seed_page.dart b/lib/src/screens/seed/wallet_seed_page.dart index ed5746d55..6e6088bdd 100644 --- a/lib/src/screens/seed/wallet_seed_page.dart +++ b/lib/src/screens/seed/wallet_seed_page.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/palette.dart'; +import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -24,9 +25,28 @@ class WalletSeedPage extends BasePage { final WalletSeedViewModel walletSeedViewModel; @override - void onClose(BuildContext context) => isNewWalletCreated - ? Navigator.of(context).popUntil((route) => route.isFirst) - : Navigator.of(context).pop(); + void onClose(BuildContext context) async { + if (isNewWalletCreated) { + final confirmed = await showDialog(context: context, builder: (BuildContext context) { + // FIXME: add translations + return AlertWithTwoActions( + alertTitle: 'Attention', + alertContent: 'Have you written it down? The seed is the only way to recover your wallet.', + leftButtonText: 'Not yet', + rightButtonText: 'Yes, I have', + actionLeftButton: () => Navigator.of(context).pop(false), + actionRightButton: () => Navigator.of(context).pop(true)); + }) ?? false; + + if (confirmed) { + Navigator.of(context).popUntil((route) => route.isFirst); + } + + return; + } + + Navigator.of(context).pop(); + } @override Widget leading(BuildContext context) => @@ -36,31 +56,39 @@ class WalletSeedPage extends BasePage { Widget trailing(BuildContext context) { return isNewWalletCreated ? GestureDetector( - onTap: () => onClose(context), - child: Container( - width: 100, - height: 32, - alignment: Alignment.center, - margin: EdgeInsets.only(left: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(16)), - color: Theme.of(context).accentTextTheme.caption.color), - child: Text( - S.of(context).seed_language_next, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Palette.blueCraiola), - ), - ), - ) + onTap: () => onClose(context), + child: Container( + width: 100, + height: 32, + alignment: Alignment.center, + margin: EdgeInsets.only(left: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(16)), + color: Theme + .of(context) + .accentTextTheme + .caption + .color), + child: Text( + S + .of(context) + .seed_language_next, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Palette.blueCraiola), + ), + ), + ) : Offstage(); } @override Widget body(BuildContext context) { final image = - getIt.get().isDarkTheme ? imageDark : imageLight; + getIt + .get() + .isDarkTheme ? imageDark : imageLight; return Container( padding: EdgeInsets.all(24), @@ -87,21 +115,23 @@ class WalletSeedPage extends BasePage { style: TextStyle( fontSize: 20, fontWeight: FontWeight.w600, - color: Theme.of(context) + color: Theme + .of(context) .primaryTextTheme .title .color), ), Padding( padding: - EdgeInsets.only(top: 20, left: 16, right: 16), + EdgeInsets.only(top: 20, left: 16, right: 16), child: Text( walletSeedViewModel.seed, textAlign: TextAlign.center, style: TextStyle( fontSize: 14, fontWeight: FontWeight.normal, - color: Theme.of(context) + color: Theme + .of(context) .primaryTextTheme .caption .color), @@ -115,62 +145,78 @@ class WalletSeedPage extends BasePage { children: [ isNewWalletCreated ? Padding( - padding: EdgeInsets.only( - bottom: 52, left: 43, right: 43), - child: Text( - S.of(context).seed_reminder, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.normal, - color: Theme.of(context) - .primaryTextTheme - .overline - .color), - ), - ) + padding: EdgeInsets.only( + bottom: 52, left: 43, right: 43), + child: Text( + S + .of(context) + .seed_reminder, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.normal, + color: Theme + .of(context) + .primaryTextTheme + .overline + .color), + ), + ) : Offstage(), Row( mainAxisSize: MainAxisSize.max, children: [ Flexible( child: Container( - padding: EdgeInsets.only(right: 8.0), - child: PrimaryButton( - onPressed: () => Share.text( - S.of(context).seed_share, - walletSeedViewModel.seed, - 'text/plain'), - text: S.of(context).save, - color: Colors.green, - textColor: Colors.white), - )), + padding: EdgeInsets.only(right: 8.0), + child: PrimaryButton( + onPressed: () => + Share.text( + S + .of(context) + .seed_share, + walletSeedViewModel.seed, + 'text/plain'), + text: S + .of(context) + .save, + color: Colors.green, + textColor: Colors.white), + )), Flexible( child: Container( - padding: EdgeInsets.only(left: 8.0), - child: Builder( - builder: (context) => PrimaryButton( - onPressed: () { - Clipboard.setData(ClipboardData( - text: walletSeedViewModel.seed)); - Scaffold.of(context).showSnackBar( - SnackBar( - content: Text(S - .of(context) - .copied_to_clipboard), - backgroundColor: Colors.green, - duration: - Duration(milliseconds: 1500), - ), - ); - }, - text: S.of(context).copy, - color: Theme.of(context) - .accentTextTheme - .body2 - .color, - textColor: Colors.white)), - )) + padding: EdgeInsets.only(left: 8.0), + child: Builder( + builder: (context) => + PrimaryButton( + onPressed: () { + Clipboard.setData(ClipboardData( + text: walletSeedViewModel + .seed)); + Scaffold.of(context) + .showSnackBar( + SnackBar( + content: Text(S + .of(context) + .copied_to_clipboard), + backgroundColor: Colors + .green, + duration: + Duration( + milliseconds: 1500), + ), + ); + }, + text: S + .of(context) + .copy, + color: Theme + .of(context) + .accentTextTheme + .body2 + .color, + textColor: Colors.white)), + )) ], ) ],