Skip to content

Add Dimensions.getDisplayFeatures / useDisplayFeatures (iPhone Duo) - #58594

Draft
saqibkayani2077 wants to merge 5 commits into
react:mainfrom
saqibkayani2077:iphone-duo-support
Draft

saqibkayani2077 wants to merge 5 commits into
react:mainfrom
saqibkayani2077:iphone-duo-support

Conversation

@saqibkayani2077

@saqibkayani2077 saqibkayani2077 commented Sep 18, 2026

Copy link
Copy Markdown

Summary

Adds a displayFeatures field to DimensionsPayload/NativeDeviceInfo (type only: 'hinge' | 'cutout', a posture, and bounds), a Dimensions.getDisplayFeatures() accessor, and a useDisplayFeatures() hook mirroring useWindowDimensions(). Modeled on the reserved regions of iPhone Duo (Apple Tech Talk 111463, "Strike a pose with adaptive layouts on iPhone Duo"), so a future foldable/dual-display Android device could report through the same shape.

Companion changes with the same model were made alongside this one in flutter/flutter, tauri-apps/tauri, ionic-team/capacitor (ionic-team/capacitor#8597), and expo/expo (expo/expo#50343).

Why not wired up natively yet

RCTDeviceInfo.mm always reports an empty array for now — deliberately, not a bug. The underlying iOS API (UIView.reservedRegions(kind:)) is Swift-only and, as of this PR, not part of any Xcode release GitHub-hosted CI can build against (I checked directly — GitHub's macOS runners currently offer up to Xcode 26.6, not the 27.1 that ships this API). This podspec target also compiles no Swift sources today, so wiring the real query in would mean either guessing at an unverified Objective-C bridging approach or modifying the podspec's build setup without being able to verify it compiles. Left as a clearly-commented follow-up rather than guessed at blind.

Test Plan

  • yarn jest packages/react-native/Libraries/Utilities/__tests__/Dimensions-displayFeatures-test.js — 3/3 pass:
    • Dimensions.getDisplayFeatures defaults to an empty array
    • reports the display features passed to set()
    • falls back to an empty array when a later update omits displayFeatures
  • CI (this fork, manually dispatched): full RNTester app build for iphonesimulator, Debug config, via the traditional CocoaPods integration — succeeds, confirming RCTDeviceInfo.mm compiles cleanly: https://github.com/saqibkayani2077/react-native/actions/runs/35209458976
  • Not run: yarn flow-check, yarn lint, yarn fantom.

Changelog:

[GENERAL] [ADDED] - Dimensions.getDisplayFeatures() / useDisplayFeatures() hook (type-only for now; iOS native query intentionally deferred, see above).

This PR was drafted with AI assistance (Claude Code) and is submitted as a draft: the native iOS query is intentionally still a stub, pending either Xcode 27.1 reaching CI or maintainer guidance on the right way to wire a Swift-only API into this Objective-C++ file.

saqibkayani2077 and others added 5 commits September 10, 2026 20:03
Adds a displayFeatures field to DimensionsPayload/NativeDeviceInfo (type
only: 'hinge' | 'cutout', a posture, and bounds), a Dimensions.getDisplayFeatures()
accessor, and a useDisplayFeatures() hook mirroring useWindowDimensions().
Modeled on the reserved regions of iPhone Duo (Apple Tech Talk 111463,
"Strike a pose with adaptive layouts on iPhone Duo") so a future
foldable/dual-display Android device could report through the same shape.

Native (RCTDeviceInfo.mm) always reports an empty array for now. The
underlying iOS 27.1 API (UIView.reservedRegions(kind:)) is Swift-only and
not part of any publicly available Xcode as of 2026-09-10; this podspec
target compiles no Swift sources today, so there is no safe way to wire
the real query in without either guessing at an unverified Objective-C
selector name or modifying the podspec's build setup blind. Left as a
clearly-commented follow-up rather than guessed at.

Verified: `yarn jest packages/react-native/Libraries/Utilities/__tests__/Dimensions-displayFeatures-test.js`
- all 3 tests pass:
  Dimensions.getDisplayFeatures
    ✓ defaults to an empty array
    ✓ reports the display features passed to set()
    ✓ falls back to an empty array when a later update omits displayFeatures
This machine's Node (v21.1.0) is below this repo's declared engine
requirement (^22.13.0+); `yarn install` needed YARN_IGNORE_ENGINES=true
to proceed. No other checks (flow-check, lint) were run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LAkF81dVyenmpEChH2Nh1k
@meta-cla

meta-cla Bot commented Sep 18, 2026

Copy link
Copy Markdown

Hi @saqibkayani2077!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

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.

1 participant