diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/core/model/domain/weather/Weather.kt b/app/src/main/java/com/pranshulgg/weather_master_app/core/model/domain/weather/Weather.kt index 90a1dc191..3de2d23ea 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/core/model/domain/weather/Weather.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/core/model/domain/weather/Weather.kt @@ -64,6 +64,7 @@ data class WeatherHourly( val pressureMsl: Double?, // NOTE: ALWAYS HPA val visibility: Int?, // NOTE: ALWAYS METERS val humidity: Double?, + val dewPoint: Double?, val weatherCondition: WeatherCondition, val time: Long, // NOTE: ALWAYS MILLISECONDS val precipitationProbability: Int? @@ -96,7 +97,9 @@ data class WeatherDaily( val sunset: Long, // NOTE: ALWAYS MILLISECONDS val moonrise: Long, // NOTE: ALWAYS MILLISECONDS val moonset: Long, // NOTE: ALWAYS MILLISECONDS - val moonPhase: MoonPhase + val moonPhase: MoonPhase, + val dawn: Long, + val dusk: Long ) { fun isWindSpeedValid(): Boolean { diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/HumidityBlock.kt b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/HumidityBlock.kt index b6310263a..97ba548b4 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/HumidityBlock.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/HumidityBlock.kt @@ -31,7 +31,10 @@ import com.pranshulgg.weather_master_app.core.ui.theme.ShadowElevation import kotlin.math.roundToInt @Composable -fun HumidityBlock(weather: Weather, units: WeatherUnits) { +fun HumidityBlock( + weather: Weather, units: WeatherUnits, + onClickBlock: () -> Unit +) { val color = MaterialTheme.colorScheme.inversePrimary val humidity = weather.current.humidity.roundToInt() @@ -53,7 +56,8 @@ fun HumidityBlock(weather: Weather, units: WeatherUnits) { Surface( color = MaterialTheme.colorScheme.surface, shape = MaterialTheme.shapes.extraLarge, - shadowElevation = ShadowElevation.level2 + shadowElevation = ShadowElevation.level2, + onClick = onClickBlock ) { Box( Modifier diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/MoonBlock.kt b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/MoonBlock.kt index 51b4927bd..d26da5750 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/MoonBlock.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/MoonBlock.kt @@ -43,7 +43,7 @@ import com.pranshulgg.weather_master_app.core.utils.formatters.to24HourTimeStrin import com.pranshulgg.weather_master_app.core.utils.weather.cache.isWeatherDailyDomainSafe @Composable -fun MoonBlock(weather: Weather, dailyIndex: Int, prefs: AppPrefsState) { +fun MoonBlock(weather: Weather, dailyIndex: Int, prefs: AppPrefsState, onClickBlock: () -> Unit) { if (!isWeatherDailyDomainSafe(weather)) return @@ -54,7 +54,8 @@ fun MoonBlock(weather: Weather, dailyIndex: Int, prefs: AppPrefsState) { Surface( color = MaterialTheme.colorScheme.surface, shape = MaterialTheme.shapes.extraLarge, - shadowElevation = ShadowElevation.level2 + shadowElevation = ShadowElevation.level2, + onClick = onClickBlock ) { Box( Modifier diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/PressureBlock.kt b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/PressureBlock.kt index 72aced1bb..8c868ec7c 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/PressureBlock.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/PressureBlock.kt @@ -30,13 +30,19 @@ import com.pranshulgg.weather_master_app.core.model.weather.toName import com.pranshulgg.weather_master_app.core.ui.components.Symbol import com.pranshulgg.weather_master_app.core.ui.theme.ShadowElevation import com.pranshulgg.weather_master_app.core.ui.theme.ShapeRadius +import kotlin.math.roundToInt @Composable -fun PressureBlock(weather: Weather, units: WeatherUnits, context: Context) { +fun PressureBlock( + weather: Weather, + units: WeatherUnits, + context: Context, + onClickBlock: () -> Unit +) { val pressure = weather.current.pressureMsl val pressureConverted = PressureUnit.HPA.convert(pressure!!, units.pressureUnit) - val pressureHpa = weather.current.pressureMsl.toInt() + val pressureHpa = weather.current.pressureMsl.roundToInt() val progressDrawable = when { pressureHpa < 980 -> R.drawable.pressure_progress_low @@ -50,7 +56,8 @@ fun PressureBlock(weather: Weather, units: WeatherUnits, context: Context) { Surface( color = MaterialTheme.colorScheme.surface, shape = RoundedCornerShape(ShapeRadius.Full), - shadowElevation = ShadowElevation.level2 + shadowElevation = ShadowElevation.level2, + onClick = onClickBlock ) { Box( Modifier diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/SunBlock.kt b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/SunBlock.kt index 826245653..920552b91 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/SunBlock.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/SunBlock.kt @@ -43,7 +43,7 @@ import com.pranshulgg.weather_master_app.core.utils.formatters.to24HourTimeStrin import com.pranshulgg.weather_master_app.core.utils.weather.cache.isWeatherDailyDomainSafe @Composable -fun SunBlock(weather: Weather, dailyIndex: Int, prefs: AppPrefsState) { +fun SunBlock(weather: Weather, dailyIndex: Int, prefs: AppPrefsState, onClickBlock: () -> Unit) { if (!isWeatherDailyDomainSafe(weather)) return @@ -54,7 +54,8 @@ fun SunBlock(weather: Weather, dailyIndex: Int, prefs: AppPrefsState) { Surface( color = MaterialTheme.colorScheme.surface, shape = MaterialTheme.shapes.extraLarge, - shadowElevation = ShadowElevation.level2 + shadowElevation = ShadowElevation.level2, + onClick = onClickBlock, ) { Box( Modifier diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/WeatherBlocks.kt b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/WeatherBlocks.kt index a5bd52fd3..4ee3d7290 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/WeatherBlocks.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/feature/shared/components/blocks/WeatherBlocks.kt @@ -172,12 +172,16 @@ fun WeatherBlocks( ) ) { when (item.type) { - WeatherBlockType.HUMIDITY_BLOCK -> HumidityBlock(weather, units) + WeatherBlockType.HUMIDITY_BLOCK -> HumidityBlock( + weather, + units, + onClickBlock = { onClickBlock(NavRoutes.HUMIDITY) }) WeatherBlockType.VISIBILITY_BLOCK -> VisibilityBlock( weather, units, - context + context, + onClickBlock = { onClickBlock(NavRoutes.VISIBILITY) } ) WeatherBlockType.UV_INDEX_BLOCK -> UvIndexBlock( @@ -188,10 +192,24 @@ fun WeatherBlocks( onClickBlock = { onClickBlock(NavRoutes.UV_INDEX) } ) - WeatherBlockType.PRESSURE_BLOCK -> PressureBlock(weather, units, context) + WeatherBlockType.PRESSURE_BLOCK -> PressureBlock( + weather, + units, + context, + onClickBlock = { onClickBlock(NavRoutes.PRESSURE) }) + + WeatherBlockType.SUN_BLOCK -> SunBlock( + weather, + dailyIndex, + prefs, + onClickBlock = { onClickBlock(NavRoutes.SUN_MOON) }) + + WeatherBlockType.MOON_BLOCK -> MoonBlock( + weather, + dailyIndex, + prefs, + onClickBlock = { onClickBlock(NavRoutes.SUN_MOON) }) - WeatherBlockType.SUN_BLOCK -> SunBlock(weather, dailyIndex, prefs) - WeatherBlockType.MOON_BLOCK -> MoonBlock(weather, dailyIndex, prefs) WeatherBlockType.AIR_QUALITY_BLOCK -> AirQualityBlock(airQuality, context)