Skip to content
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

fix(iOS): PoC: initial content jump on screens with header #1998

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Dec 28, 2023

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

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 (as 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...

Some option would be to use `UIView.topLayoutGuide` 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?
@kkafar kkafar marked this pull request as draft December 28, 2023 13:55
@kkafar kkafar self-assigned this Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] Native Stack layout shift, initial render doesn't take header into account
1 participant