Focussing amount TextField after selecting a recipient from dropdown

This commit is contained in:
dankito 2024-09-04 21:37:50 +02:00
parent 4761876cf2
commit 88ef0a703e
1 changed files with 11 additions and 4 deletions

View File

@ -7,14 +7,14 @@ import androidx.compose.material.*
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.*
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import net.codinux.banking.client.model.Amount import net.codinux.banking.client.model.Amount
import net.codinux.banking.client.model.BankAccountFeatures import net.codinux.banking.client.model.BankAccountFeatures
import net.codinux.banking.ui.IOorDefault import net.codinux.banking.ui.IOorDefault
@ -71,6 +71,8 @@ fun TransferMoneyDialog(
var isTransferringMoney by remember { mutableStateOf(false) } var isTransferringMoney by remember { mutableStateOf(false) }
val amountFocus = remember { FocusRequester() }
val verticalSpace = 8.dp val verticalSpace = 8.dp
val coroutineScope = rememberCoroutineScope() val coroutineScope = rememberCoroutineScope()
@ -139,6 +141,11 @@ fun TransferMoneyDialog(
recipientName = it.name recipientName = it.name
recipientAccountIdentifier = it.accountIdentifier recipientAccountIdentifier = it.accountIdentifier
// TODO: set recipient bank identifier // TODO: set recipient bank identifier
coroutineScope.launch {
delay(250)
amountFocus.requestFocus()
}
} else { } else {
recipientName = "" recipientName = ""
recipientAccountIdentifier = "" recipientAccountIdentifier = ""
@ -177,7 +184,7 @@ fun TransferMoneyDialog(
value = amount, value = amount,
onValueChange = { amount = it }, onValueChange = { amount = it },
label = { Text("Betrag") }, label = { Text("Betrag") },
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth().focusRequester(amountFocus),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal, imeAction = ImeAction.Next) keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal, imeAction = ImeAction.Next)
) )