-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentView.swift
47 lines (42 loc) · 1.62 KB
/
ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import SwiftUI
extension Notification.Name {
static let onboardingCompleted = Notification.Name("onboardingCompleted")
}
struct ContentView: View {
// MARK: - Variables for HomeView
@StateObject var homeViewModel = HomeViewModel()
@State private var hasShownOnboarding: Bool = UserDefaults.standard.bool(forKey: "hasShownOnboarding")
var body: some View {
VStack {
if hasShownOnboarding {
UITabBarWrapper([
TabBarElement(tabBarElementItem: .init(title: "Home", systemImageName: "house.fill")) {
HomeView()
},
TabBarElement(tabBarElementItem: .init(title: "Chat", systemImageName: "chat.fill")) {
ChatbotView()
},
TabBarElement(tabBarElementItem: .init(title: "Schedule", systemImageName: "calendar")) {
ScheduleView()
},
TabBarElement(tabBarElementItem: .init(title: "Insights", systemImageName: "waveform.path.ecg.rectangle.fill")) {
InsightsView()
}
])
} else {
OnboardingView()
}
}
.onAppear {
hasShownOnboarding = UserDefaults.standard.bool(forKey: "hasShownOnboarding")
}
.onReceive(NotificationCenter.default.publisher(for: .onboardingCompleted)) { _ in
hasShownOnboarding = true
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}