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 ff5f28b..c38693f 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 @@ -45,6 +45,8 @@ fun NavigationMenuItem( ) { val transactionsFilter by DI.uiState.transactionsFilter.collectAsState() + val showBalance by DI.uiSettings.showBalance.collectAsState() + val showColoredAmounts by DI.uiSettings.showColoredAmounts.collectAsState() Row( @@ -71,7 +73,9 @@ fun NavigationMenuItem( Text(text, color = textColor, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis) - val balance = if (bankAccount != null) { + val balance = if (showBalance == false) { + null + } else if (bankAccount != null) { bankAccount.balance } else if (userAccount != null) { calculator.calculateBalanceOfUserAccount(userAccount) diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/settings/UiSettings.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/settings/UiSettings.kt index 1c7188f..420a657 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/settings/UiSettings.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/settings/UiSettings.kt @@ -13,6 +13,8 @@ import net.codinux.banking.ui.forms.BooleanOption fun UiSettings(modifier: Modifier, textColor: Color = Color.Unspecified) { val uiSettings = DI.uiSettings + val showBalance by uiSettings.showBalance.collectAsState() + val groupTransactions by uiSettings.groupTransactions.collectAsState() val zebraStripes by uiSettings.zebraStripes.collectAsState() @@ -23,6 +25,8 @@ fun UiSettings(modifier: Modifier, textColor: Color = Color.Unspecified) { Column(modifier) { + BooleanOption("Kontostand anzeigen", showBalance, textColor = textColor) { uiSettings.showBalance.value = it } + BooleanOption("Umsätze gruppieren", groupTransactions, textColor = textColor) { uiSettings.groupTransactions.value = it } BooleanOption("Zebra Stripes", zebraStripes, textColor = textColor) { uiSettings.zebraStripes.value = it } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/TransactionsList.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/TransactionsList.kt index eedbb73..b7db049 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/TransactionsList.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/TransactionsList.kt @@ -37,6 +37,8 @@ fun TransactionsList(uiState: UiState, uiSettings: UiSettings) { derivedStateOf { filterService.filterAccounts(transactions, transactionsFilter) } } + val showBalance by uiSettings.showBalance.collectAsState() + val groupTransactions by uiSettings.groupTransactions.collectAsState() val showColoredAmounts by DI.uiSettings.showColoredAmounts.collectAsState() @@ -49,8 +51,10 @@ fun TransactionsList(uiState: UiState, uiSettings: UiSettings) { Text("${transactionsToDisplay.size} Umsätze") Spacer(Modifier.weight(1f)) - val balance = calculator.calculateBalanceOfDisplayedTransactions(transactionsToDisplay, userAccounts, transactionsFilter) - Text(formatUtil.formatAmount(balance, "EUR"), color = formatUtil.getColorForAmount(balance, showColoredAmounts)) + if (showBalance) { + val balance = calculator.calculateBalanceOfDisplayedTransactions(transactionsToDisplay, userAccounts, transactionsFilter) + Text(formatUtil.formatAmount(balance, "EUR"), color = formatUtil.getColorForAmount(balance, showColoredAmounts)) + } } if (groupTransactions) { diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/settings/UiSettings.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/settings/UiSettings.kt index b70efe6..b78dfaa 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/settings/UiSettings.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/settings/UiSettings.kt @@ -5,6 +5,8 @@ import kotlinx.coroutines.flow.MutableStateFlow class UiSettings : ViewModel() { + val showBalance = MutableStateFlow(true) + val groupTransactions = MutableStateFlow(true) val zebraStripes = MutableStateFlow(true)