soft keyboard dismisses when generate-name icon is pressed

RafiaChy committed Jan 26, 2022 at 16:04 UTC 0fd4f132dc76549c05f5960fe708f94b39b0ada0
3 files changed +114 -83
lib/src/screens/new_wallet/new_wallet_page.dart
+43 -33
@@ -105,18 +105,50 @@ class _WalletNameFormState extends State<WalletNameForm> {
105 padding: EdgeInsets.only(top: 24),
106 child: Form(
107 key: _formKey,
108 - child: TextFormField(
109 - onChanged: (value) => _walletNewVM.name = value,
110 - controller: _controller,
111 - textAlign: TextAlign.center,
112 - style: TextStyle(
113 - fontSize: 20.0,
114 - fontWeight: FontWeight.w600,
115 - color: Theme.of(context).primaryTextTheme.title.color),
116 - decoration: InputDecoration(
117 - suffixIcon: IconButton(
108 + child: Stack(
109 + alignment: Alignment.centerRight,
110 + children: [
111 + TextFormField(
112 + onChanged: (value) => _walletNewVM.name = value,
113 + controller: _controller,
114 + textAlign: TextAlign.center,
115 + style: TextStyle(
116 + fontSize: 20.0,
117 + fontWeight: FontWeight.w600,
118 + color:
119 + Theme.of(context).primaryTextTheme.title.color),
120 + decoration: InputDecoration(
121 + hintStyle: TextStyle(
122 + fontSize: 18.0,
123 + fontWeight: FontWeight.w500,
124 + color: Theme.of(context)
125 + .accentTextTheme
126 + .display3
127 + .color),
128 + hintText: S.of(context).wallet_name,
129 + focusedBorder: UnderlineInputBorder(
130 + borderSide: BorderSide(
131 + color: Theme.of(context)
132 + .accentTextTheme
133 + .display3
134 + .decorationColor,
135 + width: 1.0)),
136 + enabledBorder: UnderlineInputBorder(
137 + borderSide: BorderSide(
138 + color: Theme.of(context)
139 + .accentTextTheme
140 + .display3
141 + .decorationColor,
142 + width: 1.0),
143 + ),
144 + ),
145 + validator: WalletNameValidator(),
146 + ),
147 + IconButton(
148 onPressed: () async {
149 final rName = await generateName();
150 + FocusManager.instance.primaryFocus?.unfocus();
151 +
152 setState(() {
153 _controller.text = rName;
154 _walletNewVM.name = rName;
@@ -141,29 +173,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
173 ),
174 ),
175 ),
144 - hintStyle: TextStyle(
145 - fontSize: 18.0,
146 - fontWeight: FontWeight.w500,
147 - color:
148 - Theme.of(context).accentTextTheme.display3.color),
149 - hintText: S.of(context).wallet_name,
150 - focusedBorder: UnderlineInputBorder(
151 - borderSide: BorderSide(
152 - color: Theme.of(context)
153 - .accentTextTheme
154 - .display3
155 - .decorationColor,
156 - width: 1.0)),
157 - enabledBorder: UnderlineInputBorder(
158 - borderSide: BorderSide(
159 - color: Theme.of(context)
160 - .accentTextTheme
161 - .display3
162 - .decorationColor,
163 - width: 1.0),
164 - ),
165 - ),
166 - validator: WalletNameValidator(),
176 + ],
177 ),
178 ),
179 ),
lib/src/screens/restore/wallet_restore_from_keys_form.dart
+36 -21
@@ -37,6 +37,13 @@ class WalletRestoreFromKeysFromState extends State<WalletRestoreFromKeysFrom> {
37 final TextEditingController viewKeyController;
38 final TextEditingController spendKeyController;
39 final TextEditingController nameTextEditingController;
40 + bool buttonPressed;
41 +
42 + @override
43 + void initState() {
44 + super.initState();
45 + buttonPressed = false;
46 + }
47
48 @override
49 void dispose() {
@@ -54,17 +61,19 @@ class WalletRestoreFromKeysFromState extends State<WalletRestoreFromKeysFrom> {
61 child: Form(
62 key: formKey,
63 child: Column(children: <Widget>[
57 - BaseTextFormField(
58 - controller: nameTextEditingController,
59 - hintText: S.of(context).wallet_name,
60 - validator: WalletNameValidator(),
61 - suffixIcon: Container(
62 - width: 12,
63 - height: 14,
64 - margin: const EdgeInsets.only(bottom: 15, left: 13),
65 - child: InkWell(
66 - onTap: () async {
64 + Stack(
65 + alignment: Alignment.centerRight,
66 + children: [
67 + BaseTextFormField(
68 + controller: nameTextEditingController,
69 + hintText: S.of(context).wallet_name,
70 + validator: WalletNameValidator(),
71 + ),
72 + IconButton(
73 + onPressed: () async {
74 final rName = await generateName();
75 + FocusManager.instance.primaryFocus?.unfocus();
76 +
77 setState(() {
78 nameTextEditingController.text = rName;
79 nameTextEditingController.selection =
@@ -72,18 +81,24 @@ class WalletRestoreFromKeysFromState extends State<WalletRestoreFromKeysFrom> {
81 offset: nameTextEditingController.text.length));
82 });
83 },
75 - child: Container(
76 - padding: EdgeInsets.all(8),
77 - decoration: BoxDecoration(
78 - color: Theme.of(context).hintColor,
79 - borderRadius: BorderRadius.all(Radius.circular(6))),
80 - child: Image.asset('assets/images/refresh_icon.png',
81 - color: Theme.of(context)
82 - .primaryTextTheme
83 - .display1
84 - .decorationColor)),
84 + icon: Container(
85 + padding: const EdgeInsets.all(8),
86 + decoration: BoxDecoration(
87 + borderRadius: BorderRadius.circular(6.0),
88 + color: Theme.of(context).hintColor,
89 + ),
90 + width: 34,
91 + height: 34,
92 + child: Image.asset(
93 + 'assets/images/refresh_icon.png',
94 + color: Theme.of(context)
95 + .primaryTextTheme
96 + .display1
97 + .decorationColor,
98 + ),
99 + ),
100 ),
86 - ),
101 + ],
102 ),
103 Container(height: 20),
104 BaseTextFormField(
lib/src/screens/restore/wallet_restore_from_seed_form.dart
+35 -29
@@ -61,36 +61,42 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
61 return Container(
62 padding: EdgeInsets.only(left: 24, right: 24),
63 child: Column(children: [
64 - BaseTextFormField(
65 - controller: nameTextEditingController,
66 - hintText: S.of(context).wallet_name,
67 - validator: WalletNameValidator(),
68 - suffixIcon: Container(
69 - width: 12,
70 - height: 14,
71 - margin: const EdgeInsets.only(bottom: 15, left: 13),
72 - child: InkWell(
73 - onTap: () async {
74 - final rName = await generateName();
75 - setState(() {
76 - nameTextEditingController.text = rName;
77 - nameTextEditingController.selection =
78 - TextSelection.fromPosition(TextPosition(
79 - offset: nameTextEditingController.text.length));
80 - });
81 - },
82 - child: Container(
83 - padding: EdgeInsets.all(8),
84 - decoration: BoxDecoration(
85 - color: Theme.of(context).hintColor,
86 - borderRadius: BorderRadius.all(Radius.circular(6))),
87 - child: Image.asset('assets/images/refresh_icon.png',
88 - color: Theme.of(context)
89 - .primaryTextTheme
90 - .display1
91 - .decorationColor)),
64 + Stack(
65 + alignment: Alignment.centerRight,
66 + children: [
67 + BaseTextFormField(
68 + controller: nameTextEditingController,
69 + hintText: S.of(context).wallet_name,
70 + validator: WalletNameValidator(),
71 + ),
72 + Container(
73 + width: 34,
74 + height: 34,
75 + margin: const EdgeInsets.only(bottom: 15, left: 13),
76 + child: InkWell(
77 + onTap: () async {
78 + final rName = await generateName();
79 + FocusManager.instance.primaryFocus?.unfocus();
80 + setState(() {
81 + nameTextEditingController.text = rName;
82 + nameTextEditingController.selection =
83 + TextSelection.fromPosition(TextPosition(
84 + offset: nameTextEditingController.text.length));
85 + });
86 + },
87 + child: Container(
88 + padding: EdgeInsets.all(8),
89 + decoration: BoxDecoration(
90 + color: Theme.of(context).hintColor,
91 + borderRadius: BorderRadius.all(Radius.circular(6))),
92 + child: Image.asset('assets/images/refresh_icon.png',
93 + color: Theme.of(context)
94 + .primaryTextTheme
95 + .display1
96 + .decorationColor)),
97 + ),
98 ),
93 - ),
99 + ],
100 ),
101 Container(height: 20),
102 SeedWidget(