Skip to content

Commit f5195b7

Browse files
committed
Change TextField to TextEditor
1 parent fdbc979 commit f5195b7

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

Copilot for Xcode/CustomCommandView.swift

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,40 @@ struct EditCustomCommandView: View {
302302
.frame(width: 600)
303303
}
304304

305+
@ViewBuilder
305306
var promptTextField: some View {
306-
if #available(macOS 13.0, *) {
307-
return TextField("Prompt", text: $prompt, axis: .vertical)
307+
VStack(alignment: .leading, spacing: 4) {
308+
Text("Prompt")
309+
TextEditor(text: $prompt)
310+
.font(Font.system(.body, design: .monospaced))
311+
.padding(2)
312+
.frame(minHeight: 120)
308313
.multilineTextAlignment(.leading)
309-
.lineLimit(4, reservesSpace: true)
310-
} else {
311-
return TextField("Prompt", text: $prompt)
314+
.overlay(
315+
RoundedRectangle(cornerRadius: 1)
316+
.stroke(.black, lineWidth: 1 / 3)
317+
.opacity(0.3)
318+
)
312319
}
320+
.padding(.vertical, 4)
313321
}
314322

323+
@ViewBuilder
315324
func systemPromptTextField(title: String? = nil) -> some View {
316-
if #available(macOS 13.0, *) {
317-
return TextField(title ?? "System Prompt", text: $systemPrompt, axis: .vertical)
325+
VStack(alignment: .leading, spacing: 4) {
326+
Text(title ?? "System Prompt")
327+
TextEditor(text: $systemPrompt)
328+
.font(Font.system(.body, design: .monospaced))
329+
.padding(2)
330+
.frame(minHeight: 120)
318331
.multilineTextAlignment(.leading)
319-
.lineLimit(4, reservesSpace: true)
320-
} else {
321-
return TextField("Prompt", text: $prompt)
332+
.overlay(
333+
RoundedRectangle(cornerRadius: 1)
334+
.stroke(.black, lineWidth: 1 / 3)
335+
.opacity(0.3)
336+
)
322337
}
338+
.padding(.vertical, 4)
323339
}
324340

325341
var continuousModeToggle: some View {
@@ -355,3 +371,23 @@ struct CustomCommandView_Preview: PreviewProvider {
355371
.background(.purple)
356372
}
357373
}
374+
375+
struct EditCustomCommandView_Preview: PreviewProvider {
376+
static var previews: some View {
377+
EditCustomCommandView(
378+
editingCommand: .constant(CustomCommandView.EditingCommand(
379+
isNew: false,
380+
command: .init(
381+
name: "Explain Code",
382+
feature: .promptToCode(
383+
extraSystemPrompt: nil,
384+
prompt: "Hello",
385+
continuousMode: false
386+
)
387+
)
388+
)),
389+
settings: .init(customCommands: .init(wrappedValue: [], "CustomCommandView_Preview"))
390+
)
391+
.background(.purple)
392+
}
393+
}

0 commit comments

Comments
 (0)