Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
[FEATURE] Setting to hide balances from the "Accounts" tab (#3478)
Browse files Browse the repository at this point in the history
* Add Setting to hide balances from the "Accounts" tab

* Add Setting to hide balances from the "Accounts" tab
  • Loading branch information
paulolima18 authored Sep 6, 2024
1 parent 8ea2182 commit 7eaaba2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ data class AccountsState(
val totalBalanceWithoutExcluded: String,
val totalBalanceWithoutExcludedText: String,
val reorderVisible: Boolean,
val compactAccountsModeEnabled: Boolean
val compactAccountsModeEnabled: Boolean,
val hideTotalBalance: Boolean,
)
9 changes: 6 additions & 3 deletions screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ private fun BoxWithConstraintsScope.UI(
incomeLabel = stringResource(id = R.string.total_balance),
income = state.totalBalanceWithoutExcluded.toDoubleOrNull() ?: 0.00,
expensesLabel = stringResource(id = R.string.total_balance_excluded),
expenses = state.totalBalanceWithExcluded.toDoubleOrNull() ?: 0.00
expenses = state.totalBalanceWithExcluded.toDoubleOrNull() ?: 0.00,
hiddenMode = state.hideTotalBalance
)
}
Spacer(Modifier.height(16.dp))
Expand Down Expand Up @@ -413,7 +414,8 @@ private fun PreviewAccountsTabCompactModeDisabled(theme: Theme = Theme.LIGHT) {
totalBalanceWithoutExcluded = "25.54",
totalBalanceWithoutExcludedText = "BGN 25.54",
reorderVisible = false,
compactAccountsModeEnabled = false
compactAccountsModeEnabled = false,
hideTotalBalance = false
)
UI(state = state)
}
Expand Down Expand Up @@ -499,7 +501,8 @@ private fun PreviewAccountsTabCompactModeEnabled(theme: Theme = Theme.LIGHT) {
totalBalanceWithoutExcluded = "25.54",
totalBalanceWithoutExcludedText = "BGN 25.54",
reorderVisible = false,
compactAccountsModeEnabled = true
compactAccountsModeEnabled = true,
hideTotalBalance = false
)
UI(state = state)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ class AccountsViewModel @Inject constructor(
totalBalanceWithoutExcluded = getTotalBalanceWithoutExcluded(),
totalBalanceWithoutExcludedText = getTotalBalanceWithoutExcludedText(),
reorderVisible = getReorderVisible(),
compactAccountsModeEnabled = getCompactAccountsMode()
compactAccountsModeEnabled = getCompactAccountsMode(),
hideTotalBalance = getHideTotalBalance()
)
}

@Composable
private fun getHideTotalBalance(): Boolean {
return features.hideTotalBalance.asEnabledState()
}

@Composable
private fun getBaseCurrency(): String {
return baseCurrency.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fun IncomeExpensesRow(
dividerColor: Color = UI.colors.medium,
incomeLabel: String = stringResource(R.string.income_uppercase),
expensesLabel: String = stringResource(R.string.expenses_uppercase),
hiddenMode: Boolean = false,
center: Boolean = true,
dividerSpacer: Dp? = null,
) {
Expand All @@ -47,7 +48,8 @@ fun IncomeExpensesRow(
label = incomeLabel,
amount = income,
currency = currency,
center = center
center = center,
hiddenMode = hiddenMode
)

if (center) {
Expand Down Expand Up @@ -79,7 +81,8 @@ fun IncomeExpensesRow(
label = expensesLabel,
amount = expenses,
currency = currency,
center = center
center = center,
hiddenMode = hiddenMode
)

if (center) {
Expand All @@ -94,7 +97,8 @@ private fun LabelAmountColumn(
amount: Double,
currency: String,
textColor: Color,
center: Boolean
center: Boolean,
hiddenMode: Boolean
) {
Column(
horizontalAlignment = if (center) Alignment.CenterHorizontally else Alignment.Start
Expand All @@ -115,7 +119,8 @@ private fun LabelAmountColumn(
AmountCurrencyB1(
textColor = textColor,
amount = amount,
currency = currency
currency = currency,
hideIncome = hiddenMode
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface Features {
val compactAccountsMode: BoolFeature
val compactCategoriesMode: BoolFeature
val showTitleSuggestions: BoolFeature
val hideTotalBalance: BoolFeature

val allFeatures: List<BoolFeature>
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,19 @@ class IvyFeatures @Inject constructor() : Features {
defaultValue = true
)

override val hideTotalBalance = BoolFeature(
key = "hide_total_balance",
name = "Hide total balance",
description = "Enable hide the total balance from the accounts tab",
defaultValue = false
)

override val allFeatures: List<BoolFeature>
get() = listOf(
sortCategoriesAlphabetically,
compactAccountsMode,
compactCategoriesMode,
showTitleSuggestions
showTitleSuggestions,
hideTotalBalance
)
}

0 comments on commit 7eaaba2

Please sign in to comment.