Skip to content

Commit

Permalink
fix(Android): do not crash in case background can not be casted to Ma…
Browse files Browse the repository at this point in the history
…terialShapeDrawable (software-mansion#2388)

## Description

It turns out, that this check:
software-mansion@b2dab78
was necessary,
and I forgot about it while applying the code review.

Current code will crash if `background != null && !(background is
MaterialShapeDrawable)`, so e.g. when `background is ColorDrawable`.
We don't wanna fail in this case.

## Changes

Allowed the cast to fail instead of throwing exception, when casting
background to `MaterialShapeDrawable`.
One thing that concerns me 

## Test code and steps to reproduce

`Test1649`

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Ensured that CI passes
  • Loading branch information
kkafar authored and ja1ns committed Oct 9, 2024
1 parent fa44285 commit 4ce3c45
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion android/src/main/java/com/swmansion/rnscreens/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class Screen(
if (stackPresentation !== StackPresentation.FORM_SHEET || background == null) {
return
}
(background as MaterialShapeDrawable?)?.let {
(background as? MaterialShapeDrawable?)?.let {
val resolvedCornerRadius = PixelUtil.toDIPFromPixel(sheetCornerRadius)
it.shapeAppearanceModel =
ShapeAppearanceModel
Expand Down

0 comments on commit 4ce3c45

Please sign in to comment.