I want to make a Quiz within my SwiftUI-App and I'm wondering how I can go back to the RootView (which has a TabBar) after asking several Questions.
In theory my Quiz should work like This:
- First Go to the "Game" Tab on the TabBar
- Click the on the
NavigationLink
with "Quiz" in the PrimaryView - Get Infos about the Quiz and start the Quiz in the StartQuizView
- Answer Question 1 in the QuizQuestionView
- See if Answer 1 is correct or not in the AnswerQuizView
- Answer Question2 in the QuizQuestionView
- See if Answer 2 is correct or not in the AnswerQuizView and go back to Primary View
So it should look like this:
PrimaryView -> StartQuiz -> Question1 -> Answer1 -> Question2 -> Answer2 -> PrimaryView
how can I do this - my Way is working until the Answer2 View, but I can't get back to the root view: PrimaryView
and since I work with the same views (QuestionView & AnswerView) several times but with other data I can't really understand how the NavigationStack(path: )
works...
So does it give an opportunity - where I can push a button on the Answer2-View to go back to PrimaryView ?