From 1fe7aa0e5f256f17572ff40e62c1af80e770b2ec Mon Sep 17 00:00:00 2001 From: shamim-emon Date: Sat, 12 Oct 2024 19:06:46 +0600 Subject: [PATCH] Hide Total Income When Corresponding Toggle Is Off --- .../main/java/com/ivy/accounts/AccountsTab.kt | 21 ++++++------- .../com/ivy/accounts/IncomeExpensesRow.kt | 13 +++----- .../src/main/java/com/ivy/home/HomeHeader.kt | 5 +--- .../legacy/ui/theme/wallet/AmountCurrency.kt | 30 +++++++++++++------ 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt b/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt index db6aad9f8c..44c58d50d2 100644 --- a/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt +++ b/screen/accounts/src/main/java/com/ivy/accounts/AccountsTab.kt @@ -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)) diff --git a/screen/accounts/src/main/java/com/ivy/accounts/IncomeExpensesRow.kt b/screen/accounts/src/main/java/com/ivy/accounts/IncomeExpensesRow.kt index f4f9014cbe..f84769e65e 100644 --- a/screen/accounts/src/main/java/com/ivy/accounts/IncomeExpensesRow.kt +++ b/screen/accounts/src/main/java/com/ivy/accounts/IncomeExpensesRow.kt @@ -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, ) { @@ -48,8 +47,7 @@ fun IncomeExpensesRow( label = incomeLabel, amount = income, currency = currency, - center = center, - hiddenMode = hiddenMode + center = center ) if (center) { @@ -81,8 +79,7 @@ fun IncomeExpensesRow( label = expensesLabel, amount = expenses, currency = currency, - center = center, - hiddenMode = hiddenMode + center = center ) if (center) { @@ -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 @@ -119,8 +115,7 @@ private fun LabelAmountColumn( AmountCurrencyB1( textColor = textColor, amount = amount, - currency = currency, - hideIncome = hiddenMode + currency = currency ) } } diff --git a/screen/home/src/main/java/com/ivy/home/HomeHeader.kt b/screen/home/src/main/java/com/ivy/home/HomeHeader.kt index 603f239bab..96e3e10941 100644 --- a/screen/home/src/main/java/com/ivy/home/HomeHeader.kt +++ b/screen/home/src/main/java/com/ivy/home/HomeHeader.kt @@ -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() @@ -362,7 +361,6 @@ private fun RowScope.HeaderCard( currency: String, amount: Double, testTag: String, - hideIncome: Boolean = false, onClick: () -> Unit, ) { Column( @@ -415,7 +413,6 @@ private fun RowScope.HeaderCard( amount = amount, currency = currency, textColor = textColor, - hideIncome = hideIncome, shortenBigNumbers = true, ) diff --git a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/wallet/AmountCurrency.kt b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/wallet/AmountCurrency.kt index 8a1eb5ddc7..0030ee45e9 100644 --- a/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/wallet/AmountCurrency.kt +++ b/temp/legacy-code/src/main/java/com/ivy/legacy/legacy/ui/theme/wallet/AmountCurrency.kt @@ -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( @@ -47,6 +48,7 @@ fun AmountCurrencyB2Row( } } +@SuppressLint("ComposeModifierMissing") @Composable fun AmountCurrencyB1Row( amount: Double, @@ -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, @@ -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), @@ -123,6 +129,7 @@ fun AmountCurrencyH1( ) } +@SuppressLint("ComposeModifierMissing") @Composable fun AmountCurrencyH2Row( amount: Double, @@ -150,6 +157,11 @@ fun AmountCurrencyH2Row( } } +@SuppressLint( + "ComposeContentEmitterReturningValues", + "ComposeMultipleContentEmitters", + "ComposeModifierMissing" +) @Composable fun AmountCurrencyCaption( amount: Double,