@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.
package/dist/index.mjs CHANGED
@@ -31,7 +31,7 @@ import { DialogHeaderStyleProvider, LetteringProvider, ScreenFrame } from "@tast
31
31
  import { ProfileColorProvider } from "@tastic/profile";
32
32
  import * as Haptics from "expo-haptics";
33
33
  import { DarkTheme, DefaultTheme, Stack, ThemeProvider as NavigationThemeProvider } from "expo-router";
34
- import { useCallback as useCallback6, useMemo as useMemo3 } from "react";
34
+ import { useCallback as useCallback6, useMemo as useMemo3, useRef as useRef3 } from "react";
35
35
  import { Platform as Platform3, StyleSheet, View } from "react-native";
36
36
  import { GestureHandlerRootView } from "react-native-gesture-handler";
37
37
  import * as RNPaper2 from "react-native-paper";
@@ -46,7 +46,7 @@ import { Platform } from "react-native";
46
46
 
47
47
  // src/splashGate.ts
48
48
  import { createGate } from "@rific/splash-gate";
49
- var { markReady: markSplashReady, useReady: useSplashReady, pendingGates: pendingSplashGates, Gate: SplashGate } = createGate(["theme", "fonts", "profiles"]);
49
+ var { markReady: markSplashReady, useReady: useSplashReady, pendingGates: pendingSplashGates, Gate: SplashGate } = createGate(["theme", "fonts", "profiles", "screen"]);
50
50
 
51
51
  // src/components/Fonts.tsx
52
52
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
@@ -173,8 +173,9 @@ import { Provider as ReduxProvider, useDispatch as useDispatch2, useSelector as
173
173
  import { PersistGate } from "redux-persist/integration/react";
174
174
  import { Fragment as Fragment2, jsx as jsx4 } from "react/jsx-runtime";
175
175
  function useShellFeedbackSounds() {
176
- const selection = useAudioPool(__require("./select-MLBNNA4N.wav"));
177
- const notification = useAudioPool(__require("./notification-CGGFPYK7.wav"));
176
+ const enabled = useSelector2((state) => state.sound.enabled);
177
+ const selection = useAudioPool(__require("./select-MLBNNA4N.wav"), { enabled });
178
+ const notification = useAudioPool(__require("./notification-CGGFPYK7.wav"), { enabled });
178
179
  return { selection, notification };
179
180
  }
180
181
  var FeedbackBridge = ({ children }) => {
@@ -415,8 +416,17 @@ var REPLACE_AS_BACK = { animationTypeForReplace: "pop" };
415
416
  var REPLACE_AS_FORWARD = { animationTypeForReplace: "push" };
416
417
  var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
417
418
  var noScreenOptions = () => ({});
419
+ function useFirstScreenGate() {
420
+ const marked = useRef3(false);
421
+ return useCallback6(() => {
422
+ if (marked.current) return;
423
+ marked.current = true;
424
+ requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
425
+ }, []);
426
+ }
418
427
  function AppStack() {
419
428
  const pack = usePack();
429
+ const onFirstLayout = useFirstScreenGate();
420
430
  const { Backdrop } = pack;
421
431
  const { dark } = useAutoPaperTheme();
422
432
  const darkRoot = Backdrop ? true : dark;
@@ -440,14 +450,12 @@ function AppStack() {
440
450
  const base = darkRoot ? DarkTheme : DefaultTheme;
441
451
  return { ...base, colors: { ...base.colors, background: navigationBackground } };
442
452
  }, [darkRoot, navigationBackground]);
443
- const stack = /* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
444
- /* @__PURE__ */ jsx10(Stack.Screen, { name: "index" }),
445
- /* @__PURE__ */ jsx10(Stack.Screen, { name: "play/[game]", options: playOptions })
446
- ] }) });
447
- if (!Backdrop) return stack;
448
- return /* @__PURE__ */ jsxs2(View, { style: styles.root, children: [
449
- /* @__PURE__ */ jsx10(Backdrop, {}),
450
- stack
453
+ return /* @__PURE__ */ jsxs2(View, { style: styles.root, onLayout: onFirstLayout, children: [
454
+ Backdrop && /* @__PURE__ */ jsx10(Backdrop, {}),
455
+ /* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
456
+ /* @__PURE__ */ jsx10(Stack.Screen, { name: "index" }),
457
+ /* @__PURE__ */ jsx10(Stack.Screen, { name: "play/[game]", options: playOptions })
458
+ ] }) })
451
459
  ] });
452
460
  }
453
461
  function GatedApp({ children }) {
@@ -569,7 +577,7 @@ import { CornerActionButtons, PressAwayOverlay, useLettering, usePopoverHost } f
569
577
  import { PlayerSetupPanel, ReadyButton, SharedActionBand } from "@tastic/hud/lobby";
570
578
  import { DualZoneLayout, needsSharedNeutralZone, useDualZoneLayout } from "@tastic/split-screen";
571
579
  import { router as router4, useFocusEffect as useFocusEffect2 } from "expo-router";
572
- import { useCallback as useCallback9, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef4, useState as useState4 } from "react";
580
+ import { useCallback as useCallback9, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef5, useState as useState4 } from "react";
573
581
  import { StyleSheet as StyleSheet3, View as View3 } from "react-native";
574
582
  import { Text } from "react-native-paper";
575
583
  import Animated from "react-native-reanimated";
@@ -616,7 +624,7 @@ function OpponentPicker({ idPrefix, host, choices, seatTwo, onSeatTwoChange, cpu
616
624
  const size = getOptionPickerContentSize(options, colorSection);
617
625
  const useAlign = usePickerAlign ?? useZoneClampedAlign;
618
626
  const align = useAlign(host.openId === pickerId, size.width, size.height);
619
- return /* @__PURE__ */ jsx13(View2, { style: [styles2.button, host.openId === pickerId && styles2.buttonOpen], children: /* @__PURE__ */ jsx13(OptionPicker, { id: pickerId, host, options, value, onChange: handleChange, color: drawn, dark, icon, colorSection, alignOverride: align, triggerStyle }) });
627
+ return /* @__PURE__ */ jsx13(View2, { style: [styles2.button, host.openId === pickerId && styles2.buttonOpen], children: /* @__PURE__ */ jsx13(OptionPicker, { id: pickerId, host, caption: "Opponent", options, value, onChange: handleChange, color: drawn, dark, icon, colorSection, alignOverride: align, triggerStyle }) });
620
628
  }
621
629
  var styles2 = StyleSheet2.create({
622
630
  // Its own column, so a row of seat buttons doesn't stretch the pill to the tallest of them.
@@ -683,7 +691,7 @@ function useOpponent() {
683
691
  import { getThirdColor, useAutoPaperTheme as useAutoPaperTheme2, useThemeSettings } from "@rific/auto-paper";
684
692
  import { avoidSeatColorClash, profileSeatColor } from "@tastic/profile";
685
693
  import { useFocusEffect } from "expo-router";
686
- import { useCallback as useCallback8, useEffect as useEffect3, useRef as useRef3 } from "react";
694
+ import { useCallback as useCallback8, useEffect as useEffect3, useRef as useRef4 } from "react";
687
695
  import { useDispatch as useDispatch8, useSelector as useSelector7 } from "react-redux";
688
696
 
689
697
  // src/redux/seatColorsSlice.ts
@@ -724,12 +732,12 @@ function useSeatColors(p2IsHuman) {
724
732
  const p1Color = seatTheme ? remembered.p1 : themeColors.primary;
725
733
  const p2Color = seatTheme ? remembered.p2 : themeColors.secondary;
726
734
  const themeFor = useCallback8((p1, p2) => seatTheme ? seatTheme({ 1: p1, 2: p2 }, dark) : { color: { primary: p1, secondary: p2, tertiary: getThirdColor(p1, p2) } }, [seatTheme, dark]);
727
- const p1ProfileRef = useRef3(p1Profile);
728
- const p2ProfileRef = useRef3(p2Profile);
729
- const guestColorsRef = useRef3(guestColors);
730
- const cpuColorRef = useRef3(cpuColor);
731
- const profileColorsRef = useRef3(profileColors);
732
- const themeForRef = useRef3(themeFor);
735
+ const p1ProfileRef = useRef4(p1Profile);
736
+ const p2ProfileRef = useRef4(p2Profile);
737
+ const guestColorsRef = useRef4(guestColors);
738
+ const cpuColorRef = useRef4(cpuColor);
739
+ const profileColorsRef = useRef4(profileColors);
740
+ const themeForRef = useRef4(themeFor);
733
741
  useEffect3(() => {
734
742
  p1ProfileRef.current = p1Profile;
735
743
  }, [p1Profile]);
@@ -852,7 +860,7 @@ function LoadoutScreen({ game }) {
852
860
  },
853
861
  [setSeatTwo, setReady]
854
862
  );
855
- const roundSettingsRef = useRef4(loadout.roundSettings);
863
+ const roundSettingsRef = useRef5(loadout.roundSettings);
856
864
  useEffect4(() => {
857
865
  roundSettingsRef.current = loadout.roundSettings;
858
866
  }, [loadout.roundSettings]);
@@ -881,7 +889,8 @@ function LoadoutScreen({ game }) {
881
889
  const p1ControlOpen = controlsHost.openId === P1_CONTROL_ID;
882
890
  const controlLook = { accentColor: themeColors.tertiary, mutedColor: fgMuted, dark };
883
891
  const p1Control = loadout.seatControl(1, controlsHost, { ...controlLook, seatColor: p1Drawn });
884
- const p1Panel = /* @__PURE__ */ jsx15(PlayerSetupPanel, { idPrefix: "p1", host: controlsHost, color: p1Color, onColorChange: handleP1ColorChange, swatches: defaultColors2, takenColor: p2Exists ? p2Color : void 0, allowSwapTaken: mode === "vsCpu", colorCaption: pack.colorCaption, isHuman: true, dark, showReadyButton: false, profiles, selectedProfileId: lastSelected[1], takenProfileId: p2IsHuman ? lastSelected[2] : null, guestLabel: pack.guestLabel ?? "P1", nullLabel: pack.nullLabel, onProfileSelect: handleP1ProfileSelect, onManageProfiles: () => router4.push(profilesHref(1)), previewValue: seatPreview, triggerStyle, useSeatPickerAlign: seatPickerAlign }, `p1-${layoutKey}`);
892
+ const p1Caption = p2IsHuman ? "Player 1" : "Player";
893
+ const p1Panel = /* @__PURE__ */ jsx15(PlayerSetupPanel, { idPrefix: "p1", caption: p1Caption, host: controlsHost, color: p1Color, onColorChange: handleP1ColorChange, swatches: defaultColors2, takenColor: p2Exists ? p2Color : void 0, allowSwapTaken: mode === "vsCpu", colorCaption: pack.colorCaption, isHuman: true, dark, showReadyButton: false, profiles, selectedProfileId: lastSelected[1], takenProfileId: p2IsHuman ? lastSelected[2] : null, guestLabel: pack.guestLabel ?? "P1", nullLabel: pack.nullLabel, onProfileSelect: handleP1ProfileSelect, onManageProfiles: () => router4.push(profilesHref(1)), previewValue: seatPreview, triggerStyle, useSeatPickerAlign: seatPickerAlign }, `p1-${layoutKey}`);
885
894
  const opponentPicker = game.seatTwo && /* @__PURE__ */ jsx15(OpponentPicker, { idPrefix: "p1", host: controlsHost, choices: game.seatTwo, seatTwo, onSeatTwoChange: changeSeatTwo, cpuDifficulty: loadout.cpuDifficulty, color: p2Color, onColorChange: handleP2ColorChange, swatches: defaultColors2, takenColor: p1Color, allowSwapTaken: mode === "vsCpu", dark, previewValue: seatPreview, triggerStyle, usePickerAlign: seatPickerAlign }, `opponent-${layoutKey}`);
886
895
  const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }));
887
896
  const readyInOptions = !p2IsHuman && !!loadout.drawsReady;
@@ -913,7 +922,7 @@ function LoadoutScreen({ game }) {
913
922
  const optionsPopoverOpen = controlsHost.openId !== null && loadout.optionIds.includes(controlsHost.openId);
914
923
  const sharedControls = showMetaInSharedBand ? /* @__PURE__ */ jsx15(SharedActionBand, { onBack: safeBack, onSettings: () => setSettingsOpen(true), onRandomize: loadout.randomize, onReset: loadout.reset, fg, popoverOpen: optionsPopoverOpen, children: optionsRow }) : optionsRow;
915
924
  const p2Control = p2IsHuman ? loadout.seatControl(2, p2Host, { ...controlLook, seatColor: p2Drawn }) : void 0;
916
- const p2Panel = p2IsHuman && /* @__PURE__ */ jsx15(PlayerSetupPanel, { idPrefix: "p2", host: p2Host, color: p2Color, onColorChange: handleP2ColorChange, swatches: defaultColors2, takenColor: p1Color, colorCaption: pack.colorCaption, isHuman: true, ready: ready[2], onToggleReady: () => setReady((r) => ({ ...r, 2: !r[2] })), dark, secondPicker: p2Control, secondPickerId: p2Control ? P2_CONTROL_ID : void 0, profiles, selectedProfileId: lastSelected[2], takenProfileId: lastSelected[1], guestLabel: pack.guestLabel ?? "P2", nullLabel: pack.nullLabel, onProfileSelect: handleP2ProfileSelect, previewValue: seatPreview, triggerStyle, readySurfaceColor: readySurface }, "p2-zones");
925
+ const p2Panel = p2IsHuman && /* @__PURE__ */ jsx15(PlayerSetupPanel, { idPrefix: "p2", caption: "Player 2", host: p2Host, color: p2Color, onColorChange: handleP2ColorChange, swatches: defaultColors2, takenColor: p1Color, colorCaption: pack.colorCaption, isHuman: true, ready: ready[2], onToggleReady: () => setReady((r) => ({ ...r, 2: !r[2] })), dark, secondPicker: p2Control, secondPickerId: p2Control ? P2_CONTROL_ID : void 0, profiles, selectedProfileId: lastSelected[2], takenProfileId: lastSelected[1], guestLabel: pack.guestLabel ?? "P2", nullLabel: pack.nullLabel, onProfileSelect: handleP2ProfileSelect, previewValue: seatPreview, triggerStyle, readySurfaceColor: readySurface }, "p2-zones");
917
926
  return /* @__PURE__ */ jsxs4(View3, { style: [styles3.container, { backgroundColor: bg }], children: [
918
927
  /* @__PURE__ */ jsxs4(View3, { style: [styles3.frame, !showMetaInSharedBand && { paddingTop: HEADER_TOP + HEADER_ROW_HEIGHT + insets.top }], children: [
919
928
  /* @__PURE__ */ jsx15(PressAwayOverlay, { active: controlsHost.openId !== null, onPress: controlsHost.close }),
@@ -1066,8 +1075,8 @@ import { IconButton, Pressable } from "@rific/feedback-press";
1066
1075
  import { PressAwayOverlay as PressAwayOverlay2, usePopoverHost as usePopoverHost2, useWellColors, WELL_SHADOW } from "@tastic/hud/chrome";
1067
1076
  import { getProfilePickerContentSize, ProfilePicker } from "@tastic/profile";
1068
1077
  import { router as router5, useFocusEffect as useFocusEffect3, useIsFocused } from "expo-router";
1069
- import { useCallback as useCallback10, useDeferredValue, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef5, useState as useState6 } from "react";
1070
- import { AppState as AppState2, StyleSheet as StyleSheet4, View as View4 } from "react-native";
1078
+ import { createContext as createContext5, memo, startTransition, useCallback as useCallback10, useContext as useContext5, useDeferredValue, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef6, useState as useState6 } from "react";
1079
+ import { AppState as AppState2, Platform as Platform5, StyleSheet as StyleSheet4, View as View4 } from "react-native";
1071
1080
  import { Icon, Portal, SegmentedButtons, Text as Text2 } from "react-native-paper";
1072
1081
 
1073
1082
  // src/components/segmentTheme.ts
@@ -1169,7 +1178,7 @@ function HomeScreen() {
1169
1178
  }
1170
1179
  function useResume(game) {
1171
1180
  const pack = usePack();
1172
- const done = useRef5(false);
1181
+ const done = useRef6(false);
1173
1182
  useFocusEffect3(
1174
1183
  useCallback10(() => {
1175
1184
  if (!game || done.current) return;
@@ -1228,6 +1237,10 @@ function HomeMenu() {
1228
1237
  const tab = tabs ? tabs.find((t) => t.label === tabLabel) ?? tabs[0] : null;
1229
1238
  const tabButtons = useMemo6(() => tabs?.map(({ label }) => ({ value: label, label, labelStyle: pack.labelStyle })) ?? [], [tabs, pack.labelStyle]);
1230
1239
  const tabBar = tab && /* @__PURE__ */ jsx17(SegmentedButtons, { value: tab.label, onValueChange: setTabLabel, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles4.tabs, pack.Backdrop && { backgroundColor: colors.surface }] });
1240
+ const panes = useMemo6(() => tabs ? tabs.map((t) => ({ key: t.label, games: pack.games.filter(t.includes) })) : [{ key: ALL_GAMES, games: pack.games }], [tabs, pack.games]);
1241
+ const shownPane = tab?.label ?? ALL_GAMES;
1242
+ const { width: fitWidth, height: fitHeight } = layout.heroFit ?? NO_FIT;
1243
+ const hero = useMemo6(() => /* @__PURE__ */ jsx17(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive, fit: isWide && fitWidth !== void 0 ? { width: fitWidth, height: fitHeight } : void 0 }), [pack, fg, p1Color, p2Color, heroActive, isWide, fitWidth, fitHeight]);
1231
1244
  const columnClamp = useClampOnShrink();
1232
1245
  const gridClamp = useClampOnShrink();
1233
1246
  const openGame = useCallback10((game) => openFirstTime(game.id, () => router5.push(game.useLoadout ? loadoutHref(game.id) : playHref(game.id))), [openFirstTime]);
@@ -1236,28 +1249,28 @@ function HomeMenu() {
1236
1249
  const usePickerAlign = pack.usePickerAlign ?? noPickerAlign;
1237
1250
  const pickerSize = getProfilePickerContentSize(profiles.length, true, colorSection);
1238
1251
  const pickerAlign = usePickerAlign(pickerHost.openId === `${SEAT_ONE_PICKER}-profile`, pickerSize.width, pickerSize.height);
1239
- const picker = /* @__PURE__ */ jsx17(ProfilePicker, { idPrefix: SEAT_ONE_PICKER, host: pickerHost, profiles, selectedId: lastSelected[1], color: p1Drawn, dark, guestLabel: pack.guestLabel ?? "P1", nullLabel: pack.nullLabel, onSelect: (profile) => selectProfile(1, profile?.id ?? null), onManage: () => router5.push(profilesHref(1)), colorSection, alignOverride: pickerAlign, triggerStyle });
1252
+ const picker = /* @__PURE__ */ jsx17(ProfilePicker, { idPrefix: SEAT_ONE_PICKER, host: pickerHost, caption: "Player", profiles, selectedId: lastSelected[1], color: p1Drawn, dark, guestLabel: pack.guestLabel ?? "P1", nullLabel: pack.nullLabel, onSelect: (profile) => selectProfile(1, profile?.id ?? null), onManage: () => router5.push(profilesHref(1)), colorSection, alignOverride: pickerAlign, triggerStyle });
1240
1253
  const pressAway = /* @__PURE__ */ jsx17(PressAwayOverlay2, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles4.pressAway });
1241
1254
  const RulesSheet = rulesGame?.Rules;
1242
1255
  return /* @__PURE__ */ jsxs5(View4, { style: [styles4.container, { backgroundColor: bg }], children: [
1243
1256
  /* @__PURE__ */ jsx17(View4, { style: styles4.frame, children: /* @__PURE__ */ jsxs5(RulesHost, { enabled: pack.games.some((game) => game.Rules), children: [
1244
- isWide ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
1257
+ /* @__PURE__ */ jsx17(PreviewsRevealed, { value: previewsRevealed, children: isWide ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
1245
1258
  pressAway,
1246
1259
  /* @__PURE__ */ jsxs5(FadingScrollView, { ...tab && gridClamp, style: [styles4.wideRightPane, { left: layout.paddingLeft + layout.leftPaneWidth + HOME_WIDE_PANE_GAP }], contentContainerStyle: { paddingTop: 16 + insets.top, paddingBottom: 16 + insets.bottom, paddingRight: layout.paddingRight }, children: [
1247
1260
  tabBar && /* @__PURE__ */ jsx17(View4, { style: [styles4.wideTabs, { width: layout.rightPaneWidth }], children: tabBar }),
1248
- /* @__PURE__ */ jsx17(View4, { style: [styles4.grid, { width: layout.rightPaneWidth }], children: pack.games.map((game) => /* @__PURE__ */ jsx17(GameTile, { game, hidden: isHidden(tab, game), width: layout.tileWidth, previewWidth: layout.previewWidth, previewRevealed: previewsRevealed, dark, p1Color, p2Color, onPress: () => openGame(game), onRules: hasRules(game) ? () => openRules(game) : void 0 }, game.id)) })
1261
+ /* @__PURE__ */ jsx17(View4, { style: { width: layout.rightPaneWidth }, children: /* @__PURE__ */ jsx17(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.grid, children: (games, built) => /* @__PURE__ */ jsx17(GameGrid, { games, built, width: layout.tileWidth, previewWidth: layout.previewWidth, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
1249
1262
  ] }),
1250
1263
  /* @__PURE__ */ jsxs5(View4, { style: [styles4.wideLeftPane, { left: layout.paddingLeft, width: layout.leftPaneWidth, paddingTop: HOME_TOP_BAND + insets.top, paddingBottom: 16 + insets.bottom }, pickerHost.openId !== null && styles4.pickerOpen], children: [
1251
- /* @__PURE__ */ jsx17(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive, fit: layout.heroFit }),
1264
+ hero,
1252
1265
  showPicker && /* @__PURE__ */ jsx17(View4, { style: styles4.widePicker, children: picker })
1253
1266
  ] })
1254
1267
  ] }) : /* @__PURE__ */ jsxs5(FadingScrollView, { ...tab && columnClamp, style: styles4.scroll, contentContainerStyle: [styles4.content, { paddingTop: 56 + insets.top, paddingBottom: 24 + insets.bottom, paddingLeft: 16 + insets.left, paddingRight: 16 + insets.right }], children: [
1255
1268
  pressAway,
1256
- /* @__PURE__ */ jsx17(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive }),
1269
+ hero,
1257
1270
  showPicker && /* @__PURE__ */ jsx17(View4, { style: [styles4.picker, pickerHost.openId !== null && styles4.pickerOpen], children: picker }),
1258
1271
  tabBar && /* @__PURE__ */ jsx17(View4, { style: styles4.listWidth, children: tabBar }),
1259
- /* @__PURE__ */ jsx17(View4, { style: styles4.list, children: pack.games.map((game) => /* @__PURE__ */ jsx17(GameRow, { game, hidden: isHidden(tab, game), dark, p1Color, p2Color, previewRevealed: previewsRevealed, onPress: () => openGame(game), onRules: hasRules(game) ? () => openRules(game) : void 0 }, game.id)) })
1260
- ] }),
1272
+ /* @__PURE__ */ jsx17(View4, { style: styles4.listWidth, children: /* @__PURE__ */ jsx17(TabPanes, { panes, shown: shownPane, buildOthers: isFocused, style: styles4.list, children: (games, built) => /* @__PURE__ */ jsx17(GameList, { games, built, dark, p1Color, p2Color, onOpen: openGame, onRules: openRules }) }) })
1273
+ ] }) }),
1261
1274
  /* @__PURE__ */ jsx17(IconButton, { icon: "trophy", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, left: 8 + insets.left }], onPress: () => router5.push(STATS_HREF), accessibilityLabel: "Stats & Achievements" }),
1262
1275
  /* @__PURE__ */ jsx17(IconButton, { icon: "cog", iconColor: fg, size: 24, style: [styles4.corner, { top: 8 + insets.top, right: 8 + insets.right }], onPress: () => setSettingsOpen(true), accessibilityLabel: "Settings" }),
1263
1276
  RulesSheet && /* @__PURE__ */ jsx17(RulesSheet, { visible: true, onDismiss: () => setRulesGame(null) })
@@ -1267,12 +1280,39 @@ function HomeMenu() {
1267
1280
  }
1268
1281
  var SEAT_ONE_PICKER = "home-p1";
1269
1282
  var noPickerAlign = () => void 0;
1270
- function isHidden(tab, game) {
1271
- return !!tab && !tab.includes(game);
1283
+ var NO_FIT = { height: 0 };
1284
+ var ALL_GAMES = "__all__";
1285
+ function TabPanes({ panes, shown, buildOthers, style, children }) {
1286
+ const mostGames = Math.max(...panes.map(({ games }) => games.length));
1287
+ const builtGames = useBuiltGames(shown, mostGames, buildOthers && panes.length > 1);
1288
+ return panes.map(({ key, games }) => {
1289
+ const built = builtGames(key);
1290
+ if (built === 0) return null;
1291
+ return /* @__PURE__ */ jsx17(TabPane, { shown: key === shown, style, children: children(games, built) }, key);
1292
+ });
1272
1293
  }
1294
+ function useBuiltGames(shown, total, buildOthers) {
1295
+ const [picked, setPicked] = useState6([shown]);
1296
+ if (!picked.includes(shown)) setPicked([...picked, shown]);
1297
+ const [others, setOthers] = useState6(Platform5.OS === "web" ? total : 0);
1298
+ const building = buildOthers && others < total;
1299
+ useEffect6(() => {
1300
+ if (!building) return;
1301
+ const id = setTimeout(() => startTransition(() => setOthers(others + 1)), others === 0 ? OTHER_PANES_DELAY_MS : OTHER_PANES_STEP_MS);
1302
+ return () => clearTimeout(id);
1303
+ }, [building, others]);
1304
+ return (pane) => pane === shown || picked.includes(pane) ? total : others;
1305
+ }
1306
+ var OTHER_PANES_DELAY_MS = 1200;
1307
+ var OTHER_PANES_STEP_MS = 150;
1308
+ function TabPane({ shown, style, children }) {
1309
+ return /* @__PURE__ */ jsx17(View4, { collapsable: false, "aria-hidden": !shown, style: [style, !shown && styles4.paneHidden], children });
1310
+ }
1311
+ var PreviewsRevealedContext = createContext5(false);
1312
+ var PreviewsRevealed = PreviewsRevealedContext.Provider;
1273
1313
  function useClampOnShrink() {
1274
- const view = useRef5(null);
1275
- const sizes = useRef5({ viewport: 0, offset: 0 });
1314
+ const view = useRef6(null);
1315
+ const sizes = useRef6({ viewport: 0, offset: 0 });
1276
1316
  return useMemo6(
1277
1317
  () => ({
1278
1318
  ref: (instance) => {
@@ -1301,39 +1341,46 @@ function hasRules(game) {
1301
1341
  function RulesHost({ enabled, children }) {
1302
1342
  return enabled ? /* @__PURE__ */ jsx17(Portal.Host, { children }) : /* @__PURE__ */ jsx17(Fragment5, { children });
1303
1343
  }
1344
+ var GameList = memo(function GameList2({ games, built, ...rest }) {
1345
+ return games.slice(0, built).map((game) => /* @__PURE__ */ jsx17(GameRow, { game, ...rest }, game.id));
1346
+ });
1347
+ var GameGrid = memo(function GameGrid2({ games, built, ...rest }) {
1348
+ return games.slice(0, built).map((game) => /* @__PURE__ */ jsx17(GameTile, { game, ...rest }, game.id));
1349
+ });
1304
1350
  var ROW_BLURB_LINES = 3;
1305
- function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
1351
+ var GameRow = memo(function GameRow2({ game, dark, p1Color, p2Color, onOpen, onRules }) {
1306
1352
  const { titleStyle } = usePack();
1307
1353
  const well = useWellColors();
1308
1354
  const GameIcon = game.icon;
1309
1355
  return (
1310
1356
  // The rules button sits beside the row's own button, laid over its end, not inside it: a button
1311
1357
  // inside a button is invalid on the web.
1312
- /* @__PURE__ */ jsxs5(View4, { style: hidden ? styles4.hidden : void 0, children: [
1313
- /* @__PURE__ */ jsxs5(Pressable, { onPress, style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1314
- game.Preview ? /* @__PURE__ */ jsx17(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, revealed: previewRevealed, dark, p1Color, p2Color }) : /* @__PURE__ */ jsx17(View4, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ jsx17(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
1358
+ /* @__PURE__ */ jsxs5(View4, { children: [
1359
+ /* @__PURE__ */ jsxs5(Pressable, { onPress: () => onOpen(game), style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1360
+ game.Preview ? /* @__PURE__ */ jsx17(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, dark, p1Color, p2Color }) : /* @__PURE__ */ jsx17(View4, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ jsx17(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
1315
1361
  /* @__PURE__ */ jsxs5(View4, { style: styles4.rowText, children: [
1316
1362
  /* @__PURE__ */ jsx17(Text2, { variant: "titleLarge", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
1317
1363
  /* @__PURE__ */ jsx17(Text2, { variant: "bodyMedium", style: { color: well.fgMuted }, numberOfLines: ROW_BLURB_LINES, children: game.blurb })
1318
1364
  ] })
1319
1365
  ] }),
1320
- onRules && /* @__PURE__ */ jsx17(Pressable, { onPress: onRules, style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx17(Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
1366
+ hasRules(game) && /* @__PURE__ */ jsx17(Pressable, { onPress: () => onRules(game), style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx17(Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
1321
1367
  ] })
1322
1368
  );
1323
- }
1324
- function GameTile({ game, hidden, width, previewWidth, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
1369
+ });
1370
+ var GameTile = memo(function GameTile2({ game, width, previewWidth, dark, p1Color, p2Color, onOpen, onRules }) {
1325
1371
  const { titleStyle } = usePack();
1326
1372
  const well = useWellColors();
1327
- return /* @__PURE__ */ jsxs5(View4, { style: [{ width }, hidden && styles4.hidden], children: [
1328
- /* @__PURE__ */ jsxs5(Pressable, { onPress, style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1329
- /* @__PURE__ */ jsx17(PreviewBox, { game, width: previewWidth, revealed: previewRevealed, dark, p1Color, p2Color }),
1373
+ return /* @__PURE__ */ jsxs5(View4, { style: { width }, children: [
1374
+ /* @__PURE__ */ jsxs5(Pressable, { onPress: () => onOpen(game), style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
1375
+ /* @__PURE__ */ jsx17(PreviewBox, { game, width: previewWidth, dark, p1Color, p2Color }),
1330
1376
  /* @__PURE__ */ jsx17(Text2, { variant: "titleMedium", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
1331
1377
  /* @__PURE__ */ jsx17(Text2, { variant: "bodySmall", style: { color: well.fgMuted }, numberOfLines: 3, children: game.blurb })
1332
1378
  ] }),
1333
- onRules && /* @__PURE__ */ jsx17(Pressable, { onPress: onRules, style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx17(Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
1379
+ hasRules(game) && /* @__PURE__ */ jsx17(Pressable, { onPress: () => onRules(game), style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ jsx17(Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
1334
1380
  ] });
1335
- }
1336
- function PreviewBox({ game, width, revealed, dark, p1Color, p2Color }) {
1381
+ });
1382
+ function PreviewBox({ game, width, dark, p1Color, p2Color }) {
1383
+ const revealed = useContext5(PreviewsRevealedContext);
1337
1384
  const height = Math.round(width / PREVIEW_ASPECT);
1338
1385
  const { Preview, icon: GameIcon } = game;
1339
1386
  const iconSize = Math.min(height, ROW_ICON_SIZE);
@@ -1363,21 +1410,21 @@ var styles4 = StyleSheet4.create({
1363
1410
  flexWrap: "wrap",
1364
1411
  gap: HOME_GRID_GAP
1365
1412
  },
1366
- // Out of the layout (a grid closes up around it) and hidden from screen readers.
1367
- hidden: {
1368
- display: "none"
1369
- },
1370
- // Solitaire's list: one column, never wider than a phone's, centred on a wide screen.
1413
+ // Solitaire's list: one column.
1371
1414
  list: {
1372
- gap: 14,
1373
- maxWidth: 480,
1374
- width: "100%"
1415
+ gap: 14
1375
1416
  },
1376
- // The list's width, for the tabs over it.
1417
+ // The list's width, and the tabs' over it: never wider than a phone's, centred on a wide screen.
1377
1418
  listWidth: {
1378
1419
  maxWidth: 480,
1379
1420
  width: "100%"
1380
1421
  },
1422
+ // A tab's pane that isn't shown (TabPane): out of the layout, over the shown pane's place, drawing
1423
+ // nothing.
1424
+ paneHidden: Platform5.select({
1425
+ web: { display: "none" },
1426
+ default: { left: 0, opacity: 0, pointerEvents: "none", position: "absolute", right: 0, top: 0 }
1427
+ }),
1381
1428
  picker: {
1382
1429
  alignItems: "center"
1383
1430
  },
@@ -1506,7 +1553,7 @@ var TABS = [
1506
1553
  var LABEL_WIDE_TAB = { flex: 0, flexBasis: "auto", flexGrow: 1, flexShrink: 1 };
1507
1554
  var NO_PACK_TABS = [];
1508
1555
  var EVERYONE = "__everyone__";
1509
- var ALL_GAMES = "__all__";
1556
+ var ALL_GAMES2 = "__all__";
1510
1557
  var tabGroup = (index) => `__tab-group-${index}__`;
1511
1558
  var tabGames = (index) => `__tab-${index}__`;
1512
1559
  var PLAYER_PICKER_ID = "stats-player";
@@ -1532,22 +1579,22 @@ function StatsContent({ pickerHost }) {
1532
1579
  const dispatch = useDispatch10();
1533
1580
  const fg = pack.foreground ?? colors.onBackground;
1534
1581
  const [tab, setTab] = useState7(STATS);
1535
- const [gameId, setGameId] = useState7(ALL_GAMES);
1582
+ const [gameId, setGameId] = useState7(ALL_GAMES2);
1536
1583
  const useStatsPlayer = pack.useStatsPlayer ?? useNoStatsPlayer;
1537
1584
  const statsPlayer = useStatsPlayer();
1538
1585
  const [selectedProfileId, setSelectedProfileId] = useState7(() => pack.useStatsPlayer ? statsPlayer : pack.guestStats ? lastSelected[1] ?? GUEST_PLAYER_ID : null);
1539
1586
  const profileId = selectedProfileId && profiles.length > 0 && (pack.guestStats && selectedProfileId === GUEST_PLAYER_ID || profiles.some((p) => p.id === selectedProfileId)) ? selectedProfileId : null;
1540
1587
  const homeTabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
1541
1588
  const pickedTab = homeTabs?.findIndex((_, index) => gameId === tabGames(index)) ?? -1;
1542
- const games = gameId === ALL_GAMES ? pack.games : pickedTab >= 0 ? pack.games.filter((g) => homeTabs[pickedTab].includes(g)) : pack.games.filter((g) => g.id === gameId);
1543
- const gameIds = gameId === ALL_GAMES ? null : games.map((g) => g.id);
1544
- const oneGameId = gameId === ALL_GAMES || pickedTab >= 0 ? null : gameId;
1589
+ const games = gameId === ALL_GAMES2 ? pack.games : pickedTab >= 0 ? pack.games.filter((g) => homeTabs[pickedTab].includes(g)) : pack.games.filter((g) => g.id === gameId);
1590
+ const gameIds = gameId === ALL_GAMES2 ? null : games.map((g) => g.id);
1591
+ const oneGameId = gameId === ALL_GAMES2 || pickedTab >= 0 ? null : gameId;
1545
1592
  const packTabs = pack.statsTabs ?? NO_PACK_TABS;
1546
1593
  const packTab = packTabs.find((t) => t.value === tab);
1547
1594
  const showGamePicker = !(tab === ACHIEVEMENTS && pack.AchievementList);
1548
1595
  const playerOptions = useMemo7(() => [{ value: EVERYONE, label: "Everyone", icon: "account-group" }, ...pack.guestStats && profiles.length > 0 ? [{ value: GUEST_PLAYER_ID, label: "Guest", icon: "account-outline" }] : [], ...profiles.map((p) => ({ value: p.id, label: p.name, icon: "account", color: pack.previewColor ? pack.previewColor(p.color, dark) : p.color })), MANAGE_OPTION], [profiles, pack, dark]);
1549
1596
  const gameOptions = useMemo7(() => {
1550
- const all = { value: ALL_GAMES, label: "All Games", icon: "view-grid-outline" };
1597
+ const all = { value: ALL_GAMES2, label: "All Games", icon: "view-grid-outline" };
1551
1598
  const option = (g) => ({ value: g.id, label: g.title, icon: "cards-playing-outline" });
1552
1599
  if (!homeTabs) return [all, ...pack.games.map(option)];
1553
1600
  return [all, ...homeTabs.map((tab2, index) => ({ value: tabGroup(index), label: tab2.label, icon: "folder-outline", options: [{ value: tabGames(index), label: "All", triggerLabel: tab2.label, icon: "view-grid-outline" }, ...pack.games.filter((g) => tab2.includes(g)).map(option)] }))];
@@ -1690,11 +1737,11 @@ function useActiveRound(game, defaults) {
1690
1737
 
1691
1738
  // src/hooks/useBackBlock.ts
1692
1739
  import { usePreventRemove } from "expo-router";
1693
- import { useCallback as useCallback11, useEffect as useEffect8, useRef as useRef6, useState as useState8 } from "react";
1740
+ import { useCallback as useCallback11, useEffect as useEffect8, useRef as useRef7, useState as useState8 } from "react";
1694
1741
  function useBackBlock(held, onHeld, leave = safeBack) {
1695
- const leavingRef = useRef6(false);
1742
+ const leavingRef = useRef7(false);
1696
1743
  const [leaving, setLeaving] = useState8(false);
1697
- const leaveRef = useRef6(leave);
1744
+ const leaveRef = useRef7(leave);
1698
1745
  useEffect8(() => {
1699
1746
  leaveRef.current = leave;
1700
1747
  });
@@ -1839,7 +1886,7 @@ function forgetProfileAchievements(dropStats) {
1839
1886
 
1840
1887
  // src/gameStats.tsx
1841
1888
  import { createAchievementsSlice, mapUnlocksBySeat, useAchievements } from "@tastic/achievements";
1842
- import { createContext as createContext5, useCallback as useCallback12, useContext as useContext5, useMemo as useMemo8 } from "react";
1889
+ import { createContext as createContext6, useCallback as useCallback12, useContext as useContext6, useMemo as useMemo8 } from "react";
1843
1890
  import { jsx as jsx21 } from "react/jsx-runtime";
1844
1891
  var SEATS = [1, 2];
1845
1892
  function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
@@ -1857,7 +1904,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1857
1904
  };
1858
1905
  const reducer6 = onProfileRemoved(sliceReducer, forgetProfileAchievements(dropProfileStats));
1859
1906
  const profileViews = (stats) => Object.fromEntries(Object.entries(stats.profiles).map(([profileId, bucket]) => [profileId, getProfileStatsView(bucket)]));
1860
- const Context = createContext5(null);
1907
+ const Context = createContext6(null);
1861
1908
  function Provider({ children }) {
1862
1909
  const { stats, unlockedAchievements, recordOutcome, resetAll } = useAchievements({
1863
1910
  catalog,
@@ -1876,7 +1923,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
1876
1923
  return /* @__PURE__ */ jsx21(Context.Provider, { value, children });
1877
1924
  }
1878
1925
  function useStats() {
1879
- const ctx = useContext5(Context);
1926
+ const ctx = useContext6(Context);
1880
1927
  if (!ctx) throw new Error(`The ${key} stats are read within their game's Provider`);
1881
1928
  return ctx;
1882
1929
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tastic/shell",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "The app around a pack of React Native games, two-seat or for one player: Home, the loadout, the stats screen, Profiles and Settings, the pack's Redux store and its root providers, driven by one PackDefinition",
5
5
  "keywords": [
6
6
  "react-native",
@@ -69,25 +69,25 @@
69
69
  "@babel/core": "^7.29.13",
70
70
  "@expo/vector-icons": "^15.1.1",
71
71
  "@infinitetoken/eslint-config": "^0.2.1",
72
- "@infinitetoken/jest-config": "^0.5.2",
72
+ "@infinitetoken/jest-config": "^0.5.3",
73
73
  "@infinitetoken/tsconfig": "^0.7.0",
74
74
  "@react-native-async-storage/async-storage": "2.2.0",
75
75
  "@react-native-masked-view/masked-view": "0.3.2",
76
76
  "@react-native/jest-preset": "^0.88.0",
77
77
  "@reduxjs/toolkit": "^2.14.0",
78
- "@rific/auto-paper": "^0.14.0",
79
- "@rific/core": "^0.5.0",
80
- "@rific/feedback-press": "^0.13.1",
81
- "@rific/focus-chain": "^0.4.8",
82
- "@rific/gestures": "^0.1.3",
83
- "@rific/splash-gate": "^0.2.3",
84
- "@rific/toaster": "^0.12.0",
85
- "@rific/updater": "^0.8.0",
78
+ "@rific/auto-paper": "^0.15.2",
79
+ "@rific/core": "^0.5.2",
80
+ "@rific/feedback-press": "^0.15.0",
81
+ "@rific/focus-chain": "^0.4.9",
82
+ "@rific/gestures": "^0.1.5",
83
+ "@rific/splash-gate": "^0.2.4",
84
+ "@rific/toaster": "^0.14.0",
85
+ "@rific/updater": "^0.9.3",
86
86
  "@tastic/achievements": "^0.6.1",
87
- "@tastic/core": "^0.17.0",
87
+ "@tastic/core": "^0.19.0",
88
88
  "@tastic/edge-guard": "^0.2.1",
89
- "@tastic/hud": "^0.37.0",
90
- "@tastic/profile": "^0.26.0",
89
+ "@tastic/hud": "^0.40.0",
90
+ "@tastic/profile": "^0.29.0",
91
91
  "@tastic/split-screen": "^0.6.0",
92
92
  "@testing-library/react-native": "^14.1.0",
93
93
  "@types/jest": "30.0.0",
@@ -132,14 +132,14 @@
132
132
  "@reduxjs/toolkit": ">=2.13.0",
133
133
  "@rific/auto-paper": ">=0.13.4",
134
134
  "@rific/core": ">=0.5.0",
135
- "@rific/feedback-press": ">=0.13.1",
135
+ "@rific/feedback-press": ">=0.15.0",
136
136
  "@rific/splash-gate": ">=0.2.3",
137
137
  "@rific/toaster": ">=0.10.1",
138
138
  "@tastic/achievements": ">=0.6.0",
139
139
  "@tastic/core": ">=0.16.0",
140
140
  "@tastic/edge-guard": ">=0.2.0",
141
- "@tastic/hud": ">=0.37.0",
142
- "@tastic/profile": ">=0.26.0",
141
+ "@tastic/hud": ">=0.40.0",
142
+ "@tastic/profile": ">=0.29.0",
143
143
  "@tastic/split-screen": ">=0.5.5",
144
144
  "expo-audio": ">=58.0.11",
145
145
  "expo-blur": ">=58.0.4",
@@ -7,7 +7,7 @@ import { DialogHeaderStyleProvider, LetteringProvider, ScreenFrame } from '@tast
7
7
  import { ProfileColorProvider } from '@tastic/profile'
8
8
  import * as Haptics from 'expo-haptics'
9
9
  import { DarkTheme, DefaultTheme, Stack, ThemeProvider as NavigationThemeProvider } from 'expo-router'
10
- import { ReactNode, useCallback, useMemo } from 'react'
10
+ import { ReactNode, useCallback, useMemo, useRef } from 'react'
11
11
  import { Platform, StyleSheet, View } from 'react-native'
12
12
  import { GestureHandlerRootView } from 'react-native-gesture-handler'
13
13
  import * as RNPaper from 'react-native-paper'
@@ -25,7 +25,7 @@ import { LastActiveGameProvider } from './hooks/useLastActiveGame'
25
25
  import { ProfilesProvider, useProfiles } from './hooks/useProfiles'
26
26
  import { PackProvider, usePack } from './PackContext'
27
27
  import type { PackStore } from './redux/createPackStore'
28
- import { SplashGate } from './splashGate'
28
+ import { markSplashReady, SplashGate } from './splashGate'
29
29
  import type { PackDefinition, PackGameDefinition } from './types'
30
30
 
31
31
  // The pack's root: every provider the shell needs, the pack's games' own providers, and the stack.
@@ -82,8 +82,24 @@ const TRANSPARENT_CONTENT = { backgroundColor: 'transparent' }
82
82
  // empty object without them.
83
83
  const noScreenOptions = () => ({})
84
84
 
85
+ // Holds the splash until the stack's first screen is on the glass. The other gates open in the very commit
86
+ // that starts mounting the stack, and on a slow phone React Native draws that commit a second or more later:
87
+ // the splash faded to the theme's plain background and the first screen landed on it after 1 to 1.4 s (an LG
88
+ // Stylo 6, CardTastic). The stack's layout comes with that commit, whatever screen it opens on, and by the
89
+ // second frame after it Android has mounted it (nothing under a held splash is drawn), so the splash fades
90
+ // straight to the screen.
91
+ function useFirstScreenGate() {
92
+ const marked = useRef(false)
93
+ return useCallback(() => {
94
+ if (marked.current) return
95
+ marked.current = true
96
+ requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady('screen')))
97
+ }, [])
98
+ }
99
+
85
100
  function AppStack() {
86
101
  const pack = usePack()
102
+ const onFirstLayout = useFirstScreenGate()
87
103
  const { Backdrop } = pack
88
104
  const { dark } = useAutoPaperTheme()
89
105
  // Over a backdrop the root stays dark whatever the mode: a backdrop is a dark table (the felt), and a
@@ -114,19 +130,15 @@ function AppStack() {
114
130
  const base = darkRoot ? DarkTheme : DefaultTheme
115
131
  return { ...base, colors: { ...base.colors, background: navigationBackground } }
116
132
  }, [darkRoot, navigationBackground])
117
- const stack = (
118
- <NavigationThemeProvider value={navigationTheme}>
119
- <Stack screenOptions={{ ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }}>
120
- <Stack.Screen name='index' />
121
- <Stack.Screen name='play/[game]' options={playOptions} />
122
- </Stack>
123
- </NavigationThemeProvider>
124
- )
125
- if (!Backdrop) return stack
126
133
  return (
127
- <View style={styles.root}>
128
- <Backdrop />
129
- {stack}
134
+ <View style={styles.root} onLayout={onFirstLayout}>
135
+ {Backdrop && <Backdrop />}
136
+ <NavigationThemeProvider value={navigationTheme}>
137
+ <Stack screenOptions={{ ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }}>
138
+ <Stack.Screen name='index' />
139
+ <Stack.Screen name='play/[game]' options={playOptions} />
140
+ </Stack>
141
+ </NavigationThemeProvider>
130
142
  </View>
131
143
  )
132
144
  }
@@ -95,7 +95,7 @@ export function OpponentPicker({ idPrefix, host, choices, seatTwo, onSeatTwoChan
95
95
 
96
96
  return (
97
97
  <View style={[styles.button, host.openId === pickerId && styles.buttonOpen]}>
98
- <OptionPicker id={pickerId} host={host} options={options} value={value} onChange={handleChange} color={drawn} dark={dark} icon={icon} colorSection={colorSection} alignOverride={align} triggerStyle={triggerStyle} />
98
+ <OptionPicker id={pickerId} host={host} caption='Opponent' options={options} value={value} onChange={handleChange} color={drawn} dark={dark} icon={icon} colorSection={colorSection} alignOverride={align} triggerStyle={triggerStyle} />
99
99
  </View>
100
100
  )
101
101
  }
@@ -20,10 +20,13 @@ interface Props {
20
20
 
21
21
  // Generic UI feedback sounds, wired into every Button/IconButton/etc. in the package (see
22
22
  // useFeedbackHandlers' `fire`, which already gates these on the sound-enabled setting itself -
23
- // no need to re-check it here).
23
+ // no need to re-check it here). With sound off the pools make no players at all (`enabled`): each one
24
+ // costs a slow Android phone about 0.1 s of its launch. Read from the store, since this runs above the
25
+ // FeedbackPressProvider it feeds.
24
26
  function useShellFeedbackSounds(): FeedbackSounds {
25
- const selection = useAudioPool(require('../../assets/sounds/select.wav'))
26
- const notification = useAudioPool(require('../../assets/sounds/notification.wav'))
27
+ const enabled = useSelector((state: ShellState) => state.sound.enabled)
28
+ const selection = useAudioPool(require('../../assets/sounds/select.wav'), { enabled })
29
+ const notification = useAudioPool(require('../../assets/sounds/notification.wav'), { enabled })
27
30
  return { selection, notification }
28
31
  }
29
32