@tastic/shell 0.20.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.
- package/README.md +4 -4
- package/dist/index.js +93 -47
- package/dist/index.mjs +114 -68
- package/package.json +12 -12
- package/src/RootLayout.tsx +26 -14
- package/src/components/Providers.tsx +6 -3
- package/src/screens/HomeScreen.tsx +168 -76
- package/src/splashGate.ts +2 -1
|
@@ -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 {
|
|
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)
|
|
150
|
-
//
|
|
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
|
|
|
@@ -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
|
-
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
227
|
+
{showPicker && <View style={[styles.picker, pickerHost.openId !== null && styles.pickerOpen]}>{picker}</View>}
|
|
222
228
|
|
|
223
|
-
|
|
229
|
+
{tabBar && <View style={styles.listWidth}>{tabBar}</View>}
|
|
224
230
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
//
|
|
253
|
-
|
|
254
|
-
|
|
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
|
|
301
|
-
|
|
302
|
-
//
|
|
303
|
-
|
|
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
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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,
|
|
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
|
|
328
|
-
<Pressable onPress={
|
|
329
|
-
{game.Preview ? <PreviewBox game={game} width={ROW_PREVIEW_WIDTH}
|
|
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
|
-
{
|
|
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,
|
|
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={
|
|
363
|
-
<Pressable onPress={
|
|
364
|
-
<PreviewBox game={game} width={previewWidth}
|
|
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
|
-
{
|
|
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,
|
|
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
|
-
//
|
|
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,
|
|
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
|
},
|
package/src/splashGate.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { createGate } from '@rific/splash-gate'
|
|
2
2
|
|
|
3
|
-
|
|
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)
|