Commit bd8e57a
authored
[Android] Skip the underlay drawable when it can never be visible (#4359)
## Description
`createUnderlayDrawable` always allocated a `PaintDrawable` and
installed it as the button's underlay, even when it could not possibly
render — a fully transparent `underlayColor`, or every opacity (default,
active, hover) left at `0`. That is an allocation and an extra drawable
in the layer stack per button, for nothing.
It now returns `null` in those cases and `underlayDrawable` is left
unset.
`hoverUnderlayOpacity` and `activeUnderlayOpacity` also needed
`withBackgroundUpdate` setters — previously only
`defaultUnderlayOpacity` and `underlayColor` triggered a background
rebuild, so setting one of the other two after mount could leave the
button without an underlay it should now have.
## Test plan
- Buttons with a visible underlay (any of the three opacities non-zero)
look and animate unchanged on press and hover.
- Buttons with `underlayColor="transparent"` or all-zero opacities
render with no underlay.
- Changing `activeUnderlayOpacity` / `hoverUnderlayOpacity` at runtime
rebuilds the background.1 parent 1506f6a commit bd8e57a
1 file changed
Lines changed: 16 additions & 2 deletions
File tree
- packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
580 | 580 | | |
581 | 581 | | |
582 | 582 | | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
583 | 586 | | |
584 | 587 | | |
585 | 588 | | |
586 | 589 | | |
587 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
588 | 594 | | |
589 | 595 | | |
590 | 596 | | |
| |||
1055 | 1061 | | |
1056 | 1062 | | |
1057 | 1063 | | |
1058 | | - | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
1059 | 1073 | | |
1060 | 1074 | | |
1061 | 1075 | | |
| |||
1072 | 1086 | | |
1073 | 1087 | | |
1074 | 1088 | | |
1075 | | - | |
| 1089 | + | |
1076 | 1090 | | |
1077 | 1091 | | |
1078 | 1092 | | |
| |||
0 commit comments