@tastic/shell 0.10.0 → 0.12.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 +143 -19
- package/dist/index.d.mts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +39 -43
- package/dist/index.mjs +43 -47
- package/package.json +9 -8
- package/src/RootLayout.tsx +9 -17
- package/src/hooks/useAppSettings.ts +1 -1
- package/src/redux/createPackStore.ts +1 -8
- package/src/redux/shellState.ts +4 -10
- package/src/screens/HomeScreen.tsx +6 -4
- package/src/screens/LoadoutScreen.tsx +30 -22
- package/src/screens/ProfilesRoute.tsx +6 -7
- package/src/screens/StatsScreen.tsx +6 -7
- package/src/screens/homeLayout.ts +5 -5
- package/src/types.ts +16 -2
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ import { useHapticSettings } from "@rific/feedback-press";
|
|
|
27
27
|
import { Toaster, ToastProvider } from "@rific/toaster";
|
|
28
28
|
import { useThemedRootBackground } from "@tastic/core";
|
|
29
29
|
import { edgeGuardScreenOptions } from "@tastic/edge-guard";
|
|
30
|
-
import {
|
|
30
|
+
import { ScreenFrame } from "@tastic/hud/chrome";
|
|
31
31
|
import { ProfileColorProvider } from "@tastic/profile";
|
|
32
32
|
import * as Haptics from "expo-haptics";
|
|
33
33
|
import { DarkTheme, DefaultTheme, Stack, ThemeProvider as NavigationThemeProvider } from "expo-router";
|
|
@@ -457,15 +457,12 @@ function HapticGatedToastProvider({ children }) {
|
|
|
457
457
|
const { Toaster: PackToasterComponent } = usePack();
|
|
458
458
|
return /* @__PURE__ */ jsx10(ToastProvider, { haptics: settings.vibrate ? Haptics : void 0, paper: PackToasterComponent ? void 0 : RNPaper2, children });
|
|
459
459
|
}
|
|
460
|
-
function
|
|
461
|
-
const renderFrame = useCallback6(
|
|
462
|
-
(toasts) => /* @__PURE__ */ jsx10(RotatedFrame, { rotatedSafeArea: true, passThrough: true, children: toasts }),
|
|
463
|
-
[]
|
|
464
|
-
);
|
|
460
|
+
function FramedToaster() {
|
|
461
|
+
const renderFrame = useCallback6((toasts) => /* @__PURE__ */ jsx10(ScreenFrame, { passThrough: true, children: toasts }), []);
|
|
465
462
|
return /* @__PURE__ */ jsx10(Toaster, { historyButton: null, clearButton: null, limit: 3, renderFrame });
|
|
466
463
|
}
|
|
467
464
|
function PackToaster({ Toaster: PackToasterComponent }) {
|
|
468
|
-
return /* @__PURE__ */ jsx10(View, { style: StyleSheet.absoluteFill, pointerEvents: "box-none", children: /* @__PURE__ */ jsx10(
|
|
465
|
+
return /* @__PURE__ */ jsx10(View, { style: StyleSheet.absoluteFill, pointerEvents: "box-none", children: /* @__PURE__ */ jsx10(ScreenFrame, { passThrough: true, children: /* @__PURE__ */ jsx10(PackToasterComponent, {}) }) });
|
|
469
466
|
}
|
|
470
467
|
function GameProviders({ games, children }) {
|
|
471
468
|
return games.reduceRight((inner, game) => game.Provider ? /* @__PURE__ */ jsx10(game.Provider, { children: inner }, game.id) : inner, children);
|
|
@@ -483,7 +480,7 @@ function PackRoot({ pack, children }) {
|
|
|
483
480
|
function RootLayout({ pack, store, persistor }) {
|
|
484
481
|
return /* @__PURE__ */ jsx10(GestureHandlerRootView, { style: styles.root, children: /* @__PURE__ */ jsx10(SafeAreaProvider, { children: /* @__PURE__ */ jsx10(WindowControlsInsets, { children: /* @__PURE__ */ jsx10(PackProvider, { pack, children: /* @__PURE__ */ jsx10(Fonts, { children: /* @__PURE__ */ jsx10(Providers, { store, persistor, children: /* @__PURE__ */ jsx10(Theme, { children: /* @__PURE__ */ jsx10(ProfilesProvider, { children: /* @__PURE__ */ jsx10(LastActiveGameProvider, { children: /* @__PURE__ */ jsx10(GameProviders, { games: pack.games, children: /* @__PURE__ */ jsx10(PackRoot, { pack, children: /* @__PURE__ */ jsx10(GatedApp, { children: /* @__PURE__ */ jsxs2(HapticGatedToastProvider, { children: [
|
|
485
482
|
/* @__PURE__ */ jsx10(GuideHost, { children: /* @__PURE__ */ jsx10(AppStack, {}) }),
|
|
486
|
-
pack.Toaster ? /* @__PURE__ */ jsx10(PackToaster, { Toaster: pack.Toaster }) : /* @__PURE__ */ jsx10(
|
|
483
|
+
pack.Toaster ? /* @__PURE__ */ jsx10(PackToaster, { Toaster: pack.Toaster }) : /* @__PURE__ */ jsx10(FramedToaster, {}),
|
|
487
484
|
/* @__PURE__ */ jsx10(UpdateDialog, {})
|
|
488
485
|
] }) }) }) }) }) }) }) }) }) }) }) }) });
|
|
489
486
|
}
|
|
@@ -814,33 +811,36 @@ function LoadoutScreen({ game }) {
|
|
|
814
811
|
const p2Host = usePopoverHost();
|
|
815
812
|
const p1PickerOpen = controlsHost.openId?.startsWith("p1-") ?? false;
|
|
816
813
|
const p1ControlOpen = controlsHost.openId === P1_CONTROL_ID;
|
|
814
|
+
const controlLook = { accentColor: themeColors.tertiary, mutedColor: fgMuted, dark };
|
|
815
|
+
const p1Control = loadout.seatControl(1, controlsHost, { ...controlLook, seatColor: p1Drawn });
|
|
816
|
+
const p1Panel = /* @__PURE__ */ jsx13(PlayerSetupPanel, { idPrefix: "p1", host: controlsHost, color: p1Color, onColorChange: handleP1ColorChange, swatches: 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: () => router2.push(PROFILES_HREF), previewValue: seatPreview, triggerStyle, useSeatPickerAlign: seatPickerAlign }, `p1-${layoutKey}`);
|
|
817
|
+
const opponentPicker = game.seatTwo && /* @__PURE__ */ jsx13(OpponentPicker, { idPrefix: "p1", host: controlsHost, choices: game.seatTwo, seatTwo, onSeatTwoChange: changeSeatTwo, cpuDifficulty: loadout.cpuDifficulty, color: p2Color, onColorChange: handleP2ColorChange, swatches: defaultColors, takenColor: p1Color, allowSwapTaken: mode === "vsCpu", dark, previewValue: seatPreview, triggerStyle, usePickerAlign: seatPickerAlign }, `opponent-${layoutKey}`);
|
|
818
|
+
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }));
|
|
819
|
+
const seatButtons = /* @__PURE__ */ jsxs4(View3, { style: [styles3.seatOneButtons, p1PickerOpen && styles3.raised], children: [
|
|
820
|
+
/* @__PURE__ */ jsxs4(Animated.View, { style: [styles3.playersRow, p1PickerOpen && styles3.raised, !p2IsHuman && playersRowFade], children: [
|
|
821
|
+
p1Panel,
|
|
822
|
+
opponentPicker
|
|
823
|
+
] }),
|
|
824
|
+
p1Control && /* @__PURE__ */ jsx13(View3, { style: [styles3.controlRow, p1ControlOpen && styles3.raised], children: p1Control })
|
|
825
|
+
] });
|
|
826
|
+
const seatsInOptions = !p2IsHuman && !!loadout.placesSeats;
|
|
827
|
+
const seatOne = /* @__PURE__ */ jsxs4(View3, { style: [styles3.seatOne, !p2IsHuman && styles3.seatOneAlone, p1PickerOpen && !seatsInOptions && styles3.raised], children: [
|
|
828
|
+
!seatsInOptions && seatButtons,
|
|
829
|
+
/* @__PURE__ */ jsx13(ReadyButton, { color: p1Drawn, ready: ready[1], onToggleReady: toggleP1Ready, surfaceColor: readySurface, dark, style: !p2IsHuman && p1PickerOpen && styles3.readyButtonHidden })
|
|
830
|
+
] });
|
|
817
831
|
const optionsRow = loadout.options({
|
|
818
832
|
host: controlsHost,
|
|
819
833
|
accentColor: themeColors.tertiary,
|
|
820
834
|
mutedColor: fgMuted,
|
|
821
835
|
onAccentColor: themeColors.onTertiary,
|
|
822
836
|
dark,
|
|
837
|
+
seats: seatsInOptions ? seatButtons : void 0,
|
|
823
838
|
// Left out (the row's own actions unrendered) whenever the shared band below carries them.
|
|
824
839
|
onRandomize: showMetaInSharedBand ? void 0 : loadout.randomize,
|
|
825
840
|
onReset: showMetaInSharedBand ? void 0 : loadout.reset
|
|
826
841
|
});
|
|
827
842
|
const optionsPopoverOpen = controlsHost.openId !== null && loadout.optionIds.includes(controlsHost.openId);
|
|
828
843
|
const sharedControls = showMetaInSharedBand ? /* @__PURE__ */ jsx13(SharedActionBand, { onBack: safeBack, onSettings: () => setSettingsOpen(true), onRandomize: loadout.randomize, onReset: loadout.reset, fg, popoverOpen: optionsPopoverOpen, children: optionsRow }) : optionsRow;
|
|
829
|
-
const controlLook = { accentColor: themeColors.tertiary, mutedColor: fgMuted, dark };
|
|
830
|
-
const p1Control = loadout.seatControl(1, controlsHost, { ...controlLook, seatColor: p1Drawn });
|
|
831
|
-
const p1Panel = /* @__PURE__ */ jsx13(PlayerSetupPanel, { idPrefix: "p1", host: controlsHost, color: p1Color, onColorChange: handleP1ColorChange, swatches: 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: () => router2.push(PROFILES_HREF), previewValue: seatPreview, triggerStyle, useSeatPickerAlign: seatPickerAlign }, `p1-${layoutKey}`);
|
|
832
|
-
const opponentPicker = game.seatTwo && /* @__PURE__ */ jsx13(OpponentPicker, { idPrefix: "p1", host: controlsHost, choices: game.seatTwo, seatTwo, onSeatTwoChange: changeSeatTwo, cpuDifficulty: loadout.cpuDifficulty, color: p2Color, onColorChange: handleP2ColorChange, swatches: defaultColors, takenColor: p1Color, allowSwapTaken: mode === "vsCpu", dark, previewValue: seatPreview, triggerStyle, usePickerAlign: seatPickerAlign }, `opponent-${layoutKey}`);
|
|
833
|
-
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }));
|
|
834
|
-
const seatOne = /* @__PURE__ */ jsxs4(View3, { style: [styles3.seatOne, !p2IsHuman && styles3.seatOneAlone, p1PickerOpen && styles3.raised], children: [
|
|
835
|
-
/* @__PURE__ */ jsxs4(View3, { style: [styles3.seatOneButtons, p1PickerOpen && styles3.raised], children: [
|
|
836
|
-
/* @__PURE__ */ jsxs4(Animated.View, { style: [styles3.playersRow, p1PickerOpen && styles3.raised, !p2IsHuman && playersRowFade], children: [
|
|
837
|
-
p1Panel,
|
|
838
|
-
opponentPicker
|
|
839
|
-
] }),
|
|
840
|
-
p1Control && /* @__PURE__ */ jsx13(View3, { style: [styles3.controlRow, p1ControlOpen && styles3.raised], children: p1Control })
|
|
841
|
-
] }),
|
|
842
|
-
/* @__PURE__ */ jsx13(ReadyButton, { color: p1Drawn, ready: ready[1], onToggleReady: toggleP1Ready, surfaceColor: readySurface, dark, style: !p2IsHuman && p1PickerOpen && styles3.readyButtonHidden })
|
|
843
|
-
] });
|
|
844
844
|
const p2Control = p2IsHuman ? loadout.seatControl(2, p2Host, { ...controlLook, seatColor: p2Drawn }) : void 0;
|
|
845
845
|
const p2Panel = p2IsHuman && /* @__PURE__ */ jsx13(PlayerSetupPanel, { idPrefix: "p2", host: p2Host, color: p2Color, onColorChange: handleP2ColorChange, swatches: 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");
|
|
846
846
|
return /* @__PURE__ */ jsxs4(View3, { style: [styles3.container, { backgroundColor: bg }], children: [
|
|
@@ -861,7 +861,7 @@ function LoadoutScreen({ game }) {
|
|
|
861
861
|
sharedElevated: optionsPopoverOpen
|
|
862
862
|
}
|
|
863
863
|
) : /* @__PURE__ */ jsxs4(View3, { style: styles3.stackedZone, children: [
|
|
864
|
-
sharedControls,
|
|
864
|
+
seatsInOptions ? /* @__PURE__ */ jsx13(View3, { style: p1PickerOpen && styles3.raised, children: sharedControls }) : sharedControls,
|
|
865
865
|
seatOne
|
|
866
866
|
] })
|
|
867
867
|
] }),
|
|
@@ -1028,7 +1028,7 @@ var HOME_LEFT_PANE_PICKER_HEIGHT = 44;
|
|
|
1028
1028
|
var HOME_LEFT_PANE_PICKER_GAP = 12;
|
|
1029
1029
|
var HOME_LEFT_PANE_BOTTOM_PADDING = 16;
|
|
1030
1030
|
var HOME_HERO_SIDE_ROOM = 16;
|
|
1031
|
-
function computeHomeLayout(windowWidth, windowHeight, insets) {
|
|
1031
|
+
function computeHomeLayout(windowWidth, windowHeight, insets, withPicker = true) {
|
|
1032
1032
|
const isWide = windowWidth > windowHeight;
|
|
1033
1033
|
if (!isWide) {
|
|
1034
1034
|
return { isWide, windowWidth, windowHeight, insets, paddingLeft: 0, paddingRight: 0, leftPaneWidth: 0, rightPaneWidth: 0, columns: 1, tileWidth: 0, previewWidth: 0, heroFit: void 0 };
|
|
@@ -1044,7 +1044,7 @@ function computeHomeLayout(windowWidth, windowHeight, insets) {
|
|
|
1044
1044
|
const previewWidth = Math.max(0, tileWidth - 2 * HOME_TILE_PADDING);
|
|
1045
1045
|
const heroFit = {
|
|
1046
1046
|
width: Math.max(0, leftPaneWidth - HOME_HERO_SIDE_ROOM),
|
|
1047
|
-
height: Math.max(0, windowHeight - insets.top - insets.bottom - HOME_TOP_BAND - HOME_LEFT_PANE_PICKER_GAP
|
|
1047
|
+
height: Math.max(0, windowHeight - insets.top - insets.bottom - HOME_TOP_BAND - (withPicker ? HOME_LEFT_PANE_PICKER_GAP + HOME_LEFT_PANE_PICKER_HEIGHT : 0) - HOME_LEFT_PANE_BOTTOM_PADDING)
|
|
1048
1048
|
};
|
|
1049
1049
|
return {
|
|
1050
1050
|
isWide,
|
|
@@ -1061,10 +1061,10 @@ function computeHomeLayout(windowWidth, windowHeight, insets) {
|
|
|
1061
1061
|
heroFit
|
|
1062
1062
|
};
|
|
1063
1063
|
}
|
|
1064
|
-
function useHomeLayout() {
|
|
1064
|
+
function useHomeLayout(withPicker = true) {
|
|
1065
1065
|
const { width, height } = useWindowDimensions();
|
|
1066
1066
|
const insets = useSafeAreaInsets3();
|
|
1067
|
-
return computeHomeLayout(width, height, insets);
|
|
1067
|
+
return computeHomeLayout(width, height, insets, withPicker);
|
|
1068
1068
|
}
|
|
1069
1069
|
|
|
1070
1070
|
// src/screens/HomeScreen.tsx
|
|
@@ -1080,12 +1080,13 @@ function HomeScreen() {
|
|
|
1080
1080
|
useEffect6(() => {
|
|
1081
1081
|
if (!resumeGame) autoShowPack();
|
|
1082
1082
|
}, [resumeGame, autoShowPack]);
|
|
1083
|
-
if (resumeGame) return /* @__PURE__ */ jsx15(Redirect2, { href: playHref(resumeGame.id) });
|
|
1083
|
+
if (resumeGame) return /* @__PURE__ */ jsx15(Redirect2, { href: pack.resumeHref?.(resumeGame.id) ?? playHref(resumeGame.id) });
|
|
1084
1084
|
return /* @__PURE__ */ jsx15(HomeMenu, {});
|
|
1085
1085
|
}
|
|
1086
1086
|
function HomeMenu() {
|
|
1087
1087
|
const pack = usePack();
|
|
1088
|
-
const
|
|
1088
|
+
const showPicker = pack.homePlayerPicker !== false;
|
|
1089
|
+
const layout = useHomeLayout(showPicker);
|
|
1089
1090
|
const { insets } = layout;
|
|
1090
1091
|
const { dark, colors } = useAutoPaperTheme4();
|
|
1091
1092
|
const { openFirstTime, openFor, openPack } = useGameGuide();
|
|
@@ -1146,12 +1147,12 @@ function HomeMenu() {
|
|
|
1146
1147
|
] }),
|
|
1147
1148
|
/* @__PURE__ */ jsxs5(View4, { style: [styles4.wideLeftPane, { left: layout.paddingLeft, width: layout.leftPaneWidth, paddingTop: HOME_TOP_BAND + insets.top, paddingBottom: 16 + insets.bottom }, pickerHost.openId !== null && styles4.pickerOpen], children: [
|
|
1148
1149
|
/* @__PURE__ */ jsx15(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive, fit: layout.heroFit }),
|
|
1149
|
-
/* @__PURE__ */ jsx15(View4, { style: styles4.widePicker, children: picker })
|
|
1150
|
+
showPicker && /* @__PURE__ */ jsx15(View4, { style: styles4.widePicker, children: picker })
|
|
1150
1151
|
] })
|
|
1151
1152
|
] }) : /* @__PURE__ */ jsxs5(FadingScrollView, { ...tab && columnClamp, style: styles4.scroll, contentContainerStyle: [styles4.content, { paddingTop: 56 + insets.top, paddingBottom: 24 + insets.bottom, paddingLeft: 16 + insets.left, paddingRight: 16 + insets.right }], children: [
|
|
1152
1153
|
pressAway,
|
|
1153
1154
|
/* @__PURE__ */ jsx15(pack.HeroTitle, { words: pack.wordmark, color: fg, p1Color, p2Color, active: heroActive }),
|
|
1154
|
-
/* @__PURE__ */ jsx15(View4, { style: [styles4.picker, pickerHost.openId !== null && styles4.pickerOpen], children: picker }),
|
|
1155
|
+
showPicker && /* @__PURE__ */ jsx15(View4, { style: [styles4.picker, pickerHost.openId !== null && styles4.pickerOpen], children: picker }),
|
|
1155
1156
|
tabBar && /* @__PURE__ */ jsx15(View4, { style: styles4.listWidth, children: tabBar }),
|
|
1156
1157
|
/* @__PURE__ */ jsx15(View4, { style: styles4.list, children: pack.games.map((game) => /* @__PURE__ */ jsx15(GameRow, { game, hidden: isHidden(tab, game), dark, p1Color, p2Color, previewRevealed: previewsRevealed, onPress: () => openGame(game), onRules: hasRules(game) ? () => openRules(game) : void 0 }, game.id)) })
|
|
1157
1158
|
] }),
|
|
@@ -1383,7 +1384,7 @@ var styles4 = StyleSheet4.create({
|
|
|
1383
1384
|
|
|
1384
1385
|
// src/screens/ProfilesRoute.tsx
|
|
1385
1386
|
import { defaultColors as defaultColors3 } from "@rific/auto-paper";
|
|
1386
|
-
import {
|
|
1387
|
+
import { ScreenFrame as ScreenFrame2 } from "@tastic/hud/chrome";
|
|
1387
1388
|
import { ProfilesScreen } from "@tastic/profile";
|
|
1388
1389
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1389
1390
|
var ROSTER_MAX_WIDTH = 640;
|
|
@@ -1394,12 +1395,12 @@ function useRosterAlign(open, contentWidth, contentHeight) {
|
|
|
1394
1395
|
function ProfilesRoute() {
|
|
1395
1396
|
const { profiles, createProfile, updateProfile, deleteProfile } = useProfiles();
|
|
1396
1397
|
const { Backdrop, foreground, newProfileColor, usePickerAlign } = usePack();
|
|
1397
|
-
return /* @__PURE__ */ jsx16(
|
|
1398
|
+
return /* @__PURE__ */ jsx16(ScreenFrame2, { portalHost: true, maxContentWidth: ROSTER_MAX_WIDTH, children: /* @__PURE__ */ jsx16(ProfilesScreen, { profiles, defaultColor: newProfileColor ?? defaultColors3[0].value, onCreate: (patch) => createProfile(patch), onSave: (id, patch) => updateProfile(id, patch), onDelete: deleteProfile, onBack: safeBack, fg: foreground, bg: Backdrop ? "transparent" : void 0, useColorPickerAlign: usePickerAlign ? useRosterAlign : void 0 }) });
|
|
1398
1399
|
}
|
|
1399
1400
|
|
|
1400
1401
|
// src/screens/StatsScreen.tsx
|
|
1401
1402
|
import { useAutoPaperTheme as useAutoPaperTheme5 } from "@rific/auto-paper";
|
|
1402
|
-
import { BaseStatsScreen, PressAwayOverlay as PressAwayOverlay3,
|
|
1403
|
+
import { BaseStatsScreen, PressAwayOverlay as PressAwayOverlay3, ScreenFrame as ScreenFrame3, usePopoverHost as usePopoverHost3 } from "@tastic/hud/chrome";
|
|
1403
1404
|
import { getOptionPickerContentSize as getOptionPickerContentSize2, OptionPicker as OptionPicker2 } from "@tastic/profile";
|
|
1404
1405
|
import { useMemo as useMemo7, useState as useState7 } from "react";
|
|
1405
1406
|
import { StyleSheet as StyleSheet5, View as View5 } from "react-native";
|
|
@@ -1422,7 +1423,7 @@ var GAME_PICKER_ID = "stats-game";
|
|
|
1422
1423
|
var STATS_MAX_WIDTH = 640;
|
|
1423
1424
|
function StatsScreen() {
|
|
1424
1425
|
const pickerHost = usePopoverHost3();
|
|
1425
|
-
return /* @__PURE__ */ jsx17(StatsPressAway, { host: pickerHost, children: /* @__PURE__ */ jsx17(
|
|
1426
|
+
return /* @__PURE__ */ jsx17(StatsPressAway, { host: pickerHost, children: /* @__PURE__ */ jsx17(ScreenFrame3, { portalHost: true, maxContentWidth: STATS_MAX_WIDTH, children: /* @__PURE__ */ jsx17(StatsContent, { pickerHost }) }) });
|
|
1426
1427
|
}
|
|
1427
1428
|
function StatsPressAway({ host, children }) {
|
|
1428
1429
|
return /* @__PURE__ */ jsx17(View5, { testID: "stats-press-away", style: styles5.screen, onStartShouldSetResponder: () => host.openId !== null, onResponderRelease: host.close, children });
|
|
@@ -1459,7 +1460,7 @@ function StatsContent({ pickerHost }) {
|
|
|
1459
1460
|
const surface = pack.Backdrop ? { backgroundColor: colors.surface } : void 0;
|
|
1460
1461
|
const triggerStyle = pack.Backdrop ? [styles5.pill, surface] : void 0;
|
|
1461
1462
|
const PackTabContent = packTab?.Content;
|
|
1462
|
-
return /* @__PURE__ */ jsxs6(BaseStatsScreen, { title, onBack: safeBack, insets, onReset: reset.onReset, resetLabel: reset.label, resetConfirmTitle: reset.title, resetConfirmBody: reset.body, fg: pack.foreground, bg: pack.Backdrop ? "transparent" : void 0,
|
|
1463
|
+
return /* @__PURE__ */ jsxs6(BaseStatsScreen, { title, 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: [
|
|
1463
1464
|
/* @__PURE__ */ jsx17(PressAwayOverlay3, { active: pickerHost.openId !== null, onPress: pickerHost.close, style: styles5.pressAway }),
|
|
1464
1465
|
/* @__PURE__ */ jsx17(SegmentedButtons2, { value: tab, onValueChange: setTab, buttons: tabButtons, theme: SEGMENT_THEME, style: [styles5.tabs, surface] }),
|
|
1465
1466
|
/* @__PURE__ */ jsxs6(View5, { style: [styles5.filters, pickerHost.openId !== null && styles5.filtersOpen], onStartShouldSetResponder: () => pickerHost.openId !== null, children: [
|
|
@@ -1608,10 +1609,8 @@ import { FLUSH, PAUSE, PERSIST, persistReducer, persistStore, PURGE, REGISTER, R
|
|
|
1608
1609
|
// src/redux/shellState.ts
|
|
1609
1610
|
import { createThemeReducer, getThirdColor as getThirdColor2 } from "@rific/auto-paper";
|
|
1610
1611
|
import { keepAwakeReducer } from "@rific/core";
|
|
1611
|
-
import {
|
|
1612
|
+
import { hapticReducer, soundReducer } from "@rific/feedback-press";
|
|
1612
1613
|
import { profilesReducer } from "@tastic/profile";
|
|
1613
|
-
var initialSoundSettings = { ...defaultSoundSettings, enabled: !__DEV__ };
|
|
1614
|
-
var appSoundReducer = (state = initialSoundSettings, action) => soundReducer(state, action);
|
|
1615
1614
|
function createShellReducers({ seatColors, appearance = "system", seatTheme }) {
|
|
1616
1615
|
return {
|
|
1617
1616
|
// Explicit primary/secondary triad (rather than a single seed expanded via harmony) so the pack's
|
|
@@ -1625,7 +1624,9 @@ function createShellReducers({ seatColors, appearance = "system", seatTheme }) {
|
|
|
1625
1624
|
// only when the pack's appearance is; hooks/useSeatColors.ts re-applies it with the live mode).
|
|
1626
1625
|
theme: createThemeReducer(seatTheme ? { appearance, ...seatTheme(seatColors, appearance === "dark") } : { appearance, color: { primary: seatColors[1], secondary: seatColors[2], tertiary: getThirdColor2(seatColors[1], seatColors[2]) } }),
|
|
1627
1626
|
haptic: hapticReducer,
|
|
1628
|
-
|
|
1627
|
+
// Starts off in a development build (feedback-press's defaultSoundSettings is `!__DEV__`), so local
|
|
1628
|
+
// testing on a simulator is silent; a production build starts with sound on.
|
|
1629
|
+
sound: soundReducer,
|
|
1629
1630
|
// @rific/core's Keep Awake setting (see Providers.tsx's KeepAwakeBridge), under the namespace its
|
|
1630
1631
|
// REHYDRATE handling expects.
|
|
1631
1632
|
keepAwake: keepAwakeReducer,
|
|
@@ -1646,11 +1647,6 @@ function createShellReducers({ seatColors, appearance = "system", seatTheme }) {
|
|
|
1646
1647
|
}
|
|
1647
1648
|
|
|
1648
1649
|
// src/redux/createPackStore.ts
|
|
1649
|
-
var hasError = (action) => typeof action === "object" && action !== null && "error" in action && Boolean(action.error);
|
|
1650
|
-
var errorMiddleware = () => (next) => (action) => {
|
|
1651
|
-
if (!hasError(action)) return next(action);
|
|
1652
|
-
return action;
|
|
1653
|
-
};
|
|
1654
1650
|
function createPackStore(pack, { keyPrefix, migrate, blacklist = [], serializableIgnoredPaths = [], middleware = [] }) {
|
|
1655
1651
|
const gameReducers = Object.assign({}, ...pack.games.map((game) => game.reducers));
|
|
1656
1652
|
const resumeReducers = pack.games.some((game) => game.resumable) ? { lastActiveGame: lastActiveGameSlice_default } : {};
|
|
@@ -1683,7 +1679,7 @@ function createPackStore(pack, { keyPrefix, migrate, blacklist = [], serializabl
|
|
|
1683
1679
|
ignoredPaths: [...serializableIgnoredPaths]
|
|
1684
1680
|
}
|
|
1685
1681
|
});
|
|
1686
|
-
return defaultMiddleware.concat(
|
|
1682
|
+
return defaultMiddleware.concat(...middleware);
|
|
1687
1683
|
},
|
|
1688
1684
|
reducer: persistedReducer
|
|
1689
1685
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tastic/shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.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",
|
|
@@ -83,12 +83,12 @@
|
|
|
83
83
|
"@rific/splash-gate": "^0.2.3",
|
|
84
84
|
"@rific/toaster": "^0.12.0",
|
|
85
85
|
"@rific/updater": "^0.8.0",
|
|
86
|
-
"@tastic/achievements": "^0.6.
|
|
87
|
-
"@tastic/core": "^0.
|
|
88
|
-
"@tastic/edge-guard": "^0.2.
|
|
89
|
-
"@tastic/hud": "^0.
|
|
90
|
-
"@tastic/profile": "^0.
|
|
91
|
-
"@tastic/split-screen": "^0.
|
|
86
|
+
"@tastic/achievements": "^0.6.1",
|
|
87
|
+
"@tastic/core": "^0.17.0",
|
|
88
|
+
"@tastic/edge-guard": "^0.2.1",
|
|
89
|
+
"@tastic/hud": "^0.34.0",
|
|
90
|
+
"@tastic/profile": "^0.19.0",
|
|
91
|
+
"@tastic/split-screen": "^0.6.0",
|
|
92
92
|
"@testing-library/react-native": "^14.1.0",
|
|
93
93
|
"@types/jest": "30.0.0",
|
|
94
94
|
"@types/react": "~19.3.0",
|
|
@@ -138,9 +138,10 @@
|
|
|
138
138
|
"@tastic/achievements": ">=0.6.0",
|
|
139
139
|
"@tastic/core": ">=0.16.0",
|
|
140
140
|
"@tastic/edge-guard": ">=0.2.0",
|
|
141
|
-
"@tastic/hud": ">=0.
|
|
141
|
+
"@tastic/hud": ">=0.34.0",
|
|
142
142
|
"@tastic/profile": ">=0.18.0",
|
|
143
143
|
"@tastic/split-screen": ">=0.5.5",
|
|
144
|
+
"expo-audio": ">=58.0.11",
|
|
144
145
|
"expo-blur": ">=58.0.4",
|
|
145
146
|
"expo-constants": ">=58.0.12",
|
|
146
147
|
"expo-font": ">=58.0.8",
|
package/src/RootLayout.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { useHapticSettings } from '@rific/feedback-press'
|
|
|
3
3
|
import { Toaster, ToastProvider } from '@rific/toaster'
|
|
4
4
|
import { useThemedRootBackground } from '@tastic/core'
|
|
5
5
|
import { edgeGuardScreenOptions } from '@tastic/edge-guard'
|
|
6
|
-
import {
|
|
6
|
+
import { ScreenFrame } from '@tastic/hud/chrome'
|
|
7
7
|
import { ProfileColorProvider } from '@tastic/profile'
|
|
8
8
|
import * as Haptics from 'expo-haptics'
|
|
9
9
|
import { DarkTheme, DefaultTheme, Stack, ThemeProvider as NavigationThemeProvider } from 'expo-router'
|
|
@@ -152,28 +152,20 @@ function HapticGatedToastProvider({ children }: { children: ReactNode }) {
|
|
|
152
152
|
)
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
function
|
|
156
|
-
const renderFrame = useCallback(
|
|
157
|
-
(toasts: ReactNode) => (
|
|
158
|
-
<RotatedFrame rotatedSafeArea passThrough>
|
|
159
|
-
{toasts}
|
|
160
|
-
</RotatedFrame>
|
|
161
|
-
),
|
|
162
|
-
[]
|
|
163
|
-
)
|
|
155
|
+
function FramedToaster() {
|
|
156
|
+
const renderFrame = useCallback((toasts: ReactNode) => <ScreenFrame passThrough>{toasts}</ScreenFrame>, [])
|
|
164
157
|
return <Toaster historyButton={null} clearButton={null} limit={3} renderFrame={renderFrame} />
|
|
165
158
|
}
|
|
166
159
|
|
|
167
|
-
// The pack's own toaster (PackDefinition.Toaster), laid over the whole app in hud's
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
// the layout beside the stack.
|
|
160
|
+
// The pack's own toaster (PackDefinition.Toaster), laid over the whole app in hud's ScreenFrame:
|
|
161
|
+
// passThrough, so only a toast claims a touch over the stack. The absoluteFill wrapper takes the frame
|
|
162
|
+
// out of the layout beside the stack.
|
|
171
163
|
function PackToaster({ Toaster: PackToasterComponent }: { Toaster: NonNullable<PackDefinition['Toaster']> }) {
|
|
172
164
|
return (
|
|
173
165
|
<View style={StyleSheet.absoluteFill} pointerEvents='box-none'>
|
|
174
|
-
<
|
|
166
|
+
<ScreenFrame passThrough>
|
|
175
167
|
<PackToasterComponent />
|
|
176
|
-
</
|
|
168
|
+
</ScreenFrame>
|
|
177
169
|
</View>
|
|
178
170
|
)
|
|
179
171
|
}
|
|
@@ -234,7 +226,7 @@ export function RootLayout({ pack, store, persistor }: RootLayoutProps) {
|
|
|
234
226
|
{/* historyButton/clearButton off: there's no toast history to open, and a
|
|
235
227
|
control row for it above the toast stack would go nowhere. limit pins the
|
|
236
228
|
package's current default (3) so a future toaster release can't change it. */}
|
|
237
|
-
{pack.Toaster ? <PackToaster Toaster={pack.Toaster} /> : <
|
|
229
|
+
{pack.Toaster ? <PackToaster Toaster={pack.Toaster} /> : <FramedToaster />}
|
|
238
230
|
<UpdateDialog />
|
|
239
231
|
</HapticGatedToastProvider>
|
|
240
232
|
</GatedApp>
|
|
@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from 'react-redux'
|
|
|
4
4
|
import { type AppSettings, appSettingsActions } from '../redux/appSettingsSlice'
|
|
5
5
|
import type { ShellState } from '../redux/shellState'
|
|
6
6
|
|
|
7
|
-
// The one way the pack-wide settings are read and written (
|
|
7
|
+
// The one way the pack-wide settings are read and written (Edge Guard). Writes
|
|
8
8
|
// merge, so a patch only changes the fields it names.
|
|
9
9
|
export function useAppSettings(): { settings: AppSettings; setSettings: (patch: Partial<AppSettings>) => void } {
|
|
10
10
|
const settings = useSelector((state: ShellState) => state.appSettings)
|
|
@@ -6,13 +6,6 @@ import type { PackDefinition, PackGameDefinition } from '../types'
|
|
|
6
6
|
import lastActiveGame from './lastActiveGameSlice'
|
|
7
7
|
import { createShellReducers } from './shellState'
|
|
8
8
|
|
|
9
|
-
const hasError = (action: unknown): action is { error?: unknown } => typeof action === 'object' && action !== null && 'error' in action && Boolean(action.error)
|
|
10
|
-
|
|
11
|
-
const errorMiddleware: Middleware = () => (next) => (action) => {
|
|
12
|
-
if (!hasError(action)) return next(action)
|
|
13
|
-
return action
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
export interface PackStoreConfig {
|
|
17
10
|
// On web every Tastic app shares one origin (games.infinitetoken.com) and so one localStorage,
|
|
18
11
|
// where AsyncStorage keeps this state under keyPrefix + 'root': the default prefix would make every
|
|
@@ -76,7 +69,7 @@ export function createPackStore(pack: PackStoreSource, { keyPrefix, migrate, bla
|
|
|
76
69
|
ignoredPaths: [...serializableIgnoredPaths]
|
|
77
70
|
}
|
|
78
71
|
})
|
|
79
|
-
return defaultMiddleware.concat(
|
|
72
|
+
return defaultMiddleware.concat(...middleware)
|
|
80
73
|
},
|
|
81
74
|
reducer: persistedReducer
|
|
82
75
|
})
|
package/src/redux/shellState.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createThemeReducer, getThirdColor } from '@rific/auto-paper'
|
|
2
2
|
import { keepAwakeReducer } from '@rific/core'
|
|
3
|
-
import {
|
|
3
|
+
import { hapticReducer, soundReducer } from '@rific/feedback-press'
|
|
4
4
|
import { profilesReducer } from '@tastic/profile'
|
|
5
5
|
|
|
6
6
|
import type { PackDefinition } from '../types'
|
|
@@ -11,14 +11,6 @@ import opponent from './opponentSlice'
|
|
|
11
11
|
import profileSelection from './profileSelectionSlice'
|
|
12
12
|
import { createSeatColorsReducer } from './seatColorsSlice'
|
|
13
13
|
|
|
14
|
-
// @rific/feedback-press's own soundReducer defaults `enabled` to true unconditionally (that
|
|
15
|
-
// default isn't published with the dev-only override yet). Wrap it so a fresh install with no
|
|
16
|
-
// persisted preference (redux-persist finds nothing in AsyncStorage for the `sound` key) defaults
|
|
17
|
-
// muted in dev/simulator builds so Claude/local testing doesn't blast audio; production builds
|
|
18
|
-
// still default to sound on. All actual action handling still delegates to the package's reducer.
|
|
19
|
-
const initialSoundSettings: SoundSettings = { ...defaultSoundSettings, enabled: !__DEV__ }
|
|
20
|
-
const appSoundReducer = (state: SoundSettings = initialSoundSettings, action: { type: string }): SoundSettings => soundReducer(state, action)
|
|
21
|
-
|
|
22
14
|
// The store keys every pack has, whatever its games, built from the pack's own seat colors and
|
|
23
15
|
// appearance. Each game adds its own keys beside these (see GameDefinition.reducers).
|
|
24
16
|
export function createShellReducers({ seatColors, appearance = 'system', seatTheme }: Pick<PackDefinition, 'seatColors' | 'appearance' | 'seatTheme'>) {
|
|
@@ -34,7 +26,9 @@ export function createShellReducers({ seatColors, appearance = 'system', seatThe
|
|
|
34
26
|
// only when the pack's appearance is; hooks/useSeatColors.ts re-applies it with the live mode).
|
|
35
27
|
theme: createThemeReducer(seatTheme ? { appearance, ...seatTheme(seatColors, appearance === 'dark') } : { appearance, color: { primary: seatColors[1], secondary: seatColors[2], tertiary: getThirdColor(seatColors[1], seatColors[2]) } }),
|
|
36
28
|
haptic: hapticReducer,
|
|
37
|
-
|
|
29
|
+
// Starts off in a development build (feedback-press's defaultSoundSettings is `!__DEV__`), so local
|
|
30
|
+
// testing on a simulator is silent; a production build starts with sound on.
|
|
31
|
+
sound: soundReducer,
|
|
38
32
|
// @rific/core's Keep Awake setting (see Providers.tsx's KeepAwakeBridge), under the namespace its
|
|
39
33
|
// REHYDRATE handling expects.
|
|
40
34
|
keepAwake: keepAwakeReducer,
|
|
@@ -47,13 +47,14 @@ export function HomeScreen() {
|
|
|
47
47
|
useEffect(() => {
|
|
48
48
|
if (!resumeGame) autoShowPack()
|
|
49
49
|
}, [resumeGame, autoShowPack])
|
|
50
|
-
if (resumeGame) return <Redirect href={playHref(resumeGame.id)} />
|
|
50
|
+
if (resumeGame) return <Redirect href={pack.resumeHref?.(resumeGame.id) ?? playHref(resumeGame.id)} />
|
|
51
51
|
return <HomeMenu />
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function HomeMenu() {
|
|
55
55
|
const pack = usePack()
|
|
56
|
-
const
|
|
56
|
+
const showPicker = pack.homePlayerPicker !== false
|
|
57
|
+
const layout = useHomeLayout(showPicker)
|
|
57
58
|
const { insets } = layout
|
|
58
59
|
const { dark, colors } = useAutoPaperTheme()
|
|
59
60
|
const { openFirstTime, openFor, openPack } = useGameGuide()
|
|
@@ -136,6 +137,7 @@ function HomeMenu() {
|
|
|
136
137
|
const pickerSize = getProfilePickerContentSize(profiles.length, true, colorSection)
|
|
137
138
|
const pickerAlign = usePickerAlign(pickerHost.openId === `${SEAT_ONE_PICKER}-profile`, pickerSize.width, pickerSize.height)
|
|
138
139
|
|
|
140
|
+
// A pack can leave seat 1's button off Home (PackDefinition.homePlayerPicker)
|
|
139
141
|
const picker = <ProfilePicker idPrefix={SEAT_ONE_PICKER} host={pickerHost} profiles={profiles} selectedId={lastSelected[1]} color={p1Drawn} dark={dark} guestLabel={pack.guestLabel ?? 'P1'} nullLabel={pack.nullLabel} onSelect={(profile: Profile | null) => selectProfile(1, profile?.id ?? null)} onManage={() => router.push(PROFILES_HREF)} colorSection={colorSection} alignOverride={pickerAlign} triggerStyle={triggerStyle} />
|
|
140
142
|
|
|
141
143
|
// Closes seat 1's menu on a press anywhere but the menu and its button. Where it's mounted matters on
|
|
@@ -173,7 +175,7 @@ function HomeMenu() {
|
|
|
173
175
|
paints over the tiles. box-none: only its controls claim taps. */}
|
|
174
176
|
<View style={[styles.wideLeftPane, { left: layout.paddingLeft, width: layout.leftPaneWidth, paddingTop: HOME_TOP_BAND + insets.top, paddingBottom: 16 + insets.bottom }, pickerHost.openId !== null && styles.pickerOpen]}>
|
|
175
177
|
<pack.HeroTitle words={pack.wordmark} color={fg} p1Color={p1Color} p2Color={p2Color} active={heroActive} fit={layout.heroFit} />
|
|
176
|
-
<View style={styles.widePicker}>{picker}</View>
|
|
178
|
+
{showPicker && <View style={styles.widePicker}>{picker}</View>}
|
|
177
179
|
</View>
|
|
178
180
|
</>
|
|
179
181
|
) : (
|
|
@@ -183,7 +185,7 @@ function HomeMenu() {
|
|
|
183
185
|
|
|
184
186
|
{/* Who's playing: seat 1's button, the same one each loadout starts with. Lifted above the
|
|
185
187
|
tiles while its menu is open, so the menu paints over them. */}
|
|
186
|
-
<View style={[styles.picker, pickerHost.openId !== null && styles.pickerOpen]}>{picker}</View>
|
|
188
|
+
{showPicker && <View style={[styles.picker, pickerHost.openId !== null && styles.pickerOpen]}>{picker}</View>}
|
|
187
189
|
|
|
188
190
|
{tabBar && <View style={styles.listWidth}>{tabBar}</View>}
|
|
189
191
|
|
|
@@ -169,12 +169,40 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
169
169
|
const p1PickerOpen = controlsHost.openId?.startsWith('p1-') ?? false
|
|
170
170
|
const p1ControlOpen = controlsHost.openId === P1_CONTROL_ID
|
|
171
171
|
|
|
172
|
+
const controlLook = { accentColor: themeColors.tertiary, mutedColor: fgMuted, dark }
|
|
173
|
+
const p1Control = loadout.seatControl(1, controlsHost, { ...controlLook, seatColor: p1Drawn })
|
|
174
|
+
// Seat 1's button alone: player 1's controls and Ready sit under the row it shares with the
|
|
175
|
+
// opponent button, centered under both.
|
|
176
|
+
const p1Panel = <PlayerSetupPanel key={`p1-${layoutKey}`} idPrefix='p1' host={controlsHost} color={p1Color} onColorChange={handleP1ColorChange} swatches={defaultColors} takenColor={p2Exists ? p2Color : undefined} allowSwapTaken={mode === 'vsCpu'} colorCaption={pack.colorCaption} isHuman dark={dark} showReadyButton={false} profiles={profiles} selectedProfileId={lastSelected[1]} takenProfileId={p2IsHuman ? lastSelected[2] : null} guestLabel={pack.guestLabel ?? 'P1'} nullLabel={pack.nullLabel} onProfileSelect={handleP1ProfileSelect} onManageProfiles={() => router.push(PROFILES_HREF)} previewValue={seatPreview} triggerStyle={triggerStyle} useSeatPickerAlign={seatPickerAlign} />
|
|
177
|
+
// Who sits in seat 2, player 1's to pick in every mode. A game for one player (no seatTwo) has none:
|
|
178
|
+
// seat 1's button stands alone.
|
|
179
|
+
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
|
+
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }))
|
|
181
|
+
const seatButtons = (
|
|
182
|
+
<View style={[styles.seatOneButtons, p1PickerOpen && styles.raised]}>
|
|
183
|
+
<Animated.View style={[styles.playersRow, p1PickerOpen && styles.raised, !p2IsHuman && playersRowFade]}>
|
|
184
|
+
{p1Panel}
|
|
185
|
+
{opponentPicker}
|
|
186
|
+
</Animated.View>
|
|
187
|
+
{p1Control && <View style={[styles.controlRow, p1ControlOpen && styles.raised]}>{p1Control}</View>}
|
|
188
|
+
</View>
|
|
189
|
+
)
|
|
190
|
+
// With one person a game can place the seat buttons among its own options (GameLoadout.placesSeats).
|
|
191
|
+
const seatsInOptions = !p2IsHuman && !!loadout.placesSeats
|
|
192
|
+
const seatOne = (
|
|
193
|
+
<View style={[styles.seatOne, !p2IsHuman && styles.seatOneAlone, p1PickerOpen && !seatsInOptions && styles.raised]}>
|
|
194
|
+
{!seatsInOptions && seatButtons}
|
|
195
|
+
<ReadyButton color={p1Drawn} ready={ready[1]} onToggleReady={toggleP1Ready} surfaceColor={readySurface} dark={dark} style={!p2IsHuman && p1PickerOpen && styles.readyButtonHidden} />
|
|
196
|
+
</View>
|
|
197
|
+
)
|
|
198
|
+
|
|
172
199
|
const optionsRow = loadout.options({
|
|
173
200
|
host: controlsHost,
|
|
174
201
|
accentColor: themeColors.tertiary,
|
|
175
202
|
mutedColor: fgMuted,
|
|
176
203
|
onAccentColor: themeColors.onTertiary,
|
|
177
204
|
dark,
|
|
205
|
+
seats: seatsInOptions ? seatButtons : undefined,
|
|
178
206
|
// Left out (the row's own actions unrendered) whenever the shared band below carries them.
|
|
179
207
|
onRandomize: showMetaInSharedBand ? undefined : loadout.randomize,
|
|
180
208
|
onReset: showMetaInSharedBand ? undefined : loadout.reset
|
|
@@ -189,27 +217,6 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
189
217
|
optionsRow
|
|
190
218
|
)
|
|
191
219
|
|
|
192
|
-
const controlLook = { accentColor: themeColors.tertiary, mutedColor: fgMuted, dark }
|
|
193
|
-
const p1Control = loadout.seatControl(1, controlsHost, { ...controlLook, seatColor: p1Drawn })
|
|
194
|
-
// Seat 1's button alone: player 1's controls and Ready sit under the row it shares with the
|
|
195
|
-
// opponent button, centered under both.
|
|
196
|
-
const p1Panel = <PlayerSetupPanel key={`p1-${layoutKey}`} idPrefix='p1' host={controlsHost} color={p1Color} onColorChange={handleP1ColorChange} swatches={defaultColors} takenColor={p2Exists ? p2Color : undefined} allowSwapTaken={mode === 'vsCpu'} colorCaption={pack.colorCaption} isHuman dark={dark} showReadyButton={false} profiles={profiles} selectedProfileId={lastSelected[1]} takenProfileId={p2IsHuman ? lastSelected[2] : null} guestLabel={pack.guestLabel ?? 'P1'} nullLabel={pack.nullLabel} onProfileSelect={handleP1ProfileSelect} onManageProfiles={() => router.push(PROFILES_HREF)} previewValue={seatPreview} triggerStyle={triggerStyle} useSeatPickerAlign={seatPickerAlign} />
|
|
197
|
-
// Who sits in seat 2, player 1's to pick in every mode. A game for one player (no seatTwo) has none:
|
|
198
|
-
// seat 1's button stands alone.
|
|
199
|
-
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} />
|
|
200
|
-
const toggleP1Ready = () => setReady((r) => ({ ...r, 1: !r[1] }))
|
|
201
|
-
const seatOne = (
|
|
202
|
-
<View style={[styles.seatOne, !p2IsHuman && styles.seatOneAlone, p1PickerOpen && styles.raised]}>
|
|
203
|
-
<View style={[styles.seatOneButtons, p1PickerOpen && styles.raised]}>
|
|
204
|
-
<Animated.View style={[styles.playersRow, p1PickerOpen && styles.raised, !p2IsHuman && playersRowFade]}>
|
|
205
|
-
{p1Panel}
|
|
206
|
-
{opponentPicker}
|
|
207
|
-
</Animated.View>
|
|
208
|
-
{p1Control && <View style={[styles.controlRow, p1ControlOpen && styles.raised]}>{p1Control}</View>}
|
|
209
|
-
</View>
|
|
210
|
-
<ReadyButton color={p1Drawn} ready={ready[1]} onToggleReady={toggleP1Ready} surfaceColor={readySurface} dark={dark} style={!p2IsHuman && p1PickerOpen && styles.readyButtonHidden} />
|
|
211
|
-
</View>
|
|
212
|
-
)
|
|
213
220
|
// A person in seat 2: their own seat button (Player 2 or a profile, never the CPU), controls and
|
|
214
221
|
// Ready, in their half.
|
|
215
222
|
const p2Control = p2IsHuman ? loadout.seatControl(2, p2Host, { ...controlLook, seatColor: p2Drawn }) : undefined
|
|
@@ -243,7 +250,8 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
243
250
|
/>
|
|
244
251
|
) : (
|
|
245
252
|
<View style={styles.stackedZone}>
|
|
246
|
-
{
|
|
253
|
+
{/* A menu opening from seat buttons placed in the options has to clear Ready, the next sibling */}
|
|
254
|
+
{seatsInOptions ? <View style={p1PickerOpen && styles.raised}>{sharedControls}</View> : sharedControls}
|
|
247
255
|
{seatOne}
|
|
248
256
|
</View>
|
|
249
257
|
)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultColors } from '@rific/auto-paper'
|
|
2
|
-
import { type AlignResult,
|
|
2
|
+
import { type AlignResult, ScreenFrame } from '@tastic/hud/chrome'
|
|
3
3
|
import { ProfilesScreen } from '@tastic/profile'
|
|
4
4
|
|
|
5
5
|
import { useProfiles } from '../hooks/useProfiles'
|
|
@@ -14,10 +14,9 @@ const ROSTER_MAX_WIDTH = 640
|
|
|
14
14
|
// stats and achievements in every game: each game's reducers listen for the removal (see
|
|
15
15
|
// onProfileRemoved.ts).
|
|
16
16
|
//
|
|
17
|
-
// In hud's
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// the wide layout. Over a
|
|
17
|
+
// In hud's ScreenFrame: ProfilesManager reads the safe-area insets itself (the header's padding); its
|
|
18
|
+
// delete confirm is a Paper Portal, which lands in a host inside the frame (portalHost); and the roster's
|
|
19
|
+
// column is capped in the wide layout. Over a
|
|
21
20
|
// pack's Backdrop the screen is transparent, drawn in the pack's foreground.
|
|
22
21
|
// The pack's own placement for a profile's color swatch (PackDefinition.usePickerAlign), kept inside the
|
|
23
22
|
// roster's capped column: the roster scrolls in it, which clips the menu at its edges. Handed to
|
|
@@ -32,8 +31,8 @@ export function ProfilesRoute() {
|
|
|
32
31
|
const { Backdrop, foreground, newProfileColor, usePickerAlign } = usePack()
|
|
33
32
|
|
|
34
33
|
return (
|
|
35
|
-
<
|
|
34
|
+
<ScreenFrame portalHost maxContentWidth={ROSTER_MAX_WIDTH}>
|
|
36
35
|
<ProfilesScreen profiles={profiles} defaultColor={newProfileColor ?? defaultColors[0].value} onCreate={(patch) => createProfile(patch)} onSave={(id, patch) => updateProfile(id, patch)} onDelete={deleteProfile} onBack={safeBack} fg={foreground} bg={Backdrop ? 'transparent' : undefined} useColorPickerAlign={usePickerAlign ? useRosterAlign : undefined} />
|
|
37
|
-
</
|
|
36
|
+
</ScreenFrame>
|
|
38
37
|
)
|
|
39
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAutoPaperTheme } from '@rific/auto-paper'
|
|
2
|
-
import { BaseStatsScreen, type PopoverHost, PressAwayOverlay,
|
|
2
|
+
import { BaseStatsScreen, type PopoverHost, PressAwayOverlay, ScreenFrame, usePopoverHost } from '@tastic/hud/chrome'
|
|
3
3
|
import { getOptionPickerContentSize, OptionPicker, type OptionPickerOption } from '@tastic/profile'
|
|
4
4
|
import { type ReactNode, useMemo, useState } from 'react'
|
|
5
5
|
import { StyleSheet, View } from 'react-native'
|
|
@@ -50,15 +50,15 @@ const STATS_MAX_WIDTH = 640
|
|
|
50
50
|
// can't be told apart. A pack for one player at a time (PackDefinition.guestStats) keeps a guest's
|
|
51
51
|
// stats under GUEST_PLAYER_ID, offers Guest in the picker and opens on whoever is in seat 1.
|
|
52
52
|
//
|
|
53
|
-
// In hud's
|
|
54
|
-
//
|
|
53
|
+
// In hud's ScreenFrame: it hosts the reset confirm's portal inside the frame, and caps the column in the
|
|
54
|
+
// wide layout.
|
|
55
55
|
export function StatsScreen() {
|
|
56
56
|
const pickerHost = usePopoverHost()
|
|
57
57
|
return (
|
|
58
58
|
<StatsPressAway host={pickerHost}>
|
|
59
|
-
<
|
|
59
|
+
<ScreenFrame portalHost maxContentWidth={STATS_MAX_WIDTH}>
|
|
60
60
|
<StatsContent pickerHost={pickerHost} />
|
|
61
|
-
</
|
|
61
|
+
</ScreenFrame>
|
|
62
62
|
</StatsPressAway>
|
|
63
63
|
)
|
|
64
64
|
}
|
|
@@ -85,7 +85,6 @@ const noPickerAlign = () => undefined
|
|
|
85
85
|
function StatsContent({ pickerHost }: { pickerHost: PopoverHost }) {
|
|
86
86
|
const pack = usePack()
|
|
87
87
|
const { dark, colors } = useAutoPaperTheme()
|
|
88
|
-
// Handed over by RotatedFrame's rotatedSafeArea.
|
|
89
88
|
const insets = useSafeAreaInsets()
|
|
90
89
|
const { profiles, lastSelected } = useProfiles()
|
|
91
90
|
const dispatch = useDispatch()
|
|
@@ -130,7 +129,7 @@ function StatsContent({ pickerHost }: { pickerHost: PopoverHost }) {
|
|
|
130
129
|
const PackTabContent = packTab?.Content
|
|
131
130
|
|
|
132
131
|
return (
|
|
133
|
-
<BaseStatsScreen title={title} onBack={safeBack} insets={insets} onReset={reset.onReset} resetLabel={reset.label} resetConfirmTitle={reset.title} resetConfirmBody={reset.body} fg={pack.foreground} bg={pack.Backdrop ? 'transparent' : undefined}
|
|
132
|
+
<BaseStatsScreen title={title} onBack={safeBack} insets={insets} onReset={reset.onReset} resetLabel={reset.label} resetConfirmTitle={reset.title} resetConfirmBody={reset.body} fg={pack.foreground} bg={pack.Backdrop ? 'transparent' : undefined}>
|
|
134
133
|
{/* Inside the page, not before it: BaseStatsScreen paints an opaque full-screen container that
|
|
135
134
|
would hide a tap catcher placed underneath it. Over the stat sections and under the open
|
|
136
135
|
filters (pressAway's zIndex sits below filtersOpen's), so a tap anywhere on the page but a
|