Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Setting to hide balances from the "Accounts" tab #3478

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)
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
)
}