Skip to content
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

Adding shared elements to Jetsnack 🎉 #1314

Open
wants to merge 37 commits into
base: compose-latest
Choose a base branch
from

Conversation

riggaroo
Copy link
Collaborator

@riggaroo riggaroo commented Apr 4, 2024

Adding shared elements between Home feed and SnackDetail.

Introduced SnackSharedElementKey to create a unique key for the shared element to match.

Using Modifier.sharedBounds() on the Card container, and Modifier.sharedElement() on the Image.

Using Modifier.sharedBounds() with Modifier.animateEnterExit() on Text.

The above modifiers require being in an AnimatedVisibilityScope and SharedTransitionScope, in order to use the correct scope at the correct point, we save the scopes in a CompositionLocal and retrieve it when required.

jetsnack.mp4

@riggaroo riggaroo changed the title Adding Shared elements to Jetsnack Adding shared elements to Jetsnack 🎉 Apr 5, 2024
@riggaroo riggaroo marked this pull request as ready for review April 22, 2024 14:31
@riggaroo riggaroo requested a review from a team as a code owner April 22, 2024 14:31
@riggaroo riggaroo changed the base branch from main to compose-latest April 29, 2024 13:36
@@ -41,183 +42,183 @@ val snacks = listOf(
price = 299
),
Snack(
id = 2L,
id = Random.nextLong(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cupcake above still has a fixed ID. Do these IDs need to be random? Also, isn't it now possible (albeit very improbable) that two snacks end up with the same ID?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its for preview purposes to be able to query for a certain snack. yes it is somewhat possible, but this is fake mock data so I dont think its worth the hassle of making it more robust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants