Skip to content

Commit

Permalink
Merge pull request #164 from mhmd-android/optimize/price-change-color…
Browse files Browse the repository at this point in the history
…s-in-market-list

Optimize/price change colors in market list
  • Loading branch information
Kaaveh authored Oct 29, 2023
2 parents 64f042b + 46d16a1 commit f7e935b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ 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
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

Expand Down Expand Up @@ -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,
)
}
}
Expand All @@ -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,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit f7e935b

Please sign in to comment.