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

Fix issue 3637 #3647

Merged
merged 10 commits into from
Oct 25, 2024
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ captures/
.DS_Store
.idea/deploymentTargetSelector.xml
.idea/other.xml
.idea/appInsightsSettings.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
Expand Down
26 changes: 26 additions & 0 deletions .idea/appInsightsSettings.xml
viratde marked this conversation as resolved.
Show resolved Hide resolved
viratde marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml
viratde marked this conversation as resolved.
Show resolved Hide resolved
viratde marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/runConfigurations.xml
viratde marked this conversation as resolved.
Show resolved Hide resolved
viratde marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.testTag
Expand Down Expand Up @@ -325,7 +326,8 @@ private fun TransactionHeaderRow(
}
TransferHeader(
accounts = accounts,
transaction = transaction
transaction = transaction,
shouldShowAccountSpecificColorInTransactions = shouldShowAccountSpecificColorInTransactions
)
}
} else {
Expand Down Expand Up @@ -454,22 +456,49 @@ private fun TransactionBadge(
}
}

private const val TRANSFER_HEADER_GRADIENT_THRESHOLD = 0.35f
viratde marked this conversation as resolved.
Show resolved Hide resolved
@Composable
private fun TransferHeader(
accounts: List<Account>,
transaction: Transaction
transaction: Transaction,
shouldShowAccountSpecificColorInTransactions: Boolean
) {
val account = accounts.find { transaction.accountId == it.id }
ILIYANGERMANOV marked this conversation as resolved.
Show resolved Hide resolved
val toAccount = accounts.find { transaction.toAccountId == it.id }

Row(
modifier = Modifier
.background(UI.colors.pure, UI.shapes.rFull),
.then(
if (shouldShowAccountSpecificColorInTransactions && account != null && toAccount != null) {
Modifier
.background(
brush = Brush.horizontalGradient(
0f to account.color.toComposeColor(),
(TRANSFER_HEADER_GRADIENT_THRESHOLD) to account.color.toComposeColor(),
(1f - TRANSFER_HEADER_GRADIENT_THRESHOLD) to toAccount.color.toComposeColor(),
1f to toAccount.color.toComposeColor()
),
shape = UI.shapes.rFull
)
} else {
Modifier.background(UI.colors.pure, UI.shapes.rFull)
}
),
verticalAlignment = Alignment.CenterVertically
) {
Spacer(Modifier.width(8.dp))

val account = accounts.find { transaction.accountId == it.id }
val accountContrastColor =
if (shouldShowAccountSpecificColorInTransactions && account != null) {
findContrastTextColor(account.color.toComposeColor())
} else {
UI.colors.pureInverse
}

ItemIconSDefaultIcon(
iconName = account?.icon,
defaultIcon = R.drawable.ic_custom_account_s
defaultIcon = R.drawable.ic_custom_account_s,
tint = accountContrastColor
)

Spacer(Modifier.width(4.dp))
Expand All @@ -481,20 +510,27 @@ private fun TransferHeader(
text = account?.name.toString(),
style = UI.typo.c.style(
fontWeight = FontWeight.ExtraBold,
color = UI.colors.pureInverse
color = accountContrastColor
)
)

Spacer(Modifier.width(12.dp))

IvyIcon(icon = R.drawable.ic_arrow_right)
IvyIcon(icon = R.drawable.ic_arrow_right, tint = accountContrastColor)

Spacer(Modifier.width(12.dp))

val toAccount = accounts.find { transaction.toAccountId == it.id }
val toAccountContrastColor =
if (shouldShowAccountSpecificColorInTransactions && toAccount != null) {
findContrastTextColor(toAccount.color.toComposeColor())
} else {
UI.colors.pureInverse
}

ItemIconSDefaultIcon(
iconName = toAccount?.icon,
defaultIcon = R.drawable.ic_custom_account_s
defaultIcon = R.drawable.ic_custom_account_s,
tint = toAccountContrastColor
)

Spacer(Modifier.width(4.dp))
Expand All @@ -506,7 +542,7 @@ private fun TransferHeader(
text = toAccount?.name.toString(),
style = UI.typo.c.style(
fontWeight = FontWeight.ExtraBold,
color = UI.colors.pureInverse
color = toAccountContrastColor
)
)

Expand Down Expand Up @@ -863,7 +899,7 @@ private fun PreviewTransfer_differentCurrency() {
dateTime = timeNowUTC().toInstant(ZoneOffset.UTC),
type = TransactionType.TRANSFER
),
shouldShowAccountSpecificColorInTransactions = false,
shouldShowAccountSpecificColorInTransactions = true,
onPayOrGet = {},
) {
}
Expand Down
Loading