Skip to content

Animate transition between view controllersΒ #58

@ranhsd

Description

@ranhsd

Hi,
I am currently trying to refctor my app from MVVM to ReSwift. One of the things that i adopt is the ReSwiftRouter. The router allows me to navigate from one screen to another (either by push view controller into a navigation controller or by present it modally) .

I also consider to use Hero for animate transition between view controllers.
Hero created some extension to UIViewController which allows you to send a view controller there and animationType and then it will automatically animate the transition between both view controllers.
Now I wanted to know where is the best place to add this transition code? What i did now is to add it to the routable via the following lines of code:

` Hero.shared.setDefaultAnimationForNextTransition(.zoom)
Hero.shared.setContainerColorForNextTransition(.lightGray)

    let navigationController = UINavigationController.init(rootViewController: viewController)
    self.viewController.hero_replaceViewController(with: navigationController)
    
    return SignUpRoute(viewController)`

I am not sure that this is the best place or not to put the code.

What i was thinking is maybe to write an extension to Routable that will receive the source view controller and the destination view controller and animation type and this function will execute the animation.

Wanted to know what do you think or maybe there is a better solution?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions