Updated EnterTanDialog for Decoupled TAN methods

This commit is contained in:
dankito 2024-09-03 02:35:10 +02:00
parent 55dec76f36
commit 3eb3c488da
1 changed files with 32 additions and 15 deletions

View File

@ -36,6 +36,8 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
val challenge = tanChallengeReceived.tanChallenge val challenge = tanChallengeReceived.tanChallenge
val isNotADecoupledTanMethod = !!!challenge.selectedTanMethod.type.isDecoupledMethod
var showTanMethodsDropDownMenu by remember { mutableStateOf(false) } var showTanMethodsDropDownMenu by remember { mutableStateOf(false) }
var showTanMediaDropDownMenu by remember { mutableStateOf(false) } var showTanMediaDropDownMenu by remember { mutableStateOf(false) }
@ -48,6 +50,12 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
var enteredTan by remember { mutableStateOf("") } var enteredTan by remember { mutableStateOf("") }
if (!!!isNotADecoupledTanMethod) {
challenge.addUserApprovedDecoupledTanCallback {
onDismiss()
}
}
fun confirmCalled() { fun confirmCalled() {
if (enteredTan.length > 2) { if (enteredTan.length > 2) {
tanChallengeReceived.callback(EnterTanResult(enteredTan)) tanChallengeReceived.callback(EnterTanResult(enteredTan))
@ -59,7 +67,9 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
BaseDialog( BaseDialog(
title = "TAN Eingabe", title = "TAN Eingabe",
useMoreThanPlatformDefaultWidthOnMobile = true, useMoreThanPlatformDefaultWidthOnMobile = true,
confirmButtonEnabled = enteredTan.length > 2, confirmButtonTitle = if (isNotADecoupledTanMethod) "OK" else "",
confirmButtonEnabled = enteredTan.length > 2 && isNotADecoupledTanMethod,
showProgressIndicatorOnConfirmButton = !!!isNotADecoupledTanMethod,
onConfirm = { confirmCalled() }, onConfirm = { confirmCalled() },
onDismiss = { onDismiss = {
tanChallengeReceived.callback(EnterTanResult(null)) tanChallengeReceived.callback(EnterTanResult(null))
@ -71,7 +81,7 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
Row { Row {
BankIcon(challenge.user, Modifier.padding(end = 6.dp)) BankIcon(challenge.user, Modifier.padding(end = 6.dp))
Text("${challenge.user.displayName}, Nutzer ${challenge.user.loginName}${challenge.account?.let { ", Konto ${it.productName ?: it.identifier}" } ?: ""}") Text("${challenge.user.bankName}, Nutzer ${challenge.user.loginName}${challenge.account?.let { ", Konto ${it.productName ?: it.identifier}" } ?: ""}")
} }
Text( Text(
"TAN benötigt ${Internationalization.getTextForActionRequiringTan(challenge.forAction)}", "TAN benötigt ${Internationalization.getTextForActionRequiringTan(challenge.forAction)}",
@ -173,7 +183,9 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
Text(challenge.messageToShowToUser) Text(challenge.messageToShowToUser)
} }
Column(Modifier.fillMaxWidth().padding(top = 16.dp)) { Column(Modifier.fillMaxWidth().padding(top = 16.dp)) {
if (isNotADecoupledTanMethod) {
OutlinedTextField( OutlinedTextField(
value = enteredTan, value = enteredTan,
onValueChange = { enteredTan = it }, onValueChange = { enteredTan = it },
@ -185,14 +197,19 @@ fun EnterTanDialog(tanChallengeReceived: TanChallengeReceived, onDismiss: () ->
), ),
onEnterPressed = { confirmCalled() } onEnterPressed = { confirmCalled() }
) )
} else {
Text("Sobald sie die TAN in Ihrer App freigegeben haben, wird der Dialog automatisch geschlossen.")
}
} }
} }
} }
if (isNotADecoupledTanMethod) {
LaunchedEffect(textFieldFocus) { LaunchedEffect(textFieldFocus) {
textFieldFocus.requestFocus() textFieldFocus.requestFocus()
} }
}
} }
fun getTanMediumDisplayName(tanMedium: net.codinux.banking.client.model.tan.TanMedium): String { fun getTanMediumDisplayName(tanMedium: net.codinux.banking.client.model.tan.TanMedium): String {