fix bottom sheet
This commit is contained in:
@@ -6,7 +6,7 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate {
|
|||||||
// Views
|
// Views
|
||||||
private var sheetVc: SheetViewController?
|
private var sheetVc: SheetViewController?
|
||||||
private var innerView: UIView?
|
private var innerView: UIView?
|
||||||
private var touchHandler: RCTTouchHandler?
|
private var touchHandler: RCTSurfaceTouchHandler?
|
||||||
|
|
||||||
// Native content height observation (eliminates JS bridge round-trip)
|
// Native content height observation (eliminates JS bridge round-trip)
|
||||||
private var contentHeightObservation: NSKeyValueObservation?
|
private var contentHeightObservation: NSKeyValueObservation?
|
||||||
@@ -78,33 +78,35 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate {
|
|||||||
required init (appContext: AppContext? = nil) {
|
required init (appContext: AppContext? = nil) {
|
||||||
super.init(appContext: appContext)
|
super.init(appContext: appContext)
|
||||||
self.maxHeight = Util.getScreenHeight()
|
self.maxHeight = Util.getScreenHeight()
|
||||||
self.touchHandler = RCTTouchHandler(bridge: appContext?.reactBridge)
|
self.touchHandler = RCTSurfaceTouchHandler()
|
||||||
SheetManager.shared.add(self)
|
SheetManager.shared.add(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
self.destroy()
|
self.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't want this view to actually get added to the tree, so we'll simply store it for adding
|
override func mountChildComponentView(
|
||||||
// to the SheetViewController
|
_ childComponentView: UIView,
|
||||||
override func insertReactSubview(_ subview: UIView!, at atIndex: Int) {
|
index: Int
|
||||||
self.touchHandler?.attach(to: subview)
|
) {
|
||||||
self.innerView = subview
|
self.innerView = childComponentView
|
||||||
|
touchHandler?.attach(to: childComponentView)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func unmountChildComponentView(
|
||||||
|
_ childComponentView: UIView,
|
||||||
|
index: Int
|
||||||
|
) {
|
||||||
|
touchHandler?.detach(from: childComponentView)
|
||||||
|
if self.innerView === childComponentView {
|
||||||
|
self.innerView = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll grab the content height from here so we know the initial detent to set
|
// We'll grab the content height from here so we know the initial detent to set
|
||||||
override func layoutSubviews() {
|
override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
guard let innerView = self.innerView else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if innerView.subviews.count != 1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
self.present()
|
self.present()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +116,6 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate {
|
|||||||
self.isClosing = false
|
self.isClosing = false
|
||||||
self.isOpen = false
|
self.isOpen = false
|
||||||
self.sheetVc = nil
|
self.sheetVc = nil
|
||||||
self.touchHandler?.detach(from: self.innerView)
|
|
||||||
self.touchHandler = nil
|
self.touchHandler = nil
|
||||||
self.innerView = nil
|
self.innerView = nil
|
||||||
SheetManager.shared.remove(self)
|
SheetManager.shared.remove(self)
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#if __has_include(<React/RCTSurfaceTouchHandler.h>)
|
||||||
|
#import <React/RCTSurfaceTouchHandler.h>
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user