Skip to content

Commit

Permalink
[FEATURE] Fix issue Ivy-Apps#2984: Added UI to reflect category of Ac…
Browse files Browse the repository at this point in the history
…count Transfers (Ivy-Apps#2985)

* Fix issue Ivy-Apps#2984: Categories are now reflected for each Account Transfer in the TransactionCard

* Fix issue Ivy-Apps#2984: Made sure extra vertical Spacer() is not being rendered if user chooses no category for Account Transfer

* Fix issue Ivy-Apps#2984: Added modifier to lacking TransactionHeaderRow

* Fix issue Ivy-Apps#2984: Fixed CI complaints
  • Loading branch information
diasmashikov authored Feb 24, 2024
1 parent 0cc4bed commit 0c7d840
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ivy.wallet.ui.theme.wallet

import android.annotation.SuppressLint
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.width
Expand Down Expand Up @@ -65,6 +66,7 @@ fun AmountCurrencyB1Row(
}
}

@SuppressLint("ComposeContentEmitterReturningValues")
@Composable
fun AmountCurrencyB1(
amount: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.ivy.legacy.utils.format
import com.ivy.legacy.utils.formatNicely
import com.ivy.legacy.utils.isNotNullOrBlank
import com.ivy.legacy.utils.timeNowUTC
import com.ivy.navigation.Navigation
import com.ivy.navigation.TransactionsScreen
import com.ivy.navigation.navigation
import com.ivy.resources.R
Expand Down Expand Up @@ -109,7 +110,7 @@ fun TransactionCard(
TransactionHeaderRow(
transaction = transaction,
categories = baseData.categories,
accounts = baseData.accounts
accounts = baseData.accounts,
)

if (transaction.dueDate != null) {
Expand Down Expand Up @@ -240,40 +241,35 @@ fun TransactionCard(
private fun TransactionHeaderRow(
transaction: Transaction,
categories: List<Category>,
accounts: List<Account>
accounts: List<Account>,
) {
val nav = navigation()

val category = category(
categoryId = transaction.categoryId,
categories = categories
)

if (transaction.type == TransactionType.TRANSFER) {
TransferHeader(
accounts = accounts,
transaction = transaction
)
Column(
modifier = Modifier.padding(horizontal = 20.dp),
) {
if (category != null) {
CategoryBadgeDisplay(category, nav)
Spacer(modifier = Modifier.height(8.dp))
}
TransferHeader(
accounts = accounts,
transaction = transaction
)
}
} else {
Row(
modifier = Modifier.padding(horizontal = 20.dp),
verticalAlignment = Alignment.CenterVertically
) {
val category = category(
categoryId = transaction.categoryId,
categories = categories
)

if (category != null) {
TransactionBadge(
text = category.name,
backgroundColor = category.color.toComposeColor(),
icon = category.icon,
defaultIcon = R.drawable.ic_custom_category_s
) {
nav.navigateTo(
TransactionsScreen(
accountId = null,
categoryId = category.id
)
)
}

CategoryBadgeDisplay(category, nav)
Spacer(Modifier.width(12.dp))
}

Expand Down Expand Up @@ -301,6 +297,27 @@ private fun TransactionHeaderRow(
}
}

@Composable
fun CategoryBadgeDisplay(
category: Category,
nav: Navigation,
) {
TransactionBadge(
text = category.name,
backgroundColor = category.color.toComposeColor(),
icon = category.icon,
defaultIcon = R.drawable.ic_custom_category_s
) {
// Navigation logic
nav.navigateTo(
TransactionsScreen(
accountId = null,
categoryId = category.id
)
)
}
}

@Composable
private fun TransactionBadge(
text: String,
Expand Down Expand Up @@ -351,7 +368,6 @@ private fun TransferHeader(
) {
Row(
modifier = Modifier
.padding(horizontal = 20.dp)
.background(UI.colors.pure, UI.shapes.rFull),
verticalAlignment = Alignment.CenterVertically
) {
Expand Down

0 comments on commit 0c7d840

Please sign in to comment.