From fd87598b968f0ff874d9dfcb38e80c0f823392b6 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 12 Sep 2024 11:29:40 +0200 Subject: [PATCH] Added icon for Baader Bank --- .../net/codinux/banking/ui/composables/BankIcon.kt | 4 ++-- .../net/codinux/banking/ui/service/BankIconService.kt | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/BankIcon.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/BankIcon.kt index 1808961..f7892f8 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/BankIcon.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/BankIcon.kt @@ -31,14 +31,14 @@ private val bankingGroupMapper = BankingGroupMapper() @Composable fun BankIcon(bank: BankInfo, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, fallbackIcon: ImageVector? = null) { - val iconUrl by remember(bank.bic) { mutableStateOf(bankIconService.findIconForBank(bank.name, bankingGroupMapper.getBankingGroup(bank.name, bank.bic))) } + val iconUrl by remember(bank.bic) { mutableStateOf(bankIconService.findIconForBank(bank.name, bank.bic, bankingGroupMapper.getBankingGroup(bank.name, bank.bic))) } BankIcon(iconUrl, modifier, iconModifier, fallbackIcon = fallbackIcon) } @Composable fun BankIcon(user: BankViewInfo?, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, fallbackIcon: ImageVector? = null) { - val iconUrl = user?.let { bankIconService.findIconForBank(it.bankName, it.bankingGroup) } + val iconUrl = user?.let { bankIconService.findIconForBank(it.bankName, null, it.bankingGroup) } BankIcon(iconUrl, modifier, iconModifier, fallbackIcon = fallbackIcon) } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankIconService.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankIconService.kt index 5a9ec69..5e1af6f 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankIconService.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/service/BankIconService.kt @@ -5,9 +5,9 @@ import net.codinux.banking.client.model.User class BankIconService { // TODO: extract to a common library - fun findIconForBank(user: User) = findIconForBank(user.bankName, user.bankingGroup) + fun findIconForBank(user: User) = findIconForBank(user.bankName, user.bic, user.bankingGroup) - fun findIconForBank(bankName: String, bankingGroup: BankingGroup? = null): String? = when (bankingGroup) { + fun findIconForBank(bankName: String, bic: String? = null, bankingGroup: BankingGroup? = null): String? = when (bankingGroup) { BankingGroup.Sparkasse -> "https://sparkasse.de/favicon-32x32.png" BankingGroup.DKB -> "https://www.ib.dkb.de/favicon.ico" BankingGroup.OldenburgischeLandesbank -> "https://olb.de/assets/img/icon/olb/favicon-32x32.png" @@ -33,6 +33,11 @@ class BankIconService { // TODO: extract to a common library BankingGroup.N26 -> "https://n26.de/favicon.ico" + else -> findByBicOrName(bankName, bic) + } + + private fun findByBicOrName(bankName: String, bic: String?): String? = when { + bic?.startsWith("BDWBDEMM") == true || bankName.equals("Baader Bank", true) -> "https://www.baaderbank.de/favicon.ico" else -> null // TODO: call Favicon web service }