Skip to content

Commit

Permalink
Fix shared transition issue during from popular list to detail screen
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzsout committed Oct 10, 2024
1 parent 08478ff commit 8bdc017
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private fun SharedTransitionScope.HomeListImage(
onImageClick: (String) -> Unit,
animatedVisibilityScope: AnimatedVisibilityScope,
) {
val sharedContentState = rememberSharedContentState(key = "mainImage-${id}")
val sharedContentState = rememberSharedContentState(key = "$SharedTransitionKey$id")

with(animatedVisibilityScope) {
SubcomposeAsyncImage(
Expand All @@ -478,4 +478,6 @@ private fun SharedTransitionScope.HomeListImage(
loading = { ImageLoadingState() },
)
}
}
}

const val SharedTransitionKey = "mainImage-"
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import coil.compose.SubcomposeAsyncImage
import com.oguzdogdu.walliescompose.R
import com.oguzdogdu.walliescompose.data.common.ImageLoadingState
import com.oguzdogdu.walliescompose.domain.model.popular.PopularImage
import com.oguzdogdu.walliescompose.features.home.SharedTransitionKey
import com.oguzdogdu.walliescompose.features.popular.components.PopularEditDetails
import com.oguzdogdu.walliescompose.ui.theme.medium
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -269,7 +270,7 @@ fun SharedTransitionScope.PopularListItem(
SubcomposeAsyncImage(
modifier = modifier
.sharedElement(
state = rememberSharedContentState(key = "popularImage-${popularImage.id}"),
state = rememberSharedContentState(key = "$SharedTransitionKey${popularImage.id}"),
animatedVisibilityScope = animatedVisibilityScope,
clipInOverlayDuringTransition = OverlayClip(RoundedCornerShape(16.dp)),
boundsTransform = boundsTransform
Expand Down

0 comments on commit 8bdc017

Please sign in to comment.