diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt index 829f9c9..fd41f11 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/dialogs/EnterTanDialog.kt @@ -4,8 +4,6 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.layout.* import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowDropDown import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -23,6 +21,7 @@ import net.codinux.banking.client.model.tan.EnterTanResult import net.codinux.banking.ui.composables.BankIcon import net.codinux.banking.ui.config.Internationalization import net.codinux.banking.ui.forms.OutlinedTextField +import net.codinux.banking.ui.forms.Select import net.codinux.banking.ui.model.TanChallengeReceived import net.codinux.banking.ui.service.createImageBitmap import net.codinux.log.Log @@ -30,7 +29,7 @@ import org.jetbrains.compose.resources.imageResource import kotlin.io.encoding.Base64 import kotlin.io.encoding.ExperimentalEncodingApi -@OptIn(ExperimentalEncodingApi::class, ExperimentalMaterialApi::class) +@OptIn(ExperimentalEncodingApi::class) @Composable fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () -> Unit) { @@ -38,9 +37,6 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () -> val isNotADecoupledTanMethod = !!!challenge.selectedTanMethod.type.isDecoupledMethod - var showTanMethodsDropDownMenu by remember { mutableStateOf(false) } - var showTanMediaDropDownMenu by remember { mutableStateOf(false) } - var tanImageHeight by remember { mutableStateOf(250) } val minTanImageHeight = 100 val maxTanImageHeight = 500 @@ -91,58 +87,24 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () -> Row(Modifier.padding(top = 16.dp)) { - ExposedDropdownMenuBox(showTanMethodsDropDownMenu, { isExpanded -> showTanMethodsDropDownMenu = isExpanded }, Modifier.fillMaxWidth()) { - OutlinedTextField( - value = challenge.selectedTanMethod.displayName, - onValueChange = { Log.info { "TanMethod value changed: $it" }}, - modifier = Modifier.fillMaxWidth(), - label = { Text("TAN Verfahren") }, - readOnly = true, - trailingIcon = { Icon(Icons.Filled.ArrowDropDown, "Alle TAN Medien anzeigen") } - ) - - ExposedDropdownMenu(showTanMethodsDropDownMenu, { showTanMethodsDropDownMenu = false }) { - challenge.availableTanMethods.sortedBy { it.identifier }.forEach { tanMethod -> - DropdownMenuItem( - onClick = { - showTanMethodsDropDownMenu = false - Log.info { "User selected TanMethod $tanMethod" } - // TODO: change TanMethod - } - ) { - Text(tanMethod.displayName) - } - } - } - } + Select( + "TAN Verfahren", "Alle TAN Medien anzeigen", + challenge.availableTanMethods.sortedBy { it.identifier }, + challenge.selectedTanMethod, + { Log.info { "User selected TanMethod $it" } }, // TODO: change TanMethod + { it.displayName } + ) } if (challenge.availableTanMedia.isNotEmpty()) { Row(Modifier.padding(top = 16.dp)) { - ExposedDropdownMenuBox(showTanMediaDropDownMenu, { isExpanded -> showTanMediaDropDownMenu = isExpanded }, Modifier.fillMaxWidth()) { - OutlinedTextField( - value = challenge.selectedTanMedium?.let { it.displayName } ?: "", - onValueChange = { Log.info { "TanMedia value changed: $it" }}, - modifier = Modifier.fillMaxWidth(), - label = { Text("TAN Medium") }, - readOnly = true, - trailingIcon = { Icon(Icons.Filled.ArrowDropDown, "Alle TAN Medien anzeigen") } - ) - - ExposedDropdownMenu(showTanMediaDropDownMenu, { showTanMediaDropDownMenu = false }) { - challenge.availableTanMedia.sortedBy { it.status }.forEach { tanMedium -> - DropdownMenuItem( - onClick = { - showTanMediaDropDownMenu = false - Log.info { "User selected TanMedium $tanMedium" } - // TODO: change TanMethod - } - ) { - Text(tanMedium.displayName) - } - } - } - } + Select( + "TAN Medium", "Alle TAN Medien anzeigen", + challenge.availableTanMedia.sortedBy { it.status }.map { it.displayName }, + challenge.selectedTanMedium?.displayName ?: "", + { Log.info { "User selected TanMedium $it" } }, // TODO: change TanMethod + { it } + ) } }