Closed iosYash closed 1 year ago
Hi Jimmy,
I am using 1.x package manager of UIPilot. I don’t want to use UIKit.
Thanks.
On 22-Dec-2022, at 7:56 PM, Jimmy Sanghani @.***> wrote:
Navigation Controller is not designed for such requirements, I think you should present the controller if you want to control the animation part.
If you really want to hack, you should be able to do it by forking library and adding this code in NavigationControllerHost.
private func addTransition(nav: UINavigationController, transitionType type: CATransitionType = .fade, duration: CFTimeInterval = 0.6) { let transition = CATransition() transition.duration = duration transition.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut) transition.type = type nav.view.layer.add(transition, forKey: nil) }
and then call this function before pushing or popping the view controller. For example
uipilot.onPush = { route in addTransition(nav: navigation) navigation.pushViewController( UIHostingController(rootView: routeMap(route)), animated: false ) }
— Reply to this email directly, view it on GitHub https://github.com/canopas/UIPilot/issues/40#issuecomment-1362901786, or unsubscribe https://github.com/notifications/unsubscribe-auth/A36RRK3OYN4WFUTXDLOCDKLWORQHVANCNFSM6AAAAAATGQFLGA. You are receiving this because you authored the thread.
Hello Jimmy,
Greetings!!
Apart from animation, I am facing one issue with pilot is like
I want to jump to dashboard screen if user is already logged in so how can I decide initial screen in UIPilot(initial: “/dashboard”) or UIPilot(initial: “/signin”) ?
Can you guide me here?
Thanks, Yash Patel
On 22-Dec-2022, at 7:56 PM, Jimmy Sanghani @.***> wrote:
Navigation Controller is not designed for such requirements, I think you should present the controller if you want to control the animation part.
If you really want to hack, you should be able to do it by forking library and adding this code in NavigationControllerHost.
private func addTransition(nav: UINavigationController, transitionType type: CATransitionType = .fade, duration: CFTimeInterval = 0.6) { let transition = CATransition() transition.duration = duration transition.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut) transition.type = type nav.view.layer.add(transition, forKey: nil) }
and then call this function before pushing or popping the view controller. For example
uipilot.onPush = { route in addTransition(nav: navigation) navigation.pushViewController( UIHostingController(rootView: routeMap(route)), animated: false ) }
— Reply to this email directly, view it on GitHub https://github.com/canopas/UIPilot/issues/40#issuecomment-1362901786, or unsubscribe https://github.com/notifications/unsubscribe-auth/A36RRK3OYN4WFUTXDLOCDKLWORQHVANCNFSM6AAAAAATGQFLGA. You are receiving this because you authored the thread.
@jimmy0251 Any update on above question?
@iosYash If you consider HomeRoutes
as your route and it has all screens like below case
enum HomeRoutes: Equatable {
case homeView
case signIn
case screenA
case screenB
}
Then you can get the behaviour you asked like below
struct AppRouteView: View {
private let pilot: UIPilot<HomeRoutes>
init() {
let auth = AuthManager()
pilot = .init(initial: auth.isLoggedIn ? .homeView : .signIn)
}
var body: some View {
}
}
in this if use is loggedIn then pilot initialised with homeView other wise with signIn view
Fixed
Navigation Controller is not designed for such requirements, I think you should present the controller if you want to control the animation part.
If you really want to hack, you should be able to do it by forking library and adding this code in
NavigationControllerHost
.and then call this function before pushing or popping the view controller. For example