@@ -146,7 +146,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
146
146
present ( at: initialIndex, promise: nil , animated: initialIndexAnimated)
147
147
}
148
148
149
- onMount ? ( nil )
149
+ dispatchEvent ( name : " onMount " , data : nil )
150
150
}
151
151
}
152
152
@@ -174,19 +174,19 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
174
174
175
175
func viewControllerDidChangeWidth( _ width: CGFloat ) {
176
176
// We only pass width to JS since height is handled by the constraints
177
- onContainerSizeChange ? ( [ " width " : width] )
177
+ dispatchEvent ( name : " onContainerSizeChange " , data : [ " width " : width] )
178
178
}
179
179
180
180
func viewControllerDidDrag( _ state: UIGestureRecognizer . State , _ height: CGFloat ) {
181
181
let sizeInfo = SizeInfo ( index: activeIndex ?? 0 , value: height)
182
182
183
183
switch state {
184
184
case . began:
185
- eventDispatcher ? . send ( TrueSheetEvent ( viewTag : reactTag , name: " onDragBegin " , data: sizeInfoData ( from: sizeInfo) ) )
185
+ dispatchEvent ( name: " onDragBegin " , data: sizeInfoData ( from: sizeInfo) )
186
186
case . changed:
187
- eventDispatcher ? . send ( TrueSheetEvent ( viewTag : reactTag , name: " onDragChange " , data: sizeInfoData ( from: sizeInfo) ) )
187
+ dispatchEvent ( name: " onDragChange " , data: sizeInfoData ( from: sizeInfo) )
188
188
case . ended, . cancelled:
189
- eventDispatcher ? . send ( TrueSheetEvent ( viewTag : reactTag , name: " onDragEnd " , data: sizeInfoData ( from: sizeInfo) ) )
189
+ dispatchEvent ( name: " onDragEnd " , data: sizeInfoData ( from: sizeInfo) )
190
190
default :
191
191
Logger . info ( " Drag state is not supported " )
192
192
}
@@ -199,16 +199,15 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
199
199
func viewControllerDidDismiss( ) {
200
200
isPresented = false
201
201
activeIndex = nil
202
-
203
- onDismiss ? ( nil )
202
+ dispatchEvent ( name: " onDismiss " , data: nil )
204
203
}
205
204
206
205
func viewControllerDidChangeSize( _ sizeInfo: SizeInfo ? ) {
207
206
guard let sizeInfo else { return }
208
207
209
208
if sizeInfo. index != activeIndex {
210
209
activeIndex = sizeInfo. index
211
- onSizeChange ? ( sizeInfoData ( from: sizeInfo) )
210
+ dispatchEvent ( name : " onSizeChange " , data : sizeInfoData ( from: sizeInfo) )
212
211
}
213
212
}
214
213
@@ -389,6 +388,10 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
389
388
}
390
389
}
391
390
391
+ func dispatchEvent( name: String , data: [ String : Any ] ? ) {
392
+ eventDispatcher? . send ( TrueSheetEvent ( viewTag: reactTag, name: name, data: data) )
393
+ }
394
+
392
395
func dismiss( promise: Promise ) {
393
396
guard isPresented else {
394
397
promise. resolve ( nil )
@@ -429,7 +432,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate {
429
432
}
430
433
431
434
let data = self . sizeInfoData ( from: self . viewController. currentSizeInfo)
432
- self . onPresent ? ( data)
435
+ self . dispatchEvent ( name : " onPresent " , data : data)
433
436
promise? . resolve ( nil )
434
437
}
435
438
}
0 commit comments