johnpatrickmorgan / TCACoordinators

Powerful navigation in the Composable Architecture via the coordinator pattern
MIT License
439 stars 42 forks source link

Support Custom transition #48

Closed toanbv-fabbi closed 1 year ago

toanbv-fabbi commented 1 year ago

Hi guy I want to make custom transition "flipHorizontal" like UIKit: guard let vc = storyboard?.instantiateViewController(identifier: "SecondViewController") else { return } vc.modalTransitionStyle = .flipHorizontal vc.modalPresentationStyle = .currentContext show(vc, sender: self) How can I make that transition with your library?

johnpatrickmorgan commented 1 year ago

Hi @toanbv-fabbi, thanks for raising this issue. I'm afraid this library does not offer a solution for that, because SwiftUI does not currently provide a way to customise the modal transition when presenting a sheet or a full-screen cover. To achieve a custom transition you might want to explore showing the view manually instead (e.g. see https://blog.devgenius.io/swiftui-different-ways-to-present-modal-views-26472947a800), but that's outside this library's scope.

toanbv-fabbi commented 1 year ago

@johnpatrickmorgan We can use UIKit to customise the modal transition. You can check this library

https://github.com/SwiftUIX/Coordinator

`class MyViewCoordinator: UIViewControllerCoordinator { override func transition(for route: MyRoute) -> ViewTransition { switch route { case .foo: return .present(Text("Foo")) case .bar: return .custom { guard let rootViewController = self.rootViewController else { return assertionFailure() }

                // Use `rootViewController` to perform a custom transition.
                rootViewController.present(
                    UIViewController(),
                    animated: true,
                    completion: { }
                )
            }
    }
}

}`