Reportage/Views/RootView.swift (1203B)
1import SwiftUI
2
3
4struct RootView: View {
5 @Environment(PromptInbox.self) private var inbox: PromptInbox?
6 @State private var tab = DemoSeed.screen == .charts ? RootTab.charts : .timeline
7 @State private var isWelcoming = false
8
9 var body: some View {
10 TabView(selection: $tab) {
11 Tab("Timeline", systemImage: "calendar", value: RootTab.timeline) {
12 HomeView()
13 }
14 Tab("Charts", systemImage: "chart.bar", value: RootTab.charts) {
15 ChartsView()
16 }
17 Tab("Settings", systemImage: "gearshape", value: RootTab.settings) {
18 SettingsView()
19 }
20 }
21
22 .onChange(of: inbox?.survey?.id, initial: true) {
23 if inbox?.survey != nil { tab = .timeline }
24 }
25 .task { isWelcoming = DemoSeed.isActive ? false : await FirstLaunch.isNeeded() }
26 .fullScreenCover(isPresented: $isWelcoming) {
27 WelcomeView { isWelcoming = false }
28 }
29 }
30}
31
32enum RootTab: Hashable {
33 case timeline
34 case charts
35 case settings
36}