Repository navigation
feat: add native bottom-anchored sheet content - #136
Open
arekkubaczkowski wants to merge 4 commits into
Open
arekkubaczkowski wants to merge 4 commits into
arekkubaczkowski wants to merge 4 commits into
Conversation
Verified-by: lint + TypeScript + 53 Bun tests + Bob package build + iOS simulator SDK Swift typecheck + Swift anchor geometry tests
Verified-by: 55 Bun tests, TypeScript, ESLint, Bob, 35 Android JVM tests, NDK and ObjC++ syntax checks, Swift geometry and UIKit host tests
Verified-by: 55 Bun tests, TypeScript, ESLint, Bob, iOS and Android Fabric codegen, Swift syntax check
This branch has not been deployed
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.
Summary
A chat sheet can keep its message list at a stable layout height and pin its composer to the moving bottom edge of the card. This is useful when a short detent should reveal less of the conversation without resizing the list while the user drags or releases the sheet.
bottomAnchoredContentto inline and modal sheets on iOS and Android. The native host positions and clips the slot against the card during dragging and settling.contentClipTopInseton open detents. It sets the distance from the top of the card to the start of the visible and interactive area ofbottomAnchoredContent. It defaults to zero and interpolates between detents. Regular children still determine the height of content-sized detents.For a footer on its own:
Why the visible content needs a top boundary
A sheet can reveal more or less of a view while keeping that view's layout size stable. When a separate part of the interface occupies the same area, the sheet needs a shared boundary for drawing and touch input. An opaque overlay hides pixels by replacing the surface in that area with a solid fill. That changes the appearance of a translucent or blurred surface. It also leaves the touch boundary to the overlay's separate view hierarchy.
contentClipTopInsetdefines the boundary in native card coordinates and moves it with the card during dragging and settling. It preserves the content's layout and its bottom anchor. A footer on its own normally uses the default of zero.For example, a chat can pass
bottomAnchoredContent={<Conversation />}with a separate header as a regular child. The app can reserve 48 points at the compact detent and 64 at full height, where the header might also include the safe area.What we tried in a Fabric chat sheet
The sheet opens at 50% and expands to 100%. The message list keeps a fixed layout height so opening the sheet reveals more history without resizing or remounting it. The composer stays visible at both detents. During a pause-and-release gesture on iOS, the handle continued moving upward while the list and composer briefly moved down together.
onPositionChange, using Reanimated worklets and layout offsetstranslateYon the canvas, then replace the layout offsets on all four moving viewsCADisplayLink.targetTimestampWhy the native host can keep the content aligned
During an iOS settle, Core Animation presents the card and its clip from keyframes. A display-link callback samples the spring for
onPositionChange. A consumer can handle that event in a Reanimated UI worklet and write a transform without changing React state. The consumer still applies that transform separately from the card's Core Animation animation. Even with the same spring curve, the card and child can show different steps of it in a frame.The reported position measures from the host's bottom to the card's top. The visible bottom also depends on the resolved card insets, scale, and clip. A static
bottom: 0inside the standard content wrapper attaches to the full-height layout box, so it can leave the composer below the visible clip at the compact detent. A screen-level overlay could anchor the composer independently, but would have to coordinate clipping, native scroll handoff, hit testing, keyboard, and dismissal across two separate view hierarchies.The opt-in native slot uses the geometry the host already calculates. On iOS the card, clip and slot share the same Core Animation keyframes and start time. On Android the host updates them in the same geometry pass. The list layout remains fixed, and the same clip governs visibility, hit testing and scroll handoff below the header. This was the smoothest of the tested approaches and preserves the existing gesture physics.
Test plan
Built and installed a Fabric consumer with exact commit
029679con iPhone 17 (iOS 27.2) and Pixel 9 (Android API 37).Checked both detents, fast release, scroll handoff with an inverted list, clipped touch targets, keyboard and composer, rotation, changing the header inset, remounting the slot, and regular content sizing. In 16 sampled moving frames per platform, the composer stayed at the same position while the card expanded.
Verified drag reversal on iOS. The Android reversal recording was inconclusive. Accessibility was checked through the native trees and touch behavior. Screen-reader traversal remains to be checked.
55 Bun tests, 35 focused Android JVM tests, Swift geometry and UIKit host tests passed. TypeScript, ESLint and the package build passed.
Manually compared the all-transform follower and the native anchor in the actual Fabric chat on the same iPhone 17 Pro simulator (iOS 26.4) in the native Simulator window. The follower remained visibly rough after release. The app owner confirmed the anchored build at
029679cmoved smoothly. The test was visual on a simulator. Physical-iPhone frame timing remains unmeasured.Verified the final property name in the generated Fabric schemas for iOS and Android. The rename passed 55 Bun tests, TypeScript, ESLint, the package build, and Swift syntax checking. The device runs above used the previous spelling at the cited commit.