isaac-udy/Enro

Customize animations for multistack fragment changes

Closed this issue · 3 comments

Cotel commented

Probably there is a way for doing this but I don't see it clearly.

I'm testing the multistack component in my project and eveytime I perform openStack a fragment enter animation is performed (except the first time I open a stack, which doesn't trigger any animation).

I'd like to remove that animation or use one of my own.

Currently, the openStack method will use the same animation as a regular "replace" transition, which will default to this open/exit pair: android.R.attr.activityOpenEnterAnimation and android.R.attr.activityOpenExitAnimation.

If you create a theme that replaces these attrs with other valid animation resources and set that theme on your Activity, that should allow you to change the animation.

However, this would change all "replace" animations within that Activity, so I don't think it's quite ideal. I am currently looking into adding a property to the multistack controller to allow setting of a custom animation here. I'll likely release this soon-ish (either tonight or tomorrow night).

Hello again, I've just released a new version of Enro (1.2.5), which will enable you to set animations for the MultistackController.

Previously, you would have set up your MultistackController like this:

val multistackController by multistackController(
    MultistackContainer(R.id.stackOne, StackOneRootKey()), 
    MultistackContainer(R.id.stackTwo, StackTwoRootKey())
)

I have updated the multistackController to work as a DSL builder, so set up now would look like this if you wanted to add a custom openStackAnimation:

val multistackController by multistackController {
    container(R.id.stackOne, StackOneRootKey()) 
    container(R.id.stackTwo, StackTwoRootKey())

    openStackAnimation(android.R.anim.fade_in)
} 

If you don't set an openStackAnimation, the default "REPLACE" animation will continue to be used.