-
-
Notifications
You must be signed in to change notification settings - Fork 588
feat(iOS, Stack): New implementation for calculating edgeInsets #3210
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
Draft
t0maboro
wants to merge
20
commits into
main
Choose a base branch
from
@t0maboro/update-logic-for-calculating-edge-insets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat(iOS, Stack): New implementation for calculating edgeInsets #3210
t0maboro
wants to merge
20
commits into
main
from
@t0maboro/update-logic-for-calculating-edge-insets
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 tasks
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Closes: https://github.com/software-mansion/react-native-screens-labs/issues/352
Should be reviewed/merged after #2987 - as for now, moving to draft.
Problem definition
On iOS 26, when
headerTitle
is a component containing text that overflows its parent container, the text is not correctly truncated. Instead, part of it is displayed underneath the right header button.Root cause analysis
After the changes introduced in iOS 26, our current method of calculating
edgeInsets
, which are based on the sum of theUINavigationBar.directionalLayoutMargins
and its contentdirectionalLayoutMargins
is insufficient. The problem also lies in the fact that by calculating insets only based on these components, we lack full information about the positions of the buttons within the navigation bar. These insets are approximate, which may lead to a gap between the left/right buttons and the title component.Solution
With a flexbox-based model, a better approach would be to imagine that all React components are wrapped in a single component in which they're layouting in a flex manner. This way, the layout of all
HeaderSubviews
can be fully delegated to Yoga. This is achievable by reading the left edge of theScreenStackHeaderLeftView
and the right edge of theScreenStackHeaderRightView
. In the current model, this allows Yoga to operate in the area:This enables the text to stretch across the full available width, either if
flex: 1
is provided or if the text is long enough to require truncating.Known issues
This approach for calculating insets requires a fully computed layout in the
UINavigationBar
. Therefore, during transitions, a correct update may not occur. Detection of the proper moment when update should come is problematic, what is resulting in content jumping during forward navigation. However, once the transition completes, the header stabilizes. This issue only affects headers where components do not have a fixed width.A new feature — support for
UIBarButtonItem
is causing layout issues because if a button is native, from Yoga’s perspective, it should be ignored for layout. For example, if there is one native button on both the left and right sides, we should take insets based on the right edge ofheaderLeftItems
and the left edge ofheaderRightItems
. Additionally, we need to clearly define whether we allow mixing of React components and native components inheader[Left/Right]Items
props.Testing coverage
UIBarButtonItem
) buttons supportChanges
overflow: hidden
to mitigate jumping content on thepush
transition issueScreenshots / GIFs
Before
legacy.mov
After
modern.mov
Test code and steps to reproduce
I believe that this may require more integration testing with other APIs in the future; therefore, I added a new example that will collect all new TC we should cover (e.g., support for
UIBarButtonItems
soon).Checklist
Further steps
For this PR, I need to create follow-up tickets for taking further actions:
headerTitle
prop with RN component passed in it is causing several issues in the native-stack implementation. This ticket is to determine whether we should focus on resolving them or rather add support for all native title customizations, which would guarantee "native feeling"