-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentView.swift
66 lines (60 loc) · 1.39 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
import SwiftUI
enum NavigationCategory: View {
case rules, shared, change, appended
var body: some View {
switch self {
case .rules:
PasswordRules()
case .shared:
SharedCredentials()
case .change:
ChangePasswordURLs()
case .appended:
Appended2FA()
}
}
}
struct ContentView: View {
@State private var visibility: NavigationSplitViewVisibility = .all
@State private var navigationCategory: NavigationCategory?
var body: some View {
#if os(tvOS)
NavigationStack {
PasswordRules()
.background {
HomeBackground()
}
}
#else
NavigationSplitView(columnVisibility: $visibility) {
HomeSidebar(selection: $navigationCategory)
#if os(iOS) || os(macOS)
.listStyle(.sidebar)
#endif
} content: {
if let navigationCategory {
navigationCategory
.navigationSplitViewColumnWidth(min: 320, ideal: 640)
}
} detail: {
Text("")
.accessibilityHidden(true)
.navigationSplitViewColumnWidth(min: navigationCategory == .rules ? 320 : 0,
ideal: navigationCategory == .rules ? 320 : 0,
max: navigationCategory == .rules ? 480 : 0)
}
#if os(macOS)
.frame(minWidth: 320 + 320 + (navigationCategory == .rules ? 320 : 0))
#endif
#endif
}
}
#if os(macOS)
#Preview(traits: .fixedLayout(width: 960, height: 640)) {
ContentView()
}
#else
#Preview {
ContentView()
}
#endif