-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
AccountsScreen.swift
94 lines (89 loc) · 2.47 KB
/
AccountsScreen.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
91
92
93
94
import SwiftUI
import Settings
/**
Function wrapping SwiftUI into `SettingsPane`, which is mimicking view controller's default construction syntax.
*/
let AccountsSettingsViewController: () -> SettingsPane = {
/**
Wrap your custom view into `Settings.Pane`, while providing necessary toolbar info.
*/
let paneView = Settings.Pane(
identifier: .accounts,
title: "Accounts",
toolbarIcon: NSImage(systemSymbolName: "person.crop.circle", accessibilityDescription: "Accounts settings")!
) {
AccountsScreen()
}
return Settings.PaneHostingController(pane: paneView)
}
/**
The main view of “Accounts” settings pane.
*/
struct AccountsScreen: View {
@State private var isOn1 = true
@State private var isOn2 = false
@State private var isOn3 = true
@State private var selection1 = 1
@State private var selection2 = 0
@State private var selection3 = 0
@State private var isExpanded = false
private let contentWidth: Double = 450.0
var body: some View {
Settings.Container(contentWidth: contentWidth) {
Settings.Section(title: "Permissions:") {
Toggle("Allow user to administer this computer", isOn: $isOn1)
Text("Administrator has root access to this machine.")
.settingDescription()
Toggle("Allow user to access every file", isOn: $isOn2)
}
Settings.Section(title: "Show scroll bars:") {
Picker("", selection: $selection1) {
Text("When scrolling").tag(0)
Text("Always").tag(1)
}
.labelsHidden()
.pickerStyle(.radioGroup)
}
Settings.Section(label: {
Toggle("Some toggle", isOn: $isOn3)
}) {
Picker("", selection: $selection2) {
Text("Automatic").tag(0)
Text("Manual").tag(1)
}
.labelsHidden()
.frame(width: 120.0)
Text("Automatic mode can slow things down.")
.settingDescription()
}
Settings.Section(title: "Preview mode:") {
Picker("", selection: $selection3) {
Text("Automatic").tag(0)
Text("Manual").tag(1)
}
.labelsHidden()
.frame(width: 120.0)
Text("Automatic mode can slow things down.")
.settingDescription()
}
Settings.Section(title: "Expand this pane:") {
Toggle("Expand", isOn: $isExpanded)
if isExpanded {
ZStack(alignment: .center) {
Rectangle()
.fill(.gray)
.frame(width: 200, height: 200)
.cornerRadius(20)
Text("🦄")
.frame(width: 180, height: 180)
}
}
}
}
}
}
struct AccountsScreen_Previews: PreviewProvider {
static var previews: some View {
AccountsScreen()
}
}