-
Notifications
You must be signed in to change notification settings - Fork 22
Implement shared transition animation #37
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
Conversation
833aaec to
dca283e
Compare
66491d8 to
eb000a3
Compare
dca283e to
6ae7285
Compare
| // Use the key from AnimationContentKey as indicator when content has changed | ||
| // that needs to be animated. If this key is doesn't change (the default behavior), | ||
| // then no animation occurs. | ||
| it.contentKey |
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.
This poses the "Where did it come from?" problem. Here, I think it === model, but hard to say. If it is the model, maybe state this as model.contentKey. Otherwise, I think it would be good to name it.
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.
Renamed it to template
contentKey = { template ->
// Use the key from AnimationContentKey as indicator when content has changed
// that needs to be animated. If this key is doesn't change (the default behavior),
// then no animation occurs.
template.contentKey
},| import software.amazon.app.platform.presenter.BaseModel | ||
|
|
||
| /** | ||
| * The sample application supports animations between model and even templates. [BaseModel] classes |
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.
Probably should say "between models and even templates."
| } | ||
|
|
||
| /** | ||
| * All UI composable functions in the sample application a wrapped within a [AnimatedContent]. This |
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.
This KDoc doesn't parse well. Maybe 'are' is missing in "application a wrapped within". The first phrase lacks a verb. Even guessing though, it isn't clear what this KDoc is trying to tell me.
Is this scope nested in the following LocalSharedTransitionScope, or do we have all Venn diagram possibilities?
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.
"a" was supposed to be "are".
I updated the documentation to this:
/**
* All UI composable functions for renderers in the sample application are wrapped within a
* [SharedTransitionLayout]. This composition local gives access to this wrapper instance to run a
* shared element transition. For more information see the the
* [shared element transition documentation](https://developer.android.com/develop/ui/compose/animation/shared-elements#shared-bounds).
*
* The [BaseModel] must implement [AnimationContentKey] to indicate that an animation should be
* played. See [AnimationContentKey] for more details.
*/And updated the documentation for AnimationContentKey to this with a sample:
/**
* The sample application supports animations between models and templates. [BaseModel] classes can
* implement this interface to indicate when a change occurred that should be animated. [contentKey]
* represents a unique value for an animation state. If the value doesn't change between new models,
* then no animation will be started.
*
* An example may look like this:
* ```
* data class Model(
* val showPictureFullscreen: Boolean,
* ...
* ) : BaseModel, AnimationContentKey {
* override val contentKey: Int =
* if (showPictureFullscreen) 1 else AnimationContentKey.DEFAULT_CONTENT_KEY
* }
* ```
*
* In this sample when `showPictureFullscreen` changes from `true` to `false` and vice versa then an
* animation will be started using [AnimatedContent]. Use [LocalAnimatedVisibilityScope] and
* [LocalSharedTransitionScope] to get access to the right scopes.
*/| val LocalNavAnimatedVisibilityScope = compositionLocalOf<AnimatedVisibilityScope?> { null } | ||
|
|
||
| /** | ||
| * All UI composable functions in the sample application a wrapped within a |
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.
Similar KDoc concerns to the preceeding.
Implement a shared transition animation when the user taps the profile picture. This sample highlights how animations can be implemented when switching between different models and templates.
6ae7285 to
68a514a
Compare
Implement a shared transition animation when the user taps the profile picture. This sample highlights how animations can be implemented when switching between different models and templates.
Animation.mp4