mirror of
https://github.com/PranshulGG/WeatherMaster.git
synced 2026-10-23 11:33:42 -05:00
add onClick navigation to weather blocks and update Weather domain model with dewPoint, dawn, and dusk
This commit is contained in:
1 parent
a25705ca8c
commit
4a616ace8a
6 files changed
+49
-15
No files matched your search
+4
-1
@@ -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 {
|
||||
|
||||
+6
-2
@@ -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
|
||||
|
||||
+3
-2
@@ -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
|
||||
|
||||
+10
-3
@@ -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
|
||||
|
||||
+3
-2
@@ -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
|
||||
|
||||
+23
-5
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user