fix: keep keyboard focus when changing wallet source in payment popup

https://stackoverflow.com/a/76367322/8301867
This commit is contained in:
poka 2023-11-17 12:44:44 +01:00
parent dc1b54a09c
commit b835c701b1
1 changed files with 55 additions and 50 deletions

View File

@ -145,16 +145,14 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
),
const SizedBox(height: 10),
Consumer<SubstrateSdk>(builder: (context, sub, _) {
// TODO: about keyboard dismiss issue, should try this: https://stackoverflow.com/a/76352647/8301867
return DropdownButton(
dropdownColor: const Color(0xffffeed1),
elevation: 12,
key: dropdownKey,
value: defaultWallet,
// onTap: () async {
// await Future.delayed(const Duration(milliseconds: 10));
// amountFocus.requestFocus();
// },
onTap: () {
FocusScope.of(context).requestFocus(amountFocus);
},
selectedItemBuilder: (_) {
return myWalletProvider.listWallets
.map((WalletData wallet) {
@ -268,7 +266,13 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
],
),
const SizedBox(height: 10),
TextField(
Focus(
onFocusChange: (focused) {
setState(() {
FocusScope.of(context).requestFocus(amountFocus);
});
},
child: TextField(
textInputAction: TextInputAction.done,
onEditingComplete: () async =>
canValidate ? await executeTransfert() : null,
@ -305,8 +309,8 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
filled: true,
fillColor: Colors.transparent,
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey[500]!, width: 2),
borderSide: BorderSide(
color: Colors.grey[500]!, width: 2),
borderRadius: BorderRadius.circular(8),
),
contentPadding: const EdgeInsets.all(20),
@ -317,6 +321,7 @@ void paymentPopup(BuildContext context, String toAddress, String username) {
fontWeight: FontWeight.w600,
),
),
),
const Spacer(),
SizedBox(
width: double.infinity,