Add Dimensions.getDisplayFeatures / useDisplayFeatures (iPhone Duo) - #58594
saqibkayani2077 wants to merge 5 commits into
Conversation
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
|
Hi @saqibkayani2077! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary
Adds a
displayFeaturesfield toDimensionsPayload/NativeDeviceInfo(type only:'hinge' | 'cutout', a posture, and bounds), aDimensions.getDisplayFeatures()accessor, and auseDisplayFeatures()hook mirroringuseWindowDimensions(). 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), andexpo/expo(expo/expo#50343).Why not wired up natively yet
RCTDeviceInfo.mmalways 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.getDisplayFeaturesdefaults to an empty arrayset()displayFeaturesRNTesterapp build foriphonesimulator,Debugconfig, via the traditional CocoaPods integration — succeeds, confirmingRCTDeviceInfo.mmcompiles cleanly: https://github.com/saqibkayani2077/react-native/actions/runs/35209458976yarn 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.