Initial project setup - Phases 1-3 complete
This commit is contained in:
55
UI/Compose/CURLImportView.swift
Normal file
55
UI/Compose/CURLImportView.swift
Normal file
@@ -0,0 +1,55 @@
|
||||
import SwiftUI
|
||||
import ProxyCore
|
||||
|
||||
struct CURLImportView: View {
|
||||
let onImport: (ParsedCURLRequest) -> Void
|
||||
|
||||
@State private var curlText = ""
|
||||
@State private var errorMessage: String?
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
Text("Paste a cURL command to import as a request.")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
|
||||
TextEditor(text: $curlText)
|
||||
.font(.system(.caption, design: .monospaced))
|
||||
.frame(minHeight: 200)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
.stroke(Color(.systemGray4))
|
||||
)
|
||||
|
||||
if let errorMessage {
|
||||
Text(errorMessage)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
|
||||
Button("Import") {
|
||||
if let parsed = CURLParser.parse(curlText) {
|
||||
onImport(parsed)
|
||||
} else {
|
||||
errorMessage = "Invalid cURL command. Make sure it starts with 'curl'."
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.buttonStyle(.borderedProminent)
|
||||
.disabled(curlText.isEmpty)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
.navigationTitle("Import cURL")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button("Cancel") { dismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user