From ba8b475eaff2920b1c35a2d006b1c909c1afdf98 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 26 Sep 2024 05:15:38 +0200 Subject: [PATCH] Extracted KeyboardOptions.ImeNext and KeyboardOptions.ImeDone --- .../codinux/banking/ui/dialogs/AddAccountDialog.kt | 3 ++- .../codinux/banking/ui/dialogs/TransferMoneyDialog.kt | 3 ++- .../ui/extensions/KeyboardOptionsExtensions.kt | 11 +++++++++++ .../net/codinux/banking/ui/screens/LoginScreen.kt | 1 - .../banking/ui/screens/ProtectAppSettingsDialog.kt | 6 ++++-- 5 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/net/codinux/banking/ui/extensions/KeyboardOptionsExtensions.kt diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/AddAccountDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/AddAccountDialog.kt index df1c245..9b84102 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/AddAccountDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/AddAccountDialog.kt @@ -20,6 +20,7 @@ import net.codinux.banking.ui.IOorDefault import net.codinux.banking.ui.composables.BankIcon import net.codinux.banking.ui.config.Colors import net.codinux.banking.ui.config.DI +import net.codinux.banking.ui.extensions.ImeNext import net.codinux.banking.ui.forms.* import net.codinux.banking.ui.forms.OutlinedTextField import net.codinux.banking.ui.model.BankInfo @@ -161,7 +162,7 @@ fun AddAccountDialog( onValueChange = { loginName = it }, label = { Text("Login Name") }, modifier = Modifier.fillMaxWidth().focusRequester(loginNameFocus), - keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next) + keyboardOptions = KeyboardOptions.ImeNext ) Spacer(modifier = Modifier.height(12.dp)) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt index d05177a..c9b5a0a 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/TransferMoneyDialog.kt @@ -20,6 +20,7 @@ import net.codinux.banking.ui.IOorDefault import net.codinux.banking.ui.composables.BankIcon import net.codinux.banking.ui.config.Colors import net.codinux.banking.ui.config.DI +import net.codinux.banking.ui.extensions.ImeNext import net.codinux.banking.ui.forms.AutocompleteTextField import net.codinux.banking.ui.forms.CaptionText import net.codinux.banking.ui.forms.OutlinedTextField @@ -191,7 +192,7 @@ fun TransferMoneyDialog( onValueChange = { recipientAccountIdentifier = it }, label = { Text("IBAN") }, modifier = Modifier.fillMaxWidth(), - keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next) + keyboardOptions = KeyboardOptions.ImeNext ) Row(Modifier.padding(vertical = verticalSpace).fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/extensions/KeyboardOptionsExtensions.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/extensions/KeyboardOptionsExtensions.kt new file mode 100644 index 0000000..2b1cb5e --- /dev/null +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/extensions/KeyboardOptionsExtensions.kt @@ -0,0 +1,11 @@ +package net.codinux.banking.ui.extensions + +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.ui.text.input.ImeAction + + +val KeyboardOptions.Companion.ImeNext: KeyboardOptions + get() = KeyboardOptions(imeAction = ImeAction.Next) + +val KeyboardOptions.Companion.ImeDone: KeyboardOptions + get() = KeyboardOptions(imeAction = ImeAction.Done) \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/LoginScreen.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/LoginScreen.kt index b248a3c..19ddf57 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/LoginScreen.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/LoginScreen.kt @@ -72,7 +72,6 @@ fun LoginScreen(appSettings: AppSettings, onLoginSuccess: () -> Unit) { PasswordTextField( password = password, - keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), onEnterPressed = { checkPassword() }, isError = showError ) { diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/ProtectAppSettingsDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/ProtectAppSettingsDialog.kt index 45e8e34..cc50c5e 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/ProtectAppSettingsDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/ProtectAppSettingsDialog.kt @@ -15,6 +15,8 @@ import net.codinux.banking.ui.composables.authentification.BiometricAuthenticati import net.codinux.banking.ui.config.Colors import net.codinux.banking.ui.config.DI import net.codinux.banking.ui.config.Internationalization +import net.codinux.banking.ui.extensions.ImeDone +import net.codinux.banking.ui.extensions.ImeNext import net.codinux.banking.ui.extensions.verticalScroll import net.codinux.banking.ui.forms.PasswordTextField import net.codinux.banking.ui.forms.SegmentedControl @@ -92,9 +94,9 @@ fun ProtectAppSettingsDialog(appSettings: AppSettings, onClosed: () -> Unit) { } if (selectedAuthenticationMethod == AppAuthenticationMethod.Password) { - PasswordTextField(newPassword, "Neues Password", keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next)) { newPassword = it } + PasswordTextField(newPassword, "Neues Password", keyboardOptions = KeyboardOptions.ImeNext) { newPassword = it } - PasswordTextField(confirmedNewPassword, "Password bestätigen", Modifier.padding(top = 16.dp), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done)) { confirmedNewPassword = it } + PasswordTextField(confirmedNewPassword, "Password bestätigen", Modifier.padding(top = 16.dp), keyboardOptions = KeyboardOptions.ImeDone) { confirmedNewPassword = it } } if (selectedAuthenticationMethod == AppAuthenticationMethod.Biometric) {