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

Add an example of Shared elements that are seekable using SeekableTransitionState #416

Merged
merged 10 commits into from
Dec 10, 2024

Conversation

riggaroo
Copy link
Collaborator

@riggaroo riggaroo commented Dec 10, 2024

Added an example of seekable transitions, was previously approved by Doris but pull request got outdated. #273

Copy link

snippet-bot bot commented Dec 10, 2024

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@mlykotom mlykotom self-requested a review December 10, 2024 12:38
Copy link
Contributor

@mlykotom mlykotom left a comment

Choose a reason for hiding this comment

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

should we add android:enableOnBackInvokedCallback="true" to the android manifest? otherwise the predictive back doesn't work (I don't know if we don't break some other snippet though)

@mlykotom
Copy link
Contributor

When I cancel the back gesture, then it doesn't work again :(

broken.mp4

Comment on lines 658 to 669
try {
seekableTransitionState.seekTo(backEvent.progress, targetState = Screen.Home)
} catch (e: CancellationException) {
// ignore the cancellation
}
}
// code for completion
seekableTransitionState.animateTo(seekableTransitionState.targetState)
} catch (e: CancellationException) {
// code for cancellation
seekableTransitionState.animateTo(seekableTransitionState.currentState)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it slightly confusing why do I need to suppress the cancellation exceptions here.
Can we explain it a bit more in the comments? 🙏🏼

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added comments.

@riggaroo
Copy link
Collaborator Author

When I cancel the back gesture, then it doesn't work again :(

broken.mp4

Fixed this by changing to snapTo instead of animateTo in the cancellation block, could you try it again?

Copy link
Contributor

@mlykotom mlykotom left a comment

Choose a reason for hiding this comment

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

Thank you, so much clearer with the comments. I tried it on the phone and it's working ❤️

@mlykotom mlykotom merged commit 41b6a64 into main Dec 10, 2024
5 checks passed
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.

2 participants