-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathContentView.swift
90 lines (79 loc) · 2.06 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// ContentView.swift
// Hacker News
//
// Created by Trevor Elkins on 6/20/23..
//
import SwiftUI
struct ContentView: View {
@ObservedObject var appState: AppViewModel
var body: some View {
switch appState.authState {
case .loggedIn:
TabView {
StoriesScreen(model: appState)
.tabItem {
Label("Feed", systemImage: "list.dash")
}
BookmarksScreen()
.tabItem {
Label("Bookmarks", systemImage: "book.fill")
}
SettingsScreen()
.tabItem {
Label("Settings", systemImage: "gear")
}
}
.navigationTitle("Hacker News")
case .loggedOut:
LoginScreen(appState: appState)
}
}
}
struct ContentView_LoggedOut_Previews: PreviewProvider {
static var previews: some View {
let appModel = AppViewModel()
appModel.authState = .loggedOut
return PreviewVariants {
PreviewHelpers.withNavigationView {
ContentView(appState: appModel)
}
}
}
}
struct ContentView_LoggedIn_Loading_Previews: PreviewProvider {
static var previews: some View {
let appModel = AppViewModel()
appModel.authState = .loggedIn
appModel.storiesState = .loading
return PreviewVariants {
PreviewHelpers.withNavigationView {
ContentView(appState: appModel)
}
}
}
}
struct ContentView_LoggedIn_WithPosts_Previews: PreviewProvider {
static var previews: some View {
let appModel = AppViewModel()
appModel.authState = .loggedIn
appModel.storiesState = .loaded(stories: PreviewHelpers.makeFakeStories())
return PreviewVariants {
PreviewHelpers.withNavigationView {
ContentView(appState: appModel)
}
}
}
}
struct ContentView_LoggedIn_EmptyPosts_Previews: PreviewProvider {
static var previews: some View {
let appModel = AppViewModel()
appModel.authState = .loggedIn
appModel.storiesState = .loaded(stories: [])
return PreviewVariants {
PreviewHelpers.withNavigationView {
ContentView(appState: appModel)
}
}
}
}