Using new Select Composable also in EnterTanDialog

This commit is contained in:
dankito 2024-09-04 17:27:31 +02:00
parent dde54b75d3
commit 87ed7018d0
1 changed files with 16 additions and 54 deletions

View File

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