refactor(iOS, FormSheet v5): Move detents resolving to dedicated class#4038
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extracts detent-related logic from RNSFormSheetHostComponentView into a new dedicated class RNSFormSheetDetentResolver. The refactor is behavior-preserving: building native detents from JS fractions, resolving the initial selected detent identifier, and resolving the largest-undimmed detent identifier are now static class methods on the new resolver. The _initialDetentApplied "consume-once" flag is now managed in the caller rather than inside the moved method.
Changes:
- Added
RNSFormSheetDetentResolverheader/implementation hostingbuildSheetDetentsForFractions:,initialDetentIdentifierForDetents:atRequestedIndex:, andlargestUndimmedDetentIdentifierForDetents:atIndex:, plus moved thekRNSFormSheetLastDetent/kRNSFormSheetAlwaysDimmed/kRNSFormSheetNeverDimmedsentinel constants into the header. - Removed the equivalent private methods and constants from
RNSFormSheetHostComponentView.mm; the host now delegates to the resolver and toggles_initialDetentApplieditself. areDetentsValid/areDetentsStrictlyAscendingbecome file-scope C++ helpers (RNSAreDetentsValid/RNSAreDetentsStrictlyAscending) inside the new translation unit.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ios/gamma/modals/form-sheet/RNSFormSheetDetentResolver.h | New header declaring the resolver class and sentinel index constants; uses #pragma once consistent with sibling headers and gates the C++ vector-based selector behind __cplusplus. |
| ios/gamma/modals/form-sheet/RNSFormSheetDetentResolver.mm | New implementation containing the moved detent-building and identifier-resolution logic, with the validity/ordering checks as static C++ helpers; whole @implementation is wrapped in #if !TARGET_OS_TV. |
| ios/gamma/modals/form-sheet/RNSFormSheetHostComponentView.mm | Removes moved methods and constants; updateConfiguration now calls the resolver and manages the one-shot _initialDetentApplied flag locally. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kligarski
approved these changes
May 18, 2026
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
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
Move
buildSheetDetents,consumeInitialDetentIdentifierForDetents,largestUndimmedDetentIdentifierForDetents,areDetentsValid,areDetentsStrictlyAscendingto a dedicated file. All logic related to transforming JS payload to native detents should now go through this file.Changes
Before & after - visual documentation
N/A
Test plan
I went through all SFTs for FormSheet, especially related to
largestUndimmedDetentIndex&initialDetentIndex.Checklist