@@ -361,6 +361,13 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
361361 }
362362 }
363363
364+ override fun coordinatorLayoutDidChangeConfiguration () {
365+ if (! isPresented) return
366+
367+ updateStateDimensions()
368+ sheetView?.let { emitChangePositionDelegate(it.top, realtime = false ) }
369+ }
370+
364371 // =============================================================================
365372 // MARK: - TrueSheetDimViewDelegate
366373 // =============================================================================
@@ -664,15 +671,7 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
664671 animate = isPresented
665672 )
666673
667- val offset = if (expandedOffset == 0 ) topInset else 0
668- val newHeight = realScreenHeight - expandedOffset - offset
669- val newWidth = minOf(screenWidth, DEFAULT_MAX_WIDTH .dpToPx().toInt())
670-
671- if (lastStateWidth != newWidth || lastStateHeight != newHeight) {
672- lastStateWidth = newWidth
673- lastStateHeight = newHeight
674- delegate?.viewControllerDidChangeSize(newWidth, newHeight)
675- }
674+ updateStateDimensions(expandedOffset)
676675
677676 if (isPresented) {
678677 setStateForDetentIndex(currentDetentIndex)
@@ -922,6 +921,19 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
922921 // MARK: - Detent Helpers
923922 // =============================================================================
924923
924+ private fun updateStateDimensions (expandedOffset : Int? = null) {
925+ val offset = expandedOffset ? : (realScreenHeight - detentCalculator.getDetentHeight(detents.last()))
926+ val topOffset = if (offset == 0 ) topInset else 0
927+ val newHeight = realScreenHeight - offset - topOffset
928+ val newWidth = minOf(screenWidth, DEFAULT_MAX_WIDTH .dpToPx().toInt())
929+
930+ if (lastStateWidth != newWidth || lastStateHeight != newHeight) {
931+ lastStateWidth = newWidth
932+ lastStateHeight = newHeight
933+ delegate?.viewControllerDidChangeSize(newWidth, newHeight)
934+ }
935+ }
936+
925937 fun translateSheet (translationY : Int ) {
926938 val sheet = sheetView ? : return
927939
@@ -966,22 +978,6 @@ class TrueSheetViewController(private val reactContext: ThemedReactContext) :
966978 (getTag(R .id.react_test_id) as ? String )?.let { info.viewIdResourceName = it }
967979 }
968980
969- override fun onSizeChanged (w : Int , h : Int , oldw : Int , oldh : Int ) {
970- super .onSizeChanged(w, h, oldw, oldh)
971-
972- if (w == oldw && h == oldh) return
973- if (! isPresented) return
974-
975- // Skip reconfiguration if expanded and only height changed (e.g., keyboard)
976- if (h + topInset >= screenHeight && isExpanded && oldw == w) return
977-
978- post {
979- setupSheetDetents()
980- positionFooter()
981- sheetView?.let { emitChangePositionDelegate(it.top, realtime = false ) }
982- }
983- }
984-
985981 // =============================================================================
986982 // MARK: - RootView Touch Handling
987983 // =============================================================================
0 commit comments