-
-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Android): missing background color for formSheets on RN 0.77+ (#2660
) ## Description * facebook/react-native#45688 introduced `BackgroundStyleApplicator` * facebook/react-native#47906 removed our current accessor * somewhere along the way the `ColorDrawable` used previously by `ReactViewGroup` has been exchanged for `CompositeBackgroundDrawable` added in facebook/react-native#45688 > [!caution] ~This PR breaks compatibility with older versions of react-native. While this is fine on Fabric, this also breaks things for Paper.~ > ~Possible solution is to detect react native version in gradle and add versioned sourcesets with implementations for given react native versions.~ > > Not up to date. I've added versioned source files to ensure appropriate backward compatibility down to 0.74. > [!note] > We need CI to ensure the projects do build on all versions we support. ## Changes Migrated to `BackgroundStyleApplicator API` to resolve background color of `contentWrapper`. ## Test code and steps to reproduce `TestAndroidTransitions` - the form sheet should no longer be cut. ## Checklist - [ ] Ensured that CI passes
- Loading branch information
Showing
5 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
android/src/versioned/backgroundcolor/74/ViewBackgroundUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.swmansion.rnscreens.utils | ||
|
||
import com.facebook.react.views.view.ReactViewBackgroundDrawable | ||
import com.facebook.react.views.view.ReactViewGroup | ||
|
||
internal fun ReactViewGroup.resolveBackgroundColor(): Int? = (this.background as? ReactViewBackgroundDrawable)?.color |
9 changes: 9 additions & 0 deletions
9
android/src/versioned/backgroundcolor/76/ViewBackgroundUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.swmansion.rnscreens.utils | ||
|
||
import com.facebook.react.common.annotations.UnstableReactNativeAPI | ||
import com.facebook.react.uimanager.drawable.CSSBackgroundDrawable | ||
import com.facebook.react.views.view.ReactViewGroup | ||
|
||
@OptIn(UnstableReactNativeAPI::class) | ||
internal fun ReactViewGroup.resolveBackgroundColor(): Int? = (this.background as? CSSBackgroundDrawable)?.color | ||
|
9 changes: 9 additions & 0 deletions
9
android/src/versioned/backgroundcolor/latest/ViewBackgroundUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.swmansion.rnscreens.utils | ||
|
||
import com.facebook.react.common.annotations.UnstableReactNativeAPI | ||
import com.facebook.react.uimanager.BackgroundStyleApplicator | ||
import com.facebook.react.uimanager.drawable.CSSBackgroundDrawable | ||
import com.facebook.react.views.view.ReactViewGroup | ||
|
||
internal fun ReactViewGroup.resolveBackgroundColor(): Int? = BackgroundStyleApplicator.getBackgroundColor(this) | ||
|