From a5a27c77810de35665ffe57e0351d87474e06bfa Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 6 Sep 2024 17:30:11 +0200 Subject: [PATCH] Displaying if a bank is supported or not --- composeApp/build.gradle.kts | 1 + .../banking/ui/dialogs/AddAccountDialog.kt | 54 ++++++++++++++----- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 57de705..391c03e 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -74,6 +74,7 @@ kotlin { implementation(compose.runtime) implementation(compose.foundation) implementation(compose.material) + implementation(compose.materialIconsExtended) implementation(compose.ui) implementation(compose.components.resources) implementation(compose.components.uiToolingPreview) 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 06cab19..ec830bb 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 @@ -2,8 +2,12 @@ package net.codinux.banking.ui.dialogs import androidx.compose.foundation.layout.* import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Text +import androidx.compose.material.* +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.CheckCircle +import androidx.compose.material.icons.filled.Clear import androidx.compose.runtime.* +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.input.ImeAction @@ -16,12 +20,16 @@ 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.forms.* +import net.codinux.banking.ui.forms.AutocompleteTextField +import net.codinux.banking.ui.forms.OutlinedTextField +import net.codinux.banking.ui.forms.PasswordTextField import net.codinux.banking.ui.model.BankInfo private val bankingService = DI.bankingService +private val iconSize = 36.dp + @Composable fun AddAccountDialog( onDismiss: () -> Unit, @@ -35,6 +43,8 @@ fun AddAccountDialog( derivedStateOf { selectedBank != null && loginName.length > 3 && password.length > 3 } } + val disabledColor: Color = MaterialTheme.colors.onSurface.copy(ContentAlpha.disabled) + var isAddingAccount by remember { mutableStateOf(false) } val coroutineScope = rememberCoroutineScope() @@ -79,21 +89,37 @@ fun AddAccountDialog( getItemTitle = { bank -> bank.name }, fetchSuggestions = { query -> bankingService.findBanks(query) } ) { bank -> - Row { - BankIcon(bank, Modifier.padding(end = 6.dp)) + val supportsFinTs = bank.supportsFinTs3_0 + val textColor = if (supportsFinTs) Color.Unspecified else disabledColor - Text( - bank.name, - Modifier.fillMaxWidth(), - maxLines = 1, - overflow = TextOverflow.Ellipsis - ) - } + Row(Modifier.fillMaxWidth()) { + Column(Modifier.fillMaxHeight().width(iconSize).align(Alignment.CenterVertically)) { + if (supportsFinTs) { + Icon(Icons.Filled.CheckCircle, "Bank unterstützt FinTS 3.0", tint = Colors.Accent, modifier = Modifier.size(iconSize)) + } else { + Icon(Icons.Filled.Clear, "Bank unterstützt FinTS 3.0 nicht", tint = Colors.Red600, modifier = Modifier.size(iconSize)) + } + } - Row(Modifier.fillMaxWidth().padding(top = 8.dp)) { - Text(bank.bankCode) + Column(Modifier.fillMaxWidth().weight(1f).padding(start = 8.dp)) { + Row { + BankIcon(bank, Modifier.padding(end = 6.dp)) - Text("${bank.postalCode} ${bank.city}", Modifier.weight(1f).padding(start = 8.dp), color = Color.Gray) + Text( + bank.name, + Modifier.fillMaxWidth(), + color = textColor, + maxLines = 1, + overflow = TextOverflow.Ellipsis + ) + } + + Row(Modifier.fillMaxWidth().padding(top = 6.dp)) { + Text(bank.bankCode, color = textColor) + + Text("${bank.postalCode} ${bank.city}", Modifier.weight(1f).padding(start = 8.dp), color = if (supportsFinTs) Color.Gray else textColor) + } + } } }