-
-
Notifications
You must be signed in to change notification settings - Fork 598
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
Conversation
android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetDelegate.kt
Outdated
Show resolved
Hide resolved
kkafar
left a comment
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
kkafar
left a comment
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? |
|
The work is continued here: #3336 |
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
BottomSheetBehaviorworks. For unknown reasons,onChildLayoutsometimes isn't called afterBottomSheetBehavior's insets handler runs. In this PR, we overrideScreen'ssetOnApplyWindowInsetsListener(used byBottomSheetBehaviorto register its handler), to make sure to request the layout after the listener runs.The problem
On first layout,
BottomSheetBehaviorregisters the inset listener which updatesinsetsTopfield. InonLayoutChild,BottomSheetBehaviorusesinsetsTopvalue to calculatechildHeightwhich is then used to calculatefitToContentsOffset.fitToContentsOffsetis returned fromgetExpandedOffset()ifisFitToContents == true(which is the case for single and two detents inscreens). IfisFitToContents == false(i.e. we use 3 detents),getExpandedOffset()usesinsetsTopdirectly. 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
onApplyWindowInsetsListenerTest2896test 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
Test2896test screen.Checklist