Going to amount or reference text field if other data are set in ShowTransferMoneyDialogData

This commit is contained in:
dankito 2024-10-04 01:28:19 +02:00
parent fd53b2f005
commit fbd9c9485a
1 changed files with 12 additions and 2 deletions

View File

@ -77,6 +77,8 @@ fun TransferMoneyDialog(
val amountFocus = remember { FocusRequester() }
val referenceFocus = remember { FocusRequester() }
val verticalSpace = 8.dp
var isInitialized by remember { mutableStateOf(false) }
@ -211,6 +213,7 @@ fun TransferMoneyDialog(
if (it != null) {
amount = it.amount.toString()
paymentReference = it.reference
referenceFocus.requestFocus()
}
},
fetchSuggestions = { query -> recipientFinder.findAmountPaymentDataForIban(recipientAccountIdentifier, query) }
@ -228,8 +231,9 @@ fun TransferMoneyDialog(
AutocompleteTextField(
"Verwendungszweck (optional)",
paymentReference,
dropdownMaxHeight = 175.dp, // when showing more items than on Android autocomplete dropdown covers soft keybaord
dropdownMaxHeight = 175.dp, // when showing more items than on Android autocomplete dropdown covers soft keyboard
minTextLengthForSearch = 1,
modifier = Modifier.focusRequester(referenceFocus),
getItemTitle = { suggestion -> suggestion.reference },
onEnteredTextChanged = { paymentReference = it },
onSelectedItemChanged = { paymentReference = it?.reference ?: "" },
@ -271,7 +275,13 @@ fun TransferMoneyDialog(
coroutineScope.launch {
recipientFinder.updateData(bankingService.getAllAccountTransactions()) // only a bit problematic: if in the meantime new transactions are retrieved, then RecipientFinder doesn't contain the newly retrieved transactions
recipientNameFocus.requestFocus()
if (data.recipientName.isNullOrBlank()) {
recipientNameFocus.requestFocus()
} else if (data.amount == null) {
amountFocus.requestFocus()
} else {
referenceFocus.requestFocus()
}
}
}
}