-
Notifications
You must be signed in to change notification settings - Fork 173
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
Predictive back MaterialSharedAxis sample #156
Conversation
Merge branch from main branch
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.
Thank you, Tram. Can you add in a few more things:
- Update to
material = "1.12.0-beta01"
inlibs.versions.toml
- Add an explanation of this sample in
samples/user-interface/predictiveback/README.md
. - Add the related animation in
PBListFragment.kt
in onCreateView
enterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ true)
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ false)
- Move the enterTransition and returnTransition to onCreateView in PBMaterialSharedAxisAnimations.kt. You can likely delete all of onViewCreated within this file.
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.
remove this file from the commit
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.
done
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.
remove this file from the commit
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.
Done.
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.
remove this file from the commit
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.
remove this file from the commit
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.
Done
import android.view.ViewGroup | ||
import androidx.activity.OnBackPressedCallback | ||
import androidx.fragment.app.Fragment | ||
import androidx.navigation.fragment.FragmentNavigatorExtras |
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.
remove this import as it is unused
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.
Done
enterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ true) | ||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ false) | ||
|
||
val predictiveBackCallback = object : OnBackPressedCallback(true) { |
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.
remove the callback, a callback is not needed to run cross-fragment animations
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.
Done
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.
LGTM except what Ash pointed out
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.
Thanks, Ash! Applied the edits and had a small follow up question!
exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ true) | ||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ false) | ||
|
||
|
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.
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.
PBListFragment is Fragment A so exit and reenter are correct.
enterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ true) | ||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ false) | ||
|
||
val predictiveBackCallback = object : OnBackPressedCallback(true) { |
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.
Done
import android.view.ViewGroup | ||
import androidx.activity.OnBackPressedCallback | ||
import androidx.fragment.app.Fragment | ||
import androidx.navigation.fragment.FragmentNavigatorExtras |
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.
Done
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.
Done
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.
Done.
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.
done
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.
One nit, otherwise LGTM. Thanks!
## Cross-fragment animation with MaterialSharedAxis | ||
|
||
MaterialSharedAxis is a Visibility transition. A Visibility transition is triggered when the target | ||
View's visibility is changed or when the View is added or removed. This means MaterialSharedAxis |
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.
Let's say fragments instead of views, since this is a cross-fragment transition.
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.
Done! TY!
exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ true) | ||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, /* forward= */ false) | ||
|
||
|
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.
PBListFragment is Fragment A so exit and reenter are correct.
Add MaterialSharedAxis transition to sample.
Video