@@ -24,6 +24,7 @@ import androidx.annotation.RequiresApi
24
24
import androidx.appcompat.widget.Toolbar
25
25
import androidx.coordinatorlayout.widget.CoordinatorLayout
26
26
import androidx.core.view.WindowInsetsCompat
27
+ import com.facebook.react.uimanager.BackgroundStyleApplicator
27
28
import com.facebook.react.uimanager.PixelUtil
28
29
import com.facebook.react.uimanager.PointerEvents
29
30
import com.facebook.react.uimanager.ReactPointerEventsView
@@ -461,6 +462,24 @@ class ScreenStackFragment :
461
462
internal fun createAndConfigureBottomSheetBehaviour (): BottomSheetBehavior <Screen > =
462
463
configureBottomSheetBehaviour(BottomSheetBehavior <Screen >())
463
464
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
+
464
483
private fun attachShapeToScreen (screen : Screen ) {
465
484
val cornerSize = PixelUtil .toPixelFromDIP(screen.sheetCornerRadius)
466
485
val shapeAppearanceModel =
@@ -471,10 +490,8 @@ class ScreenStackFragment :
471
490
setTopRightCorner(CornerFamily .ROUNDED , cornerSize)
472
491
}.build()
473
492
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 )
478
495
screen.background = shape
479
496
}
480
497
0 commit comments