From 09a1a41c20c7b36297eb2087cc9fc751b1df2198 Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 17 Sep 2024 02:23:38 +0200 Subject: [PATCH] Showing unsupported account types as disabled --- .../ui/composables/NavigationMenuItem.kt | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/NavigationMenuItem.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/NavigationMenuItem.kt index 1e5b1d0..4ada740 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/NavigationMenuItem.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/NavigationMenuItem.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.ContentAlpha import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState @@ -49,10 +50,24 @@ fun NavigationMenuItem( val showColoredAmounts by DI.uiSettings.showColoredAmounts.collectAsState() + val isUnsupportedAccountType = bankAccount?.isAccountTypeSupportedByApplication == false + + val effectiveText = if (isUnsupportedAccountType) "$text (nicht unterstützt)" else text + + val effectiveTextColor = if (isUnsupportedAccountType) textColor.copy(ContentAlpha.disabled) else textColor + + Row( verticalAlignment = Alignment.CenterVertically, - modifier = modifier - .clickable { onClick?.invoke() } + modifier = modifier.let { + if (isUnsupportedAccountType == false) { + it.clickable { + onClick?.invoke() + } + } else { + it + } + } .let { if (bank != null && filterService.isSelected(bank, transactionsFilter) || bankAccount != null && filterService.isSelected(bankAccount, transactionsFilter)) { @@ -68,12 +83,12 @@ fun NavigationMenuItem( icon() } } else { - BankIcon(bank, Modifier.padding(end = iconTextSpacing), Modifier.size(iconSize), fallbackIcon = fallbackIcon, fallbackIconTintColor = textColor) + BankIcon(bank, Modifier.padding(end = iconTextSpacing), Modifier.size(iconSize), fallbackIcon = fallbackIcon, fallbackIconTintColor = effectiveTextColor) } - Text(text, color = textColor, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(effectiveText, color = effectiveTextColor, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis) - val balance = if (showBalance == false) { + val balance = if (showBalance == false || isUnsupportedAccountType) { null } else if (bankAccount != null) { bankAccount.balance