Skip to content

Commit 1c1e238

Browse files
committed
feat(Wheel): UIPickerView's wheel in the iOS idiom, on the gesture recognizer and compositor curves
The picker wheel is a native scroll-snap column. WebKit gives every scroll-snapping scroller the fast deceleration rate (0.99/ms) while UIPickerView decelerates at the normal rate (0.998) onto a row it picks from its own projection, and a native scroll's momentum cannot be caught or held to a curve. In the iOS idiom (WebKit on iOS or iPadOS under a finger) the Wheel is now UIPickerView's, PickerWheel.tsx, on the gesture system and the picker's values in the UIKit constants table: - A PanGestureRecognizer drags the rows, on UIKit's rubber band past an end. The lift plays UIKit's release plan (wheelPhysics.ts); a finger landing on a moving wheel stops it where it is; a tap turns a row onto the band. - Each motion plays through wheelMotion.ts: per-row Web Animations on the compositor, each row turned onto the cylinder, with a selection tick per row reached where the browser can vibrate. - The tap spin's duration and curve and the bounce at an end are the theme's motion roles (picker.tapSpin.durationMs, timing.curves.easeInOut, scroll.bounce), resolved against the column as each motion starts. - The value commits when the wheel comes to rest; keys and clicks commit at once and turn the wheel. - isLooping, resolveRest and a spinTo(index) handle for the date and time wheels. - WheelGroup: one band and one vanishing point across picker columns. A Wheel on its own draws its own band. - The column keeps the pointer of a finger that lands on it, as it keeps the touch: a BottomSheet would otherwise arm its pull-down on the pointer and follow the first 8 px of a downward drag. The switch reads the sheet's touch modes through usePresentation (architecture:public-component-api INV16): a wheel shows only on a sheet, so a caller who pins the fine surface gets no sheet and no wheel. Everywhere else (Android, a mouse) Wheel keeps today's scrolling column, now named ScrollWheel and otherwise unchanged; there spinTo commits at once and isLooping and resolveRest do nothing, and WheelGroup renders its children alone. The shared types and nearestEnabledIndex move to wheelOptions.ts.
1 parent d19effd commit 1c1e238

13 files changed

Lines changed: 2025 additions & 90 deletions

‎.changeset/wheel-uikit-picker.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[fix] On iOS and iPadOS, under a finger, the picker wheels in the TimeInput, DateTimeInput and DateInput bottom sheets now look and move like iOS's own picker. The rows sit on a cylinder seen in perspective, and the row in the capsule band is magnified. A flick coasts at UIKit's deceleration onto the row UIKit's projection picks. A finger landing on a moving wheel stops it. A tap on a row turns it onto the band. Past the first or last row, a drag rubber-bands and the wheel bounces back. As on iOS, the value commits when the wheel comes to rest, and the coast keeps running while the page's main thread is busy. Arrow keys and clicks on a row still commit at once. A theme can retune the tap spin's duration (`picker.tapSpin.durationMs`) and curve (`timing.curves.easeInOut`) and the bounce at an end (`scroll.bounce`). On Android and with a mouse the wheels are unchanged.
6+
7+
@vjeux

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,8 @@ jobs:
16231623
--output menu-press-shadow-root-output
16241624
16251625
# A two-finger pinch over an open picker wheel must zoom the page (WCAG
1626-
# 1.4.4) while one finger still scrolls the wheel. jsdom computes no
1626+
# 1.4.4) while one finger still moves the wheel, on today's column and
1627+
# on the iOS column (the iOS idiom, emulated). jsdom computes no
16271628
# touch-action, so only a real engine shows which gesture the browser
16281629
# keeps.
16291630
- name: Run picker wheel pinch-zoom contract
@@ -1668,9 +1669,10 @@ jobs:
16681669
--output tooltip-hover-bridge-output
16691670
16701671
# A picker wheel dragged onto a row outside its bounds must come to rest
1671-
# on the nearest row inside them. The stop comes from native scrolling,
1672-
# CSS snapping and the browser's end-of-scroll signal, none of which
1673-
# jsdom has.
1672+
# on the nearest row inside them. On today's column the stop comes from
1673+
# native scrolling, CSS snapping and the browser's end-of-scroll signal;
1674+
# on the iOS column (the iOS idiom, emulated) from real touch input
1675+
# through the gesture system. jsdom has neither.
16741676
- name: Run picker wheel rest contract
16751677
run: |
16761678
pnpm exec playwright test \

‎packages/core/src/DateInput/DateInputTouch.test.tsx‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
rowsIn,
5555
DEFAULT_MONTH_REACH,
5656
} from './monthGeometry';
57+
import {picker} from '../motion/uikit';
5758
import {SWIPE_DISTANCE} from './useOwnScrollGesture';
5859
import {DRAG_SLOP} from './usePointerDragScroll';
5960
import {SCROLL_QUIET_MS} from './useScrollSettle';
@@ -2572,6 +2573,38 @@ describe('DateInput — scroll CSS (definition-level)', () => {
25722573
expect(item).not.toContain("overflow: 'hidden'");
25732574
});
25742575

2576+
it('sizes the iOS wheels as UIPickerView, with the large text of the theme', () => {
2577+
// StyleX inlines only literals, so the picker's geometry is repeated in
2578+
// the tokens; it must stay the UIKit table's.
2579+
const tokens = read('tokens.stylex.ts');
2580+
const {geometry} = picker;
2581+
expect(tokens).toContain(`pickerHeight: '${geometry.height}px'`);
2582+
expect(tokens).toContain(`rowHeight: '${geometry.rowHeight}px'`);
2583+
expect(tokens).toContain(`rowHalfHeight: '${geometry.rowHeight / 2}px'`);
2584+
expect(tokens).toContain(`rowOriginDepth: '-${geometry.cylinderRadius}px'`);
2585+
expect(tokens).toContain(`perspective: '${geometry.perspective}px'`);
2586+
expect(tokens).toContain(`bandHeight: '${geometry.bandHeight}px'`);
2587+
expect(tokens).toContain(`bandInset: '${geometry.bandInset}px'`);
2588+
expect(tokens).toContain(
2589+
`bandMagnification: '${geometry.bandMagnification.toFixed(3)}'`,
2590+
);
2591+
expect(tokens).toContain(`outerOpacity: '${geometry.outerOpacity}'`);
2592+
expect(read('PickerWheel.tsx')).toContain(
2593+
"fontSize: typeScaleVars['--text-large-size']",
2594+
);
2595+
});
2596+
2597+
it('draws the dimmed iOS rows on the cylinder, in perspective, with the band cut out', () => {
2598+
const drum = declarations(read('PickerWheel.tsx'), 'drum');
2599+
expect(drum).toContain('perspective: wheelGeometry.perspective');
2600+
expect(drum.join(' ')).toContain('polygon(evenodd');
2601+
const row = declarations(read('PickerWheel.tsx'), 'row');
2602+
expect(row).toContain(
2603+
'transformOrigin: `50% 50% ${wheelGeometry.rowOriginDepth}`',
2604+
);
2605+
expect(row).toContain("backfaceVisibility: 'hidden'");
2606+
});
2607+
25752608
it('insets the sheet content equally on every edge', () => {
25762609
const source = read('TouchDateField.tsx');
25772610
// One inset, and the header/footer must not add their own on top of it —

0 commit comments

Comments
 (0)