-
Notifications
You must be signed in to change notification settings - Fork 59
How to use MaterialFadeThrough Transition as StackTransactionModifier? #82
Comments
Hi @wman1980, thanks for checking out the library.
The full implementation is: fun MultiStackNavigator.materialFadeThroughTransition(): FragmentTransaction.(Int) -> Unit = fade@{ index ->
val rootFragmentManager = current?.activity?.supportFragmentManager ?: return@fade
rootFragmentManager.findFragmentByTag(activeIndex.toString())?.apply {
enterTransition = null
if (exitTransition !is MaterialFadeThrough) exitTransition = MaterialFadeThrough().setDuration(300)
}
rootFragmentManager.findFragmentByTag(index.toString())?.apply {
exitTransition = null
if (enterTransition !is MaterialFadeThrough) enterTransition = MaterialFadeThrough().setDuration(300)
}
} |
ahh, that is awesome! I just forgot about the supportFragmentManager and the index. Thanks a lot! |
Hi @tunjid, I have a follow up question. If I add some Transition.TransitionListener to that code above to listen to start and end events for each transition. Do you have an idea how I could pass these events to my active and target fragment? Currently the fragment returned by findFragmentByTag is a StackFragment and it does not offer a lot to me because everything is internal ... I first though I could just add this listener within my active/target fragment, but there the transition is null. So is there actually a way to get these transitions from my active/target fragment? Thanks |
@wman1980 |
Actually I have a WebView within android and the webview "flickers/blinks" if a transition (MaterialSharedAxis.X) is started. My plan to prevent that was to create a bitmap snapshot and put that snapshot in front of the webview on transition start and remove that snapshot on transition end. But unfortunately I just discovered that onDestroyView of my fragment is called before onTransitionStart e.g. during a returnTransition. Damn android! |
ok, I worked around my issue by creating a snapshot onPause within my fragment. Sorry to spam with unrelated stuff and thanks for your response. |
Hi,
very nice library!
Currently I am asking myself how to implement MaterialFadeThrough-Transition during a stack-change?
I was able to implement a Cross-Fade Transition by using stackTransactionModifier of MultiStackNavigator like this
this.stackTransactionModifier = { setCustomAnimations( R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out ) }
But how to do this by using a MaterialFadeThrough Transition?
The text was updated successfully, but these errors were encountered: