Extract Weather colors to WeatherAppColor object

This commit is contained in:
Nebojsa Vuksic 2025-07-29 15:00:11 +02:00
parent 07ab7b2f05
commit 291a35b6bd
2 changed files with 18 additions and 6 deletions

View File

@ -0,0 +1,12 @@
package org.jetbrains.plugins.template.weatherApp
import androidx.compose.ui.graphics.Color
object WeatherAppColors {
val nightWeatherColor = Color(0xFF1A237E)
val coldWeatherColor = Color(0xFF3F51B5)
val coolWeatherColor = Color(0xFF5E35B1)
val mildWeatherColor = Color(0xFF039BE5)
val warmWeatherColor = Color(0xFFFF9800)
val hotWeatherColor = Color(0xFFE91E63)
}

View File

@ -182,12 +182,12 @@ fun isNightTime(dateTime: LocalDateTime): Boolean {
*/ */
fun getCardColorByTemperature(temperature: Float, isNightTime: Boolean): Color { fun getCardColorByTemperature(temperature: Float, isNightTime: Boolean): Color {
return when { return when {
isNightTime -> Color(0xFF1A237E) // Dark blue for night isNightTime -> WeatherAppColors.nightWeatherColor
temperature < 0 -> Color(0xFF3F51B5) // Cold: blue temperature < 0 -> WeatherAppColors.coldWeatherColor
temperature < 10 -> Color(0xFF5E35B1) // Cool: purple temperature < 10 -> WeatherAppColors.coolWeatherColor
temperature < 20 -> Color(0xFF039BE5) // Mild: light blue temperature < 20 -> WeatherAppColors.mildWeatherColor
temperature < 30 -> Color(0xFFFF9800) // Warm: orange temperature < 30 -> WeatherAppColors.warmWeatherColor
else -> Color(0xFFE91E63) // Hot: pink/red else -> WeatherAppColors.hotWeatherColor
} }
} }