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

Commit

Permalink
Hide Total Income When Corresponding Toggle Is Off (#3607)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamim-emon authored Oct 12, 2024
1 parent ec621e7 commit 130e2b8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 32 deletions.
21 changes: 11 additions & 10 deletions screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,19 @@ private fun BoxWithConstraintsScope.UI(

Spacer(Modifier.width(24.dp))
}
Column {
if (!state.hideTotalBalance) {
Column {
Spacer(Modifier.height(16.dp))
IncomeExpensesRow(
currency = state.baseCurrency,
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
)
}
Spacer(Modifier.height(16.dp))
IncomeExpensesRow(
currency = state.baseCurrency,
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,
hiddenMode = state.hideTotalBalance
)
}
Spacer(Modifier.height(16.dp))
}
items(state.accountsData) {
Spacer(Modifier.height(16.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ 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 @@ -48,8 +47,7 @@ fun IncomeExpensesRow(
label = incomeLabel,
amount = income,
currency = currency,
center = center,
hiddenMode = hiddenMode
center = center
)

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

if (center) {
Expand All @@ -97,8 +94,7 @@ private fun LabelAmountColumn(
amount: Double,
currency: String,
textColor: Color,
center: Boolean,
hiddenMode: Boolean
center: Boolean
) {
Column(
horizontalAlignment = if (center) Alignment.CenterHorizontally else Alignment.Start
Expand All @@ -119,8 +115,7 @@ private fun LabelAmountColumn(
AmountCurrencyB1(
textColor = textColor,
amount = amount,
currency = currency,
hideIncome = hiddenMode
currency = currency
)
}
}
Expand Down
5 changes: 1 addition & 4 deletions screen/home/src/main/java/com/ivy/home/HomeHeader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ private fun IncomeExpenses(
label = stringResource(R.string.income),
currency = currency,
amount = monthlyIncome,
testTag = "home_card_income",
hideIncome = hideIncome
testTag = "home_card_income"
) {
if (hideIncome) {
onHiddenIncomeClick()
Expand Down Expand Up @@ -362,7 +361,6 @@ private fun RowScope.HeaderCard(
currency: String,
amount: Double,
testTag: String,
hideIncome: Boolean = false,
onClick: () -> Unit,
) {
Column(
Expand Down Expand Up @@ -415,7 +413,6 @@ private fun RowScope.HeaderCard(
amount = amount,
currency = currency,
textColor = textColor,
hideIncome = hideIncome,
shortenBigNumbers = true,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.ivy.legacy.utils.format
import com.ivy.legacy.utils.shortenAmount
import com.ivy.legacy.utils.shouldShortAmount

@SuppressLint("ComposeModifierMissing")
@Deprecated("Old design system. Use `:ivy-design` and Material3")
@Composable
fun AmountCurrencyB2Row(
Expand Down Expand Up @@ -47,6 +48,7 @@ fun AmountCurrencyB2Row(
}
}

@SuppressLint("ComposeModifierMissing")
@Composable
fun AmountCurrencyB1Row(
amount: Double,
Expand All @@ -66,22 +68,21 @@ fun AmountCurrencyB1Row(
}
}

@SuppressLint("ComposeContentEmitterReturningValues")
@SuppressLint(
"ComposeContentEmitterReturningValues",
"ComposeMultipleContentEmitters",
"ComposeModifierMissing"
)
@Composable
fun AmountCurrencyB1(
amount: Double,
currency: String,
amountFontWeight: FontWeight = FontWeight.Bold,
textColor: Color = UI.colors.pureInverse,
shortenBigNumbers: Boolean = false,
hideIncome: Boolean = false
shortenBigNumbers: Boolean = false
) {
val shortAmount = shortenBigNumbers && shouldShortAmount(amount)
val text = if (hideIncome) {
"****"
} else {
if (shortAmount) shortenAmount(amount) else amount.format(currency)
}
val text = if (shortAmount) shortenAmount(amount) else amount.format(currency)
Text(
modifier = Modifier.testTag("amount_currency_b1"),
text = text,
Expand All @@ -100,11 +101,16 @@ fun AmountCurrencyB1(
)
}

@SuppressLint(
"ComposeContentEmitterReturningValues",
"ComposeMultipleContentEmitters",
"ComposeModifierMissing"
)
@Composable
fun AmountCurrencyH1(
amount: Double,
currency: String,
textColor: Color = UI.colors.pureInverse
@SuppressLint("ComposeContentEmitterReturningValues") textColor: Color = UI.colors.pureInverse
) {
Text(
text = amount.format(currency),
Expand All @@ -123,6 +129,7 @@ fun AmountCurrencyH1(
)
}

@SuppressLint("ComposeModifierMissing")
@Composable
fun AmountCurrencyH2Row(
amount: Double,
Expand Down Expand Up @@ -150,6 +157,11 @@ fun AmountCurrencyH2Row(
}
}

@SuppressLint(
"ComposeContentEmitterReturningValues",
"ComposeMultipleContentEmitters",
"ComposeModifierMissing"
)
@Composable
fun AmountCurrencyCaption(
amount: Double,
Expand Down

0 comments on commit 130e2b8

Please sign in to comment.