From e758cb58d15126c794459cf0eb552b0ea921d799 Mon Sep 17 00:00:00 2001 From: Mohamad Rezaei Date: Sat, 28 Oct 2023 23:32:10 +0330 Subject: [PATCH 1/2] [optimize] Add Dynamic Color Selection for `Price` Change Indicator --- .../src/main/java/ir/composenews/designsystem/theme/Color.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/designsystem/src/main/java/ir/composenews/designsystem/theme/Color.kt b/library/designsystem/src/main/java/ir/composenews/designsystem/theme/Color.kt index 34e5fc39..8a477d07 100644 --- a/library/designsystem/src/main/java/ir/composenews/designsystem/theme/Color.kt +++ b/library/designsystem/src/main/java/ir/composenews/designsystem/theme/Color.kt @@ -67,3 +67,7 @@ val md_theme_dark_scrim = Color(0xFF000000) // custom colors val graphColor = Color(0xFF6750A4) val lightGraphColor = graphColor.copy(alpha = 0.5f) +val lightUptrendGreen = Color(0xFF4CAF50) +val darkUptrendGreen = Color(0xFF00A86B) +val lightDownTrendRed = Color(0xFFE50000) +val darkDownTrendRed = Color(0xFFFF1919) From 46d16a13b80193ac80ad0fc7b82d72e80eabf775 Mon Sep 17 00:00:00 2001 From: Mohamad Rezaei Date: Sat, 28 Oct 2023 23:33:04 +0330 Subject: [PATCH 2/2] [optimize] Integrate Light and Dark Color Schemes for `Price` Change Indicator --- .../composenews/designsystem/component/MarketItem.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/designsystem/src/main/java/ir/composenews/designsystem/component/MarketItem.kt b/library/designsystem/src/main/java/ir/composenews/designsystem/component/MarketItem.kt index 5bb0e1bc..358d09b5 100644 --- a/library/designsystem/src/main/java/ir/composenews/designsystem/component/MarketItem.kt +++ b/library/designsystem/src/main/java/ir/composenews/designsystem/component/MarketItem.kt @@ -42,8 +42,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color.Companion.Green -import androidx.compose.ui.graphics.Color.Companion.Red import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp @@ -51,6 +49,10 @@ import coil.compose.rememberAsyncImagePainter import ir.composenews.designsystem.R import ir.composenews.designsystem.preview.ThemePreviews import ir.composenews.designsystem.theme.ComposeNewsTheme +import ir.composenews.designsystem.theme.darkDownTrendRed +import ir.composenews.designsystem.theme.darkUptrendGreen +import ir.composenews.designsystem.theme.lightDownTrendRed +import ir.composenews.designsystem.theme.lightUptrendGreen import kotlinx.coroutines.delay import java.util.Locale @@ -192,7 +194,8 @@ private fun MarketItemCard( Text( text = "$priceChangePercentage24h %", style = MaterialTheme.typography.bodyLarge, - color = if (priceChangePercentage24h.contains("-")) Red else Green, + color = if (priceChangePercentage24h.contains("-")) if (isSystemInDarkTheme()) darkDownTrendRed else lightDownTrendRed + else if (isSystemInDarkTheme()) darkUptrendGreen else lightUptrendGreen, ) } } @@ -215,7 +218,8 @@ private fun ArrowIconUpOrDown(priceChangePercentage24h: String) { painterResource(id = R.drawable.baseline_arrow_upward_24) }, contentDescription = "", - tint = if (priceChangePercentage24h.contains("-")) Red else Green, + tint = if (priceChangePercentage24h.contains("-")) if (isSystemInDarkTheme()) darkDownTrendRed else lightDownTrendRed + else if (isSystemInDarkTheme()) darkUptrendGreen else lightUptrendGreen, ) }