-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentView.swift
More file actions
128 lines (110 loc) · 3.8 KB
/
Copy pathContentView.swift
File metadata and controls
128 lines (110 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import SwiftUI
struct ContentView: View {
@StateObject private var proxy = SocketZeroProxy()
var body: some View {
VStack(spacing: 20) {
Image(systemName: "network")
.font(.system(size: 60))
.foregroundColor(.blue)
Text("SocketZero Proxy")
.font(.title)
.bold()
Text("localhost:\(proxy.port)")
.font(.headline)
.foregroundColor(.secondary)
StatusView(status: proxy.status)
if proxy.isRunning {
VStack(alignment: .leading, spacing: 10) {
Text("Configure iOS Proxy:")
.font(.headline)
Text("Settings → Wi-Fi → (i) → Configure Proxy")
.font(.caption)
HStack {
VStack(alignment: .leading) {
Text("Server:")
Text("Port:")
}
.foregroundColor(.secondary)
VStack(alignment: .leading) {
Text("127.0.0.1")
Text("\(proxy.port)")
}
.bold()
}
.padding()
.background(Color.gray.opacity(0.1))
.cornerRadius(8)
}
.padding()
Button(action: { proxy.stop() }) {
Text("Stop Proxy")
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.padding()
.background(Color.red)
.cornerRadius(10)
}
.padding(.horizontal)
} else {
Button(action: { proxy.start() }) {
Text("Start Proxy")
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.padding()
.background(Color.blue)
.cornerRadius(10)
}
.padding(.horizontal)
}
Spacer()
// Connection log
ScrollView {
VStack(alignment: .leading, spacing: 4) {
ForEach(proxy.logs, id: \.self) { log in
Text(log)
.font(.system(size: 10, design: .monospaced))
.foregroundColor(.secondary)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
}
.frame(height: 150)
.background(Color.black.opacity(0.05))
}
.padding()
}
}
struct StatusView: View {
let status: ProxyStatus
var body: some View {
HStack {
Circle()
.fill(status.color)
.frame(width: 12, height: 12)
Text(status.rawValue)
.font(.subheadline)
}
.padding(.vertical, 8)
.padding(.horizontal, 16)
.background(status.color.opacity(0.1))
.cornerRadius(20)
}
}
enum ProxyStatus: String {
case stopped = "Stopped"
case starting = "Starting..."
case running = "Running"
case error = "Error"
var color: Color {
switch self {
case .stopped: return .gray
case .starting: return .orange
case .running: return .green
case .error: return .red
}
}
}
#Preview {
ContentView()
}