diff --git a/composeApp/src/commonMain/composeResources/drawable/account.xml b/composeApp/src/commonMain/composeResources/drawable/account.xml deleted file mode 100644 index f6b8d2c..0000000 --- a/composeApp/src/commonMain/composeResources/drawable/account.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenuContent.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenuContent.kt index 8a060b3..c1f9efd 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenuContent.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/appskeleton/SideMenuContent.kt @@ -99,7 +99,7 @@ fun SideMenuContent() { Spacer(Modifier.height(VerticalSpacing)) NavigationMenuItem(itemModifier, "Neue Überweisung", textColor, horizontalPadding = ItemHorizontalPadding, - icon = { Icon(Icons.Filled.Add, "Konto hinzufügen", Modifier.size(iconSize), tint = textColor) }) { + icon = { Icon(Icons.Filled.Add, "Neue Überweisung", Modifier.size(iconSize), tint = textColor) }) { uiState.showTransferMoneyDialogData.value = ShowTransferMoneyDialogData() coroutineScope.launch { 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 48a9a71..2e723a5 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 @@ -1,56 +1,58 @@ package net.codinux.banking.ui.composables -import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.size +import androidx.compose.material.Icon +import androidx.compose.material.LocalContentAlpha +import androidx.compose.material.LocalContentColor import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.dp import net.codinux.banking.client.model.User import net.codinux.banking.client.model.BankViewInfo import net.codinux.banking.ui.config.DI import net.codinux.banking.ui.model.BankInfo import net.dankito.banking.banklistcreator.prettifier.BankingGroupMapper -import org.jetbrains.compose.resources.DrawableResource -import org.jetbrains.compose.resources.vectorResource private val bankIconService = DI.bankIconService private val DefaultIconModifier: Modifier = Modifier.size(16.dp) @Composable -fun BankIcon(user: User?, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, iconResource: DrawableResource? = null) { +fun BankIcon(user: User?, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, fallbackIcon: ImageVector? = null, fallbackIconTintColor: Color? = null) { val iconUrl by remember(user?.bic) { mutableStateOf(user?.let { bankIconService.findIconForBank(it) }) } - BankIcon(iconUrl, modifier, iconModifier, iconResource = iconResource) + BankIcon(iconUrl, modifier, iconModifier, fallbackIcon = fallbackIcon, fallbackIconTintColor = fallbackIconTintColor) } private val bankingGroupMapper = BankingGroupMapper() @Composable -fun BankIcon(bank: BankInfo, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, iconResource: DrawableResource? = null) { +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))) } - BankIcon(iconUrl, modifier, iconModifier, iconResource = iconResource) + BankIcon(iconUrl, modifier, iconModifier, fallbackIcon = fallbackIcon) } @Composable -fun BankIcon(user: BankViewInfo?, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, iconResource: DrawableResource? = null) { +fun BankIcon(user: BankViewInfo?, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, fallbackIcon: ImageVector? = null) { val iconUrl = user?.let { bankIconService.findIconForBank(it.bankName, it.bankingGroup) } - BankIcon(iconUrl, modifier, iconModifier, iconResource = iconResource) + BankIcon(iconUrl, modifier, iconModifier, fallbackIcon = fallbackIcon) } @Composable -fun BankIcon(iconUrl: String?, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, contentDescription: String = "Favicon of this bank", iconResource: DrawableResource? = null) { +fun BankIcon(iconUrl: String?, modifier: Modifier = Modifier, iconModifier: Modifier = DefaultIconModifier, contentDescription: String = "Favicon of this bank", fallbackIcon: ImageVector? = null, fallbackIconTintColor: Color? = null) { Column(modifier) { if (iconUrl != null) { IconForUrl(iconUrl, contentDescription, modifier = iconModifier) - } else if (iconResource != null) { - Image(vectorResource(iconResource), contentDescription, iconModifier) + } else if (fallbackIcon != null) { + Icon(fallbackIcon, contentDescription, iconModifier, tint = fallbackIconTintColor ?: LocalContentColor.current.copy(alpha = LocalContentAlpha.current)) } else { Column(iconModifier) { } // show a placeholder for consistent layout } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/BanksList.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/BanksList.kt index f12c0ae..3cc7b47 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/BanksList.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/BanksList.kt @@ -1,14 +1,15 @@ package net.codinux.banking.ui.composables import androidx.compose.foundation.layout.* +import androidx.compose.material.Icon +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.AccountBalance import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import bankmeister.composeapp.generated.resources.Res -import bankmeister.composeapp.generated.resources.account import net.codinux.banking.dataaccess.entities.BankAccountEntity import net.codinux.banking.dataaccess.entities.UserEntity import net.codinux.banking.ui.config.DI @@ -17,6 +18,8 @@ private val uiState = DI.uiState private val IconTextSpacing = 24.dp +private val defaultBankIcon = Icons.Outlined.AccountBalance + @Composable fun BanksList( modifier: Modifier = Modifier, @@ -30,14 +33,14 @@ fun BanksList( Column(modifier) { - NavigationMenuItem(itemModifier, "Alle Konten", textColor, iconSize, IconTextSpacing, itemHorizontalPadding, iconResource = Res.drawable.account) { + NavigationMenuItem(itemModifier, "Alle Konten", textColor, iconSize, IconTextSpacing, itemHorizontalPadding, icon = { Icon(defaultBankIcon, "Alle Konten", Modifier.size(iconSize), tint = textColor) }) { accountSelected?.invoke(null, null) } users.value.sortedBy { it.displayIndex }.forEach { user -> Spacer(Modifier.fillMaxWidth().height(12.dp)) - NavigationMenuItem(itemModifier, user.displayName, textColor, iconSize, IconTextSpacing, itemHorizontalPadding, user, iconResource = Res.drawable.account) { + NavigationMenuItem(itemModifier, user.displayName, textColor, iconSize, IconTextSpacing, itemHorizontalPadding, user, fallbackIcon = defaultBankIcon) { accountSelected?.invoke(user, null) } 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 87b778c..bd37631 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 @@ -14,6 +14,7 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -21,7 +22,6 @@ import net.codinux.banking.dataaccess.entities.BankAccountEntity import net.codinux.banking.dataaccess.entities.UserEntity import net.codinux.banking.ui.config.Colors import net.codinux.banking.ui.config.DI -import org.jetbrains.compose.resources.DrawableResource private val filterService = DI.accountTransactionsFilterService @@ -39,7 +39,7 @@ fun NavigationMenuItem( horizontalPadding: Dp = 8.dp, user: UserEntity? = null, bankAccount: BankAccountEntity? = null, - iconResource: DrawableResource? = null, + fallbackIcon: ImageVector? = null, icon: (@Composable () -> Unit)? = null, onClick: (() -> Unit)? = null ) { @@ -68,7 +68,7 @@ fun NavigationMenuItem( icon() } } else { - BankIcon(user, Modifier.padding(end = iconTextSpacing), Modifier.size(iconSize), iconResource = iconResource) + BankIcon(user, Modifier.padding(end = iconTextSpacing), Modifier.size(iconSize), fallbackIcon = fallbackIcon, fallbackIconTintColor = textColor) } Text(text, color = textColor, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis)