From 0fd4f132dc76549c05f5960fe708f94b39b0ada0 Mon Sep 17 00:00:00 2001 From: RafiaChy Date: Wed, 26 Jan 2022 16:04:45 +0600 Subject: [PATCH] soft keyboard dismisses when generate-name icon is pressed --- .../screens/new_wallet/new_wallet_page.dart | 76 +++++++++++-------- .../wallet_restore_from_keys_form.dart | 57 +++++++++----- .../wallet_restore_from_seed_form.dart | 64 +++++++++------- 3 files changed, 114 insertions(+), 83 deletions(-) diff --git a/lib/src/screens/new_wallet/new_wallet_page.dart b/lib/src/screens/new_wallet/new_wallet_page.dart index a4a0b32be..a709dc4ce 100644 --- a/lib/src/screens/new_wallet/new_wallet_page.dart +++ b/lib/src/screens/new_wallet/new_wallet_page.dart @@ -105,18 +105,50 @@ class _WalletNameFormState extends State { padding: EdgeInsets.only(top: 24), child: Form( key: _formKey, - child: TextFormField( - onChanged: (value) => _walletNewVM.name = value, - controller: _controller, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.w600, - color: Theme.of(context).primaryTextTheme.title.color), - decoration: InputDecoration( - suffixIcon: IconButton( + child: Stack( + alignment: Alignment.centerRight, + children: [ + TextFormField( + onChanged: (value) => _walletNewVM.name = value, + controller: _controller, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20.0, + fontWeight: FontWeight.w600, + color: + Theme.of(context).primaryTextTheme.title.color), + decoration: InputDecoration( + hintStyle: TextStyle( + fontSize: 18.0, + fontWeight: FontWeight.w500, + color: Theme.of(context) + .accentTextTheme + .display3 + .color), + hintText: S.of(context).wallet_name, + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context) + .accentTextTheme + .display3 + .decorationColor, + width: 1.0)), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context) + .accentTextTheme + .display3 + .decorationColor, + width: 1.0), + ), + ), + validator: WalletNameValidator(), + ), + IconButton( onPressed: () async { final rName = await generateName(); + FocusManager.instance.primaryFocus?.unfocus(); + setState(() { _controller.text = rName; _walletNewVM.name = rName; @@ -141,29 +173,7 @@ class _WalletNameFormState extends State { ), ), ), - hintStyle: TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.w500, - color: - Theme.of(context).accentTextTheme.display3.color), - hintText: S.of(context).wallet_name, - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context) - .accentTextTheme - .display3 - .decorationColor, - width: 1.0)), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide( - color: Theme.of(context) - .accentTextTheme - .display3 - .decorationColor, - width: 1.0), - ), - ), - validator: WalletNameValidator(), + ], ), ), ), diff --git a/lib/src/screens/restore/wallet_restore_from_keys_form.dart b/lib/src/screens/restore/wallet_restore_from_keys_form.dart index 36264aa95..1364cb072 100644 --- a/lib/src/screens/restore/wallet_restore_from_keys_form.dart +++ b/lib/src/screens/restore/wallet_restore_from_keys_form.dart @@ -37,6 +37,13 @@ class WalletRestoreFromKeysFromState extends State { final TextEditingController viewKeyController; final TextEditingController spendKeyController; final TextEditingController nameTextEditingController; + bool buttonPressed; + + @override + void initState() { + super.initState(); + buttonPressed = false; + } @override void dispose() { @@ -54,17 +61,19 @@ class WalletRestoreFromKeysFromState extends State { child: Form( key: formKey, child: Column(children: [ - BaseTextFormField( - controller: nameTextEditingController, - hintText: S.of(context).wallet_name, - validator: WalletNameValidator(), - suffixIcon: Container( - width: 12, - height: 14, - margin: const EdgeInsets.only(bottom: 15, left: 13), - child: InkWell( - onTap: () async { + Stack( + alignment: Alignment.centerRight, + children: [ + BaseTextFormField( + controller: nameTextEditingController, + hintText: S.of(context).wallet_name, + validator: WalletNameValidator(), + ), + IconButton( + onPressed: () async { final rName = await generateName(); + FocusManager.instance.primaryFocus?.unfocus(); + setState(() { nameTextEditingController.text = rName; nameTextEditingController.selection = @@ -72,18 +81,24 @@ class WalletRestoreFromKeysFromState extends State { offset: nameTextEditingController.text.length)); }); }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Theme.of(context).hintColor, - borderRadius: BorderRadius.all(Radius.circular(6))), - child: Image.asset('assets/images/refresh_icon.png', - color: Theme.of(context) - .primaryTextTheme - .display1 - .decorationColor)), + icon: Container( + padding: const EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.0), + color: Theme.of(context).hintColor, + ), + width: 34, + height: 34, + child: Image.asset( + 'assets/images/refresh_icon.png', + color: Theme.of(context) + .primaryTextTheme + .display1 + .decorationColor, + ), + ), ), - ), + ], ), Container(height: 20), BaseTextFormField( diff --git a/lib/src/screens/restore/wallet_restore_from_seed_form.dart b/lib/src/screens/restore/wallet_restore_from_seed_form.dart index 6e8c10f3c..a0d314ec2 100644 --- a/lib/src/screens/restore/wallet_restore_from_seed_form.dart +++ b/lib/src/screens/restore/wallet_restore_from_seed_form.dart @@ -61,36 +61,42 @@ class WalletRestoreFromSeedFormState extends State { return Container( padding: EdgeInsets.only(left: 24, right: 24), child: Column(children: [ - BaseTextFormField( - controller: nameTextEditingController, - hintText: S.of(context).wallet_name, - validator: WalletNameValidator(), - suffixIcon: Container( - width: 12, - height: 14, - margin: const EdgeInsets.only(bottom: 15, left: 13), - child: InkWell( - onTap: () async { - final rName = await generateName(); - setState(() { - nameTextEditingController.text = rName; - nameTextEditingController.selection = - TextSelection.fromPosition(TextPosition( - offset: nameTextEditingController.text.length)); - }); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Theme.of(context).hintColor, - borderRadius: BorderRadius.all(Radius.circular(6))), - child: Image.asset('assets/images/refresh_icon.png', - color: Theme.of(context) - .primaryTextTheme - .display1 - .decorationColor)), + Stack( + alignment: Alignment.centerRight, + children: [ + BaseTextFormField( + controller: nameTextEditingController, + hintText: S.of(context).wallet_name, + validator: WalletNameValidator(), ), - ), + Container( + width: 34, + height: 34, + margin: const EdgeInsets.only(bottom: 15, left: 13), + child: InkWell( + onTap: () async { + final rName = await generateName(); + FocusManager.instance.primaryFocus?.unfocus(); + setState(() { + nameTextEditingController.text = rName; + nameTextEditingController.selection = + TextSelection.fromPosition(TextPosition( + offset: nameTextEditingController.text.length)); + }); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: Theme.of(context).hintColor, + borderRadius: BorderRadius.all(Radius.circular(6))), + child: Image.asset('assets/images/refresh_icon.png', + color: Theme.of(context) + .primaryTextTheme + .display1 + .decorationColor)), + ), + ), + ], ), Container(height: 20), SeedWidget(