@tastic/shell 0.17.0 → 0.18.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 +5 -4
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +62 -20
- package/dist/index.mjs +60 -18
- package/package.json +1 -1
- package/src/RootLayout.tsx +12 -2
- package/src/screens/GameRoute.tsx +8 -2
- package/src/screens/HomeScreen.tsx +38 -5
- package/src/screens/LoadoutScreen.tsx +38 -4
- package/src/types.ts +12 -0
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ PuckTastic and DuelTastic draw what they always did:
|
|
|
125
125
|
| `Backdrop?` | A table drawn once behind the whole stack (Solitaire's felt). The stack's two layers go transparent (the screens' `contentStyle` and the navigation theme's `colors.background`, which React Navigation paints around every screen), the root window stays dark so light mode doesn't flash white on a push, Android's push and pop crossfade (its default holds the outgoing screen opaque), and Home, each loadout, the stats screen and Profiles draw transparent, with their buttons and tabs on the theme's surface (a loadout's Ready buttons too, filled with the seat's color once ready). |
|
|
126
126
|
| `foreground?` | The color of what those screens draw straight on the background (the hero, the corner buttons, headers), and at half strength a loadout's muted options. Unset is black or white with the theme. |
|
|
127
127
|
| `Provider?` | Mounted once around How to Play and the stack, inside the store, the theme, profiles and every game's `Provider` (one stats context across the pack's games). |
|
|
128
|
-
| `useScreenOptions?` | A hook returning stack screen options (`StackScreenOptions`), merged after the shell's own (a status bar style of the pack's own, Reduce Motion's crossfade). The shell's already follow the app's theme, and stay dark over a `Backdrop`. |
|
|
128
|
+
| `useScreenOptions?` | A hook returning stack screen options (`StackScreenOptions`), merged after the shell's own (a status bar style of the pack's own, Reduce Motion's crossfade). The shell's already follow the app's theme, and stay dark over a `Backdrop`. They also slide a replaced screen in as a pop (`animationTypeForReplace: 'pop'`) on every screen but a play screen, since a replace there is a way back with nothing beneath to pop to (`safeBack`'s fallback to Home, a `dismissTo` whose screen isn't on the stack). |
|
|
129
129
|
| `useFeedbackSounds?` | A hook returning the two sounds every button plays (`FeedbackSounds`: `selection`, `notification`), in place of the shell's two wavs. |
|
|
130
130
|
| `Toaster?` | The pack's own toaster, drawn in a frame over the whole app (inside the safe area) in place of the shell's. The toast provider is given no Paper, so nothing portals it out of the frame. |
|
|
131
131
|
| `edgeGuard?` | `false` leaves Edge Guard out of Settings (no edge controls, no Edge Guard plugin), and out of the play screens' options on Android. |
|
|
@@ -164,7 +164,7 @@ What a game can leave out or add, each optional, so a two-seat game sets none of
|
|
|
164
164
|
| no `'cpu'` in `seatTwo` | A game with no CPU, such as `['nobody', 'person']`. Seat 2's saved choice is the whole pack's and starts on the CPU, so `seatTwoFor` reads a choice a game doesn't offer as the CPU where it has one, and as its first choice where it has none: a fresh install opens this game's loadout on that choice, its How to Play describes it, and `useActiveRound` falls back to it. The saved choice only changes when player 1 picks another. |
|
|
165
165
|
| no `useLoadout` | Nothing to set up first: Home opens its play screen straight away, after its How to Play the first time, and a link to its loadout plays it. Its rule variants go in its play screen's Settings: `<SettingsDialog>` takes `children`. |
|
|
166
166
|
| no `cpuDifficulty` (in `GameLoadout`) | A CPU with no levels: player 1's opponent menu offers one plain CPU. |
|
|
167
|
-
| `resumable` | A cold launch drops the player back into its play screen if they left the app there rather than backing out of it. The shell remembers only which game (`lastActiveGame`); the game saves and restores its own board. |
|
|
167
|
+
| `resumable` | A cold launch drops the player back into its play screen if they left the app there rather than backing out of it, with its loadout (when it has one) and Home beneath it, as if they'd walked there, so every way back is a pop. The shell remembers only which game (`lastActiveGame`); the game saves and restores its own board. |
|
|
168
168
|
| `Preview` | Drawn on Home in place of the icon (`GamePreviewProps`: `width`, `height`, the seats' colors, `dark`), in a box of `PREVIEW_ASPECT` (360:200), a frame after Home first paints. While any game has one, Home shows tiles: rows upright, and on a wide screen a grid beside the hero and seat 1's button. A game without one keeps its icon. |
|
|
169
169
|
| no `icon` | Only with a `Preview`, which Home draws in its place. |
|
|
170
170
|
| no `Provider` | A game whose stats live in the pack's own `Provider`. |
|
|
@@ -182,8 +182,9 @@ settings for the round `mode` seat 2 makes:
|
|
|
182
182
|
| Field | |
|
|
183
183
|
| --- | --- |
|
|
184
184
|
| `roundSettings` | The settings the round plays with, committed (liveplay's `activeRound.settings`) once every human seat is Ready. The play screen reads them back with `useActiveRound`. |
|
|
185
|
-
| `options` | `(props: LoadoutOptionsProps) => ReactNode`: the match-options row (board, rules, puck), drawn under the loadout's popover `host` in its colors (`accentColor`, `mutedColor`, `onAccentColor`, `dark`). `onRandomize` and `onReset` are undefined while the loadout folds them into its shared action band. |
|
|
186
|
-
| `placesSeats?` | With one person the seat buttons sit under `options`, over Ready. `true` passes them to `options` as `seats` instead, so a game can put them where it likes (CardTastic:
|
|
185
|
+
| `options` | `(props: LoadoutOptionsProps) => ReactNode`: the match-options row (board, rules, puck), drawn under the loadout's popover `host` in its colors (`accentColor`, `mutedColor`, `onAccentColor`, `dark`). `onRandomize` and `onReset` are undefined while the loadout folds them into its shared action band. `titleShown` says whether the loadout's header already names the game (beside Back, as the stats screen's title): everywhere but 2 Player face to face, whose back and settings fold into the band between the players, so a game that names itself among its options does so only when it's false. |
|
|
186
|
+
| `placesSeats?` | With one person the seat buttons sit under `options`, over Ready. `true` passes them to `options` as `seats` instead, so a game can put them where it likes (CardTastic: first, above its Daily Deal and rules). 2 Player's seats stay in each person's half. |
|
|
187
|
+
| `drawsReady?` | With one person Ready sits under `options` (and the seat buttons). `true` draws no Ready and passes `options` an `onReady` that starts the round, for a game that starts it from a control of its own (CardTastic's solitaire games: a New Deal or Continue row in a card, as their Daily Deal's). 2 Player's Ready buttons stay in each person's half. |
|
|
187
188
|
| `optionIds` | The popover ids the options row opens, so the loadout lifts the row while one is open. |
|
|
188
189
|
| `randomize`, `reset` | The loadout's randomize and reset buttons. |
|
|
189
190
|
| `seatControl` | `(seat, host, look) => ReactNode \| undefined`: a human seat's controls picker (shot style, keys) in `look`'s colors (`SeatControlLook`: `accentColor`, `seatColor`, `mutedColor`, `dark`), or undefined where the game has none. |
|
package/dist/index.d.mts
CHANGED
|
@@ -141,6 +141,8 @@ interface LoadoutOptionsProps {
|
|
|
141
141
|
onRandomize?: () => void;
|
|
142
142
|
onReset?: () => void;
|
|
143
143
|
seats?: ReactNode;
|
|
144
|
+
onReady?: () => void;
|
|
145
|
+
titleShown: boolean;
|
|
144
146
|
}
|
|
145
147
|
interface SeatControlLook {
|
|
146
148
|
accentColor: string;
|
|
@@ -152,6 +154,7 @@ interface GameLoadout {
|
|
|
152
154
|
roundSettings: object;
|
|
153
155
|
options: (props: LoadoutOptionsProps) => ReactNode;
|
|
154
156
|
placesSeats?: boolean;
|
|
157
|
+
drawsReady?: boolean;
|
|
155
158
|
optionIds: readonly string[];
|
|
156
159
|
randomize: () => void;
|
|
157
160
|
reset: () => void;
|
|
@@ -386,7 +389,7 @@ declare function EditProfileRoute(): react.JSX.Element;
|
|
|
386
389
|
declare function LoadoutRoute(): react.JSX.Element;
|
|
387
390
|
declare function PlayRoute(): react.JSX.Element;
|
|
388
391
|
|
|
389
|
-
declare function HomeScreen(): react.JSX.Element;
|
|
392
|
+
declare function HomeScreen(): react.JSX.Element | null;
|
|
390
393
|
|
|
391
394
|
declare const PREVIEW_ASPECT: number;
|
|
392
395
|
|
package/dist/index.d.ts
CHANGED
|
@@ -141,6 +141,8 @@ interface LoadoutOptionsProps {
|
|
|
141
141
|
onRandomize?: () => void;
|
|
142
142
|
onReset?: () => void;
|
|
143
143
|
seats?: ReactNode;
|
|
144
|
+
onReady?: () => void;
|
|
145
|
+
titleShown: boolean;
|
|
144
146
|
}
|
|
145
147
|
interface SeatControlLook {
|
|
146
148
|
accentColor: string;
|
|
@@ -152,6 +154,7 @@ interface GameLoadout {
|
|
|
152
154
|
roundSettings: object;
|
|
153
155
|
options: (props: LoadoutOptionsProps) => ReactNode;
|
|
154
156
|
placesSeats?: boolean;
|
|
157
|
+
drawsReady?: boolean;
|
|
155
158
|
optionIds: readonly string[];
|
|
156
159
|
randomize: () => void;
|
|
157
160
|
reset: () => void;
|
|
@@ -386,7 +389,7 @@ declare function EditProfileRoute(): react.JSX.Element;
|
|
|
386
389
|
declare function LoadoutRoute(): react.JSX.Element;
|
|
387
390
|
declare function PlayRoute(): react.JSX.Element;
|
|
388
391
|
|
|
389
|
-
declare function HomeScreen(): react.JSX.Element;
|
|
392
|
+
declare function HomeScreen(): react.JSX.Element | null;
|
|
390
393
|
|
|
391
394
|
declare const PREVIEW_ASPECT: number;
|
|
392
395
|
|
package/dist/index.js
CHANGED
|
@@ -490,6 +490,8 @@ function useProfiles() {
|
|
|
490
490
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
491
491
|
var PLAY_OPTIONS = { statusBarHidden: true };
|
|
492
492
|
var KEEP_STATUS_BAR_OPTIONS = {};
|
|
493
|
+
var REPLACE_AS_BACK = { animationTypeForReplace: "pop" };
|
|
494
|
+
var REPLACE_AS_FORWARD = { animationTypeForReplace: "push" };
|
|
493
495
|
var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
|
|
494
496
|
var noScreenOptions = () => ({});
|
|
495
497
|
function AppStack() {
|
|
@@ -508,7 +510,7 @@ function AppStack() {
|
|
|
508
510
|
({ route }) => {
|
|
509
511
|
const id = route.params?.game;
|
|
510
512
|
const statusBarOptions = pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS;
|
|
511
|
-
return { ...statusBarOptions, ...edgeGuardOptions };
|
|
513
|
+
return { ...statusBarOptions, ...edgeGuardOptions, ...REPLACE_AS_FORWARD };
|
|
512
514
|
},
|
|
513
515
|
[pack.games, edgeGuardOptions]
|
|
514
516
|
);
|
|
@@ -517,7 +519,7 @@ function AppStack() {
|
|
|
517
519
|
const base = darkRoot ? import_expo_router.DarkTheme : import_expo_router.DefaultTheme;
|
|
518
520
|
return { ...base, colors: { ...base.colors, background: navigationBackground } };
|
|
519
521
|
}, [darkRoot, navigationBackground]);
|
|
520
|
-
const stack = /* @__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, ...backdropOptions, ...packOptions }, children: [
|
|
522
|
+
const stack = /* @__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: [
|
|
521
523
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name: "index" }),
|
|
522
524
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_expo_router.Stack.Screen, { name: "play/[game]", options: playOptions })
|
|
523
525
|
] }) });
|
|
@@ -628,6 +630,7 @@ var import_split_screen = require("@tastic/split-screen");
|
|
|
628
630
|
var import_expo_router7 = require("expo-router");
|
|
629
631
|
var import_react13 = require("react");
|
|
630
632
|
var import_react_native6 = require("react-native");
|
|
633
|
+
var import_react_native_paper = require("react-native-paper");
|
|
631
634
|
var import_react_native_reanimated2 = __toESM(require("react-native-reanimated"));
|
|
632
635
|
var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
|
|
633
636
|
var import_react_redux9 = require("react-redux");
|
|
@@ -866,6 +869,10 @@ var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
|
866
869
|
var PANEL_SWAP_FADE_MS = 180;
|
|
867
870
|
var P1_CONTROL_ID = "p1-control";
|
|
868
871
|
var P2_CONTROL_ID = "p2-control";
|
|
872
|
+
var HEADER_TOP = 8;
|
|
873
|
+
var HEADER_ROW_HEIGHT = 52;
|
|
874
|
+
var HEADER_TITLE_LEFT = 64;
|
|
875
|
+
var HEADER_TITLE_RIGHT = 60;
|
|
869
876
|
function LoadoutScreen({ game }) {
|
|
870
877
|
const pack = usePack();
|
|
871
878
|
const { seatTwo: savedSeatTwo, setSeatTwo } = useOpponent();
|
|
@@ -885,6 +892,7 @@ function LoadoutScreen({ game }) {
|
|
|
885
892
|
const playersRowFade = panelFadeStyle;
|
|
886
893
|
const [settingsOpen, setSettingsOpen] = (0, import_react13.useState)(false);
|
|
887
894
|
const insets = (0, import_react_native_safe_area_context3.useSafeAreaInsets)();
|
|
895
|
+
const { title: lettering } = (0, import_chrome6.useLettering)();
|
|
888
896
|
const { colors: themeColors, dark } = (0, import_auto_paper5.useAutoPaperTheme)();
|
|
889
897
|
const { p1Color, p2Color, handleP1ColorChange, handleP2ColorChange } = useSeatColors(p2IsHuman);
|
|
890
898
|
const dispatch = (0, import_react_redux9.useDispatch)();
|
|
@@ -935,6 +943,7 @@ function LoadoutScreen({ game }) {
|
|
|
935
943
|
const p1Panel = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lobby2.PlayerSetupPanel, { idPrefix: "p1", host: controlsHost, color: p1Color, onColorChange: handleP1ColorChange, swatches: import_auto_paper5.defaultColors, 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: () => import_expo_router7.router.push(PROFILES_HREF), previewValue: seatPreview, triggerStyle, useSeatPickerAlign: seatPickerAlign }, `p1-${layoutKey}`);
|
|
936
944
|
const opponentPicker = game.seatTwo && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(OpponentPicker, { idPrefix: "p1", host: controlsHost, choices: game.seatTwo, seatTwo, onSeatTwoChange: changeSeatTwo, cpuDifficulty: loadout.cpuDifficulty, color: p2Color, onColorChange: handleP2ColorChange, swatches: import_auto_paper5.defaultColors, takenColor: p1Color, allowSwapTaken: mode === "vsCpu", dark, previewValue: seatPreview, triggerStyle, usePickerAlign: seatPickerAlign }, `opponent-${layoutKey}`);
|
|
937
945
|
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }));
|
|
946
|
+
const readyInOptions = !p2IsHuman && !!loadout.drawsReady;
|
|
938
947
|
const seatButtons = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native6.View, { style: [styles3.seatOneButtons, p1PickerOpen && styles3.raised], children: [
|
|
939
948
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native_reanimated2.default.View, { style: [styles3.playersRow, p1PickerOpen && styles3.raised, !p2IsHuman && playersRowFade], children: [
|
|
940
949
|
p1Panel,
|
|
@@ -945,7 +954,7 @@ function LoadoutScreen({ game }) {
|
|
|
945
954
|
const seatsInOptions = !p2IsHuman && !!loadout.placesSeats;
|
|
946
955
|
const seatOne = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native6.View, { style: [styles3.seatOne, !p2IsHuman && styles3.seatOneAlone, p1PickerOpen && !seatsInOptions && styles3.raised], children: [
|
|
947
956
|
!seatsInOptions && seatButtons,
|
|
948
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lobby2.ReadyButton, { color: p1Drawn, ready: ready[1], onToggleReady: toggleP1Ready, surfaceColor: readySurface, dark, style: !p2IsHuman && p1PickerOpen && styles3.readyButtonHidden })
|
|
957
|
+
!readyInOptions && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lobby2.ReadyButton, { color: p1Drawn, ready: ready[1], onToggleReady: toggleP1Ready, surfaceColor: readySurface, dark, style: !p2IsHuman && p1PickerOpen && styles3.readyButtonHidden })
|
|
949
958
|
] });
|
|
950
959
|
const optionsRow = loadout.options({
|
|
951
960
|
host: controlsHost,
|
|
@@ -954,6 +963,8 @@ function LoadoutScreen({ game }) {
|
|
|
954
963
|
onAccentColor: themeColors.onTertiary,
|
|
955
964
|
dark,
|
|
956
965
|
seats: seatsInOptions ? seatButtons : void 0,
|
|
966
|
+
onReady: readyInOptions ? () => setReady((r) => ({ ...r, 1: true })) : void 0,
|
|
967
|
+
titleShown: !showMetaInSharedBand,
|
|
957
968
|
// Left out (the row's own actions unrendered) whenever the shared band below carries them.
|
|
958
969
|
onRandomize: showMetaInSharedBand ? void 0 : loadout.randomize,
|
|
959
970
|
onReset: showMetaInSharedBand ? void 0 : loadout.reset
|
|
@@ -963,10 +974,11 @@ function LoadoutScreen({ game }) {
|
|
|
963
974
|
const p2Control = p2IsHuman ? loadout.seatControl(2, p2Host, { ...controlLook, seatColor: p2Drawn }) : void 0;
|
|
964
975
|
const p2Panel = p2IsHuman && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lobby2.PlayerSetupPanel, { idPrefix: "p2", host: p2Host, color: p2Color, onColorChange: handleP2ColorChange, swatches: import_auto_paper5.defaultColors, 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");
|
|
965
976
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native6.View, { style: [styles3.container, { backgroundColor: bg }], children: [
|
|
966
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native6.View, { style: styles3.frame, children: [
|
|
977
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native6.View, { style: [styles3.frame, !showMetaInSharedBand && { paddingTop: HEADER_TOP + HEADER_ROW_HEIGHT + insets.top }], children: [
|
|
967
978
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_chrome6.PressAwayOverlay, { active: controlsHost.openId !== null, onPress: controlsHost.close }),
|
|
968
979
|
p2ZoneStyle && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_chrome6.PressAwayOverlay, { active: controlsHost.openId !== null || p2Host.openId !== null, onPress: p2Host.close, style: p2ZoneStyle }),
|
|
969
980
|
!showMetaInSharedBand && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_chrome6.CornerActionButtons, { onBack: import_core6.safeBack, onSettings: () => setSettingsOpen(true), fg, insets }),
|
|
981
|
+
!showMetaInSharedBand && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native6.View, { style: [styles3.headerTitle, { top: HEADER_TOP + insets.top, left: HEADER_TITLE_LEFT + insets.left, right: HEADER_TITLE_RIGHT + insets.right }], pointerEvents: "none", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native_paper.Text, { variant: "headlineSmall", numberOfLines: 1, accessibilityRole: "header", style: [styles3.title, { color: fg }, lettering], children: game.title }) }),
|
|
970
982
|
p2IsHuman ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
971
983
|
import_split_screen.DualZoneLayout,
|
|
972
984
|
{
|
|
@@ -981,7 +993,7 @@ function LoadoutScreen({ game }) {
|
|
|
981
993
|
}
|
|
982
994
|
) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native6.View, { style: styles3.stackedZone, children: [
|
|
983
995
|
seatsInOptions ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native6.View, { style: p1PickerOpen && styles3.raised, children: sharedControls }) : sharedControls,
|
|
984
|
-
seatOne
|
|
996
|
+
!(seatsInOptions && readyInOptions) && seatOne
|
|
985
997
|
] })
|
|
986
998
|
] }),
|
|
987
999
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SettingsDialog, { visible: settingsOpen, onDismiss: () => setSettingsOpen(false), onShowHowToPlay: () => openFor(game.id), showProfile: true })
|
|
@@ -1009,6 +1021,11 @@ var styles3 = import_react_native6.StyleSheet.create({
|
|
|
1009
1021
|
justifyContent: "center",
|
|
1010
1022
|
paddingHorizontal: 16
|
|
1011
1023
|
},
|
|
1024
|
+
headerTitle: {
|
|
1025
|
+
height: HEADER_ROW_HEIGHT,
|
|
1026
|
+
justifyContent: "center",
|
|
1027
|
+
position: "absolute"
|
|
1028
|
+
},
|
|
1012
1029
|
p2ZoneRight: {
|
|
1013
1030
|
bottom: 0,
|
|
1014
1031
|
position: "absolute",
|
|
@@ -1061,6 +1078,10 @@ var styles3 = import_react_native6.StyleSheet.create({
|
|
|
1061
1078
|
stackedZone: {
|
|
1062
1079
|
alignItems: "center",
|
|
1063
1080
|
gap: 28
|
|
1081
|
+
},
|
|
1082
|
+
// hud's BaseStatsScreen title: the stats screen's header, in the pack's title lettering.
|
|
1083
|
+
title: {
|
|
1084
|
+
fontWeight: "bold"
|
|
1064
1085
|
}
|
|
1065
1086
|
});
|
|
1066
1087
|
|
|
@@ -1084,13 +1105,16 @@ function PlayRoute() {
|
|
|
1084
1105
|
const { PlayScreen } = game;
|
|
1085
1106
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PlayScreen, {}, game.id);
|
|
1086
1107
|
}
|
|
1108
|
+
var playScreensUp = 0;
|
|
1087
1109
|
function useResumePoint(gameId) {
|
|
1088
1110
|
const { setLastActiveGame, clearLastActiveGame } = useLastActiveGame();
|
|
1089
1111
|
(0, import_react14.useEffect)(() => {
|
|
1090
1112
|
if (!gameId) return;
|
|
1113
|
+
playScreensUp += 1;
|
|
1091
1114
|
setLastActiveGame(gameId);
|
|
1092
1115
|
return () => {
|
|
1093
|
-
|
|
1116
|
+
playScreensUp -= 1;
|
|
1117
|
+
if (playScreensUp === 0 && import_react_native7.AppState.currentState === "active") clearLastActiveGame();
|
|
1094
1118
|
};
|
|
1095
1119
|
}, [gameId, setLastActiveGame, clearLastActiveGame]);
|
|
1096
1120
|
}
|
|
@@ -1103,7 +1127,7 @@ var import_profile9 = require("@tastic/profile");
|
|
|
1103
1127
|
var import_expo_router9 = require("expo-router");
|
|
1104
1128
|
var import_react16 = require("react");
|
|
1105
1129
|
var import_react_native9 = require("react-native");
|
|
1106
|
-
var
|
|
1130
|
+
var import_react_native_paper2 = require("react-native-paper");
|
|
1107
1131
|
|
|
1108
1132
|
// src/components/segmentTheme.ts
|
|
1109
1133
|
var SEGMENT_THEME = { roundness: 3.8 };
|
|
@@ -1199,8 +1223,26 @@ function HomeScreen() {
|
|
|
1199
1223
|
(0, import_react16.useEffect)(() => {
|
|
1200
1224
|
if (!resumeGame) autoShowPack();
|
|
1201
1225
|
}, [resumeGame, autoShowPack]);
|
|
1202
|
-
|
|
1203
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(HomeMenu, {});
|
|
1226
|
+
useResume(resumeGame);
|
|
1227
|
+
return useMenuShown(!!resumeGame) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(HomeMenu, {}) : null;
|
|
1228
|
+
}
|
|
1229
|
+
function useResume(game) {
|
|
1230
|
+
const pack = usePack();
|
|
1231
|
+
const done = (0, import_react16.useRef)(false);
|
|
1232
|
+
(0, import_expo_router9.useFocusEffect)(
|
|
1233
|
+
(0, import_react16.useCallback)(() => {
|
|
1234
|
+
if (!game || done.current) return;
|
|
1235
|
+
done.current = true;
|
|
1236
|
+
if (game.useLoadout) import_expo_router9.router.push(loadoutHref(game.id));
|
|
1237
|
+
import_expo_router9.router.push(pack.resumeHref?.(game.id) ?? playHref(game.id));
|
|
1238
|
+
}, [game, pack])
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
function useMenuShown(resuming) {
|
|
1242
|
+
const isFocused = (0, import_expo_router9.useIsFocused)();
|
|
1243
|
+
const [covered, setCovered] = (0, import_react16.useState)(false);
|
|
1244
|
+
if (resuming && !covered && !isFocused) setCovered(true);
|
|
1245
|
+
return (0, import_react16.useDeferredValue)(!resuming || covered);
|
|
1204
1246
|
}
|
|
1205
1247
|
function HomeMenu() {
|
|
1206
1248
|
const pack = usePack();
|
|
@@ -1244,7 +1286,7 @@ function HomeMenu() {
|
|
|
1244
1286
|
const [tabLabel, setTabLabel] = (0, import_react16.useState)(() => tabs?.[0].label ?? null);
|
|
1245
1287
|
const tab = tabs ? tabs.find((t) => t.label === tabLabel) ?? tabs[0] : null;
|
|
1246
1288
|
const tabButtons = (0, import_react16.useMemo)(() => tabs?.map(({ label }) => ({ value: label, label, labelStyle: pack.labelStyle })) ?? [], [tabs, pack.labelStyle]);
|
|
1247
|
-
const tabBar = tab && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1289
|
+
const tabBar = tab && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.SegmentedButtons, { value: tab.label, onValueChange: setTabLabel, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles4.tabs, pack.Backdrop && { backgroundColor: colors.surface }] });
|
|
1248
1290
|
const columnClamp = useClampOnShrink();
|
|
1249
1291
|
const gridClamp = useClampOnShrink();
|
|
1250
1292
|
const openGame = (0, import_react16.useCallback)((game) => openFirstTime(game.id, () => import_expo_router9.router.push(game.useLoadout ? loadoutHref(game.id) : playHref(game.id))), [openFirstTime]);
|
|
@@ -1316,7 +1358,7 @@ function hasRules(game) {
|
|
|
1316
1358
|
return !!(game.Rules || game.guide);
|
|
1317
1359
|
}
|
|
1318
1360
|
function RulesHost({ enabled, children }) {
|
|
1319
|
-
return enabled ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1361
|
+
return enabled ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Portal.Host, { children }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children });
|
|
1320
1362
|
}
|
|
1321
1363
|
var ROW_BLURB_LINES = 3;
|
|
1322
1364
|
function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPress, onRules }) {
|
|
@@ -1330,11 +1372,11 @@ function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPres
|
|
|
1330
1372
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_feedback_press3.Pressable, { onPress, style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
|
|
1331
1373
|
game.Preview ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PreviewBox, { game, width: ROW_PREVIEW_WIDTH, revealed: previewRevealed, dark, p1Color, p2Color }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native9.View, { style: [styles4.rowIcon, { backgroundColor: dark ? ICON_DARK_BG : ICON_LIGHT_BG }], children: GameIcon && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(GameIcon, { size: ROW_ICON_SIZE, p1Color, p2Color, dark }) }),
|
|
1332
1374
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { style: styles4.rowText, children: [
|
|
1333
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1334
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1375
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Text, { variant: "titleLarge", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
|
|
1376
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Text, { variant: "bodyMedium", style: { color: well.fgMuted }, numberOfLines: ROW_BLURB_LINES, children: game.blurb })
|
|
1335
1377
|
] })
|
|
1336
1378
|
] }),
|
|
1337
|
-
onRules && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.Pressable, { onPress: onRules, style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1379
|
+
onRules && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.Pressable, { onPress: onRules, style: styles4.rulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Icon, { source: "information-outline", size: 22, color: well.fgMuted }) })
|
|
1338
1380
|
] })
|
|
1339
1381
|
);
|
|
1340
1382
|
}
|
|
@@ -1344,10 +1386,10 @@ function GameTile({ game, hidden, width, previewWidth, dark, p1Color, p2Color, p
|
|
|
1344
1386
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native9.View, { style: [{ width }, hidden && styles4.hidden], children: [
|
|
1345
1387
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_feedback_press3.Pressable, { onPress, style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
|
|
1346
1388
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(PreviewBox, { game, width: previewWidth, revealed: previewRevealed, dark, p1Color, p2Color }),
|
|
1347
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1348
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1389
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Text, { variant: "titleMedium", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
|
|
1390
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Text, { variant: "bodySmall", style: { color: well.fgMuted }, numberOfLines: 3, children: game.blurb })
|
|
1349
1391
|
] }),
|
|
1350
|
-
onRules && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.Pressable, { onPress: onRules, style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1392
|
+
onRules && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_feedback_press3.Pressable, { onPress: onRules, style: styles4.tileRulesButton, hitSlop: 12, accessibilityRole: "button", accessibilityLabel: `${game.title} rules`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_native_paper2.Icon, { source: "information-outline", size: 20, color: "#FFFFFF" }) })
|
|
1351
1393
|
] });
|
|
1352
1394
|
}
|
|
1353
1395
|
function PreviewBox({ game, width, revealed, dark, p1Color, p2Color }) {
|
|
@@ -1510,7 +1552,7 @@ var import_profile10 = require("@tastic/profile");
|
|
|
1510
1552
|
var import_expo_router10 = require("expo-router");
|
|
1511
1553
|
var import_react17 = require("react");
|
|
1512
1554
|
var import_react_native10 = require("react-native");
|
|
1513
|
-
var
|
|
1555
|
+
var import_react_native_paper3 = require("react-native-paper");
|
|
1514
1556
|
var import_react_native_safe_area_context5 = require("react-native-safe-area-context");
|
|
1515
1557
|
var import_react_redux10 = require("react-redux");
|
|
1516
1558
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
@@ -1587,7 +1629,7 @@ function StatsContent({ pickerHost }) {
|
|
|
1587
1629
|
const PackTabContent = packTab?.Content;
|
|
1588
1630
|
return /* @__PURE__ */ (0, import_jsx_runtime18.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: [
|
|
1589
1631
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_chrome8.PressAwayOverlay, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles5.pressAway }),
|
|
1590
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1632
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native_paper3.SegmentedButtons, { value: tab, onValueChange: setTab, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles5.tabs, surface] }),
|
|
1591
1633
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native10.View, { style: [styles5.filters, pickerHost.openId !== null && styles5.filtersOpen], onStartShouldSetResponder: () => pickerHost.openId !== null, children: [
|
|
1592
1634
|
/* @__PURE__ */ (0, import_jsx_runtime18.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 }),
|
|
1593
1635
|
showGamePicker && /* @__PURE__ */ (0, import_jsx_runtime18.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 })
|
|
@@ -1611,7 +1653,7 @@ function GameStats({ game, tab, profileId, showTitle, titleColor }) {
|
|
|
1611
1653
|
const Sections = tab === STATS ? StatsSections : AchievementList;
|
|
1612
1654
|
if (!Sections) return null;
|
|
1613
1655
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native10.View, { style: styles5.game, children: [
|
|
1614
|
-
showTitle && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1656
|
+
showTitle && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native_paper3.Text, { variant: "titleLarge", style: [styles5.gameTitle, { color: titleColor }, titleStyle], children: game.title }),
|
|
1615
1657
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Sections, { profileId })
|
|
1616
1658
|
] });
|
|
1617
1659
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -411,6 +411,8 @@ function useProfiles() {
|
|
|
411
411
|
import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
412
412
|
var PLAY_OPTIONS = { statusBarHidden: true };
|
|
413
413
|
var KEEP_STATUS_BAR_OPTIONS = {};
|
|
414
|
+
var REPLACE_AS_BACK = { animationTypeForReplace: "pop" };
|
|
415
|
+
var REPLACE_AS_FORWARD = { animationTypeForReplace: "push" };
|
|
414
416
|
var TRANSPARENT_CONTENT = { backgroundColor: "transparent" };
|
|
415
417
|
var noScreenOptions = () => ({});
|
|
416
418
|
function AppStack() {
|
|
@@ -429,7 +431,7 @@ function AppStack() {
|
|
|
429
431
|
({ route }) => {
|
|
430
432
|
const id = route.params?.game;
|
|
431
433
|
const statusBarOptions = pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS;
|
|
432
|
-
return { ...statusBarOptions, ...edgeGuardOptions };
|
|
434
|
+
return { ...statusBarOptions, ...edgeGuardOptions, ...REPLACE_AS_FORWARD };
|
|
433
435
|
},
|
|
434
436
|
[pack.games, edgeGuardOptions]
|
|
435
437
|
);
|
|
@@ -438,7 +440,7 @@ function AppStack() {
|
|
|
438
440
|
const base = darkRoot ? DarkTheme : DefaultTheme;
|
|
439
441
|
return { ...base, colors: { ...base.colors, background: navigationBackground } };
|
|
440
442
|
}, [darkRoot, navigationBackground]);
|
|
441
|
-
const stack = /* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...backdropOptions, ...packOptions }, children: [
|
|
443
|
+
const stack = /* @__PURE__ */ jsx10(NavigationThemeProvider, { value: navigationTheme, children: /* @__PURE__ */ jsxs2(Stack, { screenOptions: { ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }, children: [
|
|
442
444
|
/* @__PURE__ */ jsx10(Stack.Screen, { name: "index" }),
|
|
443
445
|
/* @__PURE__ */ jsx10(Stack.Screen, { name: "play/[game]", options: playOptions })
|
|
444
446
|
] }) });
|
|
@@ -543,12 +545,13 @@ import { AppState } from "react-native";
|
|
|
543
545
|
// src/screens/LoadoutScreen.tsx
|
|
544
546
|
import { defaultColors as defaultColors2, getRgb, useAutoPaperTheme as useAutoPaperTheme3 } from "@rific/auto-paper";
|
|
545
547
|
import { useOrientationState } from "@tastic/core";
|
|
546
|
-
import { CornerActionButtons, PressAwayOverlay, usePopoverHost } from "@tastic/hud/chrome";
|
|
548
|
+
import { CornerActionButtons, PressAwayOverlay, useLettering, usePopoverHost } from "@tastic/hud/chrome";
|
|
547
549
|
import { PlayerSetupPanel, ReadyButton, SharedActionBand } from "@tastic/hud/lobby";
|
|
548
550
|
import { DualZoneLayout, needsSharedNeutralZone, useDualZoneLayout } from "@tastic/split-screen";
|
|
549
551
|
import { router as router4, useFocusEffect as useFocusEffect2 } from "expo-router";
|
|
550
552
|
import { useCallback as useCallback9, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef4, useState as useState4 } from "react";
|
|
551
553
|
import { StyleSheet as StyleSheet3, View as View3 } from "react-native";
|
|
554
|
+
import { Text } from "react-native-paper";
|
|
552
555
|
import Animated from "react-native-reanimated";
|
|
553
556
|
import { useSafeAreaInsets as useSafeAreaInsets2 } from "react-native-safe-area-context";
|
|
554
557
|
import { useDispatch as useDispatch9 } from "react-redux";
|
|
@@ -787,6 +790,10 @@ import { jsx as jsx15, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
|
787
790
|
var PANEL_SWAP_FADE_MS = 180;
|
|
788
791
|
var P1_CONTROL_ID = "p1-control";
|
|
789
792
|
var P2_CONTROL_ID = "p2-control";
|
|
793
|
+
var HEADER_TOP = 8;
|
|
794
|
+
var HEADER_ROW_HEIGHT = 52;
|
|
795
|
+
var HEADER_TITLE_LEFT = 64;
|
|
796
|
+
var HEADER_TITLE_RIGHT = 60;
|
|
790
797
|
function LoadoutScreen({ game }) {
|
|
791
798
|
const pack = usePack();
|
|
792
799
|
const { seatTwo: savedSeatTwo, setSeatTwo } = useOpponent();
|
|
@@ -806,6 +813,7 @@ function LoadoutScreen({ game }) {
|
|
|
806
813
|
const playersRowFade = panelFadeStyle;
|
|
807
814
|
const [settingsOpen, setSettingsOpen] = useState4(false);
|
|
808
815
|
const insets = useSafeAreaInsets2();
|
|
816
|
+
const { title: lettering } = useLettering();
|
|
809
817
|
const { colors: themeColors, dark } = useAutoPaperTheme3();
|
|
810
818
|
const { p1Color, p2Color, handleP1ColorChange, handleP2ColorChange } = useSeatColors(p2IsHuman);
|
|
811
819
|
const dispatch = useDispatch9();
|
|
@@ -856,6 +864,7 @@ function LoadoutScreen({ game }) {
|
|
|
856
864
|
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(PROFILES_HREF), previewValue: seatPreview, triggerStyle, useSeatPickerAlign: seatPickerAlign }, `p1-${layoutKey}`);
|
|
857
865
|
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}`);
|
|
858
866
|
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }));
|
|
867
|
+
const readyInOptions = !p2IsHuman && !!loadout.drawsReady;
|
|
859
868
|
const seatButtons = /* @__PURE__ */ jsxs4(View3, { style: [styles3.seatOneButtons, p1PickerOpen && styles3.raised], children: [
|
|
860
869
|
/* @__PURE__ */ jsxs4(Animated.View, { style: [styles3.playersRow, p1PickerOpen && styles3.raised, !p2IsHuman && playersRowFade], children: [
|
|
861
870
|
p1Panel,
|
|
@@ -866,7 +875,7 @@ function LoadoutScreen({ game }) {
|
|
|
866
875
|
const seatsInOptions = !p2IsHuman && !!loadout.placesSeats;
|
|
867
876
|
const seatOne = /* @__PURE__ */ jsxs4(View3, { style: [styles3.seatOne, !p2IsHuman && styles3.seatOneAlone, p1PickerOpen && !seatsInOptions && styles3.raised], children: [
|
|
868
877
|
!seatsInOptions && seatButtons,
|
|
869
|
-
/* @__PURE__ */ jsx15(ReadyButton, { color: p1Drawn, ready: ready[1], onToggleReady: toggleP1Ready, surfaceColor: readySurface, dark, style: !p2IsHuman && p1PickerOpen && styles3.readyButtonHidden })
|
|
878
|
+
!readyInOptions && /* @__PURE__ */ jsx15(ReadyButton, { color: p1Drawn, ready: ready[1], onToggleReady: toggleP1Ready, surfaceColor: readySurface, dark, style: !p2IsHuman && p1PickerOpen && styles3.readyButtonHidden })
|
|
870
879
|
] });
|
|
871
880
|
const optionsRow = loadout.options({
|
|
872
881
|
host: controlsHost,
|
|
@@ -875,6 +884,8 @@ function LoadoutScreen({ game }) {
|
|
|
875
884
|
onAccentColor: themeColors.onTertiary,
|
|
876
885
|
dark,
|
|
877
886
|
seats: seatsInOptions ? seatButtons : void 0,
|
|
887
|
+
onReady: readyInOptions ? () => setReady((r) => ({ ...r, 1: true })) : void 0,
|
|
888
|
+
titleShown: !showMetaInSharedBand,
|
|
878
889
|
// Left out (the row's own actions unrendered) whenever the shared band below carries them.
|
|
879
890
|
onRandomize: showMetaInSharedBand ? void 0 : loadout.randomize,
|
|
880
891
|
onReset: showMetaInSharedBand ? void 0 : loadout.reset
|
|
@@ -884,10 +895,11 @@ function LoadoutScreen({ game }) {
|
|
|
884
895
|
const p2Control = p2IsHuman ? loadout.seatControl(2, p2Host, { ...controlLook, seatColor: p2Drawn }) : void 0;
|
|
885
896
|
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");
|
|
886
897
|
return /* @__PURE__ */ jsxs4(View3, { style: [styles3.container, { backgroundColor: bg }], children: [
|
|
887
|
-
/* @__PURE__ */ jsxs4(View3, { style: styles3.frame, children: [
|
|
898
|
+
/* @__PURE__ */ jsxs4(View3, { style: [styles3.frame, !showMetaInSharedBand && { paddingTop: HEADER_TOP + HEADER_ROW_HEIGHT + insets.top }], children: [
|
|
888
899
|
/* @__PURE__ */ jsx15(PressAwayOverlay, { active: controlsHost.openId !== null, onPress: controlsHost.close }),
|
|
889
900
|
p2ZoneStyle && /* @__PURE__ */ jsx15(PressAwayOverlay, { active: controlsHost.openId !== null || p2Host.openId !== null, onPress: p2Host.close, style: p2ZoneStyle }),
|
|
890
901
|
!showMetaInSharedBand && /* @__PURE__ */ jsx15(CornerActionButtons, { onBack: safeBack, onSettings: () => setSettingsOpen(true), fg, insets }),
|
|
902
|
+
!showMetaInSharedBand && /* @__PURE__ */ jsx15(View3, { style: [styles3.headerTitle, { top: HEADER_TOP + insets.top, left: HEADER_TITLE_LEFT + insets.left, right: HEADER_TITLE_RIGHT + insets.right }], pointerEvents: "none", children: /* @__PURE__ */ jsx15(Text, { variant: "headlineSmall", numberOfLines: 1, accessibilityRole: "header", style: [styles3.title, { color: fg }, lettering], children: game.title }) }),
|
|
891
903
|
p2IsHuman ? /* @__PURE__ */ jsx15(
|
|
892
904
|
DualZoneLayout,
|
|
893
905
|
{
|
|
@@ -902,7 +914,7 @@ function LoadoutScreen({ game }) {
|
|
|
902
914
|
}
|
|
903
915
|
) : /* @__PURE__ */ jsxs4(View3, { style: styles3.stackedZone, children: [
|
|
904
916
|
seatsInOptions ? /* @__PURE__ */ jsx15(View3, { style: p1PickerOpen && styles3.raised, children: sharedControls }) : sharedControls,
|
|
905
|
-
seatOne
|
|
917
|
+
!(seatsInOptions && readyInOptions) && seatOne
|
|
906
918
|
] })
|
|
907
919
|
] }),
|
|
908
920
|
/* @__PURE__ */ jsx15(SettingsDialog, { visible: settingsOpen, onDismiss: () => setSettingsOpen(false), onShowHowToPlay: () => openFor(game.id), showProfile: true })
|
|
@@ -930,6 +942,11 @@ var styles3 = StyleSheet3.create({
|
|
|
930
942
|
justifyContent: "center",
|
|
931
943
|
paddingHorizontal: 16
|
|
932
944
|
},
|
|
945
|
+
headerTitle: {
|
|
946
|
+
height: HEADER_ROW_HEIGHT,
|
|
947
|
+
justifyContent: "center",
|
|
948
|
+
position: "absolute"
|
|
949
|
+
},
|
|
933
950
|
p2ZoneRight: {
|
|
934
951
|
bottom: 0,
|
|
935
952
|
position: "absolute",
|
|
@@ -982,6 +999,10 @@ var styles3 = StyleSheet3.create({
|
|
|
982
999
|
stackedZone: {
|
|
983
1000
|
alignItems: "center",
|
|
984
1001
|
gap: 28
|
|
1002
|
+
},
|
|
1003
|
+
// hud's BaseStatsScreen title: the stats screen's header, in the pack's title lettering.
|
|
1004
|
+
title: {
|
|
1005
|
+
fontWeight: "bold"
|
|
985
1006
|
}
|
|
986
1007
|
});
|
|
987
1008
|
|
|
@@ -1005,13 +1026,16 @@ function PlayRoute() {
|
|
|
1005
1026
|
const { PlayScreen } = game;
|
|
1006
1027
|
return /* @__PURE__ */ jsx16(PlayScreen, {}, game.id);
|
|
1007
1028
|
}
|
|
1029
|
+
var playScreensUp = 0;
|
|
1008
1030
|
function useResumePoint(gameId) {
|
|
1009
1031
|
const { setLastActiveGame, clearLastActiveGame } = useLastActiveGame();
|
|
1010
1032
|
useEffect5(() => {
|
|
1011
1033
|
if (!gameId) return;
|
|
1034
|
+
playScreensUp += 1;
|
|
1012
1035
|
setLastActiveGame(gameId);
|
|
1013
1036
|
return () => {
|
|
1014
|
-
|
|
1037
|
+
playScreensUp -= 1;
|
|
1038
|
+
if (playScreensUp === 0 && AppState.currentState === "active") clearLastActiveGame();
|
|
1015
1039
|
};
|
|
1016
1040
|
}, [gameId, setLastActiveGame, clearLastActiveGame]);
|
|
1017
1041
|
}
|
|
@@ -1021,10 +1045,10 @@ import { defaultColors as defaultColors3, FadingScrollView, useAutoPaperTheme as
|
|
|
1021
1045
|
import { IconButton, Pressable } from "@rific/feedback-press";
|
|
1022
1046
|
import { PressAwayOverlay as PressAwayOverlay2, usePopoverHost as usePopoverHost2, useWellColors, WELL_SHADOW } from "@tastic/hud/chrome";
|
|
1023
1047
|
import { getProfilePickerContentSize, ProfilePicker } from "@tastic/profile";
|
|
1024
|
-
import {
|
|
1025
|
-
import { useCallback as useCallback10, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef5, useState as useState6 } from "react";
|
|
1048
|
+
import { router as router5, useFocusEffect as useFocusEffect3, useIsFocused } from "expo-router";
|
|
1049
|
+
import { useCallback as useCallback10, useDeferredValue, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef5, useState as useState6 } from "react";
|
|
1026
1050
|
import { AppState as AppState2, StyleSheet as StyleSheet4, View as View4 } from "react-native";
|
|
1027
|
-
import { Icon, Portal, SegmentedButtons, Text } from "react-native-paper";
|
|
1051
|
+
import { Icon, Portal, SegmentedButtons, Text as Text2 } from "react-native-paper";
|
|
1028
1052
|
|
|
1029
1053
|
// src/components/segmentTheme.ts
|
|
1030
1054
|
var SEGMENT_THEME = { roundness: 3.8 };
|
|
@@ -1120,8 +1144,26 @@ function HomeScreen() {
|
|
|
1120
1144
|
useEffect6(() => {
|
|
1121
1145
|
if (!resumeGame) autoShowPack();
|
|
1122
1146
|
}, [resumeGame, autoShowPack]);
|
|
1123
|
-
|
|
1124
|
-
return /* @__PURE__ */ jsx17(HomeMenu, {});
|
|
1147
|
+
useResume(resumeGame);
|
|
1148
|
+
return useMenuShown(!!resumeGame) ? /* @__PURE__ */ jsx17(HomeMenu, {}) : null;
|
|
1149
|
+
}
|
|
1150
|
+
function useResume(game) {
|
|
1151
|
+
const pack = usePack();
|
|
1152
|
+
const done = useRef5(false);
|
|
1153
|
+
useFocusEffect3(
|
|
1154
|
+
useCallback10(() => {
|
|
1155
|
+
if (!game || done.current) return;
|
|
1156
|
+
done.current = true;
|
|
1157
|
+
if (game.useLoadout) router5.push(loadoutHref(game.id));
|
|
1158
|
+
router5.push(pack.resumeHref?.(game.id) ?? playHref(game.id));
|
|
1159
|
+
}, [game, pack])
|
|
1160
|
+
);
|
|
1161
|
+
}
|
|
1162
|
+
function useMenuShown(resuming) {
|
|
1163
|
+
const isFocused = useIsFocused();
|
|
1164
|
+
const [covered, setCovered] = useState6(false);
|
|
1165
|
+
if (resuming && !covered && !isFocused) setCovered(true);
|
|
1166
|
+
return useDeferredValue(!resuming || covered);
|
|
1125
1167
|
}
|
|
1126
1168
|
function HomeMenu() {
|
|
1127
1169
|
const pack = usePack();
|
|
@@ -1251,8 +1293,8 @@ function GameRow({ game, hidden, dark, p1Color, p2Color, previewRevealed, onPres
|
|
|
1251
1293
|
/* @__PURE__ */ jsxs5(Pressable, { onPress, style: [styles4.row, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
|
|
1252
1294
|
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 }) }),
|
|
1253
1295
|
/* @__PURE__ */ jsxs5(View4, { style: styles4.rowText, children: [
|
|
1254
|
-
/* @__PURE__ */ jsx17(
|
|
1255
|
-
/* @__PURE__ */ jsx17(
|
|
1296
|
+
/* @__PURE__ */ jsx17(Text2, { variant: "titleLarge", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
|
|
1297
|
+
/* @__PURE__ */ jsx17(Text2, { variant: "bodyMedium", style: { color: well.fgMuted }, numberOfLines: ROW_BLURB_LINES, children: game.blurb })
|
|
1256
1298
|
] })
|
|
1257
1299
|
] }),
|
|
1258
1300
|
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 }) })
|
|
@@ -1265,8 +1307,8 @@ function GameTile({ game, hidden, width, previewWidth, dark, p1Color, p2Color, p
|
|
|
1265
1307
|
return /* @__PURE__ */ jsxs5(View4, { style: [{ width }, hidden && styles4.hidden], children: [
|
|
1266
1308
|
/* @__PURE__ */ jsxs5(Pressable, { onPress, style: [styles4.tile, { backgroundColor: well.bg }], accessibilityRole: "button", accessibilityLabel: game.title, children: [
|
|
1267
1309
|
/* @__PURE__ */ jsx17(PreviewBox, { game, width: previewWidth, revealed: previewRevealed, dark, p1Color, p2Color }),
|
|
1268
|
-
/* @__PURE__ */ jsx17(
|
|
1269
|
-
/* @__PURE__ */ jsx17(
|
|
1310
|
+
/* @__PURE__ */ jsx17(Text2, { variant: "titleMedium", style: [styles4.rowTitle, { color: well.fg }, titleStyle], numberOfLines: 1, children: game.title }),
|
|
1311
|
+
/* @__PURE__ */ jsx17(Text2, { variant: "bodySmall", style: { color: well.fgMuted }, numberOfLines: 3, children: game.blurb })
|
|
1270
1312
|
] }),
|
|
1271
1313
|
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" }) })
|
|
1272
1314
|
] });
|
|
@@ -1431,7 +1473,7 @@ import { getOptionPickerContentSize as getOptionPickerContentSize2, OptionPicker
|
|
|
1431
1473
|
import { router as router6 } from "expo-router";
|
|
1432
1474
|
import { useMemo as useMemo7, useState as useState7 } from "react";
|
|
1433
1475
|
import { StyleSheet as StyleSheet5, View as View5 } from "react-native";
|
|
1434
|
-
import { SegmentedButtons as SegmentedButtons2, Text as
|
|
1476
|
+
import { SegmentedButtons as SegmentedButtons2, Text as Text3 } from "react-native-paper";
|
|
1435
1477
|
import { useSafeAreaInsets as useSafeAreaInsets4 } from "react-native-safe-area-context";
|
|
1436
1478
|
import { useDispatch as useDispatch10 } from "react-redux";
|
|
1437
1479
|
import { jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
@@ -1532,7 +1574,7 @@ function GameStats({ game, tab, profileId, showTitle, titleColor }) {
|
|
|
1532
1574
|
const Sections = tab === STATS ? StatsSections : AchievementList;
|
|
1533
1575
|
if (!Sections) return null;
|
|
1534
1576
|
return /* @__PURE__ */ jsxs6(View5, { style: styles5.game, children: [
|
|
1535
|
-
showTitle && /* @__PURE__ */ jsx18(
|
|
1577
|
+
showTitle && /* @__PURE__ */ jsx18(Text3, { variant: "titleLarge", style: [styles5.gameTitle, { color: titleColor }, titleStyle], children: game.title }),
|
|
1536
1578
|
/* @__PURE__ */ jsx18(Sections, { profileId })
|
|
1537
1579
|
] });
|
|
1538
1580
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tastic/shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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
|
@@ -56,6 +56,16 @@ import type { PackDefinition, PackGameDefinition } from './types'
|
|
|
56
56
|
const PLAY_OPTIONS = { statusBarHidden: true }
|
|
57
57
|
const KEEP_STATUS_BAR_OPTIONS = {}
|
|
58
58
|
|
|
59
|
+
// Which way a replace slides on iOS (react-native-screens: the incoming screen's replaceAnimation picks
|
|
60
|
+
// it; a push unless told otherwise). A replace here is nearly always a way back with nothing beneath to
|
|
61
|
+
// pop to: safeBack's fallback to Home, a dismissTo whose screen isn't on the stack (a game's back to its
|
|
62
|
+
// setup screen after a deep link), a Redirect out of a game the pack doesn't have. So every screen slides
|
|
63
|
+
// a replace in as a pop, from the left, except a play screen, which a replace only ever opens (a loadout
|
|
64
|
+
// link to a game with nothing to set up). Android's crossfade over a backdrop and the web don't animate a
|
|
65
|
+
// direction.
|
|
66
|
+
const REPLACE_AS_BACK = { animationTypeForReplace: 'pop' as const }
|
|
67
|
+
const REPLACE_AS_FORWARD = { animationTypeForReplace: 'push' as const }
|
|
68
|
+
|
|
59
69
|
// The navigation theme is the root background too. React Navigation paints its theme's
|
|
60
70
|
// `colors.background` on the layers around every screen (the ScreenStack's container on native, each
|
|
61
71
|
// screen's wrapper on the web), and expo-router hands its container no theme, so that was always
|
|
@@ -95,7 +105,7 @@ function AppStack() {
|
|
|
95
105
|
({ route }: { route: { params?: object } }) => {
|
|
96
106
|
const id = (route.params as { game?: string } | undefined)?.game
|
|
97
107
|
const statusBarOptions = pack.games.some((g) => g.id === id && g.keepStatusBar) ? KEEP_STATUS_BAR_OPTIONS : PLAY_OPTIONS
|
|
98
|
-
return { ...statusBarOptions, ...edgeGuardOptions }
|
|
108
|
+
return { ...statusBarOptions, ...edgeGuardOptions, ...REPLACE_AS_FORWARD }
|
|
99
109
|
},
|
|
100
110
|
[pack.games, edgeGuardOptions]
|
|
101
111
|
)
|
|
@@ -106,7 +116,7 @@ function AppStack() {
|
|
|
106
116
|
}, [darkRoot, navigationBackground])
|
|
107
117
|
const stack = (
|
|
108
118
|
<NavigationThemeProvider value={navigationTheme}>
|
|
109
|
-
<Stack screenOptions={{ ...rootBackground, statusBarStyle, ...backdropOptions, ...packOptions }}>
|
|
119
|
+
<Stack screenOptions={{ ...rootBackground, statusBarStyle, ...REPLACE_AS_BACK, ...backdropOptions, ...packOptions }}>
|
|
110
120
|
<Stack.Screen name='index' />
|
|
111
121
|
<Stack.Screen name='play/[game]' options={playOptions} />
|
|
112
122
|
</Stack>
|
|
@@ -43,14 +43,20 @@ export function PlayRoute() {
|
|
|
43
43
|
// terminates an app it hasn't suspended yet (swiped away from the app switcher soon after leaving
|
|
44
44
|
// it), React Native's renderer stops every surface (RCTSurfacePresenter's will-terminate handler),
|
|
45
45
|
// which unmounts the whole tree, and clearing then sent every such relaunch to Home. Runs once per
|
|
46
|
-
// play screen: the context's functions never change.
|
|
46
|
+
// play screen: the context's functions never change. A play screen that goes while another is up
|
|
47
|
+
// (a pack replacing one play screen with another, CardTastic's regular game with its Daily Deal: the
|
|
48
|
+
// stack keeps the old one drawn until its transition ends, so it unmounts after the new one mounted)
|
|
49
|
+
// leaves the resume point to the one still up.
|
|
50
|
+
let playScreensUp = 0
|
|
47
51
|
function useResumePoint(gameId: string | null) {
|
|
48
52
|
const { setLastActiveGame, clearLastActiveGame } = useLastActiveGame()
|
|
49
53
|
useEffect(() => {
|
|
50
54
|
if (!gameId) return
|
|
55
|
+
playScreensUp += 1
|
|
51
56
|
setLastActiveGame(gameId)
|
|
52
57
|
return () => {
|
|
53
|
-
|
|
58
|
+
playScreensUp -= 1
|
|
59
|
+
if (playScreensUp === 0 && AppState.currentState === 'active') clearLastActiveGame()
|
|
54
60
|
}
|
|
55
61
|
}, [gameId, setLastActiveGame, clearLastActiveGame])
|
|
56
62
|
}
|
|
@@ -2,8 +2,8 @@ import { defaultColors, FadingScrollView, useAutoPaperTheme } from '@rific/auto-
|
|
|
2
2
|
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
|
-
import {
|
|
6
|
-
import { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
5
|
+
import { router, useFocusEffect, useIsFocused } from 'expo-router'
|
|
6
|
+
import { type ReactNode, useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
|
|
7
7
|
import { AppState, type AppStateStatus, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent, type ScrollView, StyleSheet, View } from 'react-native'
|
|
8
8
|
import { Icon, Portal, SegmentedButtons, Text } from 'react-native-paper'
|
|
9
9
|
|
|
@@ -28,7 +28,8 @@ import { HOME_GRID_GAP, HOME_LEFT_PANE_PICKER_GAP, HOME_TILE_PADDING, HOME_TOP_B
|
|
|
28
28
|
// (PackDefinition.homeTabs) shows one tab's games at a time, from a switch over the rows.
|
|
29
29
|
//
|
|
30
30
|
// A cold launch that finds the player left the app inside a resumable game's play screen
|
|
31
|
-
// (GameDefinition.resumable) goes straight back there instead, before the menu ever paints
|
|
31
|
+
// (GameDefinition.resumable) goes straight back there instead, before the menu ever paints, with the
|
|
32
|
+
// game's setup screen and this Home beneath it (useResume). The
|
|
32
33
|
// pack's own How to Play (PackDefinition.guide) shows by itself on a first launch, held back while
|
|
33
34
|
// that launch is about to drop into a game: it must never open over a game in progress.
|
|
34
35
|
export function HomeScreen() {
|
|
@@ -47,8 +48,40 @@ export function HomeScreen() {
|
|
|
47
48
|
useEffect(() => {
|
|
48
49
|
if (!resumeGame) autoShowPack()
|
|
49
50
|
}, [resumeGame, autoShowPack])
|
|
50
|
-
|
|
51
|
-
return <HomeMenu />
|
|
51
|
+
useResume(resumeGame)
|
|
52
|
+
return useMenuShown(!!resumeGame) ? <HomeMenu /> : null
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// The resume itself: the game's setup screen (when it has one), then its play screen (or where the pack
|
|
56
|
+
// says, PackDefinition.resumeHref), pushed over this Home, the stack the player had when they left. Every
|
|
57
|
+
// way back from there is then a pop, which slides the right way: the game's back to its setup screen, that
|
|
58
|
+
// one's back to Home, and Android's back the same (with the play screen alone on the stack, it closed the
|
|
59
|
+
// app). A Redirect replaced Home instead, and with nothing beneath the game each of those backs had to
|
|
60
|
+
// replace the screen too, which iOS animates as a push: the screen came in from the right, as if going
|
|
61
|
+
// forward. Run once, on focus, as Redirect runs its own (the stack is ready by then). Both pushes are
|
|
62
|
+
// queued in one go, so the stack takes them in one update and only the play screen slides in.
|
|
63
|
+
function useResume(game: PackGameDefinition | null) {
|
|
64
|
+
const pack = usePack()
|
|
65
|
+
const done = useRef(false)
|
|
66
|
+
useFocusEffect(
|
|
67
|
+
useCallback(() => {
|
|
68
|
+
if (!game || done.current) return
|
|
69
|
+
done.current = true
|
|
70
|
+
if (game.useLoadout) router.push(loadoutHref(game.id))
|
|
71
|
+
router.push(pack.resumeHref?.(game.id) ?? playHref(game.id))
|
|
72
|
+
}, [game, pack])
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Whether Home draws its menu. A Home resuming a game draws nothing until the game covers it (Home no
|
|
77
|
+
// longer focused), so a launch never shows the menu ahead of the game, and then draws it at low priority
|
|
78
|
+
// (useDeferredValue), behind the game's own first renders. From then on it's mounted beneath the game like
|
|
79
|
+
// any Home that opened one, so going back to it is quick.
|
|
80
|
+
function useMenuShown(resuming: boolean): boolean {
|
|
81
|
+
const isFocused = useIsFocused()
|
|
82
|
+
const [covered, setCovered] = useState(false)
|
|
83
|
+
if (resuming && !covered && !isFocused) setCovered(true)
|
|
84
|
+
return useDeferredValue(!resuming || covered)
|
|
52
85
|
}
|
|
53
86
|
|
|
54
87
|
function HomeMenu() {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { defaultColors, getRgb, useAutoPaperTheme } from '@rific/auto-paper'
|
|
2
2
|
import { useOrientationState } from '@tastic/core'
|
|
3
|
-
import { CornerActionButtons, PressAwayOverlay, usePopoverHost } from '@tastic/hud/chrome'
|
|
3
|
+
import { CornerActionButtons, PressAwayOverlay, useLettering, usePopoverHost } from '@tastic/hud/chrome'
|
|
4
4
|
import { PlayerSetupPanel, ReadyButton, SharedActionBand } from '@tastic/hud/lobby'
|
|
5
5
|
import type { Profile } from '@tastic/profile'
|
|
6
6
|
import { DualZoneLayout, needsSharedNeutralZone, useDualZoneLayout } from '@tastic/split-screen'
|
|
7
7
|
import { router, useFocusEffect } from 'expo-router'
|
|
8
8
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
9
9
|
import { type StyleProp, StyleSheet, View, type ViewStyle } from 'react-native'
|
|
10
|
+
import { Text } from 'react-native-paper'
|
|
10
11
|
import Animated from 'react-native-reanimated'
|
|
11
12
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
12
13
|
import { useDispatch } from 'react-redux'
|
|
@@ -36,6 +37,14 @@ const PANEL_SWAP_FADE_MS = 180
|
|
|
36
37
|
const P1_CONTROL_ID = 'p1-control'
|
|
37
38
|
const P2_CONTROL_ID = 'p2-control'
|
|
38
39
|
|
|
40
|
+
// The header's title, placed as the stats screen's (hud's BaseStatsScreen): beside the corner Back
|
|
41
|
+
// button (8pt from the edge, Paper's 6pt IconButton margin, its 40pt box, 6pt margin, 4pt gap), clear
|
|
42
|
+
// of the Settings button on the right, and centered on the buttons' 52pt row.
|
|
43
|
+
const HEADER_TOP = 8
|
|
44
|
+
const HEADER_ROW_HEIGHT = 52
|
|
45
|
+
const HEADER_TITLE_LEFT = 64
|
|
46
|
+
const HEADER_TITLE_RIGHT = 60
|
|
47
|
+
|
|
39
48
|
// A game that has a loadout (GameDefinition.useLoadout): the loadout route sends any other straight
|
|
40
49
|
// to its play screen.
|
|
41
50
|
export type LoadoutGame = PackGameDefinition & Required<Pick<PackGameDefinition, 'useLoadout'>>
|
|
@@ -81,6 +90,7 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
81
90
|
|
|
82
91
|
const [settingsOpen, setSettingsOpen] = useState(false)
|
|
83
92
|
const insets = useSafeAreaInsets()
|
|
93
|
+
const { title: lettering } = useLettering()
|
|
84
94
|
const { colors: themeColors, dark } = useAutoPaperTheme()
|
|
85
95
|
const { p1Color, p2Color, handleP1ColorChange, handleP2ColorChange } = useSeatColors(p2IsHuman)
|
|
86
96
|
const dispatch = useDispatch<Dispatch<Action>>()
|
|
@@ -178,6 +188,8 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
178
188
|
// seat 1's button stands alone.
|
|
179
189
|
const opponentPicker = game.seatTwo && <OpponentPicker key={`opponent-${layoutKey}`} idPrefix='p1' host={controlsHost} choices={game.seatTwo} seatTwo={seatTwo} onSeatTwoChange={changeSeatTwo} cpuDifficulty={loadout.cpuDifficulty} color={p2Color} onColorChange={handleP2ColorChange} swatches={defaultColors} takenColor={p1Color} allowSwapTaken={mode === 'vsCpu'} dark={dark} previewValue={seatPreview} triggerStyle={triggerStyle} usePickerAlign={seatPickerAlign} />
|
|
180
190
|
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }))
|
|
191
|
+
// With one person a game can draw its own start among its options (GameLoadout.drawsReady)
|
|
192
|
+
const readyInOptions = !p2IsHuman && !!loadout.drawsReady
|
|
181
193
|
const seatButtons = (
|
|
182
194
|
<View style={[styles.seatOneButtons, p1PickerOpen && styles.raised]}>
|
|
183
195
|
<Animated.View style={[styles.playersRow, p1PickerOpen && styles.raised, !p2IsHuman && playersRowFade]}>
|
|
@@ -192,7 +204,7 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
192
204
|
const seatOne = (
|
|
193
205
|
<View style={[styles.seatOne, !p2IsHuman && styles.seatOneAlone, p1PickerOpen && !seatsInOptions && styles.raised]}>
|
|
194
206
|
{!seatsInOptions && seatButtons}
|
|
195
|
-
<ReadyButton color={p1Drawn} ready={ready[1]} onToggleReady={toggleP1Ready} surfaceColor={readySurface} dark={dark} style={!p2IsHuman && p1PickerOpen && styles.readyButtonHidden} />
|
|
207
|
+
{!readyInOptions && <ReadyButton color={p1Drawn} ready={ready[1]} onToggleReady={toggleP1Ready} surfaceColor={readySurface} dark={dark} style={!p2IsHuman && p1PickerOpen && styles.readyButtonHidden} />}
|
|
196
208
|
</View>
|
|
197
209
|
)
|
|
198
210
|
|
|
@@ -203,6 +215,8 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
203
215
|
onAccentColor: themeColors.onTertiary,
|
|
204
216
|
dark,
|
|
205
217
|
seats: seatsInOptions ? seatButtons : undefined,
|
|
218
|
+
onReady: readyInOptions ? () => setReady((r) => ({ ...r, 1: true })) : undefined,
|
|
219
|
+
titleShown: !showMetaInSharedBand,
|
|
206
220
|
// Left out (the row's own actions unrendered) whenever the shared band below carries them.
|
|
207
221
|
onRandomize: showMetaInSharedBand ? undefined : loadout.randomize,
|
|
208
222
|
onReset: showMetaInSharedBand ? undefined : loadout.reset
|
|
@@ -225,7 +239,7 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
225
239
|
return (
|
|
226
240
|
<View style={[styles.container, { backgroundColor: bg }]}>
|
|
227
241
|
{/* The Settings dialog stays outside this frame: it renders through a Portal. */}
|
|
228
|
-
<View style={styles.frame}>
|
|
242
|
+
<View style={[styles.frame, !showMetaInSharedBand && { paddingTop: HEADER_TOP + HEADER_ROW_HEIGHT + insets.top }]}>
|
|
229
243
|
{/* Press-away overlays for the loadout's own menus. P1's covers the whole screen (their
|
|
230
244
|
panel plus the match options read as theirs), while P2's covers only their half and, as a
|
|
231
245
|
later sibling, takes priority there. P2's mounts whenever either host has a menu open, so it
|
|
@@ -234,6 +248,16 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
234
248
|
{p2ZoneStyle && <PressAwayOverlay active={controlsHost.openId !== null || p2Host.openId !== null} onPress={p2Host.close} style={p2ZoneStyle} />}
|
|
235
249
|
|
|
236
250
|
{!showMetaInSharedBand && <CornerActionButtons onBack={safeBack} onSettings={() => setSettingsOpen(true)} fg={fg} insets={insets} />}
|
|
251
|
+
{/* The game's name in the header, as a screen's title beside Back (Jay, 2026-11-21: over the
|
|
252
|
+
seat buttons it read as part of the options). 2 Player face to face has no header: its back
|
|
253
|
+
and settings sit in the band between the players, where a game names itself. */}
|
|
254
|
+
{!showMetaInSharedBand && (
|
|
255
|
+
<View style={[styles.headerTitle, { top: HEADER_TOP + insets.top, left: HEADER_TITLE_LEFT + insets.left, right: HEADER_TITLE_RIGHT + insets.right }]} pointerEvents='none'>
|
|
256
|
+
<Text variant='headlineSmall' numberOfLines={1} accessibilityRole='header' style={[styles.title, { color: fg }, lettering]}>
|
|
257
|
+
{game.title}
|
|
258
|
+
</Text>
|
|
259
|
+
</View>
|
|
260
|
+
)}
|
|
237
261
|
|
|
238
262
|
{p2IsHuman ? (
|
|
239
263
|
<DualZoneLayout
|
|
@@ -252,7 +276,8 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
252
276
|
<View style={styles.stackedZone}>
|
|
253
277
|
{/* A menu opening from seat buttons placed in the options has to clear Ready, the next sibling */}
|
|
254
278
|
{seatsInOptions ? <View style={p1PickerOpen && styles.raised}>{sharedControls}</View> : sharedControls}
|
|
255
|
-
{
|
|
279
|
+
{/* Nothing left of seat 1's column once a game places its buttons and draws its own start (no empty gap) */}
|
|
280
|
+
{!(seatsInOptions && readyInOptions) && seatOne}
|
|
256
281
|
</View>
|
|
257
282
|
)}
|
|
258
283
|
</View>
|
|
@@ -287,6 +312,11 @@ const styles = StyleSheet.create({
|
|
|
287
312
|
justifyContent: 'center',
|
|
288
313
|
paddingHorizontal: 16
|
|
289
314
|
},
|
|
315
|
+
headerTitle: {
|
|
316
|
+
height: HEADER_ROW_HEIGHT,
|
|
317
|
+
justifyContent: 'center',
|
|
318
|
+
position: 'absolute'
|
|
319
|
+
},
|
|
290
320
|
p2ZoneRight: {
|
|
291
321
|
bottom: 0,
|
|
292
322
|
position: 'absolute',
|
|
@@ -339,5 +369,9 @@ const styles = StyleSheet.create({
|
|
|
339
369
|
stackedZone: {
|
|
340
370
|
alignItems: 'center',
|
|
341
371
|
gap: 28
|
|
372
|
+
},
|
|
373
|
+
// hud's BaseStatsScreen title: the stats screen's header, in the pack's title lettering.
|
|
374
|
+
title: {
|
|
375
|
+
fontWeight: 'bold'
|
|
342
376
|
}
|
|
343
377
|
})
|
package/src/types.ts
CHANGED
|
@@ -56,6 +56,13 @@ export interface LoadoutOptionsProps {
|
|
|
56
56
|
// With one person, player 1's row of buttons (their seat's, the opponent's and their controls), for a
|
|
57
57
|
// game whose loadout sets placesSeats to put where it likes. Undefined otherwise.
|
|
58
58
|
seats?: ReactNode
|
|
59
|
+
// With one person, what starts the round (player 1 readying up), for a game whose loadout sets
|
|
60
|
+
// drawsReady to draw its own start among its options. Undefined otherwise.
|
|
61
|
+
onReady?: () => void
|
|
62
|
+
// Whether the loadout's header already shows the game's name (beside Back, as the stats screen's
|
|
63
|
+
// title does): everywhere but 2 Player face to face, whose back and settings fold into the band
|
|
64
|
+
// between the players. A game that names itself among its options does so only when this is false.
|
|
65
|
+
titleShown: boolean
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
// The colors a seat's controls picker draws with: the loadout's tertiary accent, or the seat's own.
|
|
@@ -78,6 +85,11 @@ export interface GameLoadout {
|
|
|
78
85
|
// instead (LoadoutOptionsProps.seats), for a game that wants them among its own (over its rules, under
|
|
79
86
|
// its name). 2 Player's seats stay in each person's half.
|
|
80
87
|
placesSeats?: boolean
|
|
88
|
+
// With one person Ready sits under the options row (and the seat buttons). True draws no Ready and
|
|
89
|
+
// hands `options` an onReady to call instead, for a game that starts the round from a control of its
|
|
90
|
+
// own (CardTastic's solitaire games: a New Deal or Continue row in a card, like their Daily Deal's, since
|
|
91
|
+
// READY? means nothing to one person). 2 Player's Ready buttons stay in each person's half.
|
|
92
|
+
drawsReady?: boolean
|
|
81
93
|
// The popover ids the options row opens, so the loadout can elevate the row while one is open.
|
|
82
94
|
optionIds: readonly string[]
|
|
83
95
|
randomize: () => void
|