@tastic/shell 0.21.0 → 0.22.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 +23 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +152 -55
- package/dist/index.mjs +143 -47
- package/package.json +1 -1
- package/src/RootLayout.tsx +40 -5
- package/src/components/Staged.tsx +46 -0
- package/src/hooks/useLastActiveGame.tsx +34 -5
- package/src/index.ts +1 -0
- package/src/screens/GameRoute.tsx +13 -0
- package/src/screens/HomeScreen.tsx +27 -6
- package/src/screens/StatsScreen.tsx +15 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ package ecosystem, on [`@tastic/hud`](https://github.com/jayrdeaton/react-native
|
|
|
45
45
|
`usePack` and `usePackGame`, `useActiveRound`, `useProfiles`, `useSeatColors`, `useOpponent`,
|
|
46
46
|
`useAppSettings`, `useGameGuide`, `useAtComputer`, `roundModeFor`, `humanSeatsFor`, `seatTwoFor`,
|
|
47
47
|
`MatchChips`, `SettingsDialog`, `safeBack`, `useBackBlock` (Android's and the browser's back
|
|
48
|
-
mid-match open Quit Match?) and `imageGameIcon` (see [Hooks and helpers](#hooks-and-helpers)).
|
|
48
|
+
mid-match open Quit Match?), `Staged` (a long page a few parts at a time) and `imageGameIcon` (see [Hooks and helpers](#hooks-and-helpers)).
|
|
49
49
|
|
|
50
50
|
## Install
|
|
51
51
|
|
|
@@ -381,6 +381,28 @@ const quit = useBackBlock(hasProgress, requestBack)
|
|
|
381
381
|
- While it's on, the web also asks before the page unloads (expo-router's `usePreventRemove` adds a
|
|
382
382
|
`beforeunload` handler with it). iOS's swipe back is off on every screen anyway.
|
|
383
383
|
|
|
384
|
+
### A long page a few parts at a time (`Staged`, 0.22.0)
|
|
385
|
+
|
|
386
|
+
A stats screen's wells or an achievement list's rows, drawn all at once, hold the screen back until the last of them is
|
|
387
|
+
built: seconds on a budget phone, for parts past its bottom edge. `Staged` draws the `first` of its children with the screen
|
|
388
|
+
(default 1) and `step` more (default 1) each time what's drawn has reached the screen and the app has a moment. It draws no
|
|
389
|
+
view of its own, so the parts are flat siblings of what's round it (a stats page's gap still spaces them), and a part never
|
|
390
|
+
renders again as later ones come. Give it a `key` that changes with what's listed (a filter), so a longer list taking a
|
|
391
|
+
shorter one's place is drawn the same way.
|
|
392
|
+
|
|
393
|
+
`StatsScreen` draws the games' own sections in it, the first with the screen (none, under a pack's own `StatsSections`). Use
|
|
394
|
+
it inside a section of your own that is long: a pack's `AchievementList`, or a tab of its own (`statsTabs`).
|
|
395
|
+
|
|
396
|
+
```tsx
|
|
397
|
+
import { Staged } from '@tastic/shell'
|
|
398
|
+
|
|
399
|
+
<Staged first={8} step={3}>
|
|
400
|
+
{rows.map((row) => (
|
|
401
|
+
<AchievementRow key={row.id} {...row} />
|
|
402
|
+
))}
|
|
403
|
+
</Staged>
|
|
404
|
+
```
|
|
405
|
+
|
|
384
406
|
## Peer dependencies
|
|
385
407
|
|
|
386
408
|
None are bundled. The floors started as the versions PuckTastic and DuelTastic ran the shell on when
|
package/dist/index.d.mts
CHANGED
|
@@ -443,6 +443,13 @@ interface SettingsDialogProps {
|
|
|
443
443
|
}
|
|
444
444
|
declare function SettingsDialog({ visible, onDismiss, onShowHowToPlay, showProfile, children }: SettingsDialogProps): react.JSX.Element;
|
|
445
445
|
|
|
446
|
+
interface Props$1 {
|
|
447
|
+
first?: number;
|
|
448
|
+
step?: number;
|
|
449
|
+
children: ReactNode;
|
|
450
|
+
}
|
|
451
|
+
declare function Staged({ first, step, children }: Props$1): react.JSX.Element;
|
|
452
|
+
|
|
446
453
|
declare function useActiveRound<S extends object>(game: string, defaults: S): {
|
|
447
454
|
mode: RoundMode;
|
|
448
455
|
settings: S;
|
|
@@ -591,5 +598,5 @@ declare function createPlayerSettings<S extends WithControls<C>, C>({ id, defaul
|
|
|
591
598
|
};
|
|
592
599
|
};
|
|
593
600
|
|
|
594
|
-
export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, EditProfileRoute, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, StatsScreen, appSettingsActions, reducer$1 as appSettingsReducer, createGameGuideSlice, createGameStats, createPackStore, createPlayerSettings, createSeatColorsReducer, createShellReducers, defaultProfileSelectionState, defaultSeatColorsState, forgetProfileAchievements, humanSeatsFor, imageGameIcon, liveplayActions, reducer$3 as liveplayReducer, onProfileRemoved, opponentActions, reducer$2 as opponentReducer, profileSelectionActions, reducer as profileSelectionReducer, roundModeFor, seatColorsActions, seatPlayerKey, seatTwoFor, useActiveRound, useAppSettings, useAtComputer, useBackBlock, useGameGuide, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
|
|
601
|
+
export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, EditProfileRoute, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, Staged, StatsScreen, appSettingsActions, reducer$1 as appSettingsReducer, createGameGuideSlice, createGameStats, createPackStore, createPlayerSettings, createSeatColorsReducer, createShellReducers, defaultProfileSelectionState, defaultSeatColorsState, forgetProfileAchievements, humanSeatsFor, imageGameIcon, liveplayActions, reducer$3 as liveplayReducer, onProfileRemoved, opponentActions, reducer$2 as opponentReducer, profileSelectionActions, reducer as profileSelectionReducer, roundModeFor, seatColorsActions, seatPlayerKey, seatTwoFor, useActiveRound, useAppSettings, useAtComputer, useBackBlock, useGameGuide, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
|
|
595
602
|
export type { ActiveRound, AppSettings, FeedbackSounds, GameDefinition, GameGuide, GameGuideState, GameIconProps, GameLoadout, GamePreviewProps, GameRulesProps, GuidelessGameDefinition, HeroTitleProps, HomeTab, LiveplaySliceState, LoadoutOptionsProps, MatchChipsProps, OpponentState, PackDefinition, PackGameDefinition, PackGuide, PackStatsReset, PackStatsSectionsProps, PackStatsTab, PackStore, PackStoreConfig, PackStoreSource, PickerAlign, PlayerControlsState, PlayerSettingsState, ProfileSelectionState, RecordResult, RoundMode, Seat, SeatColorsState, SeatControlLook, SeatTwo, SettingsDialogProps, ShellState, StackScreenOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -443,6 +443,13 @@ interface SettingsDialogProps {
|
|
|
443
443
|
}
|
|
444
444
|
declare function SettingsDialog({ visible, onDismiss, onShowHowToPlay, showProfile, children }: SettingsDialogProps): react.JSX.Element;
|
|
445
445
|
|
|
446
|
+
interface Props$1 {
|
|
447
|
+
first?: number;
|
|
448
|
+
step?: number;
|
|
449
|
+
children: ReactNode;
|
|
450
|
+
}
|
|
451
|
+
declare function Staged({ first, step, children }: Props$1): react.JSX.Element;
|
|
452
|
+
|
|
446
453
|
declare function useActiveRound<S extends object>(game: string, defaults: S): {
|
|
447
454
|
mode: RoundMode;
|
|
448
455
|
settings: S;
|
|
@@ -591,5 +598,5 @@ declare function createPlayerSettings<S extends WithControls<C>, C>({ id, defaul
|
|
|
591
598
|
};
|
|
592
599
|
};
|
|
593
600
|
|
|
594
|
-
export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, EditProfileRoute, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, StatsScreen, appSettingsActions, reducer$1 as appSettingsReducer, createGameGuideSlice, createGameStats, createPackStore, createPlayerSettings, createSeatColorsReducer, createShellReducers, defaultProfileSelectionState, defaultSeatColorsState, forgetProfileAchievements, humanSeatsFor, imageGameIcon, liveplayActions, reducer$3 as liveplayReducer, onProfileRemoved, opponentActions, reducer$2 as opponentReducer, profileSelectionActions, reducer as profileSelectionReducer, roundModeFor, seatColorsActions, seatPlayerKey, seatTwoFor, useActiveRound, useAppSettings, useAtComputer, useBackBlock, useGameGuide, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
|
|
601
|
+
export { DEFAULT_APP_SETTINGS, DEFAULT_OPPONENT, EditProfileRoute, GUEST_PLAYER_ID, HomeScreen, LoadoutRoute, MATCH_CHIPS_FADE_MS, MatchChips, PREVIEW_ASPECT, PackProvider, PlayRoute, ProfilesProvider, ProfilesRoute, RootLayout, SettingsDialog, Staged, StatsScreen, appSettingsActions, reducer$1 as appSettingsReducer, createGameGuideSlice, createGameStats, createPackStore, createPlayerSettings, createSeatColorsReducer, createShellReducers, defaultProfileSelectionState, defaultSeatColorsState, forgetProfileAchievements, humanSeatsFor, imageGameIcon, liveplayActions, reducer$3 as liveplayReducer, onProfileRemoved, opponentActions, reducer$2 as opponentReducer, profileSelectionActions, reducer as profileSelectionReducer, roundModeFor, seatColorsActions, seatPlayerKey, seatTwoFor, useActiveRound, useAppSettings, useAtComputer, useBackBlock, useGameGuide, useOpponent, usePack, usePackGame, useProfiles, useSeatColors };
|
|
595
602
|
export type { ActiveRound, AppSettings, FeedbackSounds, GameDefinition, GameGuide, GameGuideState, GameIconProps, GameLoadout, GamePreviewProps, GameRulesProps, GuidelessGameDefinition, HeroTitleProps, HomeTab, LiveplaySliceState, LoadoutOptionsProps, MatchChipsProps, OpponentState, PackDefinition, PackGameDefinition, PackGuide, PackStatsReset, PackStatsSectionsProps, PackStatsTab, PackStore, PackStoreConfig, PackStoreSource, PickerAlign, PlayerControlsState, PlayerSettingsState, ProfileSelectionState, RecordResult, RoundMode, Seat, SeatColorsState, SeatControlLook, SeatTwo, SettingsDialogProps, ShellState, StackScreenOptions };
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,7 @@ __export(index_exports, {
|
|
|
45
45
|
ProfilesRoute: () => ProfilesRoute,
|
|
46
46
|
RootLayout: () => RootLayout,
|
|
47
47
|
SettingsDialog: () => SettingsDialog,
|
|
48
|
+
Staged: () => Staged,
|
|
48
49
|
StatsScreen: () => StatsScreen,
|
|
49
50
|
appSettingsActions: () => appSettingsActions,
|
|
50
51
|
appSettingsReducer: () => appSettingsSlice_default,
|
|
@@ -373,8 +374,15 @@ function LastActiveGameProvider({ children }) {
|
|
|
373
374
|
const [initial] = (0, import_react7.useState)(() => store.getState().lastActiveGame?.gameId ?? null);
|
|
374
375
|
const pendingResume = (0, import_react7.useRef)(initial);
|
|
375
376
|
const persisted = (0, import_react7.useRef)(initial);
|
|
376
|
-
const
|
|
377
|
-
|
|
377
|
+
const resume = (0, import_react7.useRef)("idle");
|
|
378
|
+
const resumeListeners = (0, import_react7.useRef)(/* @__PURE__ */ new Set());
|
|
379
|
+
const value = (0, import_react7.useMemo)(() => {
|
|
380
|
+
const setResume = (next) => {
|
|
381
|
+
if (resume.current === next) return;
|
|
382
|
+
resume.current = next;
|
|
383
|
+
resumeListeners.current.forEach((listener) => listener());
|
|
384
|
+
};
|
|
385
|
+
return {
|
|
378
386
|
consumeResumeGame: () => {
|
|
379
387
|
const game = pendingResume.current;
|
|
380
388
|
pendingResume.current = null;
|
|
@@ -394,10 +402,20 @@ function LastActiveGameProvider({ children }) {
|
|
|
394
402
|
if (persisted.current === null) return;
|
|
395
403
|
persisted.current = null;
|
|
396
404
|
dispatch(lastActiveGameActions.setGameId(null));
|
|
405
|
+
},
|
|
406
|
+
beginResume: () => setResume("opening"),
|
|
407
|
+
playScreenUp: () => {
|
|
408
|
+
if (resume.current === "opening") setResume("up");
|
|
409
|
+
},
|
|
410
|
+
endResume: () => setResume("idle"),
|
|
411
|
+
resumeState: () => resume.current,
|
|
412
|
+
subscribeResume: (listener) => {
|
|
413
|
+
const listeners = resumeListeners.current;
|
|
414
|
+
listeners.add(listener);
|
|
415
|
+
return () => void listeners.delete(listener);
|
|
397
416
|
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
);
|
|
417
|
+
};
|
|
418
|
+
}, [dispatch]);
|
|
401
419
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LastActiveGameContext.Provider, { value, children });
|
|
402
420
|
}
|
|
403
421
|
function useLastActiveGame() {
|
|
@@ -496,16 +514,43 @@ var REPLACE_AS_FORWARD = { animationTypeForReplace: "push" };
|
|
|
496
514
|
var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
|
|
497
515
|
var noScreenOptions = () => ({});
|
|
498
516
|
function useFirstScreenGate() {
|
|
517
|
+
const { resumeState, subscribeResume } = useLastActiveGame();
|
|
499
518
|
const marked = (0, import_react9.useRef)(false);
|
|
500
519
|
return (0, import_react9.useCallback)(() => {
|
|
501
520
|
if (marked.current) return;
|
|
502
521
|
marked.current = true;
|
|
503
|
-
requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
|
|
504
|
-
|
|
522
|
+
const mark = () => requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
|
|
523
|
+
requestAnimationFrame(
|
|
524
|
+
() => requestAnimationFrame(() => {
|
|
525
|
+
if (resumeState() !== "opening") {
|
|
526
|
+
markSplashReady("screen");
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const unsubscribe = subscribeResume(() => {
|
|
530
|
+
if (resumeState() === "opening") return;
|
|
531
|
+
unsubscribe();
|
|
532
|
+
mark();
|
|
533
|
+
});
|
|
534
|
+
})
|
|
535
|
+
);
|
|
536
|
+
}, [resumeState, subscribeResume]);
|
|
537
|
+
}
|
|
538
|
+
function useResumeShown() {
|
|
539
|
+
const { endResume } = useLastActiveGame();
|
|
540
|
+
return (0, import_react9.useCallback)(
|
|
541
|
+
({ route }) => ({
|
|
542
|
+
transitionEnd: (event) => {
|
|
543
|
+
if (route.name === PLAY_ROUTE && !event.data?.closing) endResume();
|
|
544
|
+
}
|
|
545
|
+
}),
|
|
546
|
+
[endResume]
|
|
547
|
+
);
|
|
505
548
|
}
|
|
549
|
+
var PLAY_ROUTE = "play/[game]";
|
|
506
550
|
function AppStack() {
|
|
507
551
|
const pack = usePack();
|
|
508
552
|
const onFirstLayout = useFirstScreenGate();
|
|
553
|
+
const screenListeners = useResumeShown();
|
|
509
554
|
const { Backdrop } = pack;
|
|
510
555
|
const { dark } = (0, import_auto_paper2.useAutoPaperTheme)();
|
|
511
556
|
const darkRoot = Backdrop ? true : dark;
|
|
@@ -531,9 +576,9 @@ function AppStack() {
|
|
|
531
576
|
}, [darkRoot, navigationBackground]);
|
|
532
577
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native3.View, { style: styles.root, onLayout: onFirstLayout, children: [
|
|
533
578
|
Backdrop && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Backdrop, {}),
|
|
534
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.ThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_expo_router.Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
|
|
579
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.ThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_expo_router.Stack, { screenListeners, screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
|
|
535
580
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name: "index" }),
|
|
536
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name:
|
|
581
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name: PLAY_ROUTE, options: playOptions })
|
|
537
582
|
] }) })
|
|
538
583
|
] });
|
|
539
584
|
}
|
|
@@ -1130,10 +1175,20 @@ function PlayRoute() {
|
|
|
1130
1175
|
const { game: id } = (0, import_expo_router8.useLocalSearchParams)();
|
|
1131
1176
|
const game = usePackGame(id);
|
|
1132
1177
|
useResumePoint(game?.resumable ? game.id : null);
|
|
1178
|
+
useResumeUp();
|
|
1133
1179
|
if (!game) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_expo_router8.Redirect, { href: "/" });
|
|
1134
1180
|
const { PlayScreen } = game;
|
|
1135
1181
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PlayScreen, {}, game.id);
|
|
1136
1182
|
}
|
|
1183
|
+
function useResumeUp() {
|
|
1184
|
+
const { playScreenUp } = useLastActiveGame();
|
|
1185
|
+
(0, import_react14.useEffect)(() => {
|
|
1186
|
+
let frame = requestAnimationFrame(() => {
|
|
1187
|
+
frame = requestAnimationFrame(playScreenUp);
|
|
1188
|
+
});
|
|
1189
|
+
return () => cancelAnimationFrame(frame);
|
|
1190
|
+
}, [playScreenUp]);
|
|
1191
|
+
}
|
|
1137
1192
|
var playScreensUp = 0;
|
|
1138
1193
|
function useResumePoint(gameId) {
|
|
1139
1194
|
const { setLastActiveGame, clearLastActiveGame } = useLastActiveGame();
|
|
@@ -1268,11 +1323,24 @@ function useResume(game) {
|
|
|
1268
1323
|
);
|
|
1269
1324
|
}
|
|
1270
1325
|
function useMenuShown(resuming) {
|
|
1326
|
+
const { beginResume, endResume, resumeState, subscribeResume } = useLastActiveGame();
|
|
1271
1327
|
const isFocused = (0, import_expo_router9.useIsFocused)();
|
|
1272
1328
|
const [covered, setCovered] = (0, import_react16.useState)(false);
|
|
1273
1329
|
if (resuming && !covered && !isFocused) setCovered(true);
|
|
1274
|
-
|
|
1330
|
+
(0, import_react16.useLayoutEffect)(() => {
|
|
1331
|
+
if (!resuming) return;
|
|
1332
|
+
beginResume();
|
|
1333
|
+
const id = setTimeout(endResume, RESUME_SHOWN_MAX_MS);
|
|
1334
|
+
return () => {
|
|
1335
|
+
clearTimeout(id);
|
|
1336
|
+
endResume();
|
|
1337
|
+
};
|
|
1338
|
+
}, [resuming, beginResume, endResume]);
|
|
1339
|
+
const onItsWay = (0, import_react16.useSyncExternalStore)(subscribeResume, resumeState, resumeState) !== "idle";
|
|
1340
|
+
const gameShown = covered && !onItsWay;
|
|
1341
|
+
return (0, import_react16.useDeferredValue)(!resuming || gameShown || covered && isFocused);
|
|
1275
1342
|
}
|
|
1343
|
+
var RESUME_SHOWN_MAX_MS = 4e3;
|
|
1276
1344
|
function HomeMenu() {
|
|
1277
1345
|
const pack = usePack();
|
|
1278
1346
|
const showPicker = pack.homePlayerPicker !== false;
|
|
@@ -1617,12 +1685,40 @@ var import_auto_paper7 = require("@rific/auto-paper");
|
|
|
1617
1685
|
var import_chrome8 = require("@tastic/hud/chrome");
|
|
1618
1686
|
var import_profile10 = require("@tastic/profile");
|
|
1619
1687
|
var import_expo_router10 = require("expo-router");
|
|
1620
|
-
var
|
|
1688
|
+
var import_react18 = require("react");
|
|
1621
1689
|
var import_react_native10 = require("react-native");
|
|
1622
1690
|
var import_react_native_paper3 = require("react-native-paper");
|
|
1623
1691
|
var import_react_native_safe_area_context5 = require("react-native-safe-area-context");
|
|
1624
1692
|
var import_react_redux10 = require("react-redux");
|
|
1693
|
+
|
|
1694
|
+
// src/components/Staged.tsx
|
|
1695
|
+
var import_react17 = require("react");
|
|
1625
1696
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1697
|
+
function onShown(run) {
|
|
1698
|
+
let idle;
|
|
1699
|
+
let frame = requestAnimationFrame(() => {
|
|
1700
|
+
frame = requestAnimationFrame(() => {
|
|
1701
|
+
if (typeof requestIdleCallback === "function") idle = requestIdleCallback(run);
|
|
1702
|
+
else run();
|
|
1703
|
+
});
|
|
1704
|
+
});
|
|
1705
|
+
return () => {
|
|
1706
|
+
cancelAnimationFrame(frame);
|
|
1707
|
+
if (idle !== void 0) cancelIdleCallback(idle);
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
function Staged({ first = 1, step = 1, children }) {
|
|
1711
|
+
const parts = (0, import_react17.useMemo)(() => import_react17.Children.toArray(children), [children]);
|
|
1712
|
+
const [drawn, setDrawn] = (0, import_react17.useState)(first);
|
|
1713
|
+
(0, import_react17.useEffect)(() => {
|
|
1714
|
+
if (drawn >= parts.length) return;
|
|
1715
|
+
return onShown(() => setDrawn(drawn + step));
|
|
1716
|
+
}, [drawn, parts.length, step]);
|
|
1717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: parts.slice(0, drawn) });
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
// src/screens/StatsScreen.tsx
|
|
1721
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1626
1722
|
var STATS = "stats";
|
|
1627
1723
|
var ACHIEVEMENTS = "achievements";
|
|
1628
1724
|
var TABS = [
|
|
@@ -1642,10 +1738,10 @@ var MANAGE_OPTION = { value: MANAGE, label: "Manage", icon: "account-cog-outline
|
|
|
1642
1738
|
var STATS_MAX_WIDTH = 640;
|
|
1643
1739
|
function StatsScreen() {
|
|
1644
1740
|
const pickerHost = (0, import_chrome8.usePopoverHost)();
|
|
1645
|
-
return /* @__PURE__ */ (0,
|
|
1741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(StatsPressAway, { host: pickerHost, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_chrome8.ScreenFrame, { portalHost: true, maxContentWidth: STATS_MAX_WIDTH, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(StatsContent, { pickerHost }) }) });
|
|
1646
1742
|
}
|
|
1647
1743
|
function StatsPressAway({ host, children }) {
|
|
1648
|
-
return /* @__PURE__ */ (0,
|
|
1744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native10.View, { testID: "stats-press-away", style: styles5.screen, onStartShouldSetResponder: () => host.openId !== null, onResponderRelease: host.close, children });
|
|
1649
1745
|
}
|
|
1650
1746
|
var useNoPackReset = () => null;
|
|
1651
1747
|
var noPickerAlign2 = () => void 0;
|
|
@@ -1657,11 +1753,11 @@ function StatsContent({ pickerHost }) {
|
|
|
1657
1753
|
const { profiles, lastSelected } = useProfiles();
|
|
1658
1754
|
const dispatch = (0, import_react_redux10.useDispatch)();
|
|
1659
1755
|
const fg = pack.foreground ?? colors.onBackground;
|
|
1660
|
-
const [tab, setTab] = (0,
|
|
1661
|
-
const [gameId, setGameId] = (0,
|
|
1756
|
+
const [tab, setTab] = (0, import_react18.useState)(STATS);
|
|
1757
|
+
const [gameId, setGameId] = (0, import_react18.useState)(ALL_GAMES2);
|
|
1662
1758
|
const useStatsPlayer = pack.useStatsPlayer ?? useNoStatsPlayer;
|
|
1663
1759
|
const statsPlayer = useStatsPlayer();
|
|
1664
|
-
const [selectedProfileId, setSelectedProfileId] = (0,
|
|
1760
|
+
const [selectedProfileId, setSelectedProfileId] = (0, import_react18.useState)(() => pack.useStatsPlayer ? statsPlayer : pack.guestStats ? lastSelected[1] ?? GUEST_PLAYER_ID : null);
|
|
1665
1761
|
const profileId = selectedProfileId && profiles.length > 0 && (pack.guestStats && selectedProfileId === GUEST_PLAYER_ID || profiles.some((p) => p.id === selectedProfileId)) ? selectedProfileId : null;
|
|
1666
1762
|
const homeTabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
|
|
1667
1763
|
const pickedTab = homeTabs?.findIndex((_, index) => gameId === tabGames(index)) ?? -1;
|
|
@@ -1671,14 +1767,14 @@ function StatsContent({ pickerHost }) {
|
|
|
1671
1767
|
const packTabs = pack.statsTabs ?? NO_PACK_TABS;
|
|
1672
1768
|
const packTab = packTabs.find((t) => t.value === tab);
|
|
1673
1769
|
const showGamePicker = !(tab === ACHIEVEMENTS && pack.AchievementList);
|
|
1674
|
-
const playerOptions = (0,
|
|
1675
|
-
const gameOptions = (0,
|
|
1770
|
+
const playerOptions = (0, import_react18.useMemo)(() => [{ 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]);
|
|
1771
|
+
const gameOptions = (0, import_react18.useMemo)(() => {
|
|
1676
1772
|
const all = { value: ALL_GAMES2, label: "All Games", icon: "view-grid-outline" };
|
|
1677
1773
|
const option = (g) => ({ value: g.id, label: g.title, icon: "cards-playing-outline" });
|
|
1678
1774
|
if (!homeTabs) return [all, ...pack.games.map(option)];
|
|
1679
1775
|
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)] }))];
|
|
1680
1776
|
}, [pack.games, homeTabs]);
|
|
1681
|
-
const tabButtons = (0,
|
|
1777
|
+
const tabButtons = (0, import_react18.useMemo)(() => {
|
|
1682
1778
|
const buttons = packTabs.length > 0 ? [{ value: STATS, label: "Stats" }, ...packTabs.map(({ value, label }) => ({ value, label })), { value: ACHIEVEMENTS, label: "Achievements" }].map((button) => ({ ...button, style: LABEL_WIDE_TAB })) : TABS;
|
|
1683
1779
|
return pack.labelStyle ? buttons.map((button) => ({ ...button, labelStyle: pack.labelStyle })) : buttons;
|
|
1684
1780
|
}, [packTabs, pack.labelStyle]);
|
|
@@ -1694,16 +1790,16 @@ function StatsContent({ pickerHost }) {
|
|
|
1694
1790
|
const surface = pack.Backdrop ? { backgroundColor: colors.surface } : void 0;
|
|
1695
1791
|
const triggerStyle = pack.Backdrop ? [styles5.pill, surface] : void 0;
|
|
1696
1792
|
const PackTabContent = packTab?.Content;
|
|
1697
|
-
return /* @__PURE__ */ (0,
|
|
1698
|
-
/* @__PURE__ */ (0,
|
|
1699
|
-
/* @__PURE__ */ (0,
|
|
1700
|
-
/* @__PURE__ */ (0,
|
|
1701
|
-
/* @__PURE__ */ (0,
|
|
1702
|
-
showGamePicker && /* @__PURE__ */ (0,
|
|
1793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_chrome8.BaseStatsScreen, { title, titleStyle: pack.titleStyle, onBack: import_core6.safeBack, insets, onReset: reset.onReset, resetLabel: reset.label, resetConfirmTitle: reset.title, resetConfirmBody: reset.body, fg: pack.foreground, bg: pack.Backdrop ? "transparent" : void 0, children: [
|
|
1794
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_chrome8.PressAwayOverlay, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles5.pressAway }),
|
|
1795
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper3.SegmentedButtons, { value: tab, onValueChange: setTab, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles5.tabs, surface] }),
|
|
1796
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_native10.View, { style: [styles5.filters, pickerHost.openId !== null && styles5.filtersOpen], onStartShouldSetResponder: () => pickerHost.openId !== null, children: [
|
|
1797
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_profile10.OptionPicker, { id: PLAYER_PICKER_ID, host: pickerHost, options: playerOptions, value: profileId ?? EVERYONE, onChange: (value) => value === MANAGE ? import_expo_router10.router.push(PROFILES_HREF) : setSelectedProfileId(value === EVERYONE ? null : value), color: colors.primary, dark, icon: profileId ? "account" : "account-group", caption: "Player", alignOverride: playerAlign, triggerStyle }),
|
|
1798
|
+
showGamePicker && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_profile10.OptionPicker, { id: GAME_PICKER_ID, host: pickerHost, options: gameOptions, value: gameId, onChange: setGameId, color: colors.primary, dark, icon: "view-grid-outline", caption: "Game", alignOverride: gameAlign, triggerStyle })
|
|
1703
1799
|
] }),
|
|
1704
|
-
tab === STATS && pack.StatsSections && /* @__PURE__ */ (0,
|
|
1705
|
-
PackTabContent && /* @__PURE__ */ (0,
|
|
1706
|
-
tab === ACHIEVEMENTS && pack.AchievementList ? /* @__PURE__ */ (0,
|
|
1800
|
+
tab === STATS && pack.StatsSections && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(pack.StatsSections, { profileId, gameId: oneGameId, gameIds }),
|
|
1801
|
+
PackTabContent && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PackTabContent, { profileId, gameId: oneGameId, gameIds }),
|
|
1802
|
+
tab === ACHIEVEMENTS && pack.AchievementList ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(pack.AchievementList, { profileId }) : (tab === STATS || tab === ACHIEVEMENTS) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Staged, { first: tab === STATS && pack.StatsSections ? 0 : 1, children: games.map((game) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(GameStats, { game, tab, profileId, showTitle: games.length > 1 && pack.statsGameTitles !== false, titleColor: fg }, game.id)) }, `${tab} ${gameId}`)
|
|
1707
1803
|
] });
|
|
1708
1804
|
}
|
|
1709
1805
|
function resetFor(pack, packReset, profileId, profiles, games, resetGames) {
|
|
@@ -1719,9 +1815,9 @@ function GameStats({ game, tab, profileId, showTitle, titleColor }) {
|
|
|
1719
1815
|
const { StatsSections, AchievementList } = game;
|
|
1720
1816
|
const Sections = tab === STATS ? StatsSections : AchievementList;
|
|
1721
1817
|
if (!Sections) return null;
|
|
1722
|
-
return /* @__PURE__ */ (0,
|
|
1723
|
-
showTitle && /* @__PURE__ */ (0,
|
|
1724
|
-
/* @__PURE__ */ (0,
|
|
1818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react_native10.View, { style: styles5.game, children: [
|
|
1819
|
+
showTitle && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native_paper3.Text, { variant: "titleLarge", style: [styles5.gameTitle, { color: titleColor }, titleStyle], children: game.title }),
|
|
1820
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Sections, { profileId })
|
|
1725
1821
|
] });
|
|
1726
1822
|
}
|
|
1727
1823
|
var styles5 = import_react_native10.StyleSheet.create({
|
|
@@ -1759,21 +1855,21 @@ var styles5 = import_react_native10.StyleSheet.create({
|
|
|
1759
1855
|
|
|
1760
1856
|
// src/components/imageGameIcon.tsx
|
|
1761
1857
|
var import_react_native11 = require("react-native");
|
|
1762
|
-
var
|
|
1858
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1763
1859
|
function imageGameIcon(images) {
|
|
1764
1860
|
return function ImageGameIcon({ size, dark }) {
|
|
1765
|
-
return /* @__PURE__ */ (0,
|
|
1861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react_native11.Image, { source: dark ? images.dark : images.light, style: { height: size, width: size }, accessibilityIgnoresInvertColors: true });
|
|
1766
1862
|
};
|
|
1767
1863
|
}
|
|
1768
1864
|
|
|
1769
1865
|
// src/components/MatchChips.tsx
|
|
1770
1866
|
var import_auto_paper8 = require("@rific/auto-paper");
|
|
1771
1867
|
var import_feedback_press4 = require("@rific/feedback-press");
|
|
1772
|
-
var
|
|
1868
|
+
var import_react19 = require("react");
|
|
1773
1869
|
var import_react_native12 = require("react-native");
|
|
1774
1870
|
var import_react_native_reanimated3 = __toESM(require("react-native-reanimated"));
|
|
1775
1871
|
var import_react_native_safe_area_context6 = require("react-native-safe-area-context");
|
|
1776
|
-
var
|
|
1872
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1777
1873
|
var MATCH_CHIPS_FADE_MS = 150;
|
|
1778
1874
|
var CHIP_SIZE = 48;
|
|
1779
1875
|
var EDGE_PAD = 8;
|
|
@@ -1784,7 +1880,7 @@ function MatchChips({ playing, faceToFace, centerLineY, onBack, onSettings }) {
|
|
|
1784
1880
|
const atComputer = useAtComputer();
|
|
1785
1881
|
const visible = atComputer || !playing;
|
|
1786
1882
|
const opacity = (0, import_react_native_reanimated3.useSharedValue)(visible ? 1 : 0);
|
|
1787
|
-
(0,
|
|
1883
|
+
(0, import_react19.useEffect)(() => {
|
|
1788
1884
|
opacity.value = (0, import_react_native_reanimated3.withTiming)(visible ? 1 : 0, { duration: MATCH_CHIPS_FADE_MS });
|
|
1789
1885
|
}, [visible]);
|
|
1790
1886
|
const fadeStyle = (0, import_react_native_reanimated3.useAnimatedStyle)(() => ({ opacity: opacity.value }));
|
|
@@ -1795,9 +1891,9 @@ function MatchChips({ playing, faceToFace, centerLineY, onBack, onSettings }) {
|
|
|
1795
1891
|
const backSlot = { top, left: EDGE_PAD + insets.left };
|
|
1796
1892
|
const settingsSlot = { top, right: EDGE_PAD + insets.right };
|
|
1797
1893
|
const pointerEvents = visible ? "box-none" : "none";
|
|
1798
|
-
return /* @__PURE__ */ (0,
|
|
1799
|
-
/* @__PURE__ */ (0,
|
|
1800
|
-
/* @__PURE__ */ (0,
|
|
1894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
1895
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native_reanimated3.default.View, { pointerEvents, style: [styles6.slot, backSlot, fadeStyle], testID: "match-chips-back", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_feedback_press4.IconButton, { icon: "arrow-left", iconColor, containerColor, style: styles6.chip, size: 24, onPress: onBack, accessibilityLabel: "Back" }) }),
|
|
1896
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native_reanimated3.default.View, { pointerEvents, style: [styles6.slot, settingsSlot, fadeStyle], testID: "match-chips-settings", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_feedback_press4.IconButton, { icon: "cog", iconColor, containerColor, style: styles6.chip, size: 24, onPress: onSettings, accessibilityLabel: "Settings" }) })
|
|
1801
1897
|
] });
|
|
1802
1898
|
}
|
|
1803
1899
|
var styles6 = import_react_native12.StyleSheet.create({
|
|
@@ -1816,12 +1912,12 @@ function useActiveRound(game, defaults) {
|
|
|
1816
1912
|
|
|
1817
1913
|
// src/hooks/useBackBlock.ts
|
|
1818
1914
|
var import_expo_router11 = require("expo-router");
|
|
1819
|
-
var
|
|
1915
|
+
var import_react20 = require("react");
|
|
1820
1916
|
function useBackBlock(held, onHeld, leave = import_core6.safeBack) {
|
|
1821
|
-
const leavingRef = (0,
|
|
1822
|
-
const [leaving, setLeaving] = (0,
|
|
1823
|
-
const leaveRef = (0,
|
|
1824
|
-
(0,
|
|
1917
|
+
const leavingRef = (0, import_react20.useRef)(false);
|
|
1918
|
+
const [leaving, setLeaving] = (0, import_react20.useState)(false);
|
|
1919
|
+
const leaveRef = (0, import_react20.useRef)(leave);
|
|
1920
|
+
(0, import_react20.useEffect)(() => {
|
|
1825
1921
|
leaveRef.current = leave;
|
|
1826
1922
|
});
|
|
1827
1923
|
(0, import_expo_router11.usePreventRemove)(held && !leaving, ({ repeat }) => {
|
|
@@ -1830,7 +1926,7 @@ function useBackBlock(held, onHeld, leave = import_core6.safeBack) {
|
|
|
1830
1926
|
repeat();
|
|
1831
1927
|
} else onHeld();
|
|
1832
1928
|
});
|
|
1833
|
-
return (0,
|
|
1929
|
+
return (0, import_react20.useCallback)(() => {
|
|
1834
1930
|
leavingRef.current = true;
|
|
1835
1931
|
leaveRef.current();
|
|
1836
1932
|
}, []);
|
|
@@ -1965,8 +2061,8 @@ function forgetProfileAchievements(dropStats) {
|
|
|
1965
2061
|
|
|
1966
2062
|
// src/gameStats.tsx
|
|
1967
2063
|
var import_achievements2 = require("@tastic/achievements");
|
|
1968
|
-
var
|
|
1969
|
-
var
|
|
2064
|
+
var import_react21 = require("react");
|
|
2065
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1970
2066
|
var SEATS = [1, 2];
|
|
1971
2067
|
function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
|
|
1972
2068
|
const { actions: actions6, reducer: sliceReducer } = (0, import_achievements2.createAchievementsSlice)({
|
|
@@ -1983,7 +2079,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
1983
2079
|
};
|
|
1984
2080
|
const reducer6 = onProfileRemoved(sliceReducer, forgetProfileAchievements(dropProfileStats));
|
|
1985
2081
|
const profileViews = (stats) => Object.fromEntries(Object.entries(stats.profiles).map(([profileId, bucket]) => [profileId, getProfileStatsView(bucket)]));
|
|
1986
|
-
const Context = (0,
|
|
2082
|
+
const Context = (0, import_react21.createContext)(null);
|
|
1987
2083
|
function Provider({ children }) {
|
|
1988
2084
|
const { stats, unlockedAchievements, recordOutcome, resetAll } = (0, import_achievements2.useAchievements)({
|
|
1989
2085
|
catalog,
|
|
@@ -1991,18 +2087,18 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
1991
2087
|
actions: actions6,
|
|
1992
2088
|
profileViews
|
|
1993
2089
|
});
|
|
1994
|
-
const record = (0,
|
|
2090
|
+
const record = (0, import_react21.useCallback)(
|
|
1995
2091
|
(update, profileIds) => {
|
|
1996
2092
|
const result = recordOutcome(update);
|
|
1997
2093
|
return { device: result.device, profiles: (0, import_achievements2.mapUnlocksBySeat)(SEATS, profileIds, result.profiles) };
|
|
1998
2094
|
},
|
|
1999
2095
|
[recordOutcome]
|
|
2000
2096
|
);
|
|
2001
|
-
const value = (0,
|
|
2002
|
-
return /* @__PURE__ */ (0,
|
|
2097
|
+
const value = (0, import_react21.useMemo)(() => ({ stats, unlockedAchievements, record, resetAll }), [stats, unlockedAchievements, record, resetAll]);
|
|
2098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Context.Provider, { value, children });
|
|
2003
2099
|
}
|
|
2004
2100
|
function useStats() {
|
|
2005
|
-
const ctx = (0,
|
|
2101
|
+
const ctx = (0, import_react21.useContext)(Context);
|
|
2006
2102
|
if (!ctx) throw new Error(`The ${key} stats are read within their game's Provider`);
|
|
2007
2103
|
return ctx;
|
|
2008
2104
|
}
|
|
@@ -2010,7 +2106,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
2010
2106
|
}
|
|
2011
2107
|
|
|
2012
2108
|
// src/playerSettings.ts
|
|
2013
|
-
var
|
|
2109
|
+
var import_react22 = require("react");
|
|
2014
2110
|
var import_react_redux12 = require("react-redux");
|
|
2015
2111
|
var SEATS2 = [1, 2];
|
|
2016
2112
|
function seatPlayerKey(selection, seat) {
|
|
@@ -2054,8 +2150,8 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
|
|
|
2054
2150
|
const saved = (0, import_react_redux12.useSelector)((state) => state[settingsKey]);
|
|
2055
2151
|
const controls = (0, import_react_redux12.useSelector)((state) => state[controlsKey]);
|
|
2056
2152
|
const dispatch = (0, import_react_redux12.useDispatch)();
|
|
2057
|
-
const settings = (0,
|
|
2058
|
-
const setSettings = (0,
|
|
2153
|
+
const settings = (0, import_react22.useMemo)(() => compose(saved, controls, selection, seatTwoIsPerson), [saved, controls, selection, seatTwoIsPerson]);
|
|
2154
|
+
const setSettings = (0, import_react22.useCallback)(
|
|
2059
2155
|
(next) => {
|
|
2060
2156
|
const { controlScheme, ...changes } = next;
|
|
2061
2157
|
if (Object.keys(changes).length > 0) dispatch(patch(seatPlayerKey(selection, 1), changes));
|
|
@@ -2088,6 +2184,7 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
|
|
|
2088
2184
|
ProfilesRoute,
|
|
2089
2185
|
RootLayout,
|
|
2090
2186
|
SettingsDialog,
|
|
2187
|
+
Staged,
|
|
2091
2188
|
StatsScreen,
|
|
2092
2189
|
appSettingsActions,
|
|
2093
2190
|
appSettingsReducer,
|
package/dist/index.mjs
CHANGED
|
@@ -294,8 +294,15 @@ function LastActiveGameProvider({ children }) {
|
|
|
294
294
|
const [initial] = useState2(() => store.getState().lastActiveGame?.gameId ?? null);
|
|
295
295
|
const pendingResume = useRef2(initial);
|
|
296
296
|
const persisted = useRef2(initial);
|
|
297
|
-
const
|
|
298
|
-
|
|
297
|
+
const resume = useRef2("idle");
|
|
298
|
+
const resumeListeners = useRef2(/* @__PURE__ */ new Set());
|
|
299
|
+
const value = useMemo2(() => {
|
|
300
|
+
const setResume = (next) => {
|
|
301
|
+
if (resume.current === next) return;
|
|
302
|
+
resume.current = next;
|
|
303
|
+
resumeListeners.current.forEach((listener) => listener());
|
|
304
|
+
};
|
|
305
|
+
return {
|
|
299
306
|
consumeResumeGame: () => {
|
|
300
307
|
const game = pendingResume.current;
|
|
301
308
|
pendingResume.current = null;
|
|
@@ -315,10 +322,20 @@ function LastActiveGameProvider({ children }) {
|
|
|
315
322
|
if (persisted.current === null) return;
|
|
316
323
|
persisted.current = null;
|
|
317
324
|
dispatch(lastActiveGameActions.setGameId(null));
|
|
325
|
+
},
|
|
326
|
+
beginResume: () => setResume("opening"),
|
|
327
|
+
playScreenUp: () => {
|
|
328
|
+
if (resume.current === "opening") setResume("up");
|
|
329
|
+
},
|
|
330
|
+
endResume: () => setResume("idle"),
|
|
331
|
+
resumeState: () => resume.current,
|
|
332
|
+
subscribeResume: (listener) => {
|
|
333
|
+
const listeners = resumeListeners.current;
|
|
334
|
+
listeners.add(listener);
|
|
335
|
+
return () => void listeners.delete(listener);
|
|
318
336
|
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
);
|
|
337
|
+
};
|
|
338
|
+
}, [dispatch]);
|
|
322
339
|
return /* @__PURE__ */ jsx8(LastActiveGameContext.Provider, { value, children });
|
|
323
340
|
}
|
|
324
341
|
function useLastActiveGame() {
|
|
@@ -417,16 +434,43 @@ var REPLACE_AS_FORWARD = { animationTypeForReplace: "push" };
|
|
|
417
434
|
var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
|
|
418
435
|
var noScreenOptions = () => ({});
|
|
419
436
|
function useFirstScreenGate() {
|
|
437
|
+
const { resumeState, subscribeResume } = useLastActiveGame();
|
|
420
438
|
const marked = useRef3(false);
|
|
421
439
|
return useCallback6(() => {
|
|
422
440
|
if (marked.current) return;
|
|
423
441
|
marked.current = true;
|
|
424
|
-
requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
|
|
425
|
-
|
|
442
|
+
const mark = () => requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady("screen")));
|
|
443
|
+
requestAnimationFrame(
|
|
444
|
+
() => requestAnimationFrame(() => {
|
|
445
|
+
if (resumeState() !== "opening") {
|
|
446
|
+
markSplashReady("screen");
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const unsubscribe = subscribeResume(() => {
|
|
450
|
+
if (resumeState() === "opening") return;
|
|
451
|
+
unsubscribe();
|
|
452
|
+
mark();
|
|
453
|
+
});
|
|
454
|
+
})
|
|
455
|
+
);
|
|
456
|
+
}, [resumeState, subscribeResume]);
|
|
457
|
+
}
|
|
458
|
+
function useResumeShown() {
|
|
459
|
+
const { endResume } = useLastActiveGame();
|
|
460
|
+
return useCallback6(
|
|
461
|
+
({ route }) => ({
|
|
462
|
+
transitionEnd: (event) => {
|
|
463
|
+
if (route.name === PLAY_ROUTE && !event.data?.closing) endResume();
|
|
464
|
+
}
|
|
465
|
+
}),
|
|
466
|
+
[endResume]
|
|
467
|
+
);
|
|
426
468
|
}
|
|
469
|
+
var PLAY_ROUTE = "play/[game]";
|
|
427
470
|
function AppStack() {
|
|
428
471
|
const pack = usePack();
|
|
429
472
|
const onFirstLayout = useFirstScreenGate();
|
|
473
|
+
const screenListeners = useResumeShown();
|
|
430
474
|
const { Backdrop } = pack;
|
|
431
475
|
const { dark } = useAutoPaperTheme();
|
|
432
476
|
const darkRoot = Backdrop ? true : dark;
|
|
@@ -452,9 +496,9 @@ function AppStack() {
|
|
|
452
496
|
}, [darkRoot, navigationBackground]);
|
|
453
497
|
return /* @__PURE__ */ jsxs2(View, { style: styles.root, onLayout: onFirstLayout, children: [
|
|
454
498
|
Backdrop && /* @__PURE__ */ jsx10(Backdrop, {}),
|
|
455
|
-
/* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
|
|
499
|
+
/* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenListeners, screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
|
|
456
500
|
/* @__PURE__ */ jsx10(Stack.Screen, { name: "index" }),
|
|
457
|
-
/* @__PURE__ */ jsx10(Stack.Screen, { name:
|
|
501
|
+
/* @__PURE__ */ jsx10(Stack.Screen, { name: PLAY_ROUTE, options: playOptions })
|
|
458
502
|
] }) })
|
|
459
503
|
] });
|
|
460
504
|
}
|
|
@@ -1051,10 +1095,20 @@ function PlayRoute() {
|
|
|
1051
1095
|
const { game: id } = useLocalSearchParams3();
|
|
1052
1096
|
const game = usePackGame(id);
|
|
1053
1097
|
useResumePoint(game?.resumable ? game.id : null);
|
|
1098
|
+
useResumeUp();
|
|
1054
1099
|
if (!game) return /* @__PURE__ */ jsx16(Redirect, { href: "/" });
|
|
1055
1100
|
const { PlayScreen } = game;
|
|
1056
1101
|
return /* @__PURE__ */ jsx16(PlayScreen, {}, game.id);
|
|
1057
1102
|
}
|
|
1103
|
+
function useResumeUp() {
|
|
1104
|
+
const { playScreenUp } = useLastActiveGame();
|
|
1105
|
+
useEffect5(() => {
|
|
1106
|
+
let frame = requestAnimationFrame(() => {
|
|
1107
|
+
frame = requestAnimationFrame(playScreenUp);
|
|
1108
|
+
});
|
|
1109
|
+
return () => cancelAnimationFrame(frame);
|
|
1110
|
+
}, [playScreenUp]);
|
|
1111
|
+
}
|
|
1058
1112
|
var playScreensUp = 0;
|
|
1059
1113
|
function useResumePoint(gameId) {
|
|
1060
1114
|
const { setLastActiveGame, clearLastActiveGame } = useLastActiveGame();
|
|
@@ -1075,7 +1129,7 @@ import { IconButton, Pressable } from "@rific/feedback-press";
|
|
|
1075
1129
|
import { PressAwayOverlay as PressAwayOverlay2, usePopoverHost as usePopoverHost2, useWellColors, WELL_SHADOW } from "@tastic/hud/chrome";
|
|
1076
1130
|
import { getProfilePickerContentSize, ProfilePicker } from "@tastic/profile";
|
|
1077
1131
|
import { router as router5, useFocusEffect as useFocusEffect3, useIsFocused } from "expo-router";
|
|
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";
|
|
1132
|
+
import { createContext as createContext5, memo, startTransition, useCallback as useCallback10, useContext as useContext5, useDeferredValue, useEffect as useEffect6, useLayoutEffect, useMemo as useMemo6, useRef as useRef6, useState as useState6, useSyncExternalStore } from "react";
|
|
1079
1133
|
import { AppState as AppState2, Platform as Platform5, StyleSheet as StyleSheet4, View as View4 } from "react-native";
|
|
1080
1134
|
import { Icon, Portal, SegmentedButtons, Text as Text2 } from "react-native-paper";
|
|
1081
1135
|
|
|
@@ -1189,11 +1243,24 @@ function useResume(game) {
|
|
|
1189
1243
|
);
|
|
1190
1244
|
}
|
|
1191
1245
|
function useMenuShown(resuming) {
|
|
1246
|
+
const { beginResume, endResume, resumeState, subscribeResume } = useLastActiveGame();
|
|
1192
1247
|
const isFocused = useIsFocused();
|
|
1193
1248
|
const [covered, setCovered] = useState6(false);
|
|
1194
1249
|
if (resuming && !covered && !isFocused) setCovered(true);
|
|
1195
|
-
|
|
1250
|
+
useLayoutEffect(() => {
|
|
1251
|
+
if (!resuming) return;
|
|
1252
|
+
beginResume();
|
|
1253
|
+
const id = setTimeout(endResume, RESUME_SHOWN_MAX_MS);
|
|
1254
|
+
return () => {
|
|
1255
|
+
clearTimeout(id);
|
|
1256
|
+
endResume();
|
|
1257
|
+
};
|
|
1258
|
+
}, [resuming, beginResume, endResume]);
|
|
1259
|
+
const onItsWay = useSyncExternalStore(subscribeResume, resumeState, resumeState) !== "idle";
|
|
1260
|
+
const gameShown = covered && !onItsWay;
|
|
1261
|
+
return useDeferredValue(!resuming || gameShown || covered && isFocused);
|
|
1196
1262
|
}
|
|
1263
|
+
var RESUME_SHOWN_MAX_MS = 4e3;
|
|
1197
1264
|
function HomeMenu() {
|
|
1198
1265
|
const pack = usePack();
|
|
1199
1266
|
const showPicker = pack.homePlayerPicker !== false;
|
|
@@ -1538,12 +1605,40 @@ import { useAutoPaperTheme as useAutoPaperTheme5 } from "@rific/auto-paper";
|
|
|
1538
1605
|
import { BaseStatsScreen, PressAwayOverlay as PressAwayOverlay3, ScreenFrame as ScreenFrame4, usePopoverHost as usePopoverHost3 } from "@tastic/hud/chrome";
|
|
1539
1606
|
import { getOptionPickerContentSize as getOptionPickerContentSize2, OptionPicker as OptionPicker2 } from "@tastic/profile";
|
|
1540
1607
|
import { router as router6 } from "expo-router";
|
|
1541
|
-
import { useMemo as
|
|
1608
|
+
import { useMemo as useMemo8, useState as useState8 } from "react";
|
|
1542
1609
|
import { StyleSheet as StyleSheet5, View as View5 } from "react-native";
|
|
1543
1610
|
import { SegmentedButtons as SegmentedButtons2, Text as Text3 } from "react-native-paper";
|
|
1544
1611
|
import { useSafeAreaInsets as useSafeAreaInsets4 } from "react-native-safe-area-context";
|
|
1545
1612
|
import { useDispatch as useDispatch10 } from "react-redux";
|
|
1546
|
-
|
|
1613
|
+
|
|
1614
|
+
// src/components/Staged.tsx
|
|
1615
|
+
import { Children, useEffect as useEffect7, useMemo as useMemo7, useState as useState7 } from "react";
|
|
1616
|
+
import { Fragment as Fragment6, jsx as jsx18 } from "react/jsx-runtime";
|
|
1617
|
+
function onShown(run) {
|
|
1618
|
+
let idle;
|
|
1619
|
+
let frame = requestAnimationFrame(() => {
|
|
1620
|
+
frame = requestAnimationFrame(() => {
|
|
1621
|
+
if (typeof requestIdleCallback === "function") idle = requestIdleCallback(run);
|
|
1622
|
+
else run();
|
|
1623
|
+
});
|
|
1624
|
+
});
|
|
1625
|
+
return () => {
|
|
1626
|
+
cancelAnimationFrame(frame);
|
|
1627
|
+
if (idle !== void 0) cancelIdleCallback(idle);
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
function Staged({ first = 1, step = 1, children }) {
|
|
1631
|
+
const parts = useMemo7(() => Children.toArray(children), [children]);
|
|
1632
|
+
const [drawn, setDrawn] = useState7(first);
|
|
1633
|
+
useEffect7(() => {
|
|
1634
|
+
if (drawn >= parts.length) return;
|
|
1635
|
+
return onShown(() => setDrawn(drawn + step));
|
|
1636
|
+
}, [drawn, parts.length, step]);
|
|
1637
|
+
return /* @__PURE__ */ jsx18(Fragment6, { children: parts.slice(0, drawn) });
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// src/screens/StatsScreen.tsx
|
|
1641
|
+
import { jsx as jsx19, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1547
1642
|
var STATS = "stats";
|
|
1548
1643
|
var ACHIEVEMENTS = "achievements";
|
|
1549
1644
|
var TABS = [
|
|
@@ -1563,10 +1658,10 @@ var MANAGE_OPTION = { value: MANAGE, label: "Manage", icon: "account-cog-outline
|
|
|
1563
1658
|
var STATS_MAX_WIDTH = 640;
|
|
1564
1659
|
function StatsScreen() {
|
|
1565
1660
|
const pickerHost = usePopoverHost3();
|
|
1566
|
-
return /* @__PURE__ */
|
|
1661
|
+
return /* @__PURE__ */ jsx19(StatsPressAway, { host: pickerHost, children: /* @__PURE__ */ jsx19(ScreenFrame4, { portalHost: true, maxContentWidth: STATS_MAX_WIDTH, children: /* @__PURE__ */ jsx19(StatsContent, { pickerHost }) }) });
|
|
1567
1662
|
}
|
|
1568
1663
|
function StatsPressAway({ host, children }) {
|
|
1569
|
-
return /* @__PURE__ */
|
|
1664
|
+
return /* @__PURE__ */ jsx19(View5, { testID: "stats-press-away", style: styles5.screen, onStartShouldSetResponder: () => host.openId !== null, onResponderRelease: host.close, children });
|
|
1570
1665
|
}
|
|
1571
1666
|
var useNoPackReset = () => null;
|
|
1572
1667
|
var noPickerAlign2 = () => void 0;
|
|
@@ -1578,11 +1673,11 @@ function StatsContent({ pickerHost }) {
|
|
|
1578
1673
|
const { profiles, lastSelected } = useProfiles();
|
|
1579
1674
|
const dispatch = useDispatch10();
|
|
1580
1675
|
const fg = pack.foreground ?? colors.onBackground;
|
|
1581
|
-
const [tab, setTab] =
|
|
1582
|
-
const [gameId, setGameId] =
|
|
1676
|
+
const [tab, setTab] = useState8(STATS);
|
|
1677
|
+
const [gameId, setGameId] = useState8(ALL_GAMES2);
|
|
1583
1678
|
const useStatsPlayer = pack.useStatsPlayer ?? useNoStatsPlayer;
|
|
1584
1679
|
const statsPlayer = useStatsPlayer();
|
|
1585
|
-
const [selectedProfileId, setSelectedProfileId] =
|
|
1680
|
+
const [selectedProfileId, setSelectedProfileId] = useState8(() => pack.useStatsPlayer ? statsPlayer : pack.guestStats ? lastSelected[1] ?? GUEST_PLAYER_ID : null);
|
|
1586
1681
|
const profileId = selectedProfileId && profiles.length > 0 && (pack.guestStats && selectedProfileId === GUEST_PLAYER_ID || profiles.some((p) => p.id === selectedProfileId)) ? selectedProfileId : null;
|
|
1587
1682
|
const homeTabs = pack.homeTabs && pack.homeTabs.length > 1 ? pack.homeTabs : null;
|
|
1588
1683
|
const pickedTab = homeTabs?.findIndex((_, index) => gameId === tabGames(index)) ?? -1;
|
|
@@ -1592,14 +1687,14 @@ function StatsContent({ pickerHost }) {
|
|
|
1592
1687
|
const packTabs = pack.statsTabs ?? NO_PACK_TABS;
|
|
1593
1688
|
const packTab = packTabs.find((t) => t.value === tab);
|
|
1594
1689
|
const showGamePicker = !(tab === ACHIEVEMENTS && pack.AchievementList);
|
|
1595
|
-
const playerOptions =
|
|
1596
|
-
const gameOptions =
|
|
1690
|
+
const playerOptions = useMemo8(() => [{ 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]);
|
|
1691
|
+
const gameOptions = useMemo8(() => {
|
|
1597
1692
|
const all = { value: ALL_GAMES2, label: "All Games", icon: "view-grid-outline" };
|
|
1598
1693
|
const option = (g) => ({ value: g.id, label: g.title, icon: "cards-playing-outline" });
|
|
1599
1694
|
if (!homeTabs) return [all, ...pack.games.map(option)];
|
|
1600
1695
|
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)] }))];
|
|
1601
1696
|
}, [pack.games, homeTabs]);
|
|
1602
|
-
const tabButtons =
|
|
1697
|
+
const tabButtons = useMemo8(() => {
|
|
1603
1698
|
const buttons = packTabs.length > 0 ? [{ value: STATS, label: "Stats" }, ...packTabs.map(({ value, label }) => ({ value, label })), { value: ACHIEVEMENTS, label: "Achievements" }].map((button) => ({ ...button, style: LABEL_WIDE_TAB })) : TABS;
|
|
1604
1699
|
return pack.labelStyle ? buttons.map((button) => ({ ...button, labelStyle: pack.labelStyle })) : buttons;
|
|
1605
1700
|
}, [packTabs, pack.labelStyle]);
|
|
@@ -1616,15 +1711,15 @@ function StatsContent({ pickerHost }) {
|
|
|
1616
1711
|
const triggerStyle = pack.Backdrop ? [styles5.pill, surface] : void 0;
|
|
1617
1712
|
const PackTabContent = packTab?.Content;
|
|
1618
1713
|
return /* @__PURE__ */ jsxs6(BaseStatsScreen, { title, titleStyle: pack.titleStyle, onBack: safeBack, insets, onReset: reset.onReset, resetLabel: reset.label, resetConfirmTitle: reset.title, resetConfirmBody: reset.body, fg: pack.foreground, bg: pack.Backdrop ? "transparent" : void 0, children: [
|
|
1619
|
-
/* @__PURE__ */
|
|
1620
|
-
/* @__PURE__ */
|
|
1714
|
+
/* @__PURE__ */ jsx19(PressAwayOverlay3, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles5.pressAway }),
|
|
1715
|
+
/* @__PURE__ */ jsx19(SegmentedButtons2, { value: tab, onValueChange: setTab, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles5.tabs, surface] }),
|
|
1621
1716
|
/* @__PURE__ */ jsxs6(View5, { style: [styles5.filters, pickerHost.openId !== null && styles5.filtersOpen], onStartShouldSetResponder: () => pickerHost.openId !== null, children: [
|
|
1622
|
-
/* @__PURE__ */
|
|
1623
|
-
showGamePicker && /* @__PURE__ */
|
|
1717
|
+
/* @__PURE__ */ jsx19(OptionPicker2, { id: PLAYER_PICKER_ID, host: pickerHost, options: playerOptions, value: profileId ?? EVERYONE, onChange: (value) => value === MANAGE ? router6.push(PROFILES_HREF) : setSelectedProfileId(value === EVERYONE ? null : value), color: colors.primary, dark, icon: profileId ? "account" : "account-group", caption: "Player", alignOverride: playerAlign, triggerStyle }),
|
|
1718
|
+
showGamePicker && /* @__PURE__ */ jsx19(OptionPicker2, { id: GAME_PICKER_ID, host: pickerHost, options: gameOptions, value: gameId, onChange: setGameId, color: colors.primary, dark, icon: "view-grid-outline", caption: "Game", alignOverride: gameAlign, triggerStyle })
|
|
1624
1719
|
] }),
|
|
1625
|
-
tab === STATS && pack.StatsSections && /* @__PURE__ */
|
|
1626
|
-
PackTabContent && /* @__PURE__ */
|
|
1627
|
-
tab === ACHIEVEMENTS && pack.AchievementList ? /* @__PURE__ */
|
|
1720
|
+
tab === STATS && pack.StatsSections && /* @__PURE__ */ jsx19(pack.StatsSections, { profileId, gameId: oneGameId, gameIds }),
|
|
1721
|
+
PackTabContent && /* @__PURE__ */ jsx19(PackTabContent, { profileId, gameId: oneGameId, gameIds }),
|
|
1722
|
+
tab === ACHIEVEMENTS && pack.AchievementList ? /* @__PURE__ */ jsx19(pack.AchievementList, { profileId }) : (tab === STATS || tab === ACHIEVEMENTS) && /* @__PURE__ */ jsx19(Staged, { first: tab === STATS && pack.StatsSections ? 0 : 1, children: games.map((game) => /* @__PURE__ */ jsx19(GameStats, { game, tab, profileId, showTitle: games.length > 1 && pack.statsGameTitles !== false, titleColor: fg }, game.id)) }, `${tab} ${gameId}`)
|
|
1628
1723
|
] });
|
|
1629
1724
|
}
|
|
1630
1725
|
function resetFor(pack, packReset, profileId, profiles, games, resetGames) {
|
|
@@ -1641,8 +1736,8 @@ function GameStats({ game, tab, profileId, showTitle, titleColor }) {
|
|
|
1641
1736
|
const Sections = tab === STATS ? StatsSections : AchievementList;
|
|
1642
1737
|
if (!Sections) return null;
|
|
1643
1738
|
return /* @__PURE__ */ jsxs6(View5, { style: styles5.game, children: [
|
|
1644
|
-
showTitle && /* @__PURE__ */
|
|
1645
|
-
/* @__PURE__ */
|
|
1739
|
+
showTitle && /* @__PURE__ */ jsx19(Text3, { variant: "titleLarge", style: [styles5.gameTitle, { color: titleColor }, titleStyle], children: game.title }),
|
|
1740
|
+
/* @__PURE__ */ jsx19(Sections, { profileId })
|
|
1646
1741
|
] });
|
|
1647
1742
|
}
|
|
1648
1743
|
var styles5 = StyleSheet5.create({
|
|
@@ -1680,21 +1775,21 @@ var styles5 = StyleSheet5.create({
|
|
|
1680
1775
|
|
|
1681
1776
|
// src/components/imageGameIcon.tsx
|
|
1682
1777
|
import { Image } from "react-native";
|
|
1683
|
-
import { jsx as
|
|
1778
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1684
1779
|
function imageGameIcon(images) {
|
|
1685
1780
|
return function ImageGameIcon({ size, dark }) {
|
|
1686
|
-
return /* @__PURE__ */
|
|
1781
|
+
return /* @__PURE__ */ jsx20(Image, { source: dark ? images.dark : images.light, style: { height: size, width: size }, accessibilityIgnoresInvertColors: true });
|
|
1687
1782
|
};
|
|
1688
1783
|
}
|
|
1689
1784
|
|
|
1690
1785
|
// src/components/MatchChips.tsx
|
|
1691
1786
|
import { useAutoPaperTheme as useAutoPaperTheme6 } from "@rific/auto-paper";
|
|
1692
1787
|
import { IconButton as IconButton2 } from "@rific/feedback-press";
|
|
1693
|
-
import { useEffect as
|
|
1788
|
+
import { useEffect as useEffect8 } from "react";
|
|
1694
1789
|
import { StyleSheet as StyleSheet6, useWindowDimensions as useWindowDimensions2 } from "react-native";
|
|
1695
1790
|
import Animated2, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
1696
1791
|
import { useSafeAreaInsets as useSafeAreaInsets5 } from "react-native-safe-area-context";
|
|
1697
|
-
import { Fragment as
|
|
1792
|
+
import { Fragment as Fragment7, jsx as jsx21, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1698
1793
|
var MATCH_CHIPS_FADE_MS = 150;
|
|
1699
1794
|
var CHIP_SIZE = 48;
|
|
1700
1795
|
var EDGE_PAD = 8;
|
|
@@ -1705,7 +1800,7 @@ function MatchChips({ playing, faceToFace, centerLineY, onBack, onSettings }) {
|
|
|
1705
1800
|
const atComputer = useAtComputer();
|
|
1706
1801
|
const visible = atComputer || !playing;
|
|
1707
1802
|
const opacity = useSharedValue(visible ? 1 : 0);
|
|
1708
|
-
|
|
1803
|
+
useEffect8(() => {
|
|
1709
1804
|
opacity.value = withTiming(visible ? 1 : 0, { duration: MATCH_CHIPS_FADE_MS });
|
|
1710
1805
|
}, [visible]);
|
|
1711
1806
|
const fadeStyle = useAnimatedStyle(() => ({ opacity: opacity.value }));
|
|
@@ -1716,9 +1811,9 @@ function MatchChips({ playing, faceToFace, centerLineY, onBack, onSettings }) {
|
|
|
1716
1811
|
const backSlot = { top, left: EDGE_PAD + insets.left };
|
|
1717
1812
|
const settingsSlot = { top, right: EDGE_PAD + insets.right };
|
|
1718
1813
|
const pointerEvents = visible ? "box-none" : "none";
|
|
1719
|
-
return /* @__PURE__ */ jsxs7(
|
|
1720
|
-
/* @__PURE__ */
|
|
1721
|
-
/* @__PURE__ */
|
|
1814
|
+
return /* @__PURE__ */ jsxs7(Fragment7, { children: [
|
|
1815
|
+
/* @__PURE__ */ jsx21(Animated2.View, { pointerEvents, style: [styles6.slot, backSlot, fadeStyle], testID: "match-chips-back", children: /* @__PURE__ */ jsx21(IconButton2, { icon: "arrow-left", iconColor, containerColor, style: styles6.chip, size: 24, onPress: onBack, accessibilityLabel: "Back" }) }),
|
|
1816
|
+
/* @__PURE__ */ jsx21(Animated2.View, { pointerEvents, style: [styles6.slot, settingsSlot, fadeStyle], testID: "match-chips-settings", children: /* @__PURE__ */ jsx21(IconButton2, { icon: "cog", iconColor, containerColor, style: styles6.chip, size: 24, onPress: onSettings, accessibilityLabel: "Settings" }) })
|
|
1722
1817
|
] });
|
|
1723
1818
|
}
|
|
1724
1819
|
var styles6 = StyleSheet6.create({
|
|
@@ -1737,12 +1832,12 @@ function useActiveRound(game, defaults) {
|
|
|
1737
1832
|
|
|
1738
1833
|
// src/hooks/useBackBlock.ts
|
|
1739
1834
|
import { usePreventRemove } from "expo-router";
|
|
1740
|
-
import { useCallback as useCallback11, useEffect as
|
|
1835
|
+
import { useCallback as useCallback11, useEffect as useEffect9, useRef as useRef7, useState as useState9 } from "react";
|
|
1741
1836
|
function useBackBlock(held, onHeld, leave = safeBack) {
|
|
1742
1837
|
const leavingRef = useRef7(false);
|
|
1743
|
-
const [leaving, setLeaving] =
|
|
1838
|
+
const [leaving, setLeaving] = useState9(false);
|
|
1744
1839
|
const leaveRef = useRef7(leave);
|
|
1745
|
-
|
|
1840
|
+
useEffect9(() => {
|
|
1746
1841
|
leaveRef.current = leave;
|
|
1747
1842
|
});
|
|
1748
1843
|
usePreventRemove(held && !leaving, ({ repeat }) => {
|
|
@@ -1886,8 +1981,8 @@ function forgetProfileAchievements(dropStats) {
|
|
|
1886
1981
|
|
|
1887
1982
|
// src/gameStats.tsx
|
|
1888
1983
|
import { createAchievementsSlice, mapUnlocksBySeat, useAchievements } from "@tastic/achievements";
|
|
1889
|
-
import { createContext as createContext6, useCallback as useCallback12, useContext as useContext6, useMemo as
|
|
1890
|
-
import { jsx as
|
|
1984
|
+
import { createContext as createContext6, useCallback as useCallback12, useContext as useContext6, useMemo as useMemo9 } from "react";
|
|
1985
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1891
1986
|
var SEATS = [1, 2];
|
|
1892
1987
|
function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileStatsView }) {
|
|
1893
1988
|
const { actions: actions6, reducer: sliceReducer } = createAchievementsSlice({
|
|
@@ -1919,8 +2014,8 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
1919
2014
|
},
|
|
1920
2015
|
[recordOutcome]
|
|
1921
2016
|
);
|
|
1922
|
-
const value =
|
|
1923
|
-
return /* @__PURE__ */
|
|
2017
|
+
const value = useMemo9(() => ({ stats, unlockedAchievements, record, resetAll }), [stats, unlockedAchievements, record, resetAll]);
|
|
2018
|
+
return /* @__PURE__ */ jsx22(Context.Provider, { value, children });
|
|
1924
2019
|
}
|
|
1925
2020
|
function useStats() {
|
|
1926
2021
|
const ctx = useContext6(Context);
|
|
@@ -1931,7 +2026,7 @@ function createGameStats({ key, defaultStats, isValidStats, catalog, getProfileS
|
|
|
1931
2026
|
}
|
|
1932
2027
|
|
|
1933
2028
|
// src/playerSettings.ts
|
|
1934
|
-
import { useCallback as useCallback13, useMemo as
|
|
2029
|
+
import { useCallback as useCallback13, useMemo as useMemo10 } from "react";
|
|
1935
2030
|
import { useDispatch as useDispatch11, useSelector as useSelector9 } from "react-redux";
|
|
1936
2031
|
var SEATS2 = [1, 2];
|
|
1937
2032
|
function seatPlayerKey(selection, seat) {
|
|
@@ -1975,7 +2070,7 @@ function createPlayerSettings({ id, defaults, distinctControls }) {
|
|
|
1975
2070
|
const saved = useSelector9((state) => state[settingsKey]);
|
|
1976
2071
|
const controls = useSelector9((state) => state[controlsKey]);
|
|
1977
2072
|
const dispatch = useDispatch11();
|
|
1978
|
-
const settings =
|
|
2073
|
+
const settings = useMemo10(() => compose(saved, controls, selection, seatTwoIsPerson), [saved, controls, selection, seatTwoIsPerson]);
|
|
1979
2074
|
const setSettings = useCallback13(
|
|
1980
2075
|
(next) => {
|
|
1981
2076
|
const { controlScheme, ...changes } = next;
|
|
@@ -2008,6 +2103,7 @@ export {
|
|
|
2008
2103
|
ProfilesRoute,
|
|
2009
2104
|
RootLayout,
|
|
2010
2105
|
SettingsDialog,
|
|
2106
|
+
Staged,
|
|
2011
2107
|
StatsScreen,
|
|
2012
2108
|
appSettingsActions,
|
|
2013
2109
|
appSettingsSlice_default as appSettingsReducer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tastic/shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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",
|
package/src/RootLayout.tsx
CHANGED
|
@@ -21,7 +21,7 @@ import { Theme } from './components/Theme'
|
|
|
21
21
|
import { UpdateDialog } from './components/UpdateDialog'
|
|
22
22
|
import { WindowControlsInsets } from './components/WindowControlsInsets'
|
|
23
23
|
import { useAppSettings } from './hooks/useAppSettings'
|
|
24
|
-
import { LastActiveGameProvider } from './hooks/useLastActiveGame'
|
|
24
|
+
import { LastActiveGameProvider, useLastActiveGame } 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'
|
|
@@ -88,18 +88,53 @@ const noScreenOptions = () => ({})
|
|
|
88
88
|
// Stylo 6, CardTastic). The stack's layout comes with that commit, whatever screen it opens on, and by the
|
|
89
89
|
// second frame after it Android has mounted it (nothing under a held splash is drawn), so the splash fades
|
|
90
90
|
// straight to the screen.
|
|
91
|
+
//
|
|
92
|
+
// A launch going back into a game (HomeScreen's resume) holds it until that game's play screen is mounted, or
|
|
93
|
+
// the splash would lift on an empty table first. Mounted, not come in: Android draws nothing under a held
|
|
94
|
+
// splash, so a transition waited for here would never run.
|
|
91
95
|
function useFirstScreenGate() {
|
|
96
|
+
const { resumeState, subscribeResume } = useLastActiveGame()
|
|
92
97
|
const marked = useRef(false)
|
|
93
98
|
return useCallback(() => {
|
|
94
99
|
if (marked.current) return
|
|
95
100
|
marked.current = true
|
|
96
|
-
requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady('screen')))
|
|
97
|
-
|
|
101
|
+
const mark = () => requestAnimationFrame(() => requestAnimationFrame(() => markSplashReady('screen')))
|
|
102
|
+
requestAnimationFrame(() =>
|
|
103
|
+
requestAnimationFrame(() => {
|
|
104
|
+
if (resumeState() !== 'opening') {
|
|
105
|
+
markSplashReady('screen')
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
const unsubscribe = subscribeResume(() => {
|
|
109
|
+
if (resumeState() === 'opening') return
|
|
110
|
+
unsubscribe()
|
|
111
|
+
mark()
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
)
|
|
115
|
+
}, [resumeState, subscribeResume])
|
|
98
116
|
}
|
|
99
117
|
|
|
118
|
+
// Tells a resume that its game's screen has come in (the end of the play screen's transition), so Home may
|
|
119
|
+
// draw its menu beneath it.
|
|
120
|
+
function useResumeShown() {
|
|
121
|
+
const { endResume } = useLastActiveGame()
|
|
122
|
+
return useCallback(
|
|
123
|
+
({ route }: { route: { name: string } }) => ({
|
|
124
|
+
transitionEnd: (event: { data?: { closing?: boolean } }) => {
|
|
125
|
+
if (route.name === PLAY_ROUTE && !event.data?.closing) endResume()
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
[endResume]
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const PLAY_ROUTE = 'play/[game]'
|
|
133
|
+
|
|
100
134
|
function AppStack() {
|
|
101
135
|
const pack = usePack()
|
|
102
136
|
const onFirstLayout = useFirstScreenGate()
|
|
137
|
+
const screenListeners = useResumeShown()
|
|
103
138
|
const { Backdrop } = pack
|
|
104
139
|
const { dark } = useAutoPaperTheme()
|
|
105
140
|
// Over a backdrop the root stays dark whatever the mode: a backdrop is a dark table (the felt), and a
|
|
@@ -134,9 +169,9 @@ function AppStack() {
|
|
|
134
169
|
<View style={styles.root} onLayout={onFirstLayout}>
|
|
135
170
|
{Backdrop && <Backdrop />}
|
|
136
171
|
<NavigationThemeProvider value={navigationTheme}>
|
|
137
|
-
<Stack screenOptions={{ ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }}>
|
|
172
|
+
<Stack screenListeners={screenListeners} screenOptions={{ ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }}>
|
|
138
173
|
<Stack.Screen name='index' />
|
|
139
|
-
<Stack.Screen name=
|
|
174
|
+
<Stack.Screen name={PLAY_ROUTE} options={playOptions} />
|
|
140
175
|
</Stack>
|
|
141
176
|
</NavigationThemeProvider>
|
|
142
177
|
</View>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Children, type ReactNode, useEffect, useMemo, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
// How many children to draw at once: what a screen shows before any scrolling
|
|
5
|
+
first?: number
|
|
6
|
+
// How many more at each idle moment after that
|
|
7
|
+
step?: number
|
|
8
|
+
children: ReactNode
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Runs once what's drawn so far has reached the screen and the app has a moment, and returns its cancel. The frames come first:
|
|
12
|
+
// on Android a screen's views are built on the main thread, a frame's work at a time, and parts handed over before it has drawn
|
|
13
|
+
// are built before it can, so a page drawn in idle moments alone was no sooner on screen than one drawn at once. The first frame
|
|
14
|
+
// is the one that builds what was just drawn, the second the one after it's shown. Then an idle moment, with no timeout: idle
|
|
15
|
+
// callbacks run soonest deadline first, and one would put these parts, past the screen's bottom edge, ahead of what else waits
|
|
16
|
+
// for one, a calendar at the top of the screen included. Safari has no idle callbacks, so there it's the frames alone.
|
|
17
|
+
function onShown(run: () => void): () => void {
|
|
18
|
+
let idle: number | undefined
|
|
19
|
+
let frame = requestAnimationFrame(() => {
|
|
20
|
+
frame = requestAnimationFrame(() => {
|
|
21
|
+
if (typeof requestIdleCallback === 'function') idle = requestIdleCallback(run)
|
|
22
|
+
else run()
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
return () => {
|
|
26
|
+
cancelAnimationFrame(frame)
|
|
27
|
+
if (idle !== undefined) cancelIdleCallback(idle)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// A long page's parts (a stats screen's wells, an achievement list's rows) drawn a few at a time: the first ones with the
|
|
32
|
+
// screen, the rest at the idle moments after it's shown. Every part at once was a screen that took a budget phone two seconds to open,
|
|
33
|
+
// frozen, for rows far past its bottom edge (CardTastic's twenty games on the LG Stylo 6, 2026-11-30). The parts drawn keep
|
|
34
|
+
// their elements as more come, so none of them renders again. It draws no view of its own: the parts are flat siblings of
|
|
35
|
+
// whatever is round it, as they were. Give it a `key` that changes with what's listed (a tab, a filter), or a longer list
|
|
36
|
+
// taking a shorter one's place comes in all at once.
|
|
37
|
+
export function Staged({ first = 1, step = 1, children }: Props) {
|
|
38
|
+
// Kept while the children are the same, so a step hands React the very elements it has
|
|
39
|
+
const parts = useMemo(() => Children.toArray(children), [children])
|
|
40
|
+
const [drawn, setDrawn] = useState(first)
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (drawn >= parts.length) return
|
|
43
|
+
return onShown(() => setDrawn(drawn + step))
|
|
44
|
+
}, [drawn, parts.length, step])
|
|
45
|
+
return <>{parts.slice(0, drawn)}</>
|
|
46
|
+
}
|
|
@@ -4,11 +4,23 @@ import { useDispatch, useStore } from 'react-redux'
|
|
|
4
4
|
import { lastActiveGameActions } from '../redux/lastActiveGameSlice'
|
|
5
5
|
import type { ShellState } from '../redux/shellState'
|
|
6
6
|
|
|
7
|
+
// A cold launch on its way back into a game. 'opening' from the Home that resumes it (beginResume) until that
|
|
8
|
+
// game's play screen is mounted (playScreenUp): the splash is held. 'up' from then until the screen has come in
|
|
9
|
+
// (endResume): Home still draws no menu, which would show through the game's screen as it fades in. 'idle'
|
|
10
|
+
// otherwise.
|
|
11
|
+
export type ResumeState = 'idle' | 'opening' | 'up'
|
|
12
|
+
|
|
7
13
|
interface LastActiveGameContextValue {
|
|
8
14
|
// Returns the game a cold launch should drop the player straight back onto (once), or null.
|
|
9
15
|
consumeResumeGame: () => string | null
|
|
10
16
|
setLastActiveGame: (gameId: string) => void
|
|
11
17
|
clearLastActiveGame: () => void
|
|
18
|
+
// A resume on its way (ResumeState), read outside React or through useSyncExternalStore.
|
|
19
|
+
beginResume: () => void
|
|
20
|
+
playScreenUp: () => void
|
|
21
|
+
endResume: () => void
|
|
22
|
+
resumeState: () => ResumeState
|
|
23
|
+
subscribeResume: (listener: () => void) => () => void
|
|
12
24
|
}
|
|
13
25
|
|
|
14
26
|
const LastActiveGameContext = createContext<LastActiveGameContextValue | null>(null)
|
|
@@ -36,9 +48,16 @@ export function LastActiveGameProvider({ children }: { children: ReactNode }) {
|
|
|
36
48
|
// What the store currently holds, so an unchanged value is never rewritten: every game mount sets it
|
|
37
49
|
// and every exit clears it.
|
|
38
50
|
const persisted = useRef<string | null>(initial)
|
|
51
|
+
const resume = useRef<ResumeState>('idle')
|
|
52
|
+
const resumeListeners = useRef(new Set<() => void>())
|
|
39
53
|
|
|
40
|
-
const value = useMemo<LastActiveGameContextValue>(
|
|
41
|
-
() =>
|
|
54
|
+
const value = useMemo<LastActiveGameContextValue>(() => {
|
|
55
|
+
const setResume = (next: ResumeState) => {
|
|
56
|
+
if (resume.current === next) return
|
|
57
|
+
resume.current = next
|
|
58
|
+
resumeListeners.current.forEach((listener) => listener())
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
42
61
|
consumeResumeGame: () => {
|
|
43
62
|
const game = pendingResume.current
|
|
44
63
|
pendingResume.current = null
|
|
@@ -58,10 +77,20 @@ export function LastActiveGameProvider({ children }: { children: ReactNode }) {
|
|
|
58
77
|
if (persisted.current === null) return
|
|
59
78
|
persisted.current = null
|
|
60
79
|
dispatch(lastActiveGameActions.setGameId(null))
|
|
80
|
+
},
|
|
81
|
+
beginResume: () => setResume('opening'),
|
|
82
|
+
playScreenUp: () => {
|
|
83
|
+
if (resume.current === 'opening') setResume('up')
|
|
84
|
+
},
|
|
85
|
+
endResume: () => setResume('idle'),
|
|
86
|
+
resumeState: () => resume.current,
|
|
87
|
+
subscribeResume: (listener) => {
|
|
88
|
+
const listeners = resumeListeners.current
|
|
89
|
+
listeners.add(listener)
|
|
90
|
+
return () => void listeners.delete(listener)
|
|
61
91
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
)
|
|
92
|
+
}
|
|
93
|
+
}, [dispatch])
|
|
65
94
|
|
|
66
95
|
return <LastActiveGameContext.Provider value={value}>{children}</LastActiveGameContext.Provider>
|
|
67
96
|
}
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { useGameGuide } from './components/GuideHost'
|
|
|
18
18
|
export { imageGameIcon } from './components/imageGameIcon'
|
|
19
19
|
export { MATCH_CHIPS_FADE_MS, MatchChips, type MatchChipsProps } from './components/MatchChips'
|
|
20
20
|
export { SettingsDialog, type SettingsDialogProps } from './components/SettingsDialog'
|
|
21
|
+
export { Staged } from './components/Staged'
|
|
21
22
|
export { useActiveRound } from './hooks/useActiveRound'
|
|
22
23
|
export { useAppSettings } from './hooks/useAppSettings'
|
|
23
24
|
export { useAtComputer } from './hooks/useAtComputer'
|
|
@@ -31,11 +31,24 @@ export function PlayRoute() {
|
|
|
31
31
|
const { game: id } = useLocalSearchParams<{ game: string }>()
|
|
32
32
|
const game = usePackGame(id)
|
|
33
33
|
useResumePoint(game?.resumable ? game.id : null)
|
|
34
|
+
useResumeUp()
|
|
34
35
|
if (!game) return <Redirect href='/' />
|
|
35
36
|
const { PlayScreen } = game
|
|
36
37
|
return <PlayScreen key={game.id} />
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
// Tells a launch going back into a game that its play screen is mounted (by the second frame after this one
|
|
41
|
+
// commits), which is what the splash waits for. Nothing for any other play screen.
|
|
42
|
+
function useResumeUp() {
|
|
43
|
+
const { playScreenUp } = useLastActiveGame()
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
let frame = requestAnimationFrame(() => {
|
|
46
|
+
frame = requestAnimationFrame(playScreenUp)
|
|
47
|
+
})
|
|
48
|
+
return () => cancelAnimationFrame(frame)
|
|
49
|
+
}, [playScreenUp])
|
|
50
|
+
}
|
|
51
|
+
|
|
39
52
|
// A resumable game's play screen (GameDefinition.resumable) is where a cold launch comes back to:
|
|
40
53
|
// remembered as it mounts, and forgotten when the player backs out of it (its own back, hardware back
|
|
41
54
|
// or a browser back), which unmounts it while the app is in use. Backgrounding the app leaves the
|
|
@@ -3,7 +3,7 @@ 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 { createContext, memo, type ReactNode, startTransition, useCallback, useContext, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
|
|
6
|
+
import { createContext, memo, type ReactNode, startTransition, useCallback, useContext, useDeferredValue, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
|
|
7
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
|
|
|
@@ -73,17 +73,38 @@ function useResume(game: PackGameDefinition | null) {
|
|
|
73
73
|
)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
// Whether Home draws its menu. A Home resuming a game draws nothing until the game
|
|
77
|
-
//
|
|
78
|
-
// (useDeferredValue), behind the game's own first renders.
|
|
79
|
-
//
|
|
76
|
+
// Whether Home draws its menu. A Home resuming a game draws nothing until the game's screen has come in
|
|
77
|
+
// (RootLayout's stack says so, or RESUME_SHOWN_MAX_MS is up), so a launch never shows the menu ahead of the
|
|
78
|
+
// game, and then draws it at low priority (useDeferredValue), behind the game's own first renders. Home losing
|
|
79
|
+
// focus isn't enough: that comes as the navigation starts, and a menu drawn then beat the game's own screen to
|
|
80
|
+
// the glass by half a second on a slow phone, seen through the game's transparent screen. A player who is back
|
|
81
|
+
// on Home sooner gets the menu there and then. From then on it's mounted beneath the game like any Home that
|
|
82
|
+
// opened one, so going back to it is quick.
|
|
80
83
|
function useMenuShown(resuming: boolean): boolean {
|
|
84
|
+
const { beginResume, endResume, resumeState, subscribeResume } = useLastActiveGame()
|
|
81
85
|
const isFocused = useIsFocused()
|
|
82
86
|
const [covered, setCovered] = useState(false)
|
|
83
87
|
if (resuming && !covered && !isFocused) setCovered(true)
|
|
84
|
-
|
|
88
|
+
// A layout effect, so the hold is on before anything waiting on the first screen's layout looks.
|
|
89
|
+
useLayoutEffect(() => {
|
|
90
|
+
if (!resuming) return
|
|
91
|
+
beginResume()
|
|
92
|
+
const id = setTimeout(endResume, RESUME_SHOWN_MAX_MS)
|
|
93
|
+
return () => {
|
|
94
|
+
clearTimeout(id)
|
|
95
|
+
endResume()
|
|
96
|
+
}
|
|
97
|
+
}, [resuming, beginResume, endResume])
|
|
98
|
+
const onItsWay = useSyncExternalStore(subscribeResume, resumeState, resumeState) !== 'idle'
|
|
99
|
+
// Before the layout effect a resume isn't on its way yet, so `covered` is what a first render waits for.
|
|
100
|
+
const gameShown = covered && !onItsWay
|
|
101
|
+
return useDeferredValue(!resuming || gameShown || (covered && isFocused))
|
|
85
102
|
}
|
|
86
103
|
|
|
104
|
+
// The longest a resume is waited for, should the stack never say the game's screen came in (the web's says
|
|
105
|
+
// nothing): a game that never opened would hold the splash, and Home's menu, for good.
|
|
106
|
+
export const RESUME_SHOWN_MAX_MS = 4000
|
|
107
|
+
|
|
87
108
|
function HomeMenu() {
|
|
88
109
|
const pack = usePack()
|
|
89
110
|
const showPicker = pack.homePlayerPicker !== false
|
|
@@ -9,6 +9,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
|
9
9
|
import { useDispatch } from 'react-redux'
|
|
10
10
|
|
|
11
11
|
import { SEGMENT_RADIUS, SEGMENT_THEME } from '../components/segmentTheme'
|
|
12
|
+
import { Staged } from '../components/Staged'
|
|
12
13
|
import { useProfiles } from '../hooks/useProfiles'
|
|
13
14
|
import { safeBack } from '../navigation'
|
|
14
15
|
import { usePack } from '../PackContext'
|
|
@@ -181,7 +182,20 @@ function StatsContent({ pickerHost }: { pickerHost: PopoverHost }) {
|
|
|
181
182
|
|
|
182
183
|
{PackTabContent && <PackTabContent profileId={profileId} gameId={oneGameId} gameIds={gameIds} />}
|
|
183
184
|
|
|
184
|
-
{
|
|
185
|
+
{/* Each game's own sections: the first with the screen, unless the pack's own section is above it, and the rest a game at
|
|
186
|
+
each idle moment after it's shown. Every game's at once held the screen back for seconds on a budget phone, for wells past
|
|
187
|
+
its bottom edge. The parts are flat siblings on the page, as they were. */}
|
|
188
|
+
{tab === ACHIEVEMENTS && pack.AchievementList ? (
|
|
189
|
+
<pack.AchievementList profileId={profileId} />
|
|
190
|
+
) : (
|
|
191
|
+
(tab === STATS || tab === ACHIEVEMENTS) && (
|
|
192
|
+
<Staged key={`${tab} ${gameId}`} first={tab === STATS && pack.StatsSections ? 0 : 1}>
|
|
193
|
+
{games.map((game) => (
|
|
194
|
+
<GameStats key={game.id} game={game} tab={tab} profileId={profileId} showTitle={games.length > 1 && pack.statsGameTitles !== false} titleColor={fg} />
|
|
195
|
+
))}
|
|
196
|
+
</Staged>
|
|
197
|
+
)
|
|
198
|
+
)}
|
|
185
199
|
</BaseStatsScreen>
|
|
186
200
|
)
|
|
187
201
|
}
|