@tastic/shell 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,8 @@ import { IconButton, Pressable } from '@rific/feedback-press'
3
3
  import { PressAwayOverlay, usePopoverHost, useWellColors, WELL_SHADOW } from '@tastic/hud/chrome'
4
4
  import { getProfilePickerContentSize, type Profile, ProfilePicker, type ProfilePickerColorSection } from '@tastic/profile'
5
5
  import { router, useFocusEffect, useIsFocused } from 'expo-router'
6
- import { type ReactNode, useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
7
- import { AppState, type AppStateStatus, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent, type ScrollView, StyleSheet, View } from 'react-native'
6
+ import { createContext, memo, type ReactNode, startTransition, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
7
+ import { AppState, type AppStateStatus, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent, Platform, type ScrollView, type StyleProp, StyleSheet, View, type ViewStyle } from 'react-native'
8
8
  import { Icon, Portal, SegmentedButtons, Text } from 'react-native-paper'
9
9
 
10
10
  import { useGameGuide } from '../components/GuideHost'
@@ -17,7 +17,7 @@ import { useProfiles } from '../hooks/useProfiles'
17
17
  import { useSeatColors } from '../hooks/useSeatColors'
18
18
  import { usePack } from '../PackContext'
19
19
  import { loadoutHref, playHref, profilesHref, STATS_HREF } from '../routes'
20
- import type { HomeTab, PackGameDefinition } from '../types'
20
+ import type { PackGameDefinition } from '../types'
21
21
  import { HOME_GRID_GAP, HOME_LEFT_PANE_PICKER_GAP, HOME_TILE_PADDING, HOME_TOP_BAND, HOME_WIDE_PANE_GAP, PREVIEW_ASPECT, ROW_PREVIEW_WIDTH, useHomeLayout } from './homeLayout'
22
22
 
23
23
  // Home: who's playing (seat 1, the same seat 1 every loadout starts with), then every game in the
@@ -146,14 +146,19 @@ function HomeMenu() {
146
146
  const triggerStyle = useMemo(() => (pack.Backdrop ? [styles.pill, { backgroundColor: colors.surface }] : undefined), [pack.Backdrop, colors.surface])
147
147
 
148
148
  // The pack's tabs (PackDefinition.homeTabs): one tab's games at a time, the same switch as the stats
149
- // screen's tabs (on the theme's surface over a backdrop). The other tabs' games stay mounted, hidden, so
150
- // a switch draws nothing new (their previews are already there). The tab is Home's own state, kept while
151
- // Home is covered, since Home stays mounted under every screen it opens.
149
+ // screen's tabs (on the theme's surface over a backdrop), each in its own pane (TabPane). The tab is
150
+ // Home's own state, kept while Home is covered, since Home stays mounted under every screen it opens.
152
151
  const tabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null
153
152
  const [tabLabel, setTabLabel] = useState(() => tabs?.[0].label ?? null)
154
153
  const tab = tabs ? (tabs.find((t) => t.label === tabLabel) ?? tabs[0]) : null
155
154
  const tabButtons = useMemo(() => tabs?.map(({ label }) => ({ value: label, label, labelStyle: pack.labelStyle })) ?? [], [tabs, pack.labelStyle])
156
155
  const tabBar = tab && <SegmentedButtons value={tab.label} onValueChange={setTabLabel} buttons={tabButtons} theme={SEGMENT_THEME} style={[styles.tabs, pack.Backdrop && { backgroundColor: colors.surface }]} />
156
+ const panes = useMemo(() => (tabs ? tabs.map((t) => ({ key: t.label, games: pack.games.filter(t.includes) })) : [{ key: ALL_GAMES, games: pack.games }]), [tabs, pack.games])
157
+ const shownPane = tab?.label ?? ALL_GAMES
158
+ // One element for as long as nothing it shows changes: a hero is animated art (Solitaire's a fan of five
159
+ // cards), and Home's own state (a tab, a menu, a sheet) is never its business.
160
+ const { width: fitWidth, height: fitHeight } = layout.heroFit ?? NO_FIT
161
+ const hero = useMemo(() => <pack.HeroTitle words={pack.wordmark} color={fg} p1Color={p1Color} p2Color={p2Color} active={heroActive} fit={isWide && fitWidth !== undefined ? { width: fitWidth, height: fitHeight } : undefined} />, [pack, fg, p1Color, p2Color, heroActive, isWide, fitWidth, fitHeight])
157
162
  const columnClamp = useClampOnShrink()
158
163
  const gridClamp = useClampOnShrink()
159
164
 
@@ -171,7 +176,7 @@ function HomeMenu() {
171
176
  const pickerAlign = usePickerAlign(pickerHost.openId === `${SEAT_ONE_PICKER}-profile`, pickerSize.width, pickerSize.height)
172
177
 
173
178
  // A pack can leave seat 1's button off Home (PackDefinition.homePlayerPicker)
174
- const picker = <ProfilePicker idPrefix={SEAT_ONE_PICKER} host={pickerHost} profiles={profiles} selectedId={lastSelected[1]} color={p1Drawn} dark={dark} guestLabel={pack.guestLabel ?? 'P1'} nullLabel={pack.nullLabel} onSelect={(profile: Profile | null) => selectProfile(1, profile?.id ?? null)} onManage={() => router.push(profilesHref(1))} colorSection={colorSection} alignOverride={pickerAlign} triggerStyle={triggerStyle} />
179
+ const picker = <ProfilePicker idPrefix={SEAT_ONE_PICKER} host={pickerHost} caption='Player' profiles={profiles} selectedId={lastSelected[1]} color={p1Drawn} dark={dark} guestLabel={pack.guestLabel ?? 'P1'} nullLabel={pack.nullLabel} onSelect={(profile: Profile | null) => selectProfile(1, profile?.id ?? null)} onManage={() => router.push(profilesHref(1))} colorSection={colorSection} alignOverride={pickerAlign} triggerStyle={triggerStyle} />
175
180
 
176
181
  // Closes seat 1's menu on a press anywhere but the menu and its button. Where it's mounted matters on
177
182
  // a phone, where zIndex only orders the children of one parent: the menu lives inside the scroller in
@@ -188,47 +193,49 @@ function HomeMenu() {
188
193
  sheet renders inside it instead (see RulesHost). */}
189
194
  <View style={styles.frame}>
190
195
  <RulesHost enabled={pack.games.some((game) => game.Rules)}>
191
- {isWide ? (
192
- <>
193
- {pressAway}
194
- {/* Right pane: the game grid, scrolling on its own beside the left pane. The scroller runs
196
+ <PreviewsRevealed value={previewsRevealed}>
197
+ {isWide ? (
198
+ <>
199
+ {pressAway}
200
+ {/* Right pane: the game grid, scrolling on its own beside the left pane. The scroller runs
195
201
  to the frame's right edge and the cog's gutter is its content's padding, so a web scrollbar
196
202
  sits at the window's edge. Both scrollers fade out at an edge while there is more past it
197
203
  (auto-paper's FadingScrollView, a mask, so whatever is behind shows through). */}
198
- <FadingScrollView {...(tab && gridClamp)} style={[styles.wideRightPane, { left: layout.paddingLeft + layout.leftPaneWidth + HOME_WIDE_PANE_GAP }]} contentContainerStyle={{ paddingTop: 16 + insets.top, paddingBottom: 16 + insets.bottom, paddingRight: layout.paddingRight }}>
199
- {tabBar && <View style={[styles.wideTabs, { width: layout.rightPaneWidth }]}>{tabBar}</View>}
200
- <View style={[styles.grid, { width: layout.rightPaneWidth }]}>
201
- {pack.games.map((game) => (
202
- <GameTile key={game.id} game={game} hidden={isHidden(tab, game)} width={layout.tileWidth} previewWidth={layout.previewWidth} previewRevealed={previewsRevealed} dark={dark} p1Color={p1Color} p2Color={p2Color} onPress={() => openGame(game)} onRules={hasRules(game) ? () => openRules(game) : undefined} />
203
- ))}
204
- </View>
205
- </FadingScrollView>
206
- {/* Left pane: the hero, then seat 1's button, centred as one group under the corner
204
+ <FadingScrollView {...(tab && gridClamp)} style={[styles.wideRightPane, { left: layout.paddingLeft + layout.leftPaneWidth + HOME_WIDE_PANE_GAP }]} contentContainerStyle={{ paddingTop: 16 + insets.top, paddingBottom: 16 + insets.bottom, paddingRight: layout.paddingRight }}>
205
+ {tabBar && <View style={[styles.wideTabs, { width: layout.rightPaneWidth }]}>{tabBar}</View>}
206
+ <View style={{ width: layout.rightPaneWidth }}>
207
+ <TabPanes panes={panes} shown={shownPane} buildOthers={isFocused} style={styles.grid}>
208
+ {(games, built) => <GameGrid games={games} built={built} width={layout.tileWidth} previewWidth={layout.previewWidth} dark={dark} p1Color={p1Color} p2Color={p2Color} onOpen={openGame} onRules={openRules} />}
209
+ </TabPanes>
210
+ </View>
211
+ </FadingScrollView>
212
+ {/* Left pane: the hero, then seat 1's button, centred as one group under the corner
207
213
  buttons' band. A later sibling of the grid, lifted while seat 1's menu is open so the menu
208
214
  paints over the tiles. box-none: only its controls claim taps. */}
209
- <View style={[styles.wideLeftPane, { left: layout.paddingLeft, width: layout.leftPaneWidth, paddingTop: HOME_TOP_BAND + insets.top, paddingBottom: 16 + insets.bottom }, pickerHost.openId !== null && styles.pickerOpen]}>
210
- <pack.HeroTitle words={pack.wordmark} color={fg} p1Color={p1Color} p2Color={p2Color} active={heroActive} fit={layout.heroFit} />
211
- {showPicker && <View style={styles.widePicker}>{picker}</View>}
212
- </View>
213
- </>
214
- ) : (
215
- <FadingScrollView {...(tab && columnClamp)} style={styles.scroll} contentContainerStyle={[styles.content, { paddingTop: 56 + insets.top, paddingBottom: 24 + insets.bottom, paddingLeft: 16 + insets.left, paddingRight: 16 + insets.right }]}>
216
- {pressAway}
217
- <pack.HeroTitle words={pack.wordmark} color={fg} p1Color={p1Color} p2Color={p2Color} active={heroActive} />
218
-
219
- {/* Who's playing: seat 1's button, the same one each loadout starts with. Lifted above the
215
+ <View style={[styles.wideLeftPane, { left: layout.paddingLeft, width: layout.leftPaneWidth, paddingTop: HOME_TOP_BAND + insets.top, paddingBottom: 16 + insets.bottom }, pickerHost.openId !== null && styles.pickerOpen]}>
216
+ {hero}
217
+ {showPicker && <View style={styles.widePicker}>{picker}</View>}
218
+ </View>
219
+ </>
220
+ ) : (
221
+ <FadingScrollView {...(tab && columnClamp)} style={styles.scroll} contentContainerStyle={[styles.content, { paddingTop: 56 + insets.top, paddingBottom: 24 + insets.bottom, paddingLeft: 16 + insets.left, paddingRight: 16 + insets.right }]}>
222
+ {pressAway}
223
+ {hero}
224
+
225
+ {/* Who's playing: seat 1's button, the same one each loadout starts with. Lifted above the
220
226
  tiles while its menu is open, so the menu paints over them. */}
221
- {showPicker && <View style={[styles.picker, pickerHost.openId !== null && styles.pickerOpen]}>{picker}</View>}
227
+ {showPicker && <View style={[styles.picker, pickerHost.openId !== null && styles.pickerOpen]}>{picker}</View>}
222
228
 
223
- {tabBar && <View style={styles.listWidth}>{tabBar}</View>}
229
+ {tabBar && <View style={styles.listWidth}>{tabBar}</View>}
224
230
 
225
- <View style={styles.list}>
226
- {pack.games.map((game) => (
227
- <GameRow key={game.id} game={game} hidden={isHidden(tab, game)} dark={dark} p1Color={p1Color} p2Color={p2Color} previewRevealed={previewsRevealed} onPress={() => openGame(game)} onRules={hasRules(game) ? () => openRules(game) : undefined} />
228
- ))}
229
- </View>
230
- </FadingScrollView>
231
- )}
231
+ <View style={styles.listWidth}>
232
+ <TabPanes panes={panes} shown={shownPane} buildOthers={isFocused} style={styles.list}>
233
+ {(games, built) => <GameList games={games} built={built} dark={dark} p1Color={p1Color} p2Color={p2Color} onOpen={openGame} onRules={openRules} />}
234
+ </TabPanes>
235
+ </View>
236
+ </FadingScrollView>
237
+ )}
238
+ </PreviewsRevealed>
232
239
 
233
240
  <IconButton icon='trophy' iconColor={fg} size={24} style={[styles.corner, { top: 8 + insets.top, left: 8 + insets.left }]} onPress={() => router.push(STATS_HREF)} accessibilityLabel='Stats & Achievements' />
234
241
  <IconButton icon='cog' iconColor={fg} size={24} style={[styles.corner, { top: 8 + insets.top, right: 8 + insets.right }]} onPress={() => setSettingsOpen(true)} accessibilityLabel='Settings' />
@@ -249,11 +256,83 @@ const SEAT_ONE_PICKER = 'home-p1'
249
256
  // No placement of the pack's own: hud places the menu itself.
250
257
  const noPickerAlign = () => undefined
251
258
 
252
- // A game the tab picked doesn't include: kept mounted, out of the layout and out of a screen reader's way.
253
- function isHidden(tab: HomeTab | null, game: PackGameDefinition): boolean {
254
- return !!tab && !tab.includes(game)
259
+ // The upright layout's hero has no box to fit.
260
+ const NO_FIT: { width?: number; height: number } = { height: 0 }
261
+
262
+ // The one pane's key in a pack without tabs.
263
+ const ALL_GAMES = '__all__'
264
+
265
+ interface TabPanesProps {
266
+ panes: readonly { key: string; games: readonly PackGameDefinition[] }[]
267
+ // The key of the one shown.
268
+ shown: string
269
+ // Home is on screen, so the others may be built.
270
+ buildOthers: boolean
271
+ // Each pane's own style: a list or a grid.
272
+ style: StyleProp<ViewStyle>
273
+ children: (games: readonly PackGameDefinition[], built: number) => ReactNode
274
+ }
275
+
276
+ // Every tab's games, one pane shown (a pack without tabs has the one pane). Its own component, so building
277
+ // the others game by game renders nothing else of Home.
278
+ function TabPanes({ panes, shown, buildOthers, style, children }: TabPanesProps) {
279
+ const mostGames = Math.max(...panes.map(({ games }) => games.length))
280
+ const builtGames = useBuiltGames(shown, mostGames, buildOthers && panes.length > 1)
281
+ return panes.map(({ key, games }) => {
282
+ const built = builtGames(key)
283
+ if (built === 0) return null
284
+ return (
285
+ <TabPane key={key} shown={key === shown} style={style}>
286
+ {children(games, built)}
287
+ </TabPane>
288
+ )
289
+ })
290
+ }
291
+
292
+ // How many of each tab's games are built: all of the one shown, and of every other none until Home has been
293
+ // on screen for OTHER_PANES_DELAY_MS, then one more every OTHER_PANES_STEP_MS, each in a transition behind
294
+ // anything the player does. Building every game at once held a launch up by a second and a half on a slow
295
+ // phone (Solitaire's two-player tiles, on an LG Stylo 6), for games nobody had asked to see yet, and building
296
+ // the other tab in one go froze Home for half a second just as it came up. A tab picked sooner is built there
297
+ // and then, and stays built. The web builds them all at once, so a static export's page still names every game.
298
+ function useBuiltGames(shown: string, total: number, buildOthers: boolean): (pane: string) => number {
299
+ const [picked, setPicked] = useState<readonly string[]>([shown])
300
+ if (!picked.includes(shown)) setPicked([...picked, shown])
301
+ const [others, setOthers] = useState(Platform.OS === 'web' ? total : 0)
302
+ const building = buildOthers && others < total
303
+ useEffect(() => {
304
+ if (!building) return
305
+ const id = setTimeout(() => startTransition(() => setOthers(others + 1)), others === 0 ? OTHER_PANES_DELAY_MS : OTHER_PANES_STEP_MS)
306
+ return () => clearTimeout(id)
307
+ }, [building, others])
308
+ return (pane) => (pane === shown || picked.includes(pane) ? total : others)
309
+ }
310
+
311
+ // How long Home is on screen before the other tabs are built: past a launch's own work (previews, the
312
+ // hero's entrance), and before most players reach for another tab.
313
+ export const OTHER_PANES_DELAY_MS = 1200
314
+ // Between one game of the other tabs and the next, which leaves the phone more time idle than building.
315
+ export const OTHER_PANES_STEP_MS = 150
316
+
317
+ // One tab's games. A pane that isn't shown stays mounted, off the layout and out of a screen reader's way.
318
+ // On a phone it's drawn at opacity 0 over the shown pane's place, never display: none: React Native doesn't
319
+ // mount a display: none view's children at all, so every switch made one tab's native views afresh and
320
+ // deleted the other's (a frame of 0.4 to 0.5 s on a slow phone). The web has no such cost, and display: none
321
+ // also takes the hidden games out of the Tab key's way there. collapsable={false} keeps the pane one native
322
+ // view whichever way it's styled; otherwise the change of opacity would flatten and rebuild what's in it.
323
+ function TabPane({ shown, style, children }: { shown: boolean; style: StyleProp<ViewStyle>; children: ReactNode }) {
324
+ return (
325
+ <View collapsable={false} aria-hidden={!shown} style={[style, !shown && styles.paneHidden]}>
326
+ {children}
327
+ </View>
328
+ )
255
329
  }
256
330
 
331
+ // Whether a game's preview may draw yet (see previewsRevealed). A context rather than a prop, so revealing
332
+ // them draws the previews and nothing else of every row.
333
+ const PreviewsRevealedContext = createContext(false)
334
+ const PreviewsRevealed = PreviewsRevealedContext.Provider
335
+
257
336
  // iOS leaves a scroller's offset past the end when its content shrinks (React Native's own TODO, T190695447
258
337
  // in RCTScrollViewComponentView.mm), so a switch to a shorter tab while scrolled down would leave blank space
259
338
  // under the last game until the next drag. This pulls it back in, as Android and the web do by themselves.
@@ -297,18 +376,31 @@ function RulesHost({ enabled, children }: { enabled: boolean; children: ReactNod
297
376
  return enabled ? <Portal.Host>{children}</Portal.Host> : <>{children}</>
298
377
  }
299
378
 
300
- interface GameRowProps {
301
- game: PackGameDefinition
302
- // Not in the tab picked (PackDefinition.homeTabs).
303
- hidden: boolean
379
+ interface GamesProps {
380
+ games: readonly PackGameDefinition[]
381
+ // How many of them are built so far (useBuiltGames).
382
+ built: number
304
383
  dark: boolean
305
384
  p1Color: string
306
385
  p2Color: string
307
- // Whether Home has painted once, so a preview may draw (see previewsRevealed).
308
- previewRevealed: boolean
309
- onPress: () => void
310
- // Undefined for a game with no rules sheet and no How to Play cards: no rules button.
311
- onRules?: () => void
386
+ onOpen: (game: PackGameDefinition) => void
387
+ onRules: (game: PackGameDefinition) => void
388
+ }
389
+
390
+ // A pane's games as rows, or as tiles in the wide layout's grid. Memoized, and each row and tile too, so
391
+ // switching tabs, opening the player menu, building one more game or anything else Home's own state holds
392
+ // renders no other game: Home is every game in the pack, about a thousand components in Solitaire, and a
393
+ // switch that rendered them all took 0.3 s of a slow phone's JS.
394
+ const GameList = memo(function GameList({ games, built, ...rest }: GamesProps) {
395
+ return games.slice(0, built).map((game) => <GameRow key={game.id} game={game} {...rest} />)
396
+ })
397
+
398
+ const GameGrid = memo(function GameGrid({ games, built, ...rest }: GamesProps & { width: number; previewWidth: number }) {
399
+ return games.slice(0, built).map((game) => <GameTile key={game.id} game={game} {...rest} />)
400
+ })
401
+
402
+ interface GameRowProps extends Omit<GamesProps, 'games' | 'built'> {
403
+ game: PackGameDefinition
312
404
  }
313
405
 
314
406
  // One game on its own well: its icon at app-icon size (the art was drawn as an app icon), or its
@@ -317,16 +409,16 @@ interface GameRowProps {
317
409
  // How many lines a row's blurb may wrap to before it's cut off.
318
410
  export const ROW_BLURB_LINES = 3
319
411
 
320
- function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPress, onRules }: GameRowProps) {
412
+ const GameRow = memo(function GameRow({ game, dark, p1Color, p2Color, onOpen, onRules }: GameRowProps) {
321
413
  const { titleStyle } = usePack()
322
414
  const well = useWellColors()
323
415
  const GameIcon = game.icon
324
416
  return (
325
417
  // The rules button sits beside the row's own button, laid over its end, not inside it: a button
326
418
  // inside a button is invalid on the web.
327
- <View style={hidden ? styles.hidden : undefined}>
328
- <Pressable onPress={onPress} style={[styles.row, { backgroundColor: well.bg }]} accessibilityRole='button' accessibilityLabel={game.title}>
329
- {game.Preview ? <PreviewBox game={game} width={ROW_PREVIEW_WIDTH} revealed={previewRevealed} dark={dark} p1Color={p1Color} p2Color={p2Color} /> : <View style={[styles.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }]}>{GameIcon && <GameIcon size={ROW_ICON_SIZE} p1Color={p1Color} p2Color={p2Color} dark={dark} />}</View>}
419
+ <View>
420
+ <Pressable onPress={() => onOpen(game)} style={[styles.row, { backgroundColor: well.bg }]} accessibilityRole='button' accessibilityLabel={game.title}>
421
+ {game.Preview ? <PreviewBox game={game} width={ROW_PREVIEW_WIDTH} dark={dark} p1Color={p1Color} p2Color={p2Color} /> : <View style={[styles.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }]}>{GameIcon && <GameIcon size={ROW_ICON_SIZE} p1Color={p1Color} p2Color={p2Color} dark={dark} />}</View>}
330
422
  <View style={styles.rowText}>
331
423
  <Text variant='titleLarge' style={[styles.rowTitle, { color: well.fg }, titleStyle]} numberOfLines={1}>
332
424
  {game.title}
@@ -338,14 +430,14 @@ function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPres
338
430
  </Text>
339
431
  </View>
340
432
  </Pressable>
341
- {onRules && (
342
- <Pressable onPress={onRules} style={styles.rulesButton} hitSlop={12} accessibilityRole='button' accessibilityLabel={`${game.title} rules`}>
433
+ {hasRules(game) && (
434
+ <Pressable onPress={() => onRules(game)} style={styles.rulesButton} hitSlop={12} accessibilityRole='button' accessibilityLabel={`${game.title} rules`}>
343
435
  <Icon source='information-outline' size={22} color={well.fgMuted} />
344
436
  </Pressable>
345
437
  )}
346
438
  </View>
347
439
  )
348
- }
440
+ })
349
441
 
350
442
  interface GameTileProps extends GameRowProps {
351
443
  width: number
@@ -355,13 +447,13 @@ interface GameTileProps extends GameRowProps {
355
447
  // One game in the wide layout's grid: the row turned on its side, its preview (or icon) on top and its
356
448
  // name and blurb under it, since a row needs ~290pt, more than a grid column beside the hero has. The
357
449
  // rules button floats over the preview's corner, beside the tile's button rather than inside it.
358
- function GameTile({ game, hidden, width, previewWidth, dark, p1Color, p2Color, previewRevealed, onPress, onRules }: GameTileProps) {
450
+ const GameTile = memo(function GameTile({ game, width, previewWidth, dark, p1Color, p2Color, onOpen, onRules }: GameTileProps) {
359
451
  const { titleStyle } = usePack()
360
452
  const well = useWellColors()
361
453
  return (
362
- <View style={[{ width }, hidden && styles.hidden]}>
363
- <Pressable onPress={onPress} style={[styles.tile, { backgroundColor: well.bg }]} accessibilityRole='button' accessibilityLabel={game.title}>
364
- <PreviewBox game={game} width={previewWidth} revealed={previewRevealed} dark={dark} p1Color={p1Color} p2Color={p2Color} />
454
+ <View style={{ width }}>
455
+ <Pressable onPress={() => onOpen(game)} style={[styles.tile, { backgroundColor: well.bg }]} accessibilityRole='button' accessibilityLabel={game.title}>
456
+ <PreviewBox game={game} width={previewWidth} dark={dark} p1Color={p1Color} p2Color={p2Color} />
365
457
  <Text variant='titleMedium' style={[styles.rowTitle, { color: well.fg }, titleStyle]} numberOfLines={1}>
366
458
  {game.title}
367
459
  </Text>
@@ -369,19 +461,18 @@ function GameTile({ game, hidden, width, previewWidth, dark, p1Color, p2Color, p
369
461
  {game.blurb}
370
462
  </Text>
371
463
  </Pressable>
372
- {onRules && (
373
- <Pressable onPress={onRules} style={styles.tileRulesButton} hitSlop={12} accessibilityRole='button' accessibilityLabel={`${game.title} rules`}>
464
+ {hasRules(game) && (
465
+ <Pressable onPress={() => onRules(game)} style={styles.tileRulesButton} hitSlop={12} accessibilityRole='button' accessibilityLabel={`${game.title} rules`}>
374
466
  <Icon source='information-outline' size={20} color='#FFFFFF' />
375
467
  </Pressable>
376
468
  )}
377
469
  </View>
378
470
  )
379
- }
471
+ })
380
472
 
381
473
  interface PreviewBoxProps {
382
474
  game: PackGameDefinition
383
475
  width: number
384
- revealed: boolean
385
476
  dark: boolean
386
477
  p1Color: string
387
478
  p2Color: string
@@ -389,7 +480,8 @@ interface PreviewBoxProps {
389
480
 
390
481
  // A box of the preview's shape (PREVIEW_ASPECT) holding the game's preview, once Home has painted, or
391
482
  // its icon centred where it has none (a tile in a pack where only some games have one).
392
- function PreviewBox({ game, width, revealed, dark, p1Color, p2Color }: PreviewBoxProps) {
483
+ function PreviewBox({ game, width, dark, p1Color, p2Color }: PreviewBoxProps) {
484
+ const revealed = useContext(PreviewsRevealedContext)
393
485
  const height = Math.round(width / PREVIEW_ASPECT)
394
486
  const { Preview, icon: GameIcon } = game
395
487
  const iconSize = Math.min(height, ROW_ICON_SIZE)
@@ -434,21 +526,21 @@ const styles = StyleSheet.create({
434
526
  flexWrap: 'wrap',
435
527
  gap: HOME_GRID_GAP
436
528
  },
437
- // Out of the layout (a grid closes up around it) and hidden from screen readers.
438
- hidden: {
439
- display: 'none'
440
- },
441
- // Solitaire's list: one column, never wider than a phone's, centred on a wide screen.
529
+ // Solitaire's list: one column.
442
530
  list: {
443
- gap: 14,
444
- maxWidth: 480,
445
- width: '100%'
531
+ gap: 14
446
532
  },
447
- // The list's width, for the tabs over it.
533
+ // The list's width, and the tabs' over it: never wider than a phone's, centred on a wide screen.
448
534
  listWidth: {
449
535
  maxWidth: 480,
450
536
  width: '100%'
451
537
  },
538
+ // A tab's pane that isn't shown (TabPane): out of the layout, over the shown pane's place, drawing
539
+ // nothing.
540
+ paneHidden: Platform.select<ViewStyle>({
541
+ web: { display: 'none' },
542
+ default: { left: 0, opacity: 0, pointerEvents: 'none', position: 'absolute', right: 0, top: 0 }
543
+ })!,
452
544
  picker: {
453
545
  alignItems: 'center'
454
546
  },
@@ -183,7 +183,10 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
183
183
  const p1Control = loadout.seatControl(1, controlsHost, { ...controlLook, seatColor: p1Drawn })
184
184
  // Seat 1's button alone: player 1's controls and Ready sit under the row it shares with the
185
185
  // opponent button, centered under both.
186
- const p1Panel = <PlayerSetupPanel key={`p1-${layoutKey}`} idPrefix='p1' host={controlsHost} color={p1Color} onColorChange={handleP1ColorChange} swatches={defaultColors} takenColor={p2Exists ? p2Color : undefined} allowSwapTaken={mode === 'vsCpu'} colorCaption={pack.colorCaption} isHuman dark={dark} showReadyButton={false} profiles={profiles} selectedProfileId={lastSelected[1]} takenProfileId={p2IsHuman ? lastSelected[2] : null} guestLabel={pack.guestLabel ?? 'P1'} nullLabel={pack.nullLabel} onProfileSelect={handleP1ProfileSelect} onManageProfiles={() => router.push(profilesHref(1))} previewValue={seatPreview} triggerStyle={triggerStyle} useSeatPickerAlign={seatPickerAlign} />
186
+ // Each seat button names its seat (Jay, 2026-11-25, as the stats screen's PLAYER and GAME pills): PLAYER with
187
+ // one person, PLAYER 1 and PLAYER 2 in 2 Player's halves, and OPPONENT over player 1's opponent button.
188
+ const p1Caption = p2IsHuman ? 'Player 1' : 'Player'
189
+ const p1Panel = <PlayerSetupPanel key={`p1-${layoutKey}`} idPrefix='p1' caption={p1Caption} host={controlsHost} color={p1Color} onColorChange={handleP1ColorChange} swatches={defaultColors} takenColor={p2Exists ? p2Color : undefined} allowSwapTaken={mode === 'vsCpu'} colorCaption={pack.colorCaption} isHuman dark={dark} showReadyButton={false} profiles={profiles} selectedProfileId={lastSelected[1]} takenProfileId={p2IsHuman ? lastSelected[2] : null} guestLabel={pack.guestLabel ?? 'P1'} nullLabel={pack.nullLabel} onProfileSelect={handleP1ProfileSelect} onManageProfiles={() => router.push(profilesHref(1))} previewValue={seatPreview} triggerStyle={triggerStyle} useSeatPickerAlign={seatPickerAlign} />
187
190
  // Who sits in seat 2, player 1's to pick in every mode. A game for one player (no seatTwo) has none:
188
191
  // seat 1's button stands alone.
189
192
  const opponentPicker = game.seatTwo && <OpponentPicker key={`opponent-${layoutKey}`} idPrefix='p1' host={controlsHost} choices={game.seatTwo} seatTwo={seatTwo} onSeatTwoChange={changeSeatTwo} cpuDifficulty={loadout.cpuDifficulty} color={p2Color} onColorChange={handleP2ColorChange} swatches={defaultColors} takenColor={p1Color} allowSwapTaken={mode === 'vsCpu'} dark={dark} previewValue={seatPreview} triggerStyle={triggerStyle} usePickerAlign={seatPickerAlign} />
@@ -234,7 +237,7 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
234
237
  // A person in seat 2: their own seat button (Player 2 or a profile, never the CPU), controls and
235
238
  // Ready, in their half.
236
239
  const p2Control = p2IsHuman ? loadout.seatControl(2, p2Host, { ...controlLook, seatColor: p2Drawn }) : undefined
237
- const p2Panel = p2IsHuman && <PlayerSetupPanel key='p2-zones' idPrefix='p2' host={p2Host} color={p2Color} onColorChange={handleP2ColorChange} swatches={defaultColors} takenColor={p1Color} colorCaption={pack.colorCaption} isHuman ready={ready[2]} onToggleReady={() => setReady((r) => ({ ...r, 2: !r[2] }))} dark={dark} secondPicker={p2Control} secondPickerId={p2Control ? P2_CONTROL_ID : undefined} profiles={profiles} selectedProfileId={lastSelected[2]} takenProfileId={lastSelected[1]} guestLabel={pack.guestLabel ?? 'P2'} nullLabel={pack.nullLabel} onProfileSelect={handleP2ProfileSelect} previewValue={seatPreview} triggerStyle={triggerStyle} readySurfaceColor={readySurface} />
240
+ const p2Panel = p2IsHuman && <PlayerSetupPanel key='p2-zones' idPrefix='p2' caption='Player 2' host={p2Host} color={p2Color} onColorChange={handleP2ColorChange} swatches={defaultColors} takenColor={p1Color} colorCaption={pack.colorCaption} isHuman ready={ready[2]} onToggleReady={() => setReady((r) => ({ ...r, 2: !r[2] }))} dark={dark} secondPicker={p2Control} secondPickerId={p2Control ? P2_CONTROL_ID : undefined} profiles={profiles} selectedProfileId={lastSelected[2]} takenProfileId={lastSelected[1]} guestLabel={pack.guestLabel ?? 'P2'} nullLabel={pack.nullLabel} onProfileSelect={handleP2ProfileSelect} previewValue={seatPreview} triggerStyle={triggerStyle} readySurfaceColor={readySurface} />
238
241
 
239
242
  return (
240
243
  <View style={[styles.container, { backgroundColor: bg }]}>
package/src/splashGate.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { createGate } from '@rific/splash-gate'
2
2
 
3
- export const { markReady: markSplashReady, useReady: useSplashReady, pendingGates: pendingSplashGates, Gate: SplashGate } = createGate(['theme', 'fonts', 'profiles'] as const)
3
+ // 'screen' is RootLayout's AppStack: the stack's first screen is on the glass (useFirstScreenGate).
4
+ export const { markReady: markSplashReady, useReady: useSplashReady, pendingGates: pendingSplashGates, Gate: SplashGate } = createGate(['theme', 'fonts', 'profiles', 'screen'] as const)