Skip to content

Commit cc61044

Browse files
committed
WIP
1 parent ad6feff commit cc61044

File tree

3 files changed

+173
-167
lines changed

3 files changed

+173
-167
lines changed

Examples/Showcase/Showcase.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
D5B864EA2E72CE71002F5243 /* List.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B864E92E72CE71002F5243 /* List.swift */; };
1515
D5B864EC2E72D9E1002F5243 /* Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B864EB2E72D9E1002F5243 /* Navigation.swift */; };
1616
D5B864EE2E72DB42002F5243 /* Presentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B864ED2E72DB42002F5243 /* Presentation.swift */; };
17+
D5B864F02E72DC75002F5243 /* Controls.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B864EF2E72DC75002F5243 /* Controls.swift */; };
1718
D5E3180329C132B6005847DC /* SwiftUIIntrospect in Frameworks */ = {isa = PBXBuildFile; productRef = D5E3180229C132B6005847DC /* SwiftUIIntrospect */; };
1819
/* End PBXBuildFile section */
1920

@@ -27,6 +28,7 @@
2728
D5B864E92E72CE71002F5243 /* List.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = List.swift; sourceTree = "<group>"; };
2829
D5B864EB2E72D9E1002F5243 /* Navigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Navigation.swift; sourceTree = "<group>"; };
2930
D5B864ED2E72DB42002F5243 /* Presentation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Presentation.swift; sourceTree = "<group>"; };
31+
D5B864EF2E72DC75002F5243 /* Controls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Controls.swift; sourceTree = "<group>"; };
3032
/* End PBXFileReference section */
3133

3234
/* Begin PBXFrameworksBuildPhase section */
@@ -68,6 +70,7 @@
6870
D5B864E72E72BF0F002F5243 /* ScrollView.swift */,
6971
D5B864EB2E72D9E1002F5243 /* Navigation.swift */,
7072
D5B864ED2E72DB42002F5243 /* Presentation.swift */,
73+
D5B864EF2E72DC75002F5243 /* Controls.swift */,
7174
D5B829742999738200920EBD /* Helpers.swift */,
7275
);
7376
path = Showcase;
@@ -156,6 +159,7 @@
156159
D5B864E82E72BF0F002F5243 /* ScrollView.swift in Sources */,
157160
D5B829752999738200920EBD /* Helpers.swift in Sources */,
158161
D5B864EC2E72D9E1002F5243 /* Navigation.swift in Sources */,
162+
D5B864F02E72DC75002F5243 /* Controls.swift in Sources */,
159163
D5B864EA2E72CE71002F5243 /* List.swift in Sources */,
160164
D53071F729983CEF00F1936C /* App.swift in Sources */,
161165
);

Examples/Showcase/Showcase/AppView.swift

Lines changed: 0 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -123,173 +123,6 @@ struct UIViewRepresentableShowcase: View {
123123
}
124124
}
125125

126-
struct ControlsShowcase: View {
127-
128-
@State private var textFieldValue = ""
129-
@State private var toggleValue = false
130-
@State private var sliderValue = 0.0
131-
@State private var datePickerValue = Date()
132-
@State private var segmentedControlValue = 0
133-
134-
var body: some View {
135-
VStack {
136-
HStack {
137-
TextField("Text Field Red", text: $textFieldValue)
138-
#if os(iOS) || os(tvOS) || os(visionOS)
139-
.introspect(
140-
.textField,
141-
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
142-
) { textField in
143-
textField.backgroundColor = .red
144-
}
145-
#elseif os(macOS)
146-
.introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { textField in
147-
textField.backgroundColor = .red
148-
}
149-
#endif
150-
151-
TextField("Text Field Green", text: $textFieldValue)
152-
.cornerRadius(8)
153-
#if os(iOS) || os(tvOS) || os(visionOS)
154-
.introspect(
155-
.textField,
156-
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
157-
) { textField in
158-
textField.backgroundColor = .green
159-
}
160-
#elseif os(macOS)
161-
.introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { textField in
162-
textField.backgroundColor = .green
163-
}
164-
#endif
165-
}
166-
167-
#if !os(tvOS)
168-
#if !os(visionOS)
169-
HStack {
170-
Toggle("Toggle Red", isOn: $toggleValue)
171-
#if os(iOS)
172-
.introspect(
173-
.toggle,
174-
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)
175-
) { toggle in
176-
toggle.backgroundColor = .red
177-
}
178-
#elseif os(macOS)
179-
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { toggle in
180-
toggle.layer?.backgroundColor = NSColor.red.cgColor
181-
}
182-
#endif
183-
184-
Toggle("Toggle Green", isOn: $toggleValue)
185-
#if os(iOS)
186-
.introspect(
187-
.toggle,
188-
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)
189-
) { toggle in
190-
toggle.backgroundColor = .green
191-
}
192-
#elseif os(macOS)
193-
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { toggle in
194-
toggle.layer?.backgroundColor = NSColor.green.cgColor
195-
}
196-
#endif
197-
}
198-
199-
HStack {
200-
Slider(value: $sliderValue, in: 0...100)
201-
#if os(iOS)
202-
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { slider in
203-
slider.backgroundColor = .red
204-
}
205-
#elseif os(macOS)
206-
.introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { slider in
207-
slider.layer?.backgroundColor = NSColor.red.cgColor
208-
}
209-
#endif
210-
211-
Slider(value: $sliderValue, in: 0...100)
212-
#if os(iOS)
213-
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { slider in
214-
slider.backgroundColor = .green
215-
}
216-
#elseif os(macOS)
217-
.introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { slider in
218-
slider.layer?.backgroundColor = NSColor.green.cgColor
219-
}
220-
#endif
221-
}
222-
223-
HStack {
224-
Stepper(onIncrement: {}, onDecrement: {}) {
225-
Text("Stepper Red")
226-
}
227-
#if os(iOS)
228-
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { stepper in
229-
stepper.backgroundColor = .red
230-
}
231-
#elseif os(macOS)
232-
.introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { stepper in
233-
stepper.layer?.backgroundColor = NSColor.red.cgColor
234-
}
235-
#endif
236-
237-
Stepper(onIncrement: {}, onDecrement: {}) {
238-
Text("Stepper Green")
239-
}
240-
#if os(iOS)
241-
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { stepper in
242-
stepper.backgroundColor = .green
243-
}
244-
#elseif os(macOS)
245-
.introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { stepper in
246-
stepper.layer?.backgroundColor = NSColor.green.cgColor
247-
}
248-
#endif
249-
}
250-
#endif
251-
252-
HStack {
253-
DatePicker(selection: $datePickerValue) {
254-
Text("DatePicker Red")
255-
}
256-
#if os(iOS) || os(visionOS)
257-
.introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)) { datePicker in
258-
datePicker.backgroundColor = .red
259-
}
260-
#elseif os(macOS)
261-
.introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { datePicker in
262-
datePicker.layer?.backgroundColor = NSColor.red.cgColor
263-
}
264-
#endif
265-
}
266-
#endif
267-
268-
HStack {
269-
Picker(selection: $segmentedControlValue, label: Text("Segmented control")) {
270-
Text("Option 1").tag(0)
271-
Text("Option 2").tag(1)
272-
Text("Option 3").tag(2)
273-
}
274-
.pickerStyle(SegmentedPickerStyle())
275-
#if os(iOS) || os(tvOS) || os(visionOS)
276-
.introspect(
277-
.picker(style: .segmented),
278-
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
279-
) { datePicker in
280-
datePicker.backgroundColor = .red
281-
}
282-
#elseif os(macOS)
283-
.introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { datePicker in
284-
datePicker.layer?.backgroundColor = NSColor.red.cgColor
285-
}
286-
#endif
287-
}
288-
}
289-
290-
}
291-
}
292-
293126
struct ContentView_Previews: PreviewProvider {
294127
static var previews: some View {
295128
ContentView()
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
import SwiftUI
2+
import SwiftUIIntrospect
3+
4+
struct ControlsShowcase: View {
5+
6+
@State private var textFieldValue = ""
7+
@State private var toggleValue = false
8+
@State private var sliderValue = 0.0
9+
@State private var datePickerValue = Date()
10+
@State private var segmentedControlValue = 0
11+
12+
var body: some View {
13+
VStack {
14+
HStack {
15+
TextField("Text Field Red", text: $textFieldValue)
16+
#if os(iOS) || os(tvOS) || os(visionOS)
17+
.introspect(
18+
.textField,
19+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
20+
) { textField in
21+
textField.backgroundColor = .red
22+
}
23+
#elseif os(macOS)
24+
.introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { textField in
25+
textField.backgroundColor = .red
26+
}
27+
#endif
28+
29+
TextField("Text Field Green", text: $textFieldValue)
30+
.cornerRadius(8)
31+
#if os(iOS) || os(tvOS) || os(visionOS)
32+
.introspect(
33+
.textField,
34+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
35+
) { textField in
36+
textField.backgroundColor = .green
37+
}
38+
#elseif os(macOS)
39+
.introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { textField in
40+
textField.backgroundColor = .green
41+
}
42+
#endif
43+
}
44+
45+
#if !os(tvOS)
46+
#if !os(visionOS)
47+
HStack {
48+
Toggle("Toggle Red", isOn: $toggleValue)
49+
#if os(iOS)
50+
.introspect(
51+
.toggle,
52+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)
53+
) { toggle in
54+
toggle.backgroundColor = .red
55+
}
56+
#elseif os(macOS)
57+
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { toggle in
58+
toggle.layer?.backgroundColor = NSColor.red.cgColor
59+
}
60+
#endif
61+
62+
Toggle("Toggle Green", isOn: $toggleValue)
63+
#if os(iOS)
64+
.introspect(
65+
.toggle,
66+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)
67+
) { toggle in
68+
toggle.backgroundColor = .green
69+
}
70+
#elseif os(macOS)
71+
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { toggle in
72+
toggle.layer?.backgroundColor = NSColor.green.cgColor
73+
}
74+
#endif
75+
}
76+
77+
HStack {
78+
Slider(value: $sliderValue, in: 0...100)
79+
#if os(iOS)
80+
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { slider in
81+
slider.backgroundColor = .red
82+
}
83+
#elseif os(macOS)
84+
.introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { slider in
85+
slider.layer?.backgroundColor = NSColor.red.cgColor
86+
}
87+
#endif
88+
89+
Slider(value: $sliderValue, in: 0...100)
90+
#if os(iOS)
91+
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { slider in
92+
slider.backgroundColor = .green
93+
}
94+
#elseif os(macOS)
95+
.introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { slider in
96+
slider.layer?.backgroundColor = NSColor.green.cgColor
97+
}
98+
#endif
99+
}
100+
101+
HStack {
102+
Stepper(onIncrement: {}, onDecrement: {}) {
103+
Text("Stepper Red")
104+
}
105+
#if os(iOS)
106+
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { stepper in
107+
stepper.backgroundColor = .red
108+
}
109+
#elseif os(macOS)
110+
.introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { stepper in
111+
stepper.layer?.backgroundColor = NSColor.red.cgColor
112+
}
113+
#endif
114+
115+
Stepper(onIncrement: {}, onDecrement: {}) {
116+
Text("Stepper Green")
117+
}
118+
#if os(iOS)
119+
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26)) { stepper in
120+
stepper.backgroundColor = .green
121+
}
122+
#elseif os(macOS)
123+
.introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { stepper in
124+
stepper.layer?.backgroundColor = NSColor.green.cgColor
125+
}
126+
#endif
127+
}
128+
#endif
129+
130+
HStack {
131+
DatePicker(selection: $datePickerValue) {
132+
Text("DatePicker Red")
133+
}
134+
#if os(iOS) || os(visionOS)
135+
.introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)) { datePicker in
136+
datePicker.backgroundColor = .red
137+
}
138+
#elseif os(macOS)
139+
.introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { datePicker in
140+
datePicker.layer?.backgroundColor = NSColor.red.cgColor
141+
}
142+
#endif
143+
}
144+
#endif
145+
146+
HStack {
147+
Picker(selection: $segmentedControlValue, label: Text("Segmented control")) {
148+
Text("Option 1").tag(0)
149+
Text("Option 2").tag(1)
150+
Text("Option 3").tag(2)
151+
}
152+
.pickerStyle(SegmentedPickerStyle())
153+
#if os(iOS) || os(tvOS) || os(visionOS)
154+
.introspect(
155+
.picker(style: .segmented),
156+
on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .visionOS(.v1, .v2, .v26)
157+
) { datePicker in
158+
datePicker.backgroundColor = .red
159+
}
160+
#elseif os(macOS)
161+
.introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26)) { datePicker in
162+
datePicker.layer?.backgroundColor = NSColor.red.cgColor
163+
}
164+
#endif
165+
}
166+
}
167+
168+
}
169+
}

0 commit comments

Comments
 (0)