Skip to content

Commit 2a8eb50

Browse files
committed
Remove saveHandleState on current location
1 parent 6c26898 commit 2a8eb50

File tree

7 files changed

+46
-7
lines changed

7 files changed

+46
-7
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
applicationId = "com.arklan.weather"
1515
minSdk = ConfigData.minSdk
1616
targetSdk = ConfigData.targetSdk
17-
versionCode = 7
18-
versionName = "1.6"
17+
versionCode = 8
18+
versionName = "1.7"
1919

2020
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2121
vectorDrawables {

app/release/app-release.aab

1.67 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

buildSrc/build/libs/buildSrc.jar

0 Bytes
Binary file not shown.

feature/weather/src/main/java/com/trifork/feature/weather/presentation/WeatherViewModel.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ class WeatherViewModel @Inject constructor(
6666
viewModelScope.launch(dispatcherProvider.io) {
6767
val location = if (geoLocation.lat == .0 || geoLocation.long == .0) {
6868
locationTracker.getCurrentLocation()?.let {
69+
70+
savedStateHandle.run {
71+
remove<String>("name")
72+
remove<String>("lat")
73+
remove<String>("long")
74+
}
75+
6976
WeatherLocation(
7077
localResource.getCurrentLocationString(),
7178
it.latitude,

feature/weather/src/main/java/com/trifork/feature/weather/presentation/components/WeatherForecast.kt

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.trifork.feature.weather.presentation.components
22

3+
import androidx.compose.animation.core.FastOutSlowInEasing
4+
import androidx.compose.animation.core.tween
35
import androidx.compose.foundation.clickable
6+
import androidx.compose.foundation.gestures.animateScrollBy
47
import androidx.compose.foundation.layout.Arrangement
58
import androidx.compose.foundation.layout.Column
69
import androidx.compose.foundation.layout.Row
@@ -11,23 +14,32 @@ import androidx.compose.foundation.layout.padding
1114
import androidx.compose.foundation.layout.width
1215
import androidx.compose.foundation.lazy.LazyRow
1316
import androidx.compose.foundation.lazy.items
17+
import androidx.compose.foundation.lazy.rememberLazyListState
1418
import androidx.compose.material3.MaterialTheme
1519
import androidx.compose.material3.Text
1620
import androidx.compose.runtime.Composable
21+
import androidx.compose.runtime.LaunchedEffect
22+
import androidx.compose.runtime.getValue
23+
import androidx.compose.runtime.mutableFloatStateOf
24+
import androidx.compose.runtime.mutableStateOf
25+
import androidx.compose.runtime.remember
26+
import androidx.compose.runtime.setValue
1727
import androidx.compose.ui.Alignment
1828
import androidx.compose.ui.Modifier
29+
import androidx.compose.ui.layout.onGloballyPositioned
30+
import androidx.compose.ui.platform.LocalConfiguration
1931
import androidx.compose.ui.platform.LocalContext
32+
import androidx.compose.ui.platform.LocalDensity
2033
import androidx.compose.ui.unit.dp
2134
import androidx.compose.ui.unit.sp
22-
import com.trifork.feature.common.util.MonthString
2335
import com.trifork.feature.common.util.WeekString
2436
import com.trifork.feature.weather.domain.model.WeatherData
2537
import com.trifork.feature.weather.domain.model.WeatherInfo
26-
import com.trifork.feature.weather.presentation.WeatherViewModel
2738
import com.trifork.feature.weather.presentation.mvi.WeatherEvent
2839
import kotlinx.collections.immutable.ImmutableList
40+
import kotlinx.coroutines.delay
41+
import kotlinx.coroutines.launch
2942
import java.time.LocalDateTime
30-
import java.util.Locale
3143

3244
@Composable
3345
fun WeatherForecast(
@@ -73,7 +85,13 @@ fun WeatherForecast(
7385
)
7486
}
7587
Spacer(modifier = Modifier.height(16.dp))
76-
LazyRow(content = {
88+
89+
val listState = rememberLazyListState()
90+
val density = LocalDensity.current
91+
92+
LazyRow(
93+
state = listState
94+
) {
7795
items(perDay.filter { it.time.plusHours(1) > LocalDateTime.now() }) { weatherData ->
7896
HourlyWeatherDisplay(
7997
weatherData = weatherData,
@@ -93,6 +111,20 @@ fun WeatherForecast(
93111
}
94112
)
95113
}
96-
})
114+
}
115+
116+
if (perDay[0].time.dayOfMonth != LocalDateTime.now().dayOfMonth) {
117+
LaunchedEffect(key1 = perDay) {
118+
launch {
119+
delay(500)
120+
val componentWidth = with(density) { (40.dp.roundToPx() + 32.dp.roundToPx()).toFloat() }
121+
listState.animateScrollBy(
122+
value = componentWidth * 11,
123+
animationSpec = tween(3000, easing = FastOutSlowInEasing)
124+
)
125+
listState.animateScrollToItem(10)
126+
}
127+
}
128+
}
97129
}
98130
}

0 commit comments

Comments
 (0)