@@ -27,8 +27,8 @@ import androidx.annotation.RequiresApi
2727import androidx.appcompat.widget.Toolbar
2828import androidx.coordinatorlayout.widget.CoordinatorLayout
2929import androidx.core.animation.addListener
30- import androidx.core.view.OnApplyWindowInsetsListener
3130import androidx.core.view.WindowInsetsCompat
31+ import com.facebook.react.uimanager.BackgroundStyleApplicator
3232import com.facebook.react.uimanager.PixelUtil
3333import com.facebook.react.uimanager.PointerEvents
3434import com.facebook.react.uimanager.ReactPointerEventsView
@@ -586,6 +586,24 @@ class ScreenStackFragment :
586586 private fun createAndConfigureBottomSheetBehaviour (): BottomSheetBehavior <Screen > =
587587 configureBottomSheetBehaviour(createBottomSheetBehaviour())
588588
589+ private fun resolveBackgroundColor (screen : Screen ): Int? {
590+ val screenColor =
591+ (screen.background as ? ColorDrawable ? )?.color
592+ ? : (screen.background as ? MaterialShapeDrawable ? )?.tintList?.defaultColor
593+
594+ if (screenColor != null ) {
595+ return screenColor
596+ }
597+
598+ val contentWrapper = screen.contentWrapper.get()
599+ if (contentWrapper == null ) {
600+ return null
601+ }
602+
603+ val contentWrapperColor = BackgroundStyleApplicator .getBackgroundColor(contentWrapper)
604+ return contentWrapperColor
605+ }
606+
589607 private fun attachShapeToScreen (screen : Screen ) {
590608 val cornerSize = PixelUtil .toPixelFromDIP(screen.sheetCornerRadius)
591609 val shapeAppearanceModel =
@@ -596,10 +614,8 @@ class ScreenStackFragment :
596614 setTopRightCorner(CornerFamily .ROUNDED , cornerSize)
597615 }.build()
598616 val shape = MaterialShapeDrawable (shapeAppearanceModel)
599- val currentColor =
600- (screen.background as ? ColorDrawable ? )?.color
601- ? : (screen.background as ? MaterialShapeDrawable ? )?.tintList?.defaultColor
602- shape.setTint(currentColor ? : Color .TRANSPARENT )
617+ val backgroundColor = resolveBackgroundColor(screen)
618+ shape.setTint(backgroundColor ? : Color .TRANSPARENT )
603619 screen.background = shape
604620 }
605621
0 commit comments