Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -34,6 +33,7 @@ import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil3.compose.AsyncImage
import com.jetbrains.kmpapp.data.MuseumObject
import com.jetbrains.kmpapp.screens.EmptyScreenContent
Expand All @@ -57,7 +57,7 @@ fun DetailScreen(
) {
val viewModel = koinViewModel<DetailViewModel>()

val obj by viewModel.getObject(objectId).collectAsState(initial = null)
val obj by viewModel.getObject(objectId).collectAsStateWithLifecycle(initialValue = null)
AnimatedContent(obj != null) { objectAvailable ->
if (objectAvailable) {
ObjectDetails(obj!!, onBackClick = navigateBack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil3.compose.AsyncImage
import com.jetbrains.kmpapp.data.MuseumObject
import com.jetbrains.kmpapp.screens.EmptyScreenContent
Expand All @@ -37,7 +37,7 @@ fun ListScreen(
navigateToDetails: (objectId: Int) -> Unit
) {
val viewModel = koinViewModel<ListViewModel>()
val objects by viewModel.objects.collectAsState()
val objects by viewModel.objects.collectAsStateWithLifecycle()

AnimatedContent(objects.isNotEmpty()) { objectsAvailable ->
if (objectsAvailable) {
Expand Down