From af9ef76260a744998817c3352a163833884804a6 Mon Sep 17 00:00:00 2001 From: tuxsudo Date: Fri, 12 Apr 2024 11:09:37 -0400 Subject: [PATCH] Initial commit --- lib/src/screens/seed/wallet_seed_page.dart | 177 +++++++++++++-------- 1 file changed, 110 insertions(+), 67 deletions(-) diff --git a/lib/src/screens/seed/wallet_seed_page.dart b/lib/src/screens/seed/wallet_seed_page.dart index 200b87b7d..62b928688 100644 --- a/lib/src/screens/seed/wallet_seed_page.dart +++ b/lib/src/screens/seed/wallet_seed_page.dart @@ -18,7 +18,10 @@ import 'package:cake_wallet/view_model/wallet_seed_view_model.dart'; import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart'; class WalletSeedPage extends BasePage { - WalletSeedPage(this.walletSeedViewModel, {required this.isNewWalletCreated}); + WalletSeedPage(this.walletSeedViewModel, {required this.isNewWalletCreated}) + : seedController = TextEditingController(), + nameController = TextEditingController(); + final imageLight = Image.asset('assets/images/crypto_lock_light.png'); final imageDark = Image.asset('assets/images/crypto_lock.png'); @@ -29,20 +32,23 @@ class WalletSeedPage extends BasePage { final bool isNewWalletCreated; final WalletSeedViewModel walletSeedViewModel; + + @override void onClose(BuildContext context) async { + if (isNewWalletCreated) { final confirmed = await showPopUp( - context: context, - builder: (BuildContext context) { - return AlertWithTwoActions( - alertTitle: S.of(context).seed_alert_title, - alertContent: S.of(context).seed_alert_content, - leftButtonText: S.of(context).seed_alert_back, - rightButtonText: S.of(context).seed_alert_yes, - actionLeftButton: () => Navigator.of(context).pop(false), - actionRightButton: () => Navigator.of(context).pop(true)); - }) ?? + context: context, + builder: (BuildContext context) { + return AlertWithTwoActions( + alertTitle: S.of(context).seed_alert_title, + alertContent: S.of(context).seed_alert_content, + leftButtonText: S.of(context).seed_alert_back, + rightButtonText: S.of(context).seed_alert_yes, + actionLeftButton: () => Navigator.of(context).pop(false), + actionRightButton: () => Navigator.of(context).pop(true)); + }) ?? false; if (confirmed) { @@ -62,31 +68,48 @@ 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).cardColor), - child: Text( - S.of(context).seed_language_next, - style: TextStyle( - fontSize: 14, fontWeight: FontWeight.w600, color: Theme.of(context) - .extension()! - .buttonTextColor), - ), - ), - ) + 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).cardColor), + child: Text( + S.of(context).seed_language_next, + style: TextStyle( + fontSize: 14, fontWeight: FontWeight.w600, color: Theme.of(context) + .extension()! + .buttonTextColor), + ), + ), + ) : Offstage(); } + final TextEditingController nameController; + final TextEditingController seedController; + @override Widget body(BuildContext context) { + final image = currentTheme.type == ThemeType.dark ? imageDark : imageLight; + TextFormField( + autofillHints: [AutofillHints.newUsername], + //initialValue: walletSeedViewModel.name, + controller: nameController, + ); + TextFormField( + autofillHints: [AutofillHints.password], + //initialValue: walletSeedViewModel.seed, + controller: seedController + //walletSeedViewModel.seed, + + ); + return WillPopScope( onWillPop: () async => false, child: Container( @@ -105,8 +128,10 @@ class WalletSeedPage extends BasePage { return Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text( - walletSeedViewModel.name, + TextFormField( + //initialValue: walletSeedViewModel.name, + controller: nameController, + autofillHints: [AutofillHints.newUsername], style: TextStyle( fontSize: 20, fontWeight: FontWeight.w600, @@ -114,8 +139,10 @@ class WalletSeedPage extends BasePage { ), Padding( padding: EdgeInsets.only(top: 20, left: 16, right: 16), - child: Text( - walletSeedViewModel.seed, + child: TextFormField( + //initialValue: walletSeedViewModel.seed, + controller: seedController, + autofillHints: [AutofillHints.password], textAlign: TextAlign.center, style: TextStyle( fontSize: 14, @@ -130,48 +157,64 @@ class WalletSeedPage extends BasePage { children: [ isNewWalletCreated ? Padding( - padding: EdgeInsets.only(bottom: 43, 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).extension()!.detailsTitlesColor), - ), - ) + padding: EdgeInsets.only(bottom: 43, 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).extension()!.detailsTitlesColor), + ), + ) : Offstage(), Row( mainAxisSize: MainAxisSize.max, children: [ Flexible( child: Container( - padding: EdgeInsets.only(right: 8.0), - child: PrimaryButton( - onPressed: () { - ShareUtil.share( - text: walletSeedViewModel.seed, - context: context, - ); - }, - text: S.of(context).save, - color: Colors.green, - textColor: Colors.white), - )), + padding: EdgeInsets.only(right: 8.0), + child: PrimaryButton( + onPressed: () { + ShareUtil.share( + text: walletSeedViewModel.seed, + context: context, + ); + }, + 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: () { - ClipboardUtil.setSensitiveDataToClipboard( - ClipboardData(text: walletSeedViewModel.seed)); - showBar(context, S.of(context).copied_to_clipboard); - }, - text: S.of(context).copy, - color: Theme.of(context).extension()!.indicatorsColor, - textColor: Colors.white)), - )) + padding: EdgeInsets.only(left: 8.0), + child: Builder( + builder: (context) => PrimaryButton( + onPressed: () { + ClipboardUtil.setSensitiveDataToClipboard( + ClipboardData(text: walletSeedViewModel.seed)); + showBar(context, S.of(context).copied_to_clipboard); + }, + text: S.of(context).copy, + color: Theme.of(context).extension()!.indicatorsColor, + textColor: Colors.white)), + )), + Flexible( + child: Container( + padding: EdgeInsets.only(left: 8.0), + child: Builder( + builder: (context) => PrimaryButton( + onPressed: () async { + + nameController.text = walletSeedViewModel.name; + seedController.text = walletSeedViewModel.seed; + + TextInput.finishAutofillContext(); + }, + text: "Save2", + color: Colors.blue, + textColor: Colors.white)), + )) ], ) ],