Added option to hide balance
This commit is contained in:
parent
b7e693fa22
commit
a1c4f094f4
|
@ -45,6 +45,8 @@ fun NavigationMenuItem(
|
||||||
) {
|
) {
|
||||||
val transactionsFilter by DI.uiState.transactionsFilter.collectAsState()
|
val transactionsFilter by DI.uiState.transactionsFilter.collectAsState()
|
||||||
|
|
||||||
|
val showBalance by DI.uiSettings.showBalance.collectAsState()
|
||||||
|
|
||||||
val showColoredAmounts by DI.uiSettings.showColoredAmounts.collectAsState()
|
val showColoredAmounts by DI.uiSettings.showColoredAmounts.collectAsState()
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
|
@ -71,7 +73,9 @@ fun NavigationMenuItem(
|
||||||
|
|
||||||
Text(text, color = textColor, modifier = Modifier.weight(1f), maxLines = 1, overflow = TextOverflow.Ellipsis)
|
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
|
bankAccount.balance
|
||||||
} else if (userAccount != null) {
|
} else if (userAccount != null) {
|
||||||
calculator.calculateBalanceOfUserAccount(userAccount)
|
calculator.calculateBalanceOfUserAccount(userAccount)
|
||||||
|
|
|
@ -13,6 +13,8 @@ import net.codinux.banking.ui.forms.BooleanOption
|
||||||
fun UiSettings(modifier: Modifier, textColor: Color = Color.Unspecified) {
|
fun UiSettings(modifier: Modifier, textColor: Color = Color.Unspecified) {
|
||||||
val uiSettings = DI.uiSettings
|
val uiSettings = DI.uiSettings
|
||||||
|
|
||||||
|
val showBalance by uiSettings.showBalance.collectAsState()
|
||||||
|
|
||||||
val groupTransactions by uiSettings.groupTransactions.collectAsState()
|
val groupTransactions by uiSettings.groupTransactions.collectAsState()
|
||||||
|
|
||||||
val zebraStripes by uiSettings.zebraStripes.collectAsState()
|
val zebraStripes by uiSettings.zebraStripes.collectAsState()
|
||||||
|
@ -23,6 +25,8 @@ fun UiSettings(modifier: Modifier, textColor: Color = Color.Unspecified) {
|
||||||
|
|
||||||
|
|
||||||
Column(modifier) {
|
Column(modifier) {
|
||||||
|
BooleanOption("Kontostand anzeigen", showBalance, textColor = textColor) { uiSettings.showBalance.value = it }
|
||||||
|
|
||||||
BooleanOption("Umsätze gruppieren", groupTransactions, textColor = textColor) { uiSettings.groupTransactions.value = it }
|
BooleanOption("Umsätze gruppieren", groupTransactions, textColor = textColor) { uiSettings.groupTransactions.value = it }
|
||||||
|
|
||||||
BooleanOption("Zebra Stripes", zebraStripes, textColor = textColor) { uiSettings.zebraStripes.value = it }
|
BooleanOption("Zebra Stripes", zebraStripes, textColor = textColor) { uiSettings.zebraStripes.value = it }
|
||||||
|
|
|
@ -37,6 +37,8 @@ fun TransactionsList(uiState: UiState, uiSettings: UiSettings) {
|
||||||
derivedStateOf { filterService.filterAccounts(transactions, transactionsFilter) }
|
derivedStateOf { filterService.filterAccounts(transactions, transactionsFilter) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val showBalance by uiSettings.showBalance.collectAsState()
|
||||||
|
|
||||||
val groupTransactions by uiSettings.groupTransactions.collectAsState()
|
val groupTransactions by uiSettings.groupTransactions.collectAsState()
|
||||||
|
|
||||||
val showColoredAmounts by DI.uiSettings.showColoredAmounts.collectAsState()
|
val showColoredAmounts by DI.uiSettings.showColoredAmounts.collectAsState()
|
||||||
|
@ -49,9 +51,11 @@ fun TransactionsList(uiState: UiState, uiSettings: UiSettings) {
|
||||||
Text("${transactionsToDisplay.size} Umsätze")
|
Text("${transactionsToDisplay.size} Umsätze")
|
||||||
Spacer(Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
|
|
||||||
|
if (showBalance) {
|
||||||
val balance = calculator.calculateBalanceOfDisplayedTransactions(transactionsToDisplay, userAccounts, transactionsFilter)
|
val balance = calculator.calculateBalanceOfDisplayedTransactions(transactionsToDisplay, userAccounts, transactionsFilter)
|
||||||
Text(formatUtil.formatAmount(balance, "EUR"), color = formatUtil.getColorForAmount(balance, showColoredAmounts))
|
Text(formatUtil.formatAmount(balance, "EUR"), color = formatUtil.getColorForAmount(balance, showColoredAmounts))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (groupTransactions) {
|
if (groupTransactions) {
|
||||||
GroupedTransactionsListItems(transactionsListModifier, transactionsToDisplay, userAccountsId)
|
GroupedTransactionsListItems(transactionsListModifier, transactionsToDisplay, userAccountsId)
|
||||||
|
|
|
@ -5,6 +5,8 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
|
||||||
class UiSettings : ViewModel() {
|
class UiSettings : ViewModel() {
|
||||||
|
|
||||||
|
val showBalance = MutableStateFlow(true)
|
||||||
|
|
||||||
val groupTransactions = MutableStateFlow(true)
|
val groupTransactions = MutableStateFlow(true)
|
||||||
|
|
||||||
val zebraStripes = MutableStateFlow(true)
|
val zebraStripes = MutableStateFlow(true)
|
||||||
|
|
Loading…
Reference in New Issue