Skip to content

Commit

Permalink
Fix collect state on each onStarted
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Surzhykov <yuriisurzhykov@gmail.com>
  • Loading branch information
yuriisurzhykov committed May 29, 2024
1 parent 6a3f190 commit d7d1268
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ junit = "4.13.2"
mockk = "1.13.11"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
androidx-lifecycle = "2.8.0"
androidx-lifecycle = "2.8.1"
activityCompose = "1.9.0"
composeBom = "2024.05.00"
androidx-compose-runtime = "1.6.7"
Expand All @@ -17,7 +17,7 @@ retrofit = "2.9.0"
kotlinx-coroutines = "1.8.0"
retrofitAdaptersResult = "1.0.9"
retrofitConverterKotlinxSerialization = "1.0.0"
appcompat = "1.6.1"
appcompat = "1.7.0"
material = "1.12.0"
room = "2.6.1"
ksp = "1.9.24-1.0.20"
Expand Down Expand Up @@ -88,6 +88,7 @@ androidx-uiautomator = { group = "androidx.test.uiautomator", name = "uiautomato
androidx-benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "benchmarkMacroJunit4" }
androidx-profileinstaller = { group = "androidx.profileinstaller", name = "profileinstaller", version.ref = "profileinstaller" }
material = { group = "com.google.android.material", name = "material", version.ref = "materialVersion" }
androidx-lifecycle-runtime-compose-android = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose-android", version.ref = "androidx-lifecycle" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
Expand Down
1 change: 1 addition & 0 deletions ui-features/location-details/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphics)
implementation(libs.androidx.material3)
implementation(libs.androidx.lifecycle.runtime.compose.android)
debugImplementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.test.manifest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -53,6 +52,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import coil.compose.AsyncImage
import com.github.yuriisurzhykov.purs.domain.model.Location
Expand All @@ -76,7 +76,7 @@ internal fun LocationDetails(
viewModel: LocationDetailsViewModel,
modifier: Modifier = Modifier
) {
val state = viewModel.detailsResponse.collectAsState().value
val state: State by viewModel.detailsResponse.collectAsStateWithLifecycle()
BackgroundImage(modifier = modifier.fillMaxSize())
if (state != State.None) {
Content(state = state, modifier = modifier.fillMaxSize())
Expand Down

0 comments on commit d7d1268

Please sign in to comment.