Skip to content

Commit eba3d73

Browse files
committed
rework settings layout for inline tables
1 parent 5d37030 commit eba3d73

File tree

1 file changed

+52
-64
lines changed

1 file changed

+52
-64
lines changed

AllSpark-ios/SettingsView.swift

Lines changed: 52 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct SettingsView: View {
55
@AppStorage("videoFormat") private var videoFormat: String = "mp4"
66
@AppStorage("verifyCertificate") private var verifyCertificate: Bool = true
77
@AppStorage("deviceName") private var deviceName: String = ""
8-
@State private var displayText: String = "Ready."
8+
@State private var displayText: String = "Ready to test."
99

1010
init() {
1111
// Set default deviceName from UIDevice if not already set
@@ -16,83 +16,71 @@ struct SettingsView: View {
1616
}
1717

1818
var body: some View {
19-
VStack(alignment: .center) {
19+
VStack(spacing: 0) {
2020
Text("Client Settings")
2121
.font(.largeTitle)
2222
.padding(.top, 20)
23+
.padding(.bottom, 10)
24+
25+
Form {
26+
Section(header: Text("Device")) {
27+
HStack {
28+
Text("Device Name")
29+
Spacer()
30+
TextField("Device Name", text: $deviceName)
31+
.multilineTextAlignment(.trailing)
32+
.autocapitalization(.words)
33+
.textInputAutocapitalization(.words)
34+
}
2335

24-
Spacer()
25-
26-
Text("Device Name")
27-
.font(.headline)
28-
.padding(.top, 10)
36+
Picker("Video Format", selection: $videoFormat) {
37+
Text("MP4").tag("mp4")
38+
Text("MOV").tag("mov")
39+
}
40+
}
2941

30-
TextField("Device Name", text: $deviceName)
31-
.textFieldStyle(RoundedBorderTextFieldStyle())
32-
.frame(maxWidth: 300)
33-
.multilineTextAlignment(.center)
34-
.padding()
35-
.autocapitalization(.words)
36-
.textInputAutocapitalization(.words)
42+
Section(header: Text("Server")) {
43+
HStack {
44+
Text("Server Host")
45+
Spacer()
46+
TextField("Server Host", text: $serverHost)
47+
.multilineTextAlignment(.trailing)
48+
.keyboardType(.URL)
49+
.autocapitalization(.none)
50+
.textInputAutocapitalization(.never)
51+
}
3752

38-
Text("Video Format")
39-
.font(.headline)
40-
.padding(.top, 20)
53+
Toggle("Verify SSL Certificate", isOn: $verifyCertificate)
54+
}
4155

42-
Picker("Video Format", selection: $videoFormat) {
43-
Text("MP4").tag("mp4")
44-
Text("MOV").tag("mov")
45-
}
46-
.pickerStyle(.segmented)
47-
.frame(maxWidth: 300)
48-
.padding()
49-
50-
Text("Server Host")
51-
.font(.headline)
52-
.padding(.top, 10)
53-
54-
TextField("Server Host", text: $serverHost)
55-
.textFieldStyle(RoundedBorderTextFieldStyle())
56-
.frame(maxWidth: 300)
57-
.multilineTextAlignment(.center)
58-
.padding()
59-
.keyboardType(.URL)
60-
.autocapitalization(.none)
61-
.textInputAutocapitalization(.never)
62-
63-
Toggle("Verify SSL Certificate", isOn: $verifyCertificate)
64-
.frame(maxWidth: 300)
65-
.padding()
66-
67-
Button(action: {
68-
testHTTPConnection()
69-
}) {
70-
Text("Test HTTP Connection")
71-
}
72-
.padding()
56+
Section(header: Text("Actions")) {
57+
Button("Test HTTP Connection") {
58+
testHTTPConnection()
59+
}
7360

74-
Button(action: {
75-
testWebSocketConnection()
76-
}) {
77-
Text("Test WS Connection")
78-
}
79-
.padding()
61+
Button("Test WS Connection") {
62+
testWebSocketConnection()
63+
}
8064

81-
Button(action: {
82-
openAppSettings()
83-
}) {
84-
Text("App Settings")
65+
Button("App Settings") {
66+
openAppSettings()
67+
}
68+
}
8569
}
86-
.padding()
8770

88-
Spacer()
71+
Divider()
8972

90-
Text(displayText)
91-
.font(.title)
92-
.padding()
73+
ScrollView {
74+
Text(displayText)
75+
.font(.body)
76+
.padding()
77+
.frame(maxWidth: .infinity, alignment: .leading)
78+
}
79+
.frame(maxHeight: 200)
80+
.background(Color(UIColor.secondarySystemBackground))
9381
}
9482
.frame(maxWidth: .infinity, maxHeight: .infinity)
95-
.background(Color.gray.opacity(0.2))
83+
.background(Color(UIColor.systemGroupedBackground))
9684
}
9785

9886
private func testHTTPConnection() {

0 commit comments

Comments
 (0)