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

Fix issue 3364 #3431

Merged
merged 10 commits into from
Aug 27, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import com.ivy.data.model.primitive.IconAsset
import com.ivy.data.model.primitive.NotBlankTrimmedString
import com.ivy.design.l0_system.UI
import com.ivy.design.l0_system.style
import com.ivy.legacy.utils.balancePrefix
import com.ivy.legacy.utils.compactBalancePrefix
import com.ivy.legacy.utils.format
import com.ivy.navigation.CategoriesScreen
import com.ivy.navigation.TransactionsScreen
Expand Down Expand Up @@ -308,6 +310,10 @@ private fun CompactCategoryCard(
onClick: () -> Unit
) {
val category = categoryData.category
val balancePrefixValue = compactBalancePrefix(
income = categoryData.monthlyIncome,
expenses = categoryData.monthlyExpenses
)

Box(
modifier = Modifier
Expand Down Expand Up @@ -355,8 +361,10 @@ private fun CompactCategoryCard(
Row(
verticalAlignment = Alignment.CenterVertically
) {
val currencyFormatted = categoryData.monthlyBalance.format(currency)

Text(
text = categoryData.monthlyBalance.format(currency),
text = "$balancePrefixValue $currencyFormatted",
style = UI.typo.nB1.style(
color = UI.colors.pureInverse,
fontWeight = FontWeight.Bold
Expand Down Expand Up @@ -482,6 +490,10 @@ private fun CategoryHeader(
contrastColor: Color,
) {
val category = categoryData.category
val balancePrefixValue = balancePrefix(
income = categoryData.monthlyIncome,
expenses = categoryData.monthlyExpenses
)

Column(
modifier = Modifier
Expand Down Expand Up @@ -525,10 +537,7 @@ private fun CategoryHeader(
currencyFontSize = 30.sp,

currencyUpfront = false,
balanceAmountPrefix = com.ivy.legacy.utils.balancePrefix(
income = categoryData.monthlyIncome,
expenses = categoryData.monthlyExpenses
)
balanceAmountPrefix = balancePrefixValue
)

Spacer(Modifier.height(16.dp))
Expand Down
ILIYANGERMANOV marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IvyFeatures @Inject constructor() : Features {
override val compactCategoriesMode = BoolFeature(
key = "compact_categories_ui",
name = "Compact category UI",
description = "Activates a more streamlined and space-efficient interface for the \"Categories\" tab"
description = "Activates a more streamlined and space-efficient interface for the \"Categories\" Screen"
)

override val allFeatures: List<BoolFeature>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,27 @@ fun balancePrefix(
expenses != 0.0 && income != 0.0 -> {
null
}

expenses < 0.0 && income == 0.0 -> {
"-"
}

income > 0.0 && expenses == 0.0 -> {
"+"
}

else -> null
}
}

fun compactBalancePrefix(
income: Double = 0.0,
expenses: Double = 0.0
): String {
val balance = income - expenses
return when {
balance > 0 -> "+"
balance < 0 -> "-"
else -> ""
}
}