Commit 49357e1
authored
feat(predict): add TimeSlotPicker component for series time windows (PRED-788) (#28625)
## **Description**
Add a new `TimeSlotPicker` component for the Predict feature that
displays a horizontal scrollable strip of pill-shaped items representing
time windows (past, live, future) for crypto Up/Down prediction market
series.
This is a standalone reusable component built ahead of the series detail
screen (PRED-786). It includes:
- Four visual pill states: default, selected, live, and selected+live
- Animated pulse dot indicator using Reanimated v3 for the live market
- Real-time countdown timer (MM:SS) for the live market's end time
- Auto-scroll on mount to bring the selected/live pill into view
- Locale-aware time formatting via `Intl.DateTimeFormat`
- Uncontrolled selection with optional `selectedMarketId` override
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
[PRED-788](https://consensyssoftware.atlassian.net/browse/PRED-788)
## **Manual testing steps**
```gherkin
Feature: TimeSlotPicker for crypto Up/Down series
Scenario: Component renders pills for series markets
Given a crypto Up/Down market with series data is available
When the TimeSlotPicker is rendered with the series markets
Then a horizontal scrollable strip of pill-shaped items is displayed
And each pill shows the market's end time in the device's locale format
Scenario: Live market is auto-selected on mount
Given the series contains a market whose endDate is in the future (live)
When the TimeSlotPicker mounts without a selectedMarketId prop
Then the live market pill is auto-selected
And the strip auto-scrolls to bring the live pill into view
Scenario: Live pill displays countdown and pulse animation
Given a market is currently live (endDate in the future, soonest to end)
When viewing the TimeSlotPicker
Then the live pill shows a pulsing red dot, "Live" label, and a MM:SS countdown
And the countdown ticks down every second
Scenario: User taps a non-live pill
Given the live market pill is currently selected
When the user taps a different (future or past) pill
Then the tapped pill becomes selected with a white background and dark text
And the onMarketSelected callback fires with the tapped market
And the live pill remains visible with its pulse dot and countdown (unselected style)
Scenario: Countdown reaches zero
Given the live market's countdown is ticking
When the countdown reaches 00:00
Then the live indicator moves to the next market in the series
And the user's current selection does NOT change automatically
```
## **Screenshots/Recordings**
### **Before**
N/A — new component
### **After**
Demo: https://www.loom.com/share/a6ef4afae3ba4b7c83375b5ebc55971e
<img width="380" alt="Simulator Screenshot - mm-blue - 2026-04-09 at 16
02 23"
src="https://github.com/user-attachments/assets/ef26e1f1-a288-4134-99e7-f207bbffc0c3"
/>
<img width="380" alt="Simulator Screenshot - mm-blue - 2026-04-09 at 16
02 35"
src="https://github.com/user-attachments/assets/a5f9d685-87b4-4ab1-b566-03ac0a820d52"
/>
<img width="380" alt="Simulator Screenshot - mm-blue - 2026-04-09 at 16
02 43"
src="https://github.com/user-attachments/assets/24fa49ce-1231-4e90-bcbc-0d77cab2e550"
/>
<img width="380" alt="Simulator Screenshot - mm-blue - 2026-04-09 at 16
02 55"
src="https://github.com/user-attachments/assets/ed8d1d09-68c2-4cdd-acc1-34827b40826e"
/>
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
[PRED-788]:
https://consensyssoftware.atlassian.net/browse/PRED-788?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk: this is a new, self-contained UI component with helper
utilities and unit tests, with no changes to existing business logic,
auth, or data flows.
>
> **Overview**
> Adds a new `TimeSlotPicker` component that renders a horizontal list
of selectable “time window” pills for a series, auto-selecting the
*live* (soonest-ending future) market by default and auto-scrolling the
strip to the resolved selection.
>
> Live pills now show an animated pulse indicator (Reanimated) plus an
`MM:SS` countdown driven by a new `useCountdown` hook, while non-live
pills display a locale-formatted end time via `formatTime`.
>
> Includes supporting constants/types, selection utilities
(`findLiveMarket`, `findNearestMarket`), and comprehensive unit tests
for the component, utilities, and countdown behavior.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f4ee540. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 7a18715 commit 49357e1
9 files changed
Lines changed: 929 additions & 0 deletions
File tree
- app/components/UI/Predict/components/TimeSlotPicker
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 251 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
0 commit comments