refactor: new way for handling insets #207
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Setup
onApplyWindowInsetsListener
that managessystemBars
andnavigationBar
onrootView
to get correct and constant insets.💡 Motivation and Context
If we setup
onApplyWindowInsetsListener
onEdgeToEdgeReactViewGroup
, then sometimes insets are including keyboard size (it's is0, 1225
(top, bottom) instead of expected144, 84
).I discovered that if we setup
onApplyWindowInsetsListener
onrootVIew
- in this case insets are always stable. So I reworked this part (worth to note thatonApplyWindowInsetsListener
that detects keyboard size changes still should listen toEdgeToEdgeReactViewGroup
because otherwise it's not working).It fixes a problem with content jump, however the old approach (setting
padding
foraction_bar_root
) is not working anymore - instead we should apply margin. Last, but not least - we should setup it asynchronously, because if we setup it inonAttachedToWindow
/init
then it'll add undesired padding:Area in blue - undesired margin
Fixes #51
📢 Changelog
Android
margin
toaction_bar_root
instead ofpadding
;onApplyWindowInsetsListener
onrootView
, keeponApplyWindowInsetsListener
onEdgeToEdgeView
just for detecting keyboard size changes;onApplyWindowInsetsListener
onrootView
asynchronously (to avoid unnecessary margin on mount);ThemedReactContext
extension that returnsrootView
;🤔 How Has This Been Tested?
Tested (fabric/paper) on:
📸 Screenshots (if appropriate):
📝 Checklist