-
-
Notifications
You must be signed in to change notification settings - Fork 583
fix(Android): status bar insets for formSheet #2925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetDelegate.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beside my wrong suggestion to use ArraySet last time, this one looks good!
android/src/main/java/com/swmansion/rnscreens/InsetsObserverProxy.kt
Outdated
Show resolved
Hide resolved
d8783a0
to
9e383d4
Compare
9e383d4
to
3cbc2fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have follow up question that just popped in my head
3cbc2fb
to
e25bb8d
Compare
Any chance that we get this PR released soon? |
Description
Status bar insets were not handled properly when opening the formSheet with initial height that was greater than safe content area. The bug is directly connected with how
BottomSheetBehavior
works. For unknown reasons,onChildLayout
sometimes isn't called afterBottomSheetBehavior
's insets handler runs. In this PR, we overrideScreen
'ssetOnApplyWindowInsetsListener
(used byBottomSheetBehavior
to register its handler), to make sure to request the layout after the listener runs.The problem
On first layout,
BottomSheetBehavior
registers the inset listener which updatesinsetsTop
field. InonLayoutChild
,BottomSheetBehavior
usesinsetsTop
value to calculatechildHeight
which is then used to calculatefitToContentsOffset
.fitToContentsOffset
is returned fromgetExpandedOffset()
ifisFitToContents == true
(which is the case for single and two detents inscreens
). IfisFitToContents == false
(i.e. we use 3 detents),getExpandedOffset()
usesinsetsTop
directly. When layout wasn't called after the insets handler, previous value was used which caused the sheet to go under the status bar.Fixes #2896.
Changes
onApplyWindowInsetsListener
Test2896
test screen (unable to create e2e test because content behind formSheet still hasvisibility = VISIBLE
)Screenshots / GIFs
before_2896_fix.mp4
after_2896_fix.mp4
Test code and steps to reproduce
Run example app and open
Test2896
test screen.Checklist