Skip to content

Commit 7a2597d

Browse files
authored
Merge pull request #29 from owenrumney/feat/add-advanced-tab
feat: Add advanced tab
2 parents b473cee + db76bad commit 7a2597d

File tree

1 file changed

+89
-72
lines changed

1 file changed

+89
-72
lines changed

pullBar/Views/PreferencesView.swift

+89-72
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,91 @@ import KeychainAccess
1111
import LaunchAtLogin
1212

1313
struct PreferencesView: View {
14-
14+
1515
@Default(.githubApiBaseUrl) var githubApiBaseUrl
1616
@Default(.githubUsername) var githubUsername
1717
@Default(.githubAdditionalQuery) var githubAdditionalQuery
1818
@FromKeychain(.githubToken) var githubToken
19-
19+
2020
@Default(.showAssigned) var showAssigned
2121
@Default(.showCreated) var showCreated
2222
@Default(.showRequested) var showRequested
23-
23+
2424
@Default(.showAvatar) var showAvatar
2525
@Default(.showLabels) var showLabels
26-
26+
2727
@Default(.refreshRate) var refreshRate
2828
@Default(.buildType) var builtType
2929
@Default(.counterType) var counterType
30-
30+
3131
@State private var showGhAlert = false
3232

33+
@State private var selectedTab: Int = 1
34+
3335
@StateObject private var githubTokenValidator = GithubTokenValidator()
3436
@ObservedObject private var launchAtLogin = LaunchAtLogin.observable
3537

38+
@State private var isExpanded: Bool = false
39+
3640
var body: some View {
37-
38-
TabView {
41+
42+
TabView (selection: $selectedTab) {
43+
Form {
44+
HStack(alignment: .center) {
45+
Text("Pull Requests:").frame(width: 120, alignment: .trailing)
46+
VStack(alignment: .leading){
47+
Toggle("assigned", isOn: $showAssigned)
48+
Toggle("created", isOn: $showCreated)
49+
Toggle("review requested", isOn: $showRequested)
50+
}
51+
}
52+
53+
HStack(alignment: .center) {
54+
Text("Build Information:").frame(width: 120, alignment: .trailing)
55+
Picker("", selection: $builtType, content: {
56+
ForEach(BuildType.allCases) { bt in
57+
Text(bt.description)
58+
}
59+
})
60+
.labelsHidden()
61+
.pickerStyle(RadioGroupPickerStyle())
62+
.frame(width: 120)
63+
}
64+
65+
HStack(alignment: .center) {
66+
Text("Show Avatar:").frame(width: 120, alignment: .trailing)
67+
Toggle("", isOn: $showAvatar)
68+
}
69+
70+
HStack(alignment: .center) {
71+
Text("Show Labels:").frame(width: 120, alignment: .trailing)
72+
Toggle("", isOn: $showLabels)
73+
}
74+
75+
HStack(alignment: .center) {
76+
Text("Refresh Rate:").frame(width: 120, alignment: .trailing)
77+
Picker("", selection: $refreshRate, content: {
78+
Text("1 minute").tag(1)
79+
Text("5 minutes").tag(5)
80+
Text("10 minutes").tag(10)
81+
Text("15 minutes").tag(15)
82+
Text("30 minutes").tag(30)
83+
}).labelsHidden()
84+
.pickerStyle(MenuPickerStyle())
85+
.frame(width: 100)
86+
}
87+
88+
HStack(alignment: .center) {
89+
Text("Launch at login:").frame(width: 120, alignment: .trailing)
90+
Toggle("", isOn: $launchAtLogin.isEnabled)
91+
92+
}
93+
94+
}
95+
.padding(8)
96+
.frame(maxWidth: .infinity)
97+
.tabItem{Text("General")}
98+
3999
Form {
40100
HStack(alignment: .center) {
41101
Text("API Base URL:").frame(width: 120, alignment: .trailing)
@@ -53,14 +113,7 @@ struct PreferencesView: View {
53113
.textContentType(.password)
54114
.frame(width: 200)
55115
}
56-
HStack(alignment: .center) {
57-
Text("Additional Query:").frame(width: 120, alignment: .trailing)
58-
TextField("", text: $githubAdditionalQuery)
59-
.textFieldStyle(RoundedBorderTextFieldStyle())
60-
.disableAutocorrection(true)
61-
.textContentType(.password)
62-
.frame(width: 380)
63-
}
116+
64117
HStack(alignment: .center) {
65118
Text("Token:").frame(width: 120, alignment: .trailing)
66119
VStack(alignment: .leading) {
@@ -96,62 +149,8 @@ struct PreferencesView: View {
96149
githubTokenValidator.validate()
97150
}
98151
.tabItem{Text("Authentication")}
99-
100-
Form {
101-
HStack(alignment: .center) {
102-
Text("Pull Requests:").frame(width: 120, alignment: .trailing)
103-
VStack(alignment: .leading){
104-
Toggle("assigned", isOn: $showAssigned)
105-
Toggle("created", isOn: $showCreated)
106-
Toggle("review requested", isOn: $showRequested)
107-
}
108-
}
109-
110-
HStack(alignment: .center) {
111-
Text("Build Information:").frame(width: 120, alignment: .trailing)
112-
Picker("", selection: $builtType, content: {
113-
ForEach(BuildType.allCases) { bt in
114-
Text(bt.description)
115-
}
116-
})
117-
.labelsHidden()
118-
.pickerStyle(RadioGroupPickerStyle())
119-
.frame(width: 120)
120-
}
121-
122-
HStack(alignment: .center) {
123-
Text("Show Avatar:").frame(width: 120, alignment: .trailing)
124-
Toggle("", isOn: $showAvatar)
125-
}
126-
127-
HStack(alignment: .center) {
128-
Text("Show Labels:").frame(width: 120, alignment: .trailing)
129-
Toggle("", isOn: $showLabels)
130-
}
131-
132-
HStack(alignment: .center) {
133-
Text("Refresh Rate:").frame(width: 120, alignment: .trailing)
134-
Picker("", selection: $refreshRate, content: {
135-
Text("1 minute").tag(1)
136-
Text("5 minutes").tag(5)
137-
Text("10 minutes").tag(10)
138-
Text("15 minutes").tag(15)
139-
Text("30 minutes").tag(30)
140-
}).labelsHidden()
141-
.pickerStyle(MenuPickerStyle())
142-
.frame(width: 100)
143-
}
144-
145-
HStack(alignment: .center) {
146-
Text("Launch at login:").frame(width: 120, alignment: .trailing)
147-
Toggle("", isOn: $launchAtLogin.isEnabled)
148-
149-
}
150-
}
151-
.padding(8)
152-
.frame(maxWidth: .infinity)
153-
.tabItem{Text("Menu")}
154-
152+
.tag(1)
153+
155154
Form {
156155
HStack(alignment: .center) {
157156
VStack(alignment: .leading) {
@@ -173,9 +172,27 @@ struct PreferencesView: View {
173172
.frame(maxWidth: .infinity)
174173
.tabItem{Text("Menubar icon")}
175174

175+
Form {
176+
HStack(alignment: .top) {
177+
Text("Additional Query:").frame(width: 120, alignment: .trailing)
178+
TextField("", text: $githubAdditionalQuery)
179+
.textFieldStyle(RoundedBorderTextFieldStyle())
180+
.disableAutocorrection(true)
181+
.textContentType(.password)
182+
.frame(width: 380)
183+
184+
}
185+
Text("See the GitHub [search documentation](https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax) for more information on advanced queries")
186+
.font(.footnote)
187+
.padding(.leading, 8)
188+
.foregroundColor(.secondary)
189+
}.padding(8)
190+
.frame(maxWidth: .infinity)
191+
.tabItem{Text("Advanced")}
192+
176193
}
177194
.padding()
178-
195+
179196
}
180197
}
181198

0 commit comments

Comments
 (0)