@@ -24,6 +24,7 @@ import androidx.annotation.RequiresApi
2424import androidx.appcompat.widget.Toolbar
2525import androidx.coordinatorlayout.widget.CoordinatorLayout
2626import androidx.core.view.WindowInsetsCompat
27+ import com.facebook.react.uimanager.BackgroundStyleApplicator
2728import com.facebook.react.uimanager.PixelUtil
2829import com.facebook.react.uimanager.PointerEvents
2930import com.facebook.react.uimanager.ReactPointerEventsView
@@ -461,6 +462,24 @@ class ScreenStackFragment :
461462 internal fun createAndConfigureBottomSheetBehaviour (): BottomSheetBehavior <Screen > =
462463 configureBottomSheetBehaviour(BottomSheetBehavior <Screen >())
463464
465+ private fun resolveBackgroundColor (screen : Screen ): Int? {
466+ val screenColor =
467+ (screen.background as ? ColorDrawable ? )?.color
468+ ? : (screen.background as ? MaterialShapeDrawable ? )?.tintList?.defaultColor
469+
470+ if (screenColor != null ) {
471+ return screenColor
472+ }
473+
474+ val contentWrapper = screen.contentWrapper.get()
475+ if (contentWrapper == null ) {
476+ return null
477+ }
478+
479+ val contentWrapperColor = BackgroundStyleApplicator .getBackgroundColor(contentWrapper)
480+ return contentWrapperColor
481+ }
482+
464483 private fun attachShapeToScreen (screen : Screen ) {
465484 val cornerSize = PixelUtil .toPixelFromDIP(screen.sheetCornerRadius)
466485 val shapeAppearanceModel =
@@ -471,10 +490,8 @@ class ScreenStackFragment :
471490 setTopRightCorner(CornerFamily .ROUNDED , cornerSize)
472491 }.build()
473492 val shape = MaterialShapeDrawable (shapeAppearanceModel)
474- val currentColor =
475- (screen.background as ? ColorDrawable ? )?.color
476- ? : (screen.background as ? MaterialShapeDrawable ? )?.tintList?.defaultColor
477- shape.setTint(currentColor ? : Color .TRANSPARENT )
493+ val backgroundColor = resolveBackgroundColor(screen)
494+ shape.setTint(backgroundColor ? : Color .TRANSPARENT )
478495 screen.background = shape
479496 }
480497
0 commit comments