Same thing here. In my situation, I have a
WelcomeView in which you can click either "Login" or "Register". Clicking the latter will open the
RegisterView and after a successful login I want to show the "DashboardView". I have all the views setup separately, but it's not that clear to me yet how to glue everything together.
My initial thinking was to show the
WelcomeView on app start and make the
WelcomeView automatically forward to the
DashboardView in case the user is signed in. The
DashboardView should also be shown if the user signs in via
LoginView or right after app start if the user is already signed in. But after reading @piupiu's answer, I feel like I'd need to put the entire "first screen" logic into the
AppState somehow on a top level.
As a beginner with TCA, I find the Case Studies not very clear/guided, their names are quite abstract and while there's a description for each, it's not clear to me at all which of the case studies applies in my situation:
- Do I need to "Pullback and Combine" something (and what exactly?) to get this working?
- Do I need to use "Optional State" for each possible initial screen?
- Do I need to use "Shared State" to pass login information back to a parent screen?
While I think I might figure it out by trying things out and understanding things better, I feel like the learning curve could be much flatter if there was a case study explicitly mentioning one or multiple ways to do authentication, which is one of the most common cases in app development.
The "TicTacToe" example is cheating here and isn't very helpful although it technically has a login flow, because it neither has a register screen, nor does it automatically sign in if user is signed in already on app start. And it also kind of cheats with navigation because it's using sheets, which is quite uncommon for signed in state. A much more realistic example should be added to the Case Studies IMHO.