Skip to content

Commit

Permalink
fix(Android): header shadow not hidden on go back (software-mansion#2216
Browse files Browse the repository at this point in the history
)

## Description

This PR intents to fix header shadow not being hidden after navigating
back to a screen. The bug was visible when using `headerTransparent:
true` option.

The origin of this bug is [This
PR](software-mansion#2116)
fixing build depracations. Setting the `elevation` on appBarLayout
requires resetting the `stateListAnimator` to work properly, as opossed
to deprecated `targetElevation` used before.

For more info visit:
https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setTargetElevation(float)

Fixes software-mansion#2212 .


## Changes

- added missing `appBarLayout?.stateListAnimator` reset.

## Screenshots / GIFs

Here you can add screenshots / GIFs documenting your change.

You can add before / after section if you're changing some behavior.

### Before
![Screenshot 2024-06-27 at 11 39
50](https://github.com/software-mansion/react-native-screens/assets/91994767/78c42cd3-4523-46f2-93ea-2aa4a6f4da4f)

### After
![Screenshot 2024-06-27 at 11 39
29](https://github.com/software-mansion/react-native-screens/assets/91994767/b0d32daa-ee98-438e-90cb-621bb6b13ad0)



## Test code and steps to reproduce

1. use `Test1097.tsx` repro
2. navigate into second or third screen
3. go back to the first screen

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
  • Loading branch information
alduzy authored and ja1ns committed Oct 9, 2024
1 parent 9ab2597 commit 76cd414
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class ScreenStackFragment :
view?.addView(appBarLayout)
if (isToolbarShadowHidden) {
appBarLayout?.elevation = 0f
appBarLayout?.stateListAnimator = null
}
toolbar?.let { appBarLayout?.addView(recycleView(it)) }
setHasOptionsMenu(true)
Expand Down

0 comments on commit 76cd414

Please sign in to comment.