react-native-screens
react-native-screens copied to clipboard
fix(iOS): PoC: initial content jump on screens with header
Description
Just my notes:
The idea is to set top property on shadow view depending whether the
screen has header or not.
The presence of the header can be detected via prop: shadow views do get all the same initial props as normal views! (and maybe some extra), so it is possible to pass this information down from JS, so that it is available on first render (while the first layout is calculated).
Other option would be to defer setting the frame to the moment the UIKit (native) layout is calculated & set the frame only after this is done.
We should also consider what should happen if the view is resized dynamically e.g. by gesture on native side. The native layout gets triggered no matter what and we can not prevent it. The question is whether we should trigger RCT layout or not...
Triggering the layout could be problematic in context of view-clipping (especially on modals). Not triggering it will most likely (maybe there is some workaround) cause centered-views, scrollviews, etc. to not function properly.
Some option would be to use UIView.topLayoutGuide (and remove edgesForExtendedLayout (it is not deprecated, but it is recommended against using it)) and instead of
calling setSize on UIManager, what results in scheduling a block on
UIManager thread that sets the size on shadow view & schedules the
layout, we could update shadow's view top property (or any other helper
property we define) to appropriate value, set appropriate size and just
then schedule the layout?
Will Resolves #1779
Changes
Test code and steps to reproduce
Checklist
- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Updated documentation:
- [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md
- [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md
- [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx
- [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx
- [ ] Ensured that CI passes