@tastic/shell 0.14.0 → 0.16.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 +13 -9
- package/dist/index.d.mts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.js +197 -177
- package/dist/index.mjs +129 -110
- package/package.json +5 -5
- package/src/RootLayout.tsx +1 -1
- package/src/components/SettingsDialog.tsx +13 -2
- package/src/index.ts +1 -0
- package/src/routes.ts +3 -1
- package/src/screens/EditProfileRoute.tsx +31 -0
- package/src/screens/HomeScreen.tsx +1 -1
- package/src/screens/LoadoutScreen.tsx +1 -1
- package/src/screens/ProfilesRoute.tsx +16 -24
- package/src/types.ts +13 -8
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { useUpdateErrorToast } from '@rific/toaster'
|
|
2
2
|
import { BaseSettingsDialog } from '@tastic/hud/chrome'
|
|
3
|
+
import { router } from 'expo-router'
|
|
3
4
|
import type { ReactNode } from 'react'
|
|
4
5
|
|
|
5
6
|
import { useAppSettings } from '../hooks/useAppSettings'
|
|
7
|
+
import { useProfiles } from '../hooks/useProfiles'
|
|
6
8
|
import { usePack } from '../PackContext'
|
|
9
|
+
import { profileHref, PROFILES_HREF } from '../routes'
|
|
7
10
|
|
|
8
11
|
export interface SettingsDialogProps {
|
|
9
12
|
visible: boolean
|
|
@@ -12,6 +15,11 @@ export interface SettingsDialogProps {
|
|
|
12
15
|
// Left out on Home, where each tile's rules button does it, and in a match, where opening
|
|
13
16
|
// Settings pauses play.
|
|
14
17
|
onShowHowToPlay?: () => void
|
|
18
|
+
// Shows the Profile row: seat 1's profile, "Profile" over its name, opening its Edit Profile screen, or Profiles (the roster)
|
|
19
|
+
// while seat 1 is Guest (Jay, 2026-11-20: straight to your own profile, especially for someone with just the one; adding a second
|
|
20
|
+
// stays a seat picker's Manage away). Home and a loadout pass it; a play screen leaves it off, as How to Play, since leaving a game
|
|
21
|
+
// in play for another screen would keep its clock running.
|
|
22
|
+
showProfile?: boolean
|
|
15
23
|
// A play screen's own rows (a game's rule variants, where it has no loadout to set them in, see
|
|
16
24
|
// GameDefinition.useLoadout), above the pack's own sections.
|
|
17
25
|
children?: ReactNode
|
|
@@ -26,16 +34,19 @@ const noSettingsRules = () => null
|
|
|
26
34
|
// under them, a play screen's own rows and then the pack's own sections
|
|
27
35
|
// (PackDefinition.SettingsSections), in every Settings dialog the pack opens. A pack with edgeGuard
|
|
28
36
|
// false gets no Edge Guard row: hud draws it on iOS whenever its props are passed.
|
|
29
|
-
export function SettingsDialog({ visible, onDismiss, onShowHowToPlay, children }: SettingsDialogProps) {
|
|
37
|
+
export function SettingsDialog({ visible, onDismiss, onShowHowToPlay, showProfile = false, children }: SettingsDialogProps) {
|
|
30
38
|
const onUpdateError = useUpdateErrorToast()
|
|
31
39
|
const { settings, setSettings } = useAppSettings()
|
|
32
40
|
// The pack's otaVersion (src/constants/release.ts, which the OTA tooling bumps).
|
|
33
41
|
const { otaVersion, SettingsSections, edgeGuard = true, useSettingsRules = noSettingsRules } = usePack()
|
|
34
42
|
const rules = useSettingsRules()
|
|
43
|
+
const { profiles, lastSelected } = useProfiles()
|
|
44
|
+
const seatOne = profiles.find((profile) => profile.id === lastSelected[1]) ?? null
|
|
45
|
+
const profileRow = showProfile ? (seatOne ? { onShowProfiles: () => router.push(profileHref(seatOne.id)), profilesRow: { label: 'Profile', caption: seatOne.name, icon: 'account-outline' } } : { onShowProfiles: () => router.push(PROFILES_HREF) }) : {}
|
|
35
46
|
const edgeGuardProps = edgeGuard ? { deferBottomEdgeGestures: settings.deferBottomEdgeGestures, onDeferBottomEdgeGestures: (value: boolean) => setSettings({ deferBottomEdgeGestures: value }) } : {}
|
|
36
47
|
|
|
37
48
|
return (
|
|
38
|
-
<BaseSettingsDialog visible={visible} onDismiss={onDismiss} version={otaVersion} {...edgeGuardProps} onUpdateError={onUpdateError} onShowHowToPlay={onShowHowToPlay} leading={rules}>
|
|
49
|
+
<BaseSettingsDialog visible={visible} onDismiss={onDismiss} version={otaVersion} {...edgeGuardProps} onUpdateError={onUpdateError} onShowHowToPlay={onShowHowToPlay} {...profileRow} leading={rules}>
|
|
39
50
|
{children}
|
|
40
51
|
{SettingsSections && <SettingsSections />}
|
|
41
52
|
</BaseSettingsDialog>
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { RootLayout } from './RootLayout'
|
|
|
5
5
|
export { type FeedbackSounds, type GameDefinition, type GameGuide, type GameIconProps, type GameLoadout, type GamePreviewProps, type GameRulesProps, GUEST_PLAYER_ID, type GuidelessGameDefinition, type HeroTitleProps, type HomeTab, humanSeatsFor, type LoadoutOptionsProps, type PackDefinition, type PackGameDefinition, type PackGuide, type PackStatsReset, type PackStatsSectionsProps, type PackStatsTab, type PickerAlign, type RoundMode, roundModeFor, type Seat, type SeatControlLook, type SeatTwo, seatTwoFor, type StackScreenOptions } from './types'
|
|
6
6
|
|
|
7
7
|
// The screens behind an app's routes (src/app/ stays in the app: expo-router only reads routes there).
|
|
8
|
+
export { EditProfileRoute } from './screens/EditProfileRoute'
|
|
8
9
|
export { LoadoutRoute, PlayRoute } from './screens/GameRoute'
|
|
9
10
|
export { HomeScreen } from './screens/HomeScreen'
|
|
10
11
|
// The shape of the box a game's Preview draws in on Home (width / height).
|
package/src/routes.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Href } from 'expo-router'
|
|
2
2
|
|
|
3
3
|
// The shell's own routes, the ones every pack's src/app/ has (play/[game], loadout/[game], stats,
|
|
4
|
-
// profiles). An app with expo-router's typed routes type-checks this source against its own route tree
|
|
4
|
+
// profiles, profile/[id]). An app with expo-router's typed routes type-checks this source against its own route tree
|
|
5
5
|
// (its tsc reads the package's src/), and an app moving onto the shell (Solitaire) has these routes only
|
|
6
6
|
// part of the way through. So they're handed to expo-router as plain Hrefs, not checked against it.
|
|
7
7
|
export const playHref = (game: string) => ({ pathname: '/play/[game]', params: { game } }) as unknown as Href
|
|
8
8
|
export const loadoutHref = (game: string) => ({ pathname: '/loadout/[game]', params: { game } }) as unknown as Href
|
|
9
9
|
export const STATS_HREF = '/stats' as unknown as Href
|
|
10
10
|
export const PROFILES_HREF = '/profiles' as unknown as Href
|
|
11
|
+
// One profile's Edit Profile screen: a profile's id, or @tastic/profile's NEW_PROFILE_ID ('new') for New Profile.
|
|
12
|
+
export const profileHref = (id: string) => ({ pathname: '/profile/[id]', params: { id } }) as unknown as Href
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defaultColors } from '@rific/auto-paper'
|
|
2
|
+
import { ScreenFrame } from '@tastic/hud/chrome'
|
|
3
|
+
import { EditProfileScreen } from '@tastic/profile'
|
|
4
|
+
import { useLocalSearchParams } from 'expo-router'
|
|
5
|
+
|
|
6
|
+
import { useProfiles } from '../hooks/useProfiles'
|
|
7
|
+
import { safeBack } from '../navigation'
|
|
8
|
+
import { usePack } from '../PackContext'
|
|
9
|
+
import { ROSTER_MAX_WIDTH } from './ProfilesRoute'
|
|
10
|
+
|
|
11
|
+
// One profile's Edit Profile screen (@tastic/profile's EditProfileScreen), the pack's profile/[id]
|
|
12
|
+
// route, pushed from Profiles with the profile's id or 'new'. The back arrow, Done, a swipe back and a
|
|
13
|
+
// back button all save. Deleting a profile also removes its stats and achievements in every game: each
|
|
14
|
+
// game's reducers listen for the removal (see onProfileRemoved.ts).
|
|
15
|
+
//
|
|
16
|
+
// In hud's ScreenFrame, as Profiles: the delete confirm is a Paper Portal, which lands in a host inside
|
|
17
|
+
// the frame (portalHost), and the column is capped in the wide layout. A new profile starts on the
|
|
18
|
+
// pack's newProfileColor, or auto-paper's first swatch. Over a pack's Backdrop the screen is
|
|
19
|
+
// transparent, drawn in the pack's foreground. A saved profile's screen also draws the pack's own
|
|
20
|
+
// ProfileSections (its online play's, say) under Color.
|
|
21
|
+
export function EditProfileRoute() {
|
|
22
|
+
const { id } = useLocalSearchParams<{ id: string }>()
|
|
23
|
+
const { profiles, createProfile, updateProfile, deleteProfile } = useProfiles()
|
|
24
|
+
const { Backdrop, foreground, newProfileColor, ProfileSections } = usePack()
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<ScreenFrame portalHost maxContentWidth={ROSTER_MAX_WIDTH}>
|
|
28
|
+
<EditProfileScreen profileId={id} profiles={profiles} defaultColor={newProfileColor ?? defaultColors[0].value} onCreate={(patch) => createProfile(patch)} onSave={(profileId, patch) => updateProfile(profileId, patch)} onDelete={deleteProfile} onBack={safeBack} fg={foreground} bg={Backdrop ? 'transparent' : undefined} sections={ProfileSections ? (profile) => <ProfileSections profile={profile} /> : undefined} />
|
|
29
|
+
</ScreenFrame>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -205,7 +205,7 @@ function HomeMenu() {
|
|
|
205
205
|
|
|
206
206
|
{/* Home's How to Play row replays the pack's own cards (PackDefinition.guide); without them each
|
|
207
207
|
tile's rules button shows its game's. */}
|
|
208
|
-
<SettingsDialog visible={settingsOpen} onDismiss={() => setSettingsOpen(false)} onShowHowToPlay={pack.guide ? openPack : undefined} />
|
|
208
|
+
<SettingsDialog visible={settingsOpen} onDismiss={() => setSettingsOpen(false)} onShowHowToPlay={pack.guide ? openPack : undefined} showProfile />
|
|
209
209
|
</View>
|
|
210
210
|
)
|
|
211
211
|
}
|
|
@@ -257,7 +257,7 @@ export function LoadoutScreen({ game }: { game: LoadoutGame }) {
|
|
|
257
257
|
)}
|
|
258
258
|
</View>
|
|
259
259
|
|
|
260
|
-
<SettingsDialog visible={settingsOpen} onDismiss={() => setSettingsOpen(false)} onShowHowToPlay={() => openFor(game.id)} />
|
|
260
|
+
<SettingsDialog visible={settingsOpen} onDismiss={() => setSettingsOpen(false)} onShowHowToPlay={() => openFor(game.id)} showProfile />
|
|
261
261
|
</View>
|
|
262
262
|
)
|
|
263
263
|
}
|
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type AlignResult, ScreenFrame } from '@tastic/hud/chrome'
|
|
1
|
+
import { ScreenFrame } from '@tastic/hud/chrome'
|
|
3
2
|
import { ProfilesScreen } from '@tastic/profile'
|
|
3
|
+
import { router } from 'expo-router'
|
|
4
4
|
|
|
5
5
|
import { useProfiles } from '../hooks/useProfiles'
|
|
6
6
|
import { safeBack } from '../navigation'
|
|
7
7
|
import { usePack } from '../PackContext'
|
|
8
|
+
import { profileHref } from '../routes'
|
|
8
9
|
|
|
9
|
-
// Widest the roster
|
|
10
|
-
// never capped.
|
|
11
|
-
const ROSTER_MAX_WIDTH = 640
|
|
10
|
+
// Widest the roster and a profile's screen get in the wide layout (a landscape phone, a desktop
|
|
11
|
+
// window). Upright they're never capped.
|
|
12
|
+
export const ROSTER_MAX_WIDTH = 640
|
|
12
13
|
|
|
13
|
-
// The Profiles screen (Manage, from either seat 1 button).
|
|
14
|
-
//
|
|
15
|
-
//
|
|
14
|
+
// The Profiles screen (Manage, from either seat 1 button): @tastic/profile's roster. A profile opens
|
|
15
|
+
// its own Edit Profile screen, the pack's profile/[id] route (EditProfileRoute), where profiles are
|
|
16
|
+
// made, saved and deleted.
|
|
16
17
|
//
|
|
17
|
-
// In hud's ScreenFrame: ProfilesManager reads the safe-area insets itself (the header's padding)
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// pack's Backdrop the screen is transparent, drawn in the pack's foreground.
|
|
21
|
-
// The pack's own placement for a profile's color swatch (PackDefinition.usePickerAlign), kept inside the
|
|
22
|
-
// roster's capped column: the roster scrolls in it, which clips the menu at its edges. Handed to
|
|
23
|
-
// ProfilesScreen only where the pack has one.
|
|
24
|
-
function useRosterAlign(open: boolean, contentWidth: number, contentHeight: number): AlignResult {
|
|
25
|
-
const { usePickerAlign } = usePack()
|
|
26
|
-
return usePickerAlign!(open, contentWidth, contentHeight, { maxContentWidth: ROSTER_MAX_WIDTH })
|
|
27
|
-
}
|
|
28
|
-
|
|
18
|
+
// In hud's ScreenFrame: ProfilesManager reads the safe-area insets itself (the header's padding), and
|
|
19
|
+
// the roster's column is capped in the wide layout. Over a pack's Backdrop the screen is transparent,
|
|
20
|
+
// drawn in the pack's foreground.
|
|
29
21
|
export function ProfilesRoute() {
|
|
30
|
-
const { profiles
|
|
31
|
-
const { Backdrop, foreground
|
|
22
|
+
const { profiles } = useProfiles()
|
|
23
|
+
const { Backdrop, foreground } = usePack()
|
|
32
24
|
|
|
33
25
|
return (
|
|
34
|
-
<ScreenFrame
|
|
35
|
-
<ProfilesScreen profiles={profiles}
|
|
26
|
+
<ScreenFrame maxContentWidth={ROSTER_MAX_WIDTH}>
|
|
27
|
+
<ProfilesScreen profiles={profiles} onEdit={(id) => router.push(profileHref(id))} onBack={safeBack} fg={foreground} bg={Backdrop ? 'transparent' : undefined} />
|
|
36
28
|
</ScreenFrame>
|
|
37
29
|
)
|
|
38
30
|
}
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ThemeAppearance, ThemeSettings } from '@rific/auto-paper'
|
|
|
2
2
|
import type { AlignResult, PopoverHost } from '@tastic/hud/chrome'
|
|
3
3
|
import type { GuideStep } from '@tastic/hud/guide'
|
|
4
4
|
import type { MenuOption } from '@tastic/hud/lobby'
|
|
5
|
+
import type { Profile } from '@tastic/profile'
|
|
5
6
|
import type { FontSource } from 'expo-font'
|
|
6
7
|
import type { Href, Stack } from 'expo-router'
|
|
7
8
|
import type { ComponentProps, ComponentType, ReactNode } from 'react'
|
|
@@ -384,17 +385,21 @@ export interface PackDefinition {
|
|
|
384
385
|
resetStats?: PackStatsReset
|
|
385
386
|
// false leaves out each game's name over its sections on All Games, where its sections name it.
|
|
386
387
|
statsGameTitles?: boolean
|
|
387
|
-
// A new profile's starting color on
|
|
388
|
+
// A new profile's starting color on its Edit Profile screen. Unset is auto-paper's first swatch.
|
|
388
389
|
newProfileColor?: string
|
|
390
|
+
// The pack's own sections on a saved profile's Edit Profile screen (EditProfileRoute), under Color and above Delete Profile: its
|
|
391
|
+
// online play's, say (@tastic/profile/online's ProfileOnlineSection), which is where a profile's online life lives (Jay,
|
|
392
|
+
// 2026-11-20). Drawn in the screen's own colors (@tastic/profile's EditProfileSection and EditProfileRow).
|
|
393
|
+
ProfileSections?: ComponentType<{ profile: Profile }>
|
|
389
394
|
// Where a picker's menu opens (its alignOverride) on Home (seat 1's button), a loadout's one-human row
|
|
390
|
-
// (both seat buttons; 2 Player keeps each menu in its own player's half)
|
|
391
|
-
// pickers)
|
|
392
|
-
//
|
|
393
|
-
//
|
|
394
|
-
//
|
|
395
|
-
//
|
|
395
|
+
// (both seat buttons; 2 Player keeps each menu in its own player's half) and the stats screen (its two
|
|
396
|
+
// pickers). It was added because hud's own placement measured a button in a frame turned by
|
|
397
|
+
// @tastic/core's drawn rotation against the upright window; nothing turns since core 0.15, so a pack
|
|
398
|
+
// may no longer need one. (Profiles' color swatch used it too, with a capped column's width, until a
|
|
399
|
+
// profile got its own Edit Profile screen with the swatches on it, 2026-11-20.)
|
|
400
|
+
// `open` is whether this picker's menu is open, and the size is its content's. Unset is hud's own placement.
|
|
396
401
|
usePickerAlign?: PickerAlign
|
|
397
402
|
}
|
|
398
403
|
|
|
399
404
|
// What PackDefinition.usePickerAlign is: a hook, called on every render of the screen it serves.
|
|
400
|
-
export type PickerAlign = (open: boolean, contentWidth: number, contentHeight: number
|
|
405
|
+
export type PickerAlign = (open: boolean, contentWidth: number, contentHeight: number) => AlignResult
|