@@ -27,6 +27,7 @@ import androidx.appcompat.widget.Toolbar
2727import androidx.coordinatorlayout.widget.CoordinatorLayout
2828import androidx.core.animation.addListener
2929import androidx.core.view.WindowInsetsCompat
30+ import com.facebook.react.uimanager.BackgroundStyleApplicator
3031import com.facebook.react.uimanager.PixelUtil
3132import com.facebook.react.uimanager.PointerEvents
3233import com.facebook.react.uimanager.ReactPointerEventsView
@@ -574,6 +575,24 @@ class ScreenStackFragment :
574575 private fun createAndConfigureBottomSheetBehaviour (): BottomSheetBehavior <Screen > =
575576 configureBottomSheetBehaviour(createBottomSheetBehaviour())
576577
578+ private fun resolveBackgroundColor (screen : Screen ): Int? {
579+ val screenColor =
580+ (screen.background as ? ColorDrawable ? )?.color
581+ ? : (screen.background as ? MaterialShapeDrawable ? )?.tintList?.defaultColor
582+
583+ if (screenColor != null ) {
584+ return screenColor
585+ }
586+
587+ val contentWrapper = screen.contentWrapper.get()
588+ if (contentWrapper == null ) {
589+ return null
590+ }
591+
592+ val contentWrapperColor = BackgroundStyleApplicator .getBackgroundColor(contentWrapper)
593+ return contentWrapperColor
594+ }
595+
577596 private fun attachShapeToScreen (screen : Screen ) {
578597 val cornerSize = PixelUtil .toPixelFromDIP(screen.sheetCornerRadius)
579598 val shapeAppearanceModel =
@@ -584,10 +603,8 @@ class ScreenStackFragment :
584603 setTopRightCorner(CornerFamily .ROUNDED , cornerSize)
585604 }.build()
586605 val shape = MaterialShapeDrawable (shapeAppearanceModel)
587- val currentColor =
588- (screen.background as ? ColorDrawable ? )?.color
589- ? : (screen.background as ? MaterialShapeDrawable ? )?.tintList?.defaultColor
590- shape.setTint(currentColor ? : Color .TRANSPARENT )
606+ val backgroundColor = resolveBackgroundColor(screen)
607+ shape.setTint(backgroundColor ? : Color .TRANSPARENT )
591608 screen.background = shape
592609 }
593610
0 commit comments