Skip to content

Commit 3f25cc5

Browse files
committed
Adjust UI
1 parent ddbfece commit 3f25cc5

6 files changed

Lines changed: 114 additions & 131 deletions

File tree

Core/Sources/HostApp/AccountSettings/CodeiumView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import CodeiumService
22
import Foundation
3+
import SharedUIComponents
34
import SwiftUI
45

56
struct CodeiumView: View {
@@ -220,7 +221,7 @@ struct CodeiumView: View {
220221
.stroke(Color(nsColor: .separatorColor), style: .init(lineWidth: 1))
221222
}
222223

223-
Divider()
224+
SettingsDivider("Advanced")
224225

225226
Form {
226227
Toggle("Verbose Log", isOn: $viewModel.codeiumVerboseLog)

Core/Sources/HostApp/AccountSettings/GitHubCopilotView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ struct GitHubCopilotView: View {
270270
.stroke(Color(nsColor: .separatorColor), style: .init(lineWidth: 1))
271271
}
272272

273-
Divider()
273+
SettingsDivider("Advanced")
274274

275275
Form {
276276
Toggle(
@@ -287,7 +287,7 @@ struct GitHubCopilotView: View {
287287
Toggle("Verbose Log", isOn: $settings.gitHubCopilotVerboseLog)
288288
}
289289

290-
Divider()
290+
SettingsDivider("Proxy")
291291

292292
Form {
293293
TextField(

Core/Sources/HostApp/FeatureSettings/ChatSettingsView.swift

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ struct ChatSettingsView: View {
1414
@AppStorage(\.chatGPTMaxMessageCount) var chatGPTMaxMessageCount
1515
@AppStorage(\.chatFontSize) var chatFontSize
1616
@AppStorage(\.chatCodeFontSize) var chatCodeFontSize
17-
@AppStorage(\.maxFocusedCodeLineCount)
18-
var maxFocusedCodeLineCount
17+
1918
@AppStorage(\.defaultChatFeatureChatModelId) var defaultChatFeatureChatModelId
2019
@AppStorage(\.defaultChatSystemPrompt) var defaultChatSystemPrompt
2120
@AppStorage(\.chatSearchPluginMaxIterations) var chatSearchPluginMaxIterations
@@ -37,8 +36,6 @@ struct ChatSettingsView: View {
3736
chatSettingsForm
3837
SettingsDivider("UI")
3938
uiForm
40-
SettingsDivider("Context")
41-
contextForm
4239
SettingsDivider("Plugin")
4340
pluginForm
4441
ScopeForm()
@@ -171,24 +168,6 @@ struct ChatSettingsView: View {
171168
}
172169
}
173170

174-
@ViewBuilder
175-
var contextForm: some View {
176-
Form {
177-
HStack {
178-
TextField(text: .init(get: {
179-
"\(Int(settings.maxFocusedCodeLineCount))"
180-
}, set: {
181-
settings.maxFocusedCodeLineCount = Int($0) ?? 0
182-
})) {
183-
Text("Max focused code line count in chat context")
184-
}
185-
.textFieldStyle(.roundedBorder)
186-
187-
Text("lines")
188-
}
189-
}
190-
}
191-
192171
@ViewBuilder
193172
var pluginForm: some View {
194173
Form {
@@ -255,6 +234,8 @@ struct ChatSettingsView: View {
255234
@AppStorage(\.preferredChatModelIdForWebScope)
256235
var preferredChatModelIdForWebScope: String
257236
@AppStorage(\.chatModels) var chatModels
237+
@AppStorage(\.maxFocusedCodeLineCount)
238+
var maxFocusedCodeLineCount
258239

259240
init() {}
260241
}
@@ -282,6 +263,19 @@ struct ChatSettingsView: View {
282263
Toggle(isOn: $settings.enableCodeScopeByDefaultInChatContext) {
283264
Text("Enable @code scope by default in chat context.")
284265
}
266+
267+
HStack {
268+
TextField(text: .init(get: {
269+
"\(Int(settings.maxFocusedCodeLineCount))"
270+
}, set: {
271+
settings.maxFocusedCodeLineCount = Int($0) ?? 0
272+
})) {
273+
Text("Max focused code")
274+
}
275+
.textFieldStyle(.roundedBorder)
276+
277+
Text("lines")
278+
}
285279
}
286280
}
287281

@@ -322,7 +316,6 @@ struct ChatSettingsView: View {
322316
}
323317
}
324318
}
325-
.padding(.top, 20)
326319
}
327320

328321
Scope(
@@ -334,7 +327,7 @@ struct ChatSettingsView: View {
334327
Toggle(isOn: $settings.enableProjectScopeByDefaultInChatContext) {
335328
Text("Enable @project scope by default in chat context.")
336329
}
337-
330+
338331
Picker(
339332
"Preferred Chat Model",
340333
selection: $settings.preferredChatModelIdForProjectScope
@@ -372,7 +365,7 @@ struct ChatSettingsView: View {
372365
Toggle(isOn: $settings.enableWebScopeByDefaultInChatContext) {
373366
Text("Enable @web scope by default in chat context.")
374367
}
375-
368+
376369
Picker(
377370
"Preferred Chat Model",
378371
selection: $settings.preferredChatModelIdForWebScope
@@ -412,15 +405,13 @@ struct ChatSettingsView: View {
412405
Text(description)
413406
.multilineTextAlignment(.center)
414407
.foregroundStyle(.secondary)
408+
.frame(maxWidth: .infinity)
415409
.padding(8)
416410
.background {
417411
RoundedRectangle(cornerRadius: 8)
418412
.fill(Color.secondary.opacity(0.1))
419413
}
420-
.frame(maxWidth: 500)
421-
Form {
422-
content()
423-
}
414+
content()
424415
}
425416
}
426417
}

Core/Sources/HostApp/FeatureSettings/PromptToCodeSettingsView.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import SharedUIComponents
12
import SwiftUI
23

34
struct PromptToCodeSettingsView: View {
@@ -30,7 +31,7 @@ struct PromptToCodeSettingsView: View {
3031
selection: $settings.promptToCodeChatModelId
3132
) {
3233
Text("Same as Chat Feature").tag("")
33-
34+
3435
if !settings.chatModels
3536
.contains(where: { $0.id == settings.promptToCodeChatModelId }),
3637
!settings.promptToCodeChatModelId.isEmpty
@@ -52,7 +53,7 @@ struct PromptToCodeSettingsView: View {
5253
selection: $settings.promptToCodeEmbeddingModelId
5354
) {
5455
Text("Same as Chat Feature").tag("")
55-
56+
5657
if !settings.embeddingModels
5758
.contains(where: { $0.id == settings.promptToCodeEmbeddingModelId }),
5859
!settings.promptToCodeEmbeddingModelId.isEmpty
@@ -78,16 +79,7 @@ struct PromptToCodeSettingsView: View {
7879
}
7980
}
8081

81-
Divider()
82-
83-
Text("Mirroring Settings of Suggestion Feature")
84-
.foregroundColor(.white)
85-
.padding(.vertical, 2)
86-
.padding(.horizontal, 8)
87-
.background(
88-
Color.accentColor,
89-
in: RoundedRectangle(cornerRadius: 20)
90-
)
82+
SettingsDivider("Mirroring Settings of Suggestion Feature")
9183

9284
Form {
9385
Toggle(isOn: $settings.hideCommonPrecedingSpacesInSuggestion) {

Core/Sources/HostApp/FeatureSettings/SuggestionSettingsView.swift

Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Preferences
2+
import SharedUIComponents
23
import SwiftUI
34

45
#if canImport(ProHostApp)
@@ -36,112 +37,109 @@ struct SuggestionSettingsView: View {
3637

3738
var body: some View {
3839
Form {
39-
Group {
40-
Picker(selection: $settings.suggestionPresentationMode) {
41-
ForEach(PresentationMode.allCases, id: \.rawValue) {
42-
switch $0 {
43-
case .nearbyTextCursor:
44-
Text("Nearby Text Cursor").tag($0)
45-
case .floatingWidget:
46-
Text("Floating Widget").tag($0)
47-
}
40+
Picker(selection: $settings.suggestionPresentationMode) {
41+
ForEach(PresentationMode.allCases, id: \.rawValue) {
42+
switch $0 {
43+
case .nearbyTextCursor:
44+
Text("Nearby Text Cursor").tag($0)
45+
case .floatingWidget:
46+
Text("Floating Widget").tag($0)
4847
}
49-
} label: {
50-
Text("Presentation")
5148
}
49+
} label: {
50+
Text("Presentation")
51+
}
5252

53-
Picker(selection: $settings.suggestionFeatureProvider) {
54-
ForEach(SuggestionFeatureProvider.allCases, id: \.rawValue) {
55-
switch $0 {
56-
case .gitHubCopilot:
57-
Text("GitHub Copilot").tag($0)
58-
case .codeium:
59-
Text("Codeium").tag($0)
60-
}
53+
Picker(selection: $settings.suggestionFeatureProvider) {
54+
ForEach(SuggestionFeatureProvider.allCases, id: \.rawValue) {
55+
switch $0 {
56+
case .gitHubCopilot:
57+
Text("GitHub Copilot").tag($0)
58+
case .codeium:
59+
Text("Codeium").tag($0)
6160
}
62-
} label: {
63-
Text("Feature Provider")
6461
}
62+
} label: {
63+
Text("Feature Provider")
64+
}
6565

66-
Toggle(isOn: $settings.realtimeSuggestionToggle) {
67-
Text("Real-time Suggestion")
68-
}
66+
Toggle(isOn: $settings.realtimeSuggestionToggle) {
67+
Text("Real-time Suggestion")
68+
}
6969

70-
#if canImport(ProHostApp)
71-
WithFeatureEnabled(\.tabToAcceptSuggestion) {
72-
Toggle(isOn: $settings.acceptSuggestionWithTab) {
73-
Text("Accept Suggestion with Tab")
74-
}
70+
#if canImport(ProHostApp)
71+
WithFeatureEnabled(\.tabToAcceptSuggestion) {
72+
Toggle(isOn: $settings.acceptSuggestionWithTab) {
73+
Text("Accept Suggestion with Tab")
7574
}
76-
#endif
77-
78-
HStack {
79-
Toggle(isOn: $settings.disableSuggestionFeatureGlobally) {
80-
Text("Disable Suggestion Feature Globally")
81-
}
75+
}
76+
#endif
8277

83-
Button("Exception List") {
84-
isSuggestionFeatureEnabledListPickerOpen = true
85-
}
86-
}.sheet(isPresented: $isSuggestionFeatureEnabledListPickerOpen) {
87-
SuggestionFeatureEnabledProjectListView(
88-
isOpen: $isSuggestionFeatureEnabledListPickerOpen
89-
)
78+
HStack {
79+
Toggle(isOn: $settings.disableSuggestionFeatureGlobally) {
80+
Text("Disable Suggestion Feature Globally")
9081
}
9182

92-
HStack {
93-
Button("Disabled Language List") {
94-
isSuggestionFeatureDisabledLanguageListViewOpen = true
95-
}
96-
}.sheet(isPresented: $isSuggestionFeatureDisabledLanguageListViewOpen) {
97-
SuggestionFeatureDisabledLanguageListView(
98-
isOpen: $isSuggestionFeatureDisabledLanguageListViewOpen
99-
)
83+
Button("Exception List") {
84+
isSuggestionFeatureEnabledListPickerOpen = true
10085
}
86+
}.sheet(isPresented: $isSuggestionFeatureEnabledListPickerOpen) {
87+
SuggestionFeatureEnabledProjectListView(
88+
isOpen: $isSuggestionFeatureEnabledListPickerOpen
89+
)
90+
}
10191

102-
HStack {
103-
Slider(value: $settings.realtimeSuggestionDebounce, in: 0...2, step: 0.1) {
104-
Text("Real-time Suggestion Debounce")
105-
}
92+
HStack {
93+
Button("Disabled Language List") {
94+
isSuggestionFeatureDisabledLanguageListViewOpen = true
95+
}
96+
}.sheet(isPresented: $isSuggestionFeatureDisabledLanguageListViewOpen) {
97+
SuggestionFeatureDisabledLanguageListView(
98+
isOpen: $isSuggestionFeatureDisabledLanguageListViewOpen
99+
)
100+
}
106101

107-
Text(
108-
"\(settings.realtimeSuggestionDebounce.formatted(.number.precision(.fractionLength(2))))s"
109-
)
110-
.font(.body)
111-
.monospacedDigit()
112-
.padding(.vertical, 2)
113-
.padding(.horizontal, 6)
114-
.background(
115-
RoundedRectangle(cornerRadius: 4, style: .continuous)
116-
.fill(Color.primary.opacity(0.1))
117-
)
102+
HStack {
103+
Slider(value: $settings.realtimeSuggestionDebounce, in: 0...2, step: 0.1) {
104+
Text("Real-time Suggestion Debounce")
118105
}
119106

120-
Divider()
107+
Text(
108+
"\(settings.realtimeSuggestionDebounce.formatted(.number.precision(.fractionLength(2))))s"
109+
)
110+
.font(.body)
111+
.monospacedDigit()
112+
.padding(.vertical, 2)
113+
.padding(.horizontal, 6)
114+
.background(
115+
RoundedRectangle(cornerRadius: 4, style: .continuous)
116+
.fill(Color.primary.opacity(0.1))
117+
)
121118
}
119+
}
122120

123-
Group {
124-
Toggle(isOn: $settings.suggestionDisplayCompactMode) {
125-
Text("Hide Buttons")
126-
}
121+
SettingsDivider("UI")
127122

128-
Toggle(isOn: $settings.hideCommonPrecedingSpacesInSuggestion) {
129-
Text("Hide Common Preceding Spaces")
130-
}
123+
Form {
124+
Toggle(isOn: $settings.suggestionDisplayCompactMode) {
125+
Text("Hide Buttons")
126+
}
131127

132-
HStack {
133-
TextField(text: .init(get: {
134-
"\(Int(settings.suggestionCodeFontSize))"
135-
}, set: {
136-
settings.suggestionCodeFontSize = Double(Int($0) ?? 0)
137-
})) {
138-
Text("Font size of suggestion code")
139-
}
140-
.textFieldStyle(.roundedBorder)
128+
Toggle(isOn: $settings.hideCommonPrecedingSpacesInSuggestion) {
129+
Text("Hide Common Preceding Spaces")
130+
}
141131

142-
Text("pt")
132+
HStack {
133+
TextField(text: .init(get: {
134+
"\(Int(settings.suggestionCodeFontSize))"
135+
}, set: {
136+
settings.suggestionCodeFontSize = Double(Int($0) ?? 0)
137+
})) {
138+
Text("Font size of suggestion code")
143139
}
144-
Divider()
140+
.textFieldStyle(.roundedBorder)
141+
142+
Text("pt")
145143
}
146144
}
147145
}

0 commit comments

Comments
 (0)