feat(native/wheel-picker): enable looping (23->00 / 59->00) #224
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.
Time wheel: enable visual looping (…23→00 / 59→00…).
Description
This PR modifies wheel-picker.tsx so the hour/minute wheels loop visually (e.g., 23→00, 59→00) instead of stopping at the ends. Previously on Android and iOS the list ended at the last option (e.g., 23 or 59). To mimic the web experience and common native pickers, this change allows both wheels to “wrap” so users can keep scrolling in either direction.
Looping was implemented by physically repeating the option list inside the FlatList and mapping the scrolled row back to the base option via a small helper. Selection math, snapping, and UI style remain unchanged.
Changes
Bug Fix: Unexpected Initial Time Change on Time Picker load
Unexpectedly this also fixed a bug/issue where the time was reseting to 00:00 when you clicked on the header (I had a seperate branch where I fixed this issue but adding this feature seemed to have also resolved that bug making my previous branch redundant, so I didn't push these changes or make a PR for it. )
Before this change, the wheel could emit an unintended 0 during mount or view switches: using initialScrollIndex on a padded list sometimes caused an early “settle” at the top, the index could be out-of-range/undefined and then clamped or coerced (e.g. || 0), and the wheel would call onChange(0)—overwriting the parent’s seeded time and making it look like it snapped to 00:00.
This PR hardens the wheel so that can’t happen: we seed via scrollToOffset into the middle block (no initialScrollIndex), ignore the first settle (no mount-time emit), wrap indices instead of clamping, and emit the exact option value (no || 0). As a result, the wheel no longer pushes 00:00 back into state, and the header-seeded time persists.
Fixes: #169