@@ -21,15 +21,64 @@ public struct SpotLightControl: View {
21
21
orientation: spotLight. orientation,
22
22
outerAngleInDegrees: spotLight. light. outerAngleInDegrees
23
23
)
24
- ) { SpotLight ( ) }
24
+ ) {
25
+ SpotLight ( )
26
+ }
25
27
}
26
28
27
29
public var body : some View {
28
30
Form {
29
- //MARK: - Light Component
31
+ LightComponentControl ( store: store)
32
+ . onChange ( of: store. attenuationRadius) { _, newValue in
33
+ spotLight. light. attenuationRadius = newValue
34
+ }
35
+ . onChange ( of: store. color) { _, newValue in
36
+ spotLight. light. color = UIColor ( newValue)
37
+ }
38
+ . onChange ( of: store. intensity) { _, newValue in
39
+ spotLight. light. intensity = Float ( newValue. lux)
40
+ }
41
+ . onChange ( of: store. innerAngleInDegrees) { _, newValue in
42
+ spotLight. light. innerAngleInDegrees = newValue
43
+ }
30
44
45
+ OrientationControl ( store: store)
46
+ . onChange ( of: store. orientation) { _, newValue in
47
+ spotLight. orientation = newValue
48
+ }
49
+ . onChange ( of: store. outerAngleInDegrees) { _, newValue in
50
+ spotLight. light. outerAngleInDegrees = newValue
51
+ }
52
+ }
53
+ . toolbar {
54
+ ToolbarItem {
55
+ Toggle (
56
+ " Enabled " ,
57
+ systemImage: " power.circle " ,
58
+ isOn: $store. isEnabled
59
+ )
60
+ }
61
+ }
62
+ . onChange ( of: store. isEnabled) { _, newValue in
63
+ spotLight. isEnabled = newValue
64
+ }
65
+ }
66
+ }
67
+
68
+ #Preview {
69
+ SpotLightControl ( light: . init( ) )
70
+ }
71
+
72
+ //MARK: - Light Component
73
+
74
+ extension SpotLightControl {
75
+ struct LightComponentControl : View {
76
+ @Bindable var store : StoreOf < SpotLight >
77
+
78
+ var body : some View {
31
79
Section ( " Light Component " ) {
32
80
ColorPicker ( " Color " , selection: $store. color)
81
+ . accessibilityHint ( " Sets the LightComponent color attribute. " )
33
82
34
83
Picker (
35
84
" Lux Preset " ,
@@ -44,8 +93,11 @@ public struct SpotLightControl: View {
44
93
}
45
94
}
46
95
. pickerStyle ( MenuPickerStyle ( ) )
96
+ . accessibilityHint ( " Sets the intensity of light from a list of common lux settings. " )
47
97
48
98
Text ( " Attenuation Radius: \( store. attenuationRadius, format: . number) " )
99
+ . accessibilityHidden ( true )
100
+
49
101
Slider (
50
102
value: $store. attenuationRadius,
51
103
in: 0 ... 10 ,
@@ -62,8 +114,13 @@ public struct SpotLightControl: View {
62
114
. foregroundColor ( . secondary)
63
115
}
64
116
)
117
+ . accessibilityHint (
118
+ " Defines light reach and calculates its falloff. Can greatly affect performance, so it should be used sparingly. "
119
+ )
65
120
66
121
Text ( " Inner Angle: \( store. innerAngleInDegrees, format: . number) " )
122
+ . accessibilityHidden ( true )
123
+
67
124
Slider (
68
125
value: $store. innerAngleInDegrees,
69
126
in: 0 ... 360 ,
@@ -75,13 +132,18 @@ public struct SpotLightControl: View {
75
132
. foregroundColor ( . secondary)
76
133
} ,
77
134
maximumValueLabel: {
78
- Text ( " 10º " )
135
+ Text ( " 360º " )
79
136
. font ( . caption)
80
137
. foregroundColor ( . secondary)
81
138
}
82
139
)
140
+ . accessibilityHint (
141
+ " Defines the angle of the cone that emits light at full intensity, in degrees "
142
+ )
83
143
84
144
Text ( " Outer Angle: \( store. outerAngleInDegrees, format: . number) " )
145
+ . accessibilityHidden ( true )
146
+
85
147
Slider (
86
148
value: $store. outerAngleInDegrees,
87
149
in: 0 ... 360 ,
@@ -93,32 +155,32 @@ public struct SpotLightControl: View {
93
155
. foregroundColor ( . secondary)
94
156
} ,
95
157
maximumValueLabel: {
96
- Text ( " 10º " )
158
+ Text ( " 360º " )
97
159
. font ( . caption)
98
160
. foregroundColor ( . secondary)
99
161
}
100
162
)
163
+ . accessibilityHint (
164
+ " Defines the angle of the cone beyond which the light's intensity is zero, in degrees "
165
+ )
101
166
}
102
- . onChange ( of: store. attenuationRadius) { _, newValue in
103
- spotLight. light. attenuationRadius = newValue
104
- }
105
- . onChange ( of: store. color) { _, newValue in
106
- spotLight. light. color = UIColor ( newValue)
107
- }
108
- . onChange ( of: store. intensity) { _, newValue in
109
- spotLight. light. intensity = Float ( newValue. lux)
110
- }
111
- . onChange ( of: store. innerAngleInDegrees) { _, newValue in
112
- spotLight. light. innerAngleInDegrees = newValue
113
- }
167
+ }
168
+ }
169
+ }
170
+
171
+ //MARK: - Orientation
114
172
115
- //MARK: - Orientation
173
+ extension SpotLightControl {
174
+ struct OrientationControl : View {
175
+ @Bindable var store : StoreOf < SpotLight >
116
176
177
+ var body : some View {
117
178
Section ( " Orientation " ) {
118
179
Stepper (
119
180
" Rotation X: \( store. rotationX. degrees. formatted ( ) ) " ,
120
181
value: $store. rotationX. degrees
121
182
)
183
+ . accessibilityHidden ( true )
122
184
123
185
//FIXME: use propper formatters
124
186
Slider (
@@ -130,18 +192,21 @@ public struct SpotLightControl: View {
130
192
Text ( " \( Int ( store. rotationRange. lowerBound) ) º " )
131
193
. font ( . caption)
132
194
. foregroundColor ( . secondary)
195
+ . accessibilityHidden ( true )
133
196
} ,
134
197
maximumValueLabel: {
135
198
Text ( " \( Int ( store. rotationRange. upperBound) ) º " )
136
199
. font ( . caption)
137
200
. foregroundColor ( . secondary)
201
+ . accessibilityHidden ( true )
138
202
}
139
203
)
140
204
141
205
Stepper (
142
206
" Rotation Y: \( store. rotationY. degrees. formatted ( ) ) " ,
143
207
value: $store. rotationY. degrees
144
208
)
209
+ . accessibilityHidden ( true )
145
210
146
211
Slider (
147
212
value: $store. rotationY. degrees,
@@ -152,36 +217,16 @@ public struct SpotLightControl: View {
152
217
Text ( " \( Int ( store. rotationRange. lowerBound) ) º " )
153
218
. font ( . caption)
154
219
. foregroundColor ( . secondary)
220
+ . accessibilityHidden ( true )
155
221
} ,
156
222
maximumValueLabel: {
157
223
Text ( " \( Int ( store. rotationRange. upperBound) ) º " )
158
224
. font ( . caption)
159
225
. foregroundColor ( . secondary)
226
+ . accessibilityHidden ( true )
160
227
}
161
228
)
162
229
}
163
- . onChange ( of: store. orientation) { _, newValue in
164
- spotLight. orientation = newValue
165
- }
166
- . onChange ( of: store. outerAngleInDegrees) { _, newValue in
167
- spotLight. light. outerAngleInDegrees = newValue
168
- }
169
- }
170
- . toolbar {
171
- ToolbarItem {
172
- Toggle (
173
- " Enabled " ,
174
- systemImage: " power.circle " ,
175
- isOn: $store. isEnabled
176
- )
177
- }
178
- }
179
- . onChange ( of: store. isEnabled) { _, newValue in
180
- spotLight. isEnabled = newValue
181
230
}
182
231
}
183
232
}
184
-
185
- #Preview {
186
- SpotLightControl ( light: . init( ) )
187
- }
0 commit comments