From 43b7b424955b20a0a9c382d7f29c636a612f862e Mon Sep 17 00:00:00 2001 From: Henry Hiles Date: Mon, 25 Dec 2023 11:50:00 -0500 Subject: [PATCH] You can no longer go back in time --- .../components/weather/WeatherForecast.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/henryhiles/qweather/presentation/components/weather/WeatherForecast.kt b/app/src/main/java/com/henryhiles/qweather/presentation/components/weather/WeatherForecast.kt index db499a7..0c7c16f 100644 --- a/app/src/main/java/com/henryhiles/qweather/presentation/components/weather/WeatherForecast.kt +++ b/app/src/main/java/com/henryhiles/qweather/presentation/components/weather/WeatherForecast.kt @@ -3,7 +3,6 @@ package com.henryhiles.qweather.presentation.components.weather import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp @@ -17,15 +16,14 @@ fun WeatherForecast( onChangeSelected: (Int) -> Unit ) { state.hourlyWeatherInfo?.weatherData?.let { - val rowState = rememberLazyListState(LocalDateTime.now().hour) - LazyRow(state = rowState, modifier = modifier) { - itemsIndexed(it) { index, data -> + val hour = LocalDateTime.now().hour + LazyRow(modifier = modifier) { + itemsIndexed(it.subList(hour, it.size)) { index, data -> WeatherHour( data = data, modifier = Modifier - .padding(horizontal = 8.dp), - onChangeSelected = { onChangeSelected(index) } - ) + .padding(horizontal = 8.dp) + ) { onChangeSelected(index) } } } }