canopas / UIPilot

The missing typesafe SwiftUI navigation library
https://canopas.github.io/UIPilot
MIT License
309 stars 27 forks source link

Setting initial view #24

Closed cmason9 closed 2 years ago

cmason9 commented 2 years ago

I have been building a POC app with UIPilot and the library works great for me moving forwards and back in the app. My question is this: I have an authentication service set up and if the user is already logged in they should be shown to the main dashboard of the app. I have the library set up to have the initial view to be View1 for example but if the user for example kills the app and reopens it and they are still authenticated I want them to go to the dashboard view rather than View1 I have set in the initial property. Basically I dont want the initial view to always be View1.

Is there anyway of doing this?

jimmy0251 commented 2 years ago

I think you should ideally set initial view to home screen. You can add a condition in home screen "onAppear" to check if user is not authenticated and if it's not, just pop the current view and push authentication view.

jimmy0251 commented 2 years ago

Closing this now as there's no update.