Skip to content

Commit 2d88933

Browse files
committed
Add settings
1 parent e9d3f5e commit 2d88933

1 file changed

Lines changed: 45 additions & 36 deletions

File tree

Copilot for Xcode/SettingsView.swift

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ struct SettingsView: View {
2626
var promptToCodeFeatureProvider: PromptToCodeFeatureProvider
2727
@AppStorage(\.preferWidgetToStayInsideEditorWhenWidthGreaterThan)
2828
var preferWidgetToStayInsideEditorWhenWidthGreaterThan: Double
29+
@AppStorage(\.hideCommonPrecedingSpacesInSuggestion)
30+
var hideCommonPrecedingSpacesInSuggestion: Bool
2931
init() {}
3032
}
3133

@@ -94,50 +96,57 @@ struct SettingsView: View {
9496
}
9597
}
9698

97-
Toggle(isOn: $settings.realtimeSuggestionToggle) {
98-
Text("Real-time suggestion")
99-
}
100-
.toggleStyle(.switch)
101-
102-
HStack {
103-
Toggle(isOn: $settings.disableSuggestionFeatureGlobally) {
104-
Text("Disable suggestion feature globally")
99+
Group {
100+
Toggle(isOn: $settings.realtimeSuggestionToggle) {
101+
Text("Real-time suggestion")
105102
}
106103
.toggleStyle(.switch)
107104

108-
Button("Enabled Projects") {
109-
isSuggestionFeatureEnabledListPickerOpen = true
105+
HStack {
106+
Toggle(isOn: $settings.disableSuggestionFeatureGlobally) {
107+
Text("Disable suggestion feature globally")
108+
}
109+
.toggleStyle(.switch)
110+
111+
Button("Enabled Projects") {
112+
isSuggestionFeatureEnabledListPickerOpen = true
113+
}
114+
}.sheet(isPresented: $isSuggestionFeatureEnabledListPickerOpen) {
115+
SuggestionFeatureEnabledProjectListView(
116+
isOpen: $isSuggestionFeatureEnabledListPickerOpen
117+
)
110118
}
111-
}.sheet(isPresented: $isSuggestionFeatureEnabledListPickerOpen) {
112-
SuggestionFeatureEnabledProjectListView(
113-
isOpen: $isSuggestionFeatureEnabledListPickerOpen
114-
)
115-
}
116119

117-
HStack {
118-
Slider(value: $editingRealtimeSuggestionDebounce, in: 0...2, step: 0.1) {
119-
Text("Real-time suggestion fetch debounce")
120-
} onEditingChanged: { _ in
121-
settings.realtimeSuggestionDebounce = editingRealtimeSuggestionDebounce
120+
HStack {
121+
Slider(value: $editingRealtimeSuggestionDebounce, in: 0...2, step: 0.1) {
122+
Text("Real-time suggestion fetch debounce")
123+
} onEditingChanged: { _ in
124+
settings.realtimeSuggestionDebounce = editingRealtimeSuggestionDebounce
125+
}
126+
127+
Text(
128+
"\(editingRealtimeSuggestionDebounce.formatted(.number.precision(.fractionLength(2))))s"
129+
)
130+
.font(.body)
131+
.monospacedDigit()
132+
.padding(.vertical, 2)
133+
.padding(.horizontal, 6)
134+
.background(
135+
RoundedRectangle(cornerRadius: 4, style: .continuous)
136+
.fill(Color.white.opacity(0.2))
137+
)
122138
}
123139

124-
Text(
125-
"\(editingRealtimeSuggestionDebounce.formatted(.number.precision(.fractionLength(2))))s"
126-
)
127-
.font(.body)
128-
.monospacedDigit()
129-
.padding(.vertical, 2)
130-
.padding(.horizontal, 6)
131-
.background(
132-
RoundedRectangle(cornerRadius: 4, style: .continuous)
133-
.fill(Color.white.opacity(0.2))
134-
)
135-
}
140+
Toggle(isOn: $settings.hideCommonPrecedingSpacesInSuggestion) {
141+
Text("Hide Common Preceding Spaces in Suggestion")
142+
}
143+
.toggleStyle(.switch)
136144

137-
Toggle(isOn: $settings.acceptSuggestionWithAccessibilityAPI) {
138-
Text("Use accessibility API to accept suggestion in widget")
145+
Toggle(isOn: $settings.acceptSuggestionWithAccessibilityAPI) {
146+
Text("Use accessibility API to accept suggestion in widget")
147+
}
148+
.toggleStyle(.switch)
139149
}
140-
.toggleStyle(.switch)
141150

142151
Picker(selection: $settings.promptToCodeFeatureProvider) {
143152
ForEach(PromptToCodeFeatureProvider.allCases, id: \.rawValue) {
@@ -163,7 +172,7 @@ struct SettingsView: View {
163172
Text("Prefer widget to be inside editor when width greater than")
164173
}
165174
.textFieldStyle(.roundedBorder)
166-
175+
167176
Text("px")
168177
}
169178
}

0 commit comments

Comments
 (0)