diff --git a/ios/TrueSheetView.swift b/ios/TrueSheetView.swift index 4f837e0..16c3774 100644 --- a/ios/TrueSheetView.swift +++ b/ios/TrueSheetView.swift @@ -57,6 +57,8 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate { self.bridge = bridge viewController = TrueSheetViewController() + viewController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth] + touchHandler = RCTTouchHandler(bridge: bridge) super.init(frame: .zero) @@ -77,11 +79,10 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate { return } - // viewController.view.insertSubview(subview, at: 0) viewController.view.addSubview(subview) containerView = subview - touchHandler.attach(to: subview) + touchHandler.attach(to: containerView) } override func removeReactSubview(_ subview: UIView!) { @@ -165,11 +166,11 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate { @objc func setBlurStyle(_ style: NSString?) { guard let style else { - viewController.blurView.effect = nil + viewController.setBlurStyle(nil) return } - viewController.blurView.effect = UIBlurEffect(with: style as String) + viewController.setBlurStyle(style as String) } @objc diff --git a/ios/TrueSheetViewController.swift b/ios/TrueSheetViewController.swift index 2e70226..1df3d0d 100644 --- a/ios/TrueSheetViewController.swift +++ b/ios/TrueSheetViewController.swift @@ -29,6 +29,10 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe weak var delegate: TrueSheetViewControllerDelegate? + var blurView: UIVisualEffectView + var lastViewWidth: CGFloat = 0 + var detentValues: [String: SizeInfo] = [:] + var sizes: [Any] = ["medium", "large"] var maxHeight: CGFloat? @@ -48,10 +52,6 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe } } - var blurView: UIVisualEffectView - var lastViewWidth: CGFloat = 0 - var detentValues: [String: SizeInfo] = [:] - @available(iOS 15.0, *) var sheet: UISheetPresentationController? { return sheetPresentationController @@ -73,13 +73,9 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe super.init(nibName: nil, bundle: nil) - view.addSubview(blurView) - view.autoresizingMask = [.flexibleHeight, .flexibleWidth] - - let blurEffect = UIBlurEffect(style: .light) - blurView.effect = blurEffect - blurView.frame = view.bounds blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + blurView.frame = view.bounds + view.insertSubview(blurView, at: 0) } @available(*, unavailable) @@ -116,6 +112,15 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe } } + func setBlurStyle(_ style: String?) { + guard let style else { + blurView.effect = nil + return + } + + blurView.effect = UIBlurEffect(with: style) + } + /// Prepares the view controller for sheet presentation /// Do nothing on IOS 14 and below... sad @available(iOS 15.0, *) diff --git a/src/TrueSheet.tsx b/src/TrueSheet.tsx index d42868e..147ffba 100644 --- a/src/TrueSheet.tsx +++ b/src/TrueSheet.tsx @@ -149,19 +149,17 @@ export class TrueSheet extends PureComponent { > @@ -179,7 +177,3 @@ const $nativeSheet: ViewStyle = { width: 0, zIndex: -9999, } - -const $sheetWrapper: ViewStyle = { - overflow: 'hidden', -}