-
-
Notifications
You must be signed in to change notification settings - Fork 22
fix: add unique keys to shared bounds #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e69eb3c
35068a3
5f58b4a
5adac17
53a6caa
67bd6f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,15 @@ fun SharedTransitionScope.PageImage( | |
| contentDescription = photoDesc, | ||
| contentScale = contentScale, | ||
| modifier = Modifier | ||
| .sharedBounds( | ||
| sharedContentState = rememberSharedContentState(photo.source), | ||
| animatedVisibilityScope = LocalNavAnimatedContentScope.current | ||
| .then( | ||
| photo.source?.let { src -> | ||
| Modifier.sharedBounds( | ||
| sharedContentState = rememberSharedContentState( | ||
| "article-image-$src" | ||
|
||
| ), | ||
| animatedVisibilityScope = LocalNavAnimatedContentScope.current | ||
| ) | ||
| } ?: Modifier | ||
| ) | ||
| .then(modifier) | ||
| .aspectRatio(photo.width.toFloat() / photo.height.toFloat()) | ||
|
|
@@ -108,7 +114,9 @@ fun SharedTransitionScope.PageImage( | |
| contentScale = contentScale, | ||
| modifier = Modifier | ||
| .sharedBounds( | ||
| sharedContentState = rememberSharedContentState(uri), | ||
| sharedContentState = rememberSharedContentState( | ||
| "gallery-image-$uri" | ||
| ), | ||
| animatedVisibilityScope = LocalNavAnimatedContentScope.current | ||
| ) | ||
| .then(modifier) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shared transition key "article-image-$src" in ImageCard.kt (used by PageContent.kt) doesn't match the keys used in ArticleFeed.kt. When navigating from the feed to an article, the shared element transition won't work because ArticleFeed uses keys like "tfa-image-$src" for the Today's Featured Article, "trending-$page-$i-image-$src" for trending articles, and "potd-image-$src" for the Picture of the Day. For shared element transitions to work across navigation, the keys must match exactly on both the source and destination screens.