blob: c7ac1a6377dbd9d63354383a93fb9567a64e594c (
plain) (
blame)
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
|
import SwiftUI
struct ContentView: View {
@EnvironmentObject var manager: BooruManager
@State private var selectedTabIndex: Int = 0
@State private var tabs = [
"Posts",
"Bookmarks",
]
var body: some View {
#if os(macOS)
NavigationSplitView {
List(selection: $selectedTabIndex) {
ForEach(Array(tabs.enumerated()), id: \.offset) { index, element in
NavigationLink(value: index) {
Text(element)
}
}
}
} content: {
if selectedTabIndex == 1 {
BookmarksView(selectedTab: $selectedTabIndex)
} else {
PostGridView()
}
} detail: {
if let post = manager.selectedPost {
PostDetailsView(post: post)
} else {
Text("Select a Post")
.foregroundColor(.secondary)
}
}
#else
NavigationStack {
PostGridView()
}
#endif
}
}
#Preview {
ContentView()
.environmentObject(Settings())
}
|