From 5399476e15d13807ce1e52c1a547a7e26942f852 Mon Sep 17 00:00:00 2001 From: hailey Date: Mon, 19 May 2025 11:35:25 -0700 Subject: [PATCH] Discard changes to modules/bottom-sheet/ios/SheetView.swift --- modules/bottom-sheet/ios/SheetView.swift | 37 ++++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/modules/bottom-sheet/ios/SheetView.swift b/modules/bottom-sheet/ios/SheetView.swift index ef44091161..710c3c866f 100644 --- a/modules/bottom-sheet/ios/SheetView.swift +++ b/modules/bottom-sheet/ios/SheetView.swift @@ -5,7 +5,7 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate { // Views private var sheetVc: SheetViewController? private var innerView: UIView? - private var touchHandler: RCTSurfaceTouchHandler? + private var touchHandler: RCTTouchHandler? // Events private let onAttemptDismiss = EventDispatcher() @@ -73,35 +73,33 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate { required init (appContext: AppContext? = nil) { super.init(appContext: appContext) self.maxHeight = Util.getScreenHeight() - self.touchHandler = RCTSurfaceTouchHandler() + self.touchHandler = RCTTouchHandler(bridge: appContext?.reactBridge) SheetManager.shared.add(self) } deinit { self.destroy() } - - override func mountChildComponentView( - _ childComponentView: UIView, - index: Int - ) { - 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 don't want this view to actually get added to the tree, so we'll simply store it for adding + // to the SheetViewController + override func insertReactSubview(_ subview: UIView!, at atIndex: Int) { + self.touchHandler?.attach(to: subview) + self.innerView = subview } // We'll grab the content height from here so we know the initial detent to set override func layoutSubviews() { super.layoutSubviews() + + guard let innerView = self.innerView else { + return + } + + if innerView.subviews.count != 1 { + return + } + self.present() } @@ -109,6 +107,7 @@ class SheetView: ExpoView, UISheetPresentationControllerDelegate { self.isClosing = false self.isOpen = false self.sheetVc = nil + self.touchHandler?.detach(from: self.innerView) self.touchHandler = nil self.innerView = nil SheetManager.shared.remove(self)