@@ -85,7 +85,7 @@ class Element : NSObject {
8585 if ReactNativeSupport . isReactNativeApp {
8686 let className = NSStringFromClass ( type ( of: view) )
8787 switch className {
88- case " RCTScrollView " , " RCTScrollViewComponentView " :
88+ case " RCTScrollView " , " RCTScrollViewComponentView " , " RCTEnhancedScrollView " :
8989 return ( view. value ( forKey: " scrollView " ) as! UIScrollView )
9090 default :
9191 break
@@ -189,23 +189,34 @@ class Element : NSObject {
189189 }
190190
191191 func adjust( toDate date: Date ) {
192- if let view = view as? UIDatePicker {
193- view. dtx_adjust ( to: date)
194- } else {
195- dtx_fatalError ( " View “ \( view. dtx_shortDescription) ” is not an instance of “UIDatePicker” " , viewDescription: debugAttributes)
196- }
192+ var didSetPicker = false
193+
194+ view. dtx_ifDatePicker { view in
195+ view. dtx_adjust ( to: date)
196+ didSetPicker = true
197+ }
198+
199+ guard didSetPicker else {
200+ dtx_fatalError ( " View “ \( view. dtx_shortDescription) ” is not an instance of “UIDatePicker” " , viewDescription: debugAttributes)
201+ }
202+
197203 }
198204
199205 func setComponent( _ component: Int , toValue value: Any ) {
200- if let view = view as? UIPickerView {
201- view. dtx_setComponent ( component, toValue: value)
202- } else {
203- dtx_fatalError ( " View “ \( view. dtx_shortDescription) ” is not an instance of “UIPickerView” " , viewDescription: debugAttributes)
204- }
206+ var didSetPicker = false
207+
208+ view. dtx_ifPicker { view in
209+ view. dtx_setComponent ( component, toValue: value)
210+ didSetPicker = true
211+ }
212+
213+ guard didSetPicker else {
214+ dtx_fatalError ( " View “ \( view. dtx_shortDescription) ” is not an instance of “UIPickerView” " , viewDescription: debugAttributes)
215+ }
205216 }
206217
207218 func adjust( toNormalizedSliderPosition normalizedSliderPosition: Double ) {
208- guard let slider = view as? UISlider else {
219+ guard let slider = view. dtx_sliderView else {
209220 dtx_fatalError ( " View \( view. dtx_shortDescription) is not instance of “UISlider” " , viewDescription: debugAttributes)
210221 }
211222
@@ -267,17 +278,34 @@ class Element : NSObject {
267278 return view. accessibilityValue
268279 }
269280
270- @objc
271- var normalizedSliderPosition : Double {
272- get {
273- guard let slider = view as? UISlider else {
274- dtx_fatalError ( " View \( view. dtx_shortDescription) is not instance of “UISlider” " , viewDescription: debugAttributes)
275- }
276-
277- return slider. dtx_normalizedSliderPosition
278- }
279- }
280-
281+ @objc
282+ var normalizedSliderPosition : Double {
283+ get {
284+ if let slider = view. dtx_sliderView {
285+ return slider. dtx_normalizedSliderPosition
286+ }
287+
288+ dtx_fatalError (
289+ " View \( view. dtx_shortDescription) is not instance or wrapper of “UISlider” " ,
290+ viewDescription: debugAttributes
291+ )
292+ }
293+ }
294+
295+ @objc
296+ var toggleValue : Double {
297+ get {
298+ if let toggle = view. dtx_switchView {
299+ return toggle. isOn ? 1.0 : 0.0
300+ }
301+
302+ dtx_fatalError (
303+ " View \( view. dtx_shortDescription) is not instance or wrapper of “UISwitch” " ,
304+ viewDescription: debugAttributes
305+ )
306+ }
307+ }
308+
281309 @objc
282310 var attributes : [ String : Any ] {
283311 let views = self . views
0 commit comments