[ios][ui] Add scrollTargetBehavior and scrollTargetLayout modifiers#43955
Conversation
|
Subscribed to pull request
Generated by CodeMention |
35aefec to
fe50c1c
Compare
amandeepmittal
left a comment
There was a problem hiding this comment.
Thank you for adding docs. Left some minor suggestions.
Also, let's wait for the technical review.
fe50c1c to
0954ff8
Compare
0954ff8 to
c47a2ec
Compare
|
Mind taking a look when you get a chance @intergalacticspacehighway? |
|
@ramonclaudio thanks for the PR, sorry for the delay. can |
c47a2ec to
85da2b6
Compare
fe89c0b to
c3f229a
Compare
cc0f7d8 to
cf1484b
Compare
|
@intergalacticspacehighway no worries. I converted scrollTargetLayout from a prop to a modifier and stripped out all scroll position state/callbacks (onScrollPositionChange, scrollToID, scrollToEdge, scrollToPoint, id()). Happy to rebase the scroll position tracking onto main once the worklet chain lands. |
cf1484b to
c095722
Compare
amandeepmittal
left a comment
There was a problem hiding this comment.
Docs changes lg!
@intergalacticspacehighway are we planning to publish this for SDK 55?
yeah, will be shipped with 55! |
…43955) ## Why Split from the larger scroll position tracking PR per @intergalacticspacehighway feedback. Scroll position state and callbacks (`onScrollPositionChange`, `scrollToID`, `id()`) are deferred pending worklet callback support (#44214). `scrollTargetLayout` was converted from a VStack/HStack prop to a modifier, matching SwiftUI's API surface. ## What - `scrollTargetBehavior()` modifier: `paging` or `viewAligned` scroll snapping - `scrollTargetLayout()` modifier: marks a stack as a scroll target layout - `ScrollTargetBehaviorModifier.swift`, `ScrollTargetLayoutModifier.swift` registered in `ViewModifierRegistry` - TS exports in `modifiers/index.ts` with `BuiltInModifier` union entries ```tsx <ScrollView modifiers={[scrollTargetBehavior('paging')]}> <VStack modifiers={[scrollTargetLayout()]}> {items.map(item => ( <Text key={item.id}>{item.text}</Text> ))} </VStack> </ScrollView> ``` ## Test plan - `yarn build` passes - `npx tsc --noEmit` passes - `yarn test` passes (42/42) - `yarn lint --fix` passes (0 errors, 0 warnings) - Swift compiles (ExpoUI target) - Both modifiers have `#available(iOS 17.0, tvOS 17.0, macOS 14.0, *)` guards
Why
Split from the larger scroll position tracking PR per @intergalacticspacehighway feedback. Scroll position state and callbacks (
onScrollPositionChange,scrollToID,id()) are deferred pending worklet callback support (#44214).scrollTargetLayoutwas converted from a VStack/HStack prop to a modifier, matching SwiftUI's API surface.What
scrollTargetBehavior()modifier:pagingorviewAlignedscroll snappingscrollTargetLayout()modifier: marks a stack as a scroll target layoutScrollTargetBehaviorModifier.swift,ScrollTargetLayoutModifier.swiftregistered inViewModifierRegistrymodifiers/index.tswithBuiltInModifierunion entriesTest plan
yarn buildpassesnpx tsc --noEmitpassesyarn testpasses (42/42)yarn lint --fixpasses (0 errors, 0 warnings)#available(iOS 17.0, tvOS 17.0, macOS 14.0, *)guards