From a50f55dafffa0f8d78545b4f4934b6c39e5ab1fb Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 18 Sep 2024 02:28:12 +0200 Subject: [PATCH] Extracted SelectableFormListItem --- .../codinux/banking/ui/forms/FormListItem.kt | 18 +++++++++++++++++- .../ui/screens/BankAccountSettingsScreen.kt | 8 ++++---- .../banking/ui/screens/BankSettingsScreen.kt | 4 ++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/FormListItem.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/FormListItem.kt index cd87fdd..4b234b9 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/FormListItem.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/forms/FormListItem.kt @@ -16,7 +16,23 @@ import androidx.compose.ui.unit.sp import net.codinux.banking.ui.config.Colors @Composable -fun FormListItem( +fun FormListItem(label: String, itemHeight: Dp = 32.dp, onClick: (() -> Unit)? = null) { + FormListItemImpl(label, itemHeight = itemHeight, onClick = onClick) +} + +@Composable +fun SelectableFormListItem( + label: String, + isSelected: Boolean = false, + selectedIconContentDescription: String? = null, + itemHeight: Dp = 32.dp, + onClick: (() -> Unit)? = null +) { + FormListItemImpl(label, true, isSelected, selectedIconContentDescription, itemHeight, onClick) +} + +@Composable +private fun FormListItemImpl( label: String, isSelectable: Boolean = false, isSelected: Boolean = false, diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankAccountSettingsScreen.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankAccountSettingsScreen.kt index 263dd8a..29df1b7 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankAccountSettingsScreen.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankAccountSettingsScreen.kt @@ -66,10 +66,10 @@ fun BankAccountSettingsScreen(account: BankAccountEntity, onClosed: () -> Unit) SectionHeader("Unterstützt") Column(Modifier.padding(top = 8.dp)) { - FormListItem("Kontostand abrufen", true, account.supportsBalanceRetrieval, "Unterstützt das Abrufen des Kontostandes") - FormListItem("Kontoumsätze abrufen", true, account.supportsTransactionRetrieval, "Unterstützt das Abrufen der Kontoumsätze") - FormListItem("Überweisen", true, account.supportsMoneyTransfer, "Unterstützt Überweisungen") - FormListItem("Echtzeitüberweisung", true, account.supportsInstantTransfer, "Unterstützt Echtzeitüberweisungen") + SelectableFormListItem("Kontostand abrufen", account.supportsBalanceRetrieval, "Unterstützt das Abrufen des Kontostandes") + SelectableFormListItem("Kontoumsätze abrufen", account.supportsTransactionRetrieval, "Unterstützt das Abrufen der Kontoumsätze") + SelectableFormListItem("Überweisen", account.supportsMoneyTransfer, "Unterstützt Überweisungen") + SelectableFormListItem("Echtzeitüberweisung", account.supportsInstantTransfer, "Unterstützt Echtzeitüberweisungen") } } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankSettingsScreen.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankSettingsScreen.kt index 3627243..fee28b1 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankSettingsScreen.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/screens/BankSettingsScreen.kt @@ -81,7 +81,7 @@ fun BankSettingsScreen(bank: BankAccessEntity, onClosed: () -> Unit) { Column(Modifier.padding(top = 8.dp)) { bank.tanMethods.sortedBy { it.identifier }.forEach { tanMethod -> - FormListItem(tanMethod.displayName, true, tanMethod == bank.selectedTanMethod, "TAN Verfahren ist ausgewähltes TAN Verfahren") + SelectableFormListItem(tanMethod.displayName, tanMethod == bank.selectedTanMethod, "TAN Verfahren ist ausgewähltes TAN Verfahren") } } } @@ -92,7 +92,7 @@ fun BankSettingsScreen(bank: BankAccessEntity, onClosed: () -> Unit) { Column(Modifier.padding(top = 8.dp)) { bank.tanMedia.sortedBy { it.status }.forEach { tanMedium -> - FormListItem(tanMedium.displayName, true, tanMedium == bank.selectedTanMedium, "TAN Medium ist ausgewähltes TAN Medium") + SelectableFormListItem(tanMedium.displayName, tanMedium == bank.selectedTanMedium, "TAN Medium ist ausgewähltes TAN Medium") } } }