diff --git a/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt b/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt index 857ae67..01f899f 100644 --- a/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +++ b/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt @@ -172,13 +172,13 @@ class TrueSheetView(context: Context) : // Initialize content UiThreadUtil.runOnUiThread { // 1st child is the content view - val contentView = it.getChildAt(0) as ViewGroup - setContentHeight(contentView.height) + val contentView = it.getChildAt(0) as ViewGroup? + setContentHeight(contentView?.height ?: 0) // 2nd child is the footer view - val footerView = it.getChildAt(1) as ViewGroup + val footerView = it.getChildAt(1) as ViewGroup? sheetDialog.footerView = footerView - setFooterHeight(footerView.height) + setFooterHeight(footerView?.height ?: 0) if (initialIndex >= 0) { currentSizeIndex = initialIndex diff --git a/ios/TrueSheetView.swift b/ios/TrueSheetView.swift index 0ed0916..fc9f401 100644 --- a/ios/TrueSheetView.swift +++ b/ios/TrueSheetView.swift @@ -45,6 +45,11 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate { private var rctScrollView: RCTScrollView? + private var uiManager: RCTUIManager? { + guard let uiManager = bridge?.uiManager else { return nil } + return uiManager + } + // MARK: - Setup init(with bridge: RCTBridge) { @@ -143,7 +148,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate { guard let containerView else { return } let size = CGSize(width: width, height: containerView.bounds.height) - bridge?.uiManager.setSize(size, for: containerView) + uiManager?.setSize(size, for: containerView) } func viewControllerWillAppear() { @@ -297,7 +302,7 @@ class TrueSheetView: UIView, RCTInvalidating, TrueSheetViewControllerDelegate { @objc func setScrollableHandle(_ tag: NSNumber?) { - let view = bridge?.uiManager.view(forReactTag: tag) as? RCTScrollView + let view = uiManager?.view(forReactTag: tag) as? RCTScrollView rctScrollView = view }