@adelin-io/cli 0.0.0-stage → 0.1.1

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.
Files changed (175) hide show
  1. package/README.md +76 -2
  2. package/authoring-release.json +174 -0
  3. package/package.json +30 -4
  4. package/runtime-integrity.json +9 -0
  5. package/scripts/adelin.mjs +7768 -0
  6. package/scripts/assemble-checkout.mjs +93 -0
  7. package/scripts/local-save.mjs +513 -0
  8. package/scripts/materialize.mjs +319 -0
  9. package/scripts/runtime.mjs +8950 -0
  10. package/scripts/typecheck.mjs +72 -0
  11. package/scripts/workspace-state.mjs +183 -0
  12. package/skill/README.md +77 -0
  13. package/skill/SKILL.md +100 -0
  14. package/skill/authoring/access.md +193 -0
  15. package/skill/authoring/analytics.md +20 -0
  16. package/skill/authoring/app-memory.md +128 -0
  17. package/skill/authoring/app-requirements.md +99 -0
  18. package/skill/authoring/app-structure.md +265 -0
  19. package/skill/authoring/assets.md +117 -0
  20. package/skill/authoring/auth.md +263 -0
  21. package/skill/authoring/content-binding.md +26 -0
  22. package/skill/authoring/i18n.md +184 -0
  23. package/skill/authoring/language.md +503 -0
  24. package/skill/authoring/local-workflow.md +1667 -0
  25. package/skill/authoring/offline/connectivity.md +50 -0
  26. package/skill/authoring/offline/example.md +102 -0
  27. package/skill/authoring/offline/history-sync.md +39 -0
  28. package/skill/authoring/offline/index.md +29 -0
  29. package/skill/authoring/offline/package-storage.md +37 -0
  30. package/skill/authoring/offline/platforms.md +35 -0
  31. package/skill/authoring/offline/startup-navigation.md +53 -0
  32. package/skill/authoring/platform-files.md +616 -0
  33. package/skill/authoring/player/casting.md +47 -0
  34. package/skill/authoring/player/controls.md +95 -0
  35. package/skill/authoring/player/downloads.md +90 -0
  36. package/skill/authoring/player/drm.md +31 -0
  37. package/skill/authoring/player/index.md +39 -0
  38. package/skill/authoring/player/live-dvr.md +74 -0
  39. package/skill/authoring/player/platforms.md +47 -0
  40. package/skill/authoring/player/playback.md +43 -0
  41. package/skill/authoring/player/tracks-subtitles.md +32 -0
  42. package/skill/authoring/profiles.md +213 -0
  43. package/skill/authoring/remote-keys.md +139 -0
  44. package/skill/authoring/search.md +27 -0
  45. package/skill/authoring/store.md +85 -0
  46. package/skill/authoring/tv-text-entry.md +146 -0
  47. package/skill/design/approved/README.md +14 -0
  48. package/skill/design/approved/vesper-phone-home.jpg +0 -0
  49. package/skill/design/approved/vesper-tv-detail.jpg +0 -0
  50. package/skill/design/approved/vesper-tv-home.jpg +0 -0
  51. package/skill/design/design-guide.md +610 -0
  52. package/skill/design/edge-to-edge.md +66 -0
  53. package/skill/design/icons.md +50 -0
  54. package/skill/design/responsive-layout.md +175 -0
  55. package/skill/design/safe-area.md +221 -0
  56. package/skill/design/streaming-playbook.md +131 -0
  57. package/skill/design/visual-review.md +150 -0
  58. package/skill/examples/README.md +24 -0
  59. package/skill/examples/cinema/DESIGN.md +58 -0
  60. package/skill/examples/cinema/app.tsx +17 -0
  61. package/skill/examples/cinema/assets/logo.png +0 -0
  62. package/skill/examples/cinema/components/Action.tsx +40 -0
  63. package/skill/examples/cinema/components/Action.tv.tsx +44 -0
  64. package/skill/examples/cinema/components/CatalogGrid.tsx +31 -0
  65. package/skill/examples/cinema/components/ContinueRail.tsx +98 -0
  66. package/skill/examples/cinema/components/Feedback.tsx +28 -0
  67. package/skill/examples/cinema/components/Field.tsx +41 -0
  68. package/skill/examples/cinema/components/LibraryRail.tsx +46 -0
  69. package/skill/examples/cinema/components/PlayAction.tsx +29 -0
  70. package/skill/examples/cinema/components/Root.tsx +59 -0
  71. package/skill/examples/cinema/components/Shell.tsx +70 -0
  72. package/skill/examples/cinema/components/Tab.tsx +22 -0
  73. package/skill/examples/cinema/components/TitleCard.tsx +68 -0
  74. package/skill/examples/cinema/components/TitleMeta.tsx +36 -0
  75. package/skill/examples/cinema/locales/en.ts +211 -0
  76. package/skill/examples/cinema/locales/lt.ts +211 -0
  77. package/skill/examples/cinema/preview/phone-home.jpg +0 -0
  78. package/skill/examples/cinema/preview/tv-detail.jpg +0 -0
  79. package/skill/examples/cinema/preview/tv-home.jpg +0 -0
  80. package/skill/examples/cinema/screens/portrait/Account.tsx +110 -0
  81. package/skill/examples/cinema/screens/portrait/Browse.tsx +73 -0
  82. package/skill/examples/cinema/screens/portrait/Detail.tsx +159 -0
  83. package/skill/examples/cinema/screens/portrait/Home.tsx +196 -0
  84. package/skill/examples/cinema/screens/portrait/Player.tsx +299 -0
  85. package/skill/examples/cinema/screens/portrait/Search.tsx +46 -0
  86. package/skill/examples/cinema/screens/portrait/Search.tv.tsx +55 -0
  87. package/skill/examples/cinema/screens/portrait/SignIn.tsx +101 -0
  88. package/skill/examples/cinema/screens/portrait/SignUp.tsx +106 -0
  89. package/skill/examples/cinema/store.tsx +132 -0
  90. package/skill/examples/cinema/theme.ts +32 -0
  91. package/skill/examples/documentary/DESIGN.md +33 -0
  92. package/skill/examples/documentary/app.tsx +17 -0
  93. package/skill/examples/documentary/components/Action.tsx +43 -0
  94. package/skill/examples/documentary/components/CatalogGrid.tsx +47 -0
  95. package/skill/examples/documentary/components/Feedback.tsx +27 -0
  96. package/skill/examples/documentary/components/Field.tsx +33 -0
  97. package/skill/examples/documentary/components/LibraryRail.tsx +47 -0
  98. package/skill/examples/documentary/components/Root.tsx +62 -0
  99. package/skill/examples/documentary/components/Shell.tsx +93 -0
  100. package/skill/examples/documentary/components/StoryCard.tsx +53 -0
  101. package/skill/examples/documentary/components/StoryMeta.tsx +22 -0
  102. package/skill/examples/documentary/preview/phone-home.jpg +0 -0
  103. package/skill/examples/documentary/preview/tv-detail.jpg +0 -0
  104. package/skill/examples/documentary/preview/tv-home.jpg +0 -0
  105. package/skill/examples/documentary/screens/portrait/Account.tsx +97 -0
  106. package/skill/examples/documentary/screens/portrait/Browse.tsx +71 -0
  107. package/skill/examples/documentary/screens/portrait/Detail.tsx +133 -0
  108. package/skill/examples/documentary/screens/portrait/Home.tsx +89 -0
  109. package/skill/examples/documentary/screens/portrait/Player.tsx +116 -0
  110. package/skill/examples/documentary/screens/portrait/Search.tsx +48 -0
  111. package/skill/examples/documentary/screens/portrait/SignIn.tsx +96 -0
  112. package/skill/examples/documentary/screens/portrait/SignUp.tsx +101 -0
  113. package/skill/examples/documentary/store.tsx +115 -0
  114. package/skill/examples/documentary/theme.ts +20 -0
  115. package/skill/examples/series/DESIGN.md +55 -0
  116. package/skill/examples/series/app.tsx +17 -0
  117. package/skill/examples/series/components/Action.tsx +42 -0
  118. package/skill/examples/series/components/CatalogGrid.tsx +43 -0
  119. package/skill/examples/series/components/ContinueRail.tsx +78 -0
  120. package/skill/examples/series/components/Feedback.tsx +26 -0
  121. package/skill/examples/series/components/Field.tsx +34 -0
  122. package/skill/examples/series/components/LibraryRail.tsx +38 -0
  123. package/skill/examples/series/components/OutcomeNote.tsx +28 -0
  124. package/skill/examples/series/components/PlayAction.tsx +29 -0
  125. package/skill/examples/series/components/RestoreAction.tsx +33 -0
  126. package/skill/examples/series/components/Root.tsx +75 -0
  127. package/skill/examples/series/components/SaveTitle.tsx +34 -0
  128. package/skill/examples/series/components/Shell.tsx +75 -0
  129. package/skill/examples/series/components/TitleCard.tsx +62 -0
  130. package/skill/examples/series/components/UnlockAction.tsx +10 -0
  131. package/skill/examples/series/preview/phone-home.jpg +0 -0
  132. package/skill/examples/series/preview/tv-detail.jpg +0 -0
  133. package/skill/examples/series/preview/tv-home.jpg +0 -0
  134. package/skill/examples/series/screens/portrait/Account.tsx +125 -0
  135. package/skill/examples/series/screens/portrait/Browse.tsx +61 -0
  136. package/skill/examples/series/screens/portrait/Detail.tsx +231 -0
  137. package/skill/examples/series/screens/portrait/Home.tsx +109 -0
  138. package/skill/examples/series/screens/portrait/MyList.tsx +44 -0
  139. package/skill/examples/series/screens/portrait/Plans.tsx +131 -0
  140. package/skill/examples/series/screens/portrait/Player.tsx +138 -0
  141. package/skill/examples/series/screens/portrait/Profiles.tsx +103 -0
  142. package/skill/examples/series/screens/portrait/Search.tsx +50 -0
  143. package/skill/examples/series/screens/portrait/SignIn.tsx +94 -0
  144. package/skill/examples/series/screens/portrait/SignUp.tsx +100 -0
  145. package/skill/examples/series/store.tsx +192 -0
  146. package/skill/examples/series/theme.ts +32 -0
  147. package/skill/guides/final-pricing-capabilities.md +13 -0
  148. package/skill/reference/api.md +842 -0
  149. package/skill/reference/components.md +1782 -0
  150. package/skill/reference/packages.md +24 -0
  151. package/skill/scripts/assemble-checkout.mjs +93 -0
  152. package/skill/scripts/local-save.mjs +513 -0
  153. package/skill/scripts/materialize.mjs +319 -0
  154. package/skill/scripts/workspace-state.mjs +183 -0
  155. package/types/adelin-access.d.ts +70 -0
  156. package/types/adelin-analytics.d.ts +5 -0
  157. package/types/adelin-assets.d.ts +26 -0
  158. package/types/adelin-auth.d.ts +37 -0
  159. package/types/adelin-content.d.ts +120 -0
  160. package/types/adelin-device.d.ts +195 -0
  161. package/types/adelin-downloads.d.ts +47 -0
  162. package/types/adelin-env.d.ts +8 -0
  163. package/types/adelin-globals.d.ts +19 -0
  164. package/types/adelin-i18n.d.ts +31 -0
  165. package/types/adelin-native-stack.d.ts +178 -0
  166. package/types/adelin-navigation.d.ts +264 -0
  167. package/types/adelin-profiles.d.ts +51 -0
  168. package/types/adelin-react.d.ts +49 -0
  169. package/types/adelin-reanimated.d.ts +376 -0
  170. package/types/adelin-storage.d.ts +9 -0
  171. package/types/adelin-store.d.ts +74 -0
  172. package/types/adelin-ui.d.ts +1518 -0
  173. package/types/adelin-utils.d.ts +7 -0
  174. package/types/adelin-worklets.d.ts +15 -0
  175. package/workspace-tsconfig.json +53 -0
@@ -0,0 +1,55 @@
1
+ # Arc — episodic series service
2
+
3
+ **Use case:** A library where series, seasons and episodes are the main discovery path, and the
4
+ viewer's question is "where am I in the story?"
5
+ [Home on TV](preview/tv-home.jpg), [series Detail on TV](preview/tv-detail.jpg) and
6
+ [Home on phone](preview/phone-home.jpg) show the composition.
7
+
8
+ Episode order is the organising idea. Home opens on a full-bleed series hero whose kicker is
9
+ derived from the library (genre · seasons · episodes), then Continue Watching, a "Begin {series}"
10
+ rail of season-one episodes, My List, the other series, and one "Begin" rail per remaining series.
11
+ Large episode numerals ("01") sit on every still; they come from sibling position, never from a
12
+ label.
13
+
14
+ Watch progress answers the same question in the same language. A Continue Watching card is an
15
+ episode still with its numeral, the series title and its "S2 · E4" code, followed by the time left
16
+ in coral and a coral rule along the bottom of the still. An episode the server has moved on to
17
+ reads "Up next" instead. The hero leads with one play action beside "View series": it reads "Play S1 · E1" and becomes
18
+ "Resume S1 · E4" (or "Play S2 · E1" at a fresh episode) once the profile's place in that series
19
+ arrives. It is the same button with a new label, so focus stays on it. On a
20
+ series, the episode list marks watched episodes with a coral check on the still and draws the same
21
+ thin rule under a partly watched one. An episode page has a "Mark as watched" toggle and a
22
+ "Resume" action with the time left.
23
+
24
+ Read these to study the approach:
25
+
26
+ - `screens/portrait/Home.tsx` — the hero and the module-local `BeginRail`.
27
+ - `components/ContinueRail.tsx` and `components/PlayAction.tsx` — the Continue Watching cards and
28
+ the "Resume S1 · E4" / "Play S1 · E1" label, both read from the profile's progress rows.
29
+ - `components/TitleCard.tsx` — episode cards with numerals and an "S1 · E3" code, and series cards
30
+ with a season tag, both chosen from the entry's kind.
31
+ - `screens/portrait/Detail.tsx` — season tabs, the numbered `EpisodeRow` list (numeral turns
32
+ coral on focus, coral check when watched), the watched toggle, and the "Next episodes" rail on an
33
+ episode.
34
+ - `components/Shell.tsx` — a 64-unit TV icon rail with the profile avatar, and a phone tab bar.
35
+ - `screens/portrait/Profiles.tsx`, `MyList.tsx`, `components/SaveTitle.tsx` and `store.tsx` —
36
+ profile-owned saved titles and watch progress; a signed-out viewer is invited to sign in before
37
+ saving. `components/Root.tsx` clears both when the viewer or profile changes, and the player
38
+ reloads Continue Watching when it closes.
39
+
40
+ Locked titles stay in every rail with a small lock on the still. On a locked episode the play
41
+ action becomes "Ways to watch" (or "Sign in to watch") and names the offers that open it. The
42
+ paywall builds one panel per offer from the library's own offers, with period choices, trial
43
+ wording and the price exactly as the server labels it. Once the title opens, the paywall offers
44
+ "Watch now" instead of moving on by itself.
45
+
46
+ - `screens/portrait/Plans.tsx` — the paywall and plan picker, and "Restore purchases".
47
+ - `components/TitleCard.tsx`, `components/UnlockAction.tsx` and `components/PlayAction.tsx` —
48
+ the lock badge and the unlock action.
49
+ - `screens/portrait/Account.tsx` — the viewer's plan with "Manage subscription", and
50
+ "Restore purchases".
51
+
52
+ Ink-teal surfaces carry a single coral accent for focus, the active destination and the primary
53
+ action. Metadata stays factual: runtime only when it is at least a minute, and HD, 4K or HDR
54
+ from the technical fields. The design depends on episode stills and series backdrops; without
55
+ them, the numerals and titles still carry the cards over the surface colour.
@@ -0,0 +1,17 @@
1
+ import { defineApp } from '@adelin/navigation';
2
+ import Root from './components/Root';
3
+
4
+ export default defineApp({
5
+ name: 'Arc',
6
+ version: '1.0.0',
7
+ root: Root,
8
+ statusBar: { style: 'light' },
9
+ designIntent: {
10
+ audience: 'Viewers who follow serial stories season by season, on television and phone.',
11
+ thesis: 'Episode order is the content: every series opens onto a numbered path from the first episode onwards.',
12
+ palette: 'Ink-teal night surfaces keep coastal, mountain and workshop artwork vivid. One coral accent marks focus, the active destination and the primary action.',
13
+ typography: 'Heavy tight titles, tracked uppercase context lines and large episode numerals; body text stays quiet and cool grey.',
14
+ composition: 'A slim TV icon rail leaves a full-bleed series hero, then numbered episode rails and wide series cards. Phone stacks the same path under a bottom tab bar.',
15
+ motif: 'Large real episode numerals over the lower-left of each still, repeated in rails, season lists and the player.',
16
+ },
17
+ });
@@ -0,0 +1,42 @@
1
+ import { Icon, Pressable, StyleSheet, Text, View, theme, useWindowDimensions } from '@adelin/ui';
2
+ import { Platform } from '@adelin/device';
3
+
4
+ export default function Action({ label, onPress, primary = false, disabled = false, preferred = false, focusKey, icon = '' }: {
5
+ label: string;
6
+ onPress: () => void;
7
+ primary?: boolean;
8
+ disabled?: boolean;
9
+ preferred?: boolean;
10
+ focusKey?: string;
11
+ icon?: string;
12
+ }) {
13
+ const { width } = useWindowDimensions();
14
+ return (
15
+ <Pressable
16
+ onPress={onPress}
17
+ disabled={disabled}
18
+ hasTVPreferredFocus={preferred}
19
+ focusKey={focusKey}
20
+ style={[styles.button, primary === true && styles.primary, disabled === true && styles.disabled]}
21
+ focusAnimation={{ border: { color: primary ? theme.colors.text : theme.colors.accent, width: 2 } }}
22
+ accessibilityRole="button"
23
+ accessibilityLabel={label}
24
+ accessibilityState={{ disabled }}
25
+ >
26
+ <View style={styles.row}>
27
+ {icon !== '' && <View style={styles.icon}><Icon icon={icon} size={width >= 840 ? 13 : 18} color={primary ? theme.colors.background : theme.colors.text} /></View>}
28
+ <Text style={[styles.label, primary === true && styles.primaryLabel]}>{label}</Text>
29
+ </View>
30
+ </Pressable>
31
+ );
32
+ }
33
+
34
+ const styles = StyleSheet.create({
35
+ button: { minHeight: Platform.select({ tv: 30, default: 46 }), justifyContent: 'center', alignSelf: 'flex-start', paddingHorizontal: Platform.select({ tv: 14, default: 18 }), backgroundColor: theme.colors.surfaceLight, borderRadius: 4 },
36
+ primary: { backgroundColor: theme.colors.primary },
37
+ disabled: { opacity: 0.5 },
38
+ row: { flexDirection: 'row', alignItems: 'center' },
39
+ icon: { marginRight: Platform.select({ tv: 6, default: 8 }) },
40
+ label: { color: theme.colors.text, fontSize: Platform.select({ tv: 11, default: 15 }), lineHeight: Platform.select({ tv: 15, default: 20 }), fontWeight: '700' },
41
+ primaryLabel: { color: theme.colors.background },
42
+ });
@@ -0,0 +1,43 @@
1
+ import type { ContentItem } from '@adelin/content';
2
+ import { FlashList, FocusGroup, StyleSheet, View, theme, useWindowDimensions } from '@adelin/ui';
3
+ import { Platform } from '@adelin/device';
4
+ import TitleCard from './TitleCard';
5
+ import Feedback from './Feedback';
6
+
7
+ export default function CatalogGrid({ entries, emptyTitle, emptyMessage }: {
8
+ entries: ContentItem[];
9
+ emptyTitle: string;
10
+ emptyMessage: string;
11
+ }) {
12
+ const { width, height } = useWindowDimensions();
13
+ const expanded = width >= 840 && height >= 480;
14
+ const gutter = expanded ? 32 : 20;
15
+ const spacing = expanded ? 14 : 12;
16
+ const available = width - (expanded ? 64 : 0) - gutter * 2;
17
+ const columns = expanded ? 4 : width >= 600 ? 3 : 2;
18
+ const cardWidth = (available - spacing * (columns - 1)) / columns;
19
+ const rows = entries.filter((item, index) => index % columns === 0).map((item, index) => ({ id: item.id, entries: entries.slice(index * columns, index * columns + columns) }));
20
+ return (
21
+ <FocusGroup direction="vertical" remember>
22
+ <View style={styles.grid}>
23
+ <FlashList data={rows} keyExtractor={item => item.id} style={styles.grid} contentContainerStyle={styles.content} showsVerticalScrollIndicator={false}
24
+ ListEmptyComponent={<Feedback title={emptyTitle} message={emptyMessage} />}
25
+ renderItem={({ item }) => (
26
+ <FocusGroup direction="horizontal" remember>
27
+ <View style={styles.row}>
28
+ {item.entries.map((entry, index) => <View key={entry.id} style={[styles.item, { marginRight: index < columns - 1 ? spacing : 0 }]}><TitleCard item={entry} width={cardWidth} imageHeight={cardWidth / 1.7778} /></View>)}
29
+ </View>
30
+ </FocusGroup>
31
+ )}
32
+ />
33
+ </View>
34
+ </FocusGroup>
35
+ );
36
+ }
37
+
38
+ const styles = StyleSheet.create({
39
+ grid: { flex: 1 },
40
+ content: { paddingHorizontal: Platform.select({ tv: 32, default: 20 }), paddingTop: Platform.select({ tv: 8, default: 8 }), paddingBottom: theme.spacing.xl },
41
+ row: { flexDirection: 'row' },
42
+ item: { marginBottom: Platform.select({ tv: 16, default: 20 }) },
43
+ });
@@ -0,0 +1,78 @@
1
+ import type { ContentItem } from '@adelin/content';
2
+ import type { Progress } from '@adelin/profiles';
3
+ import { useNavigation } from '@adelin/navigation';
4
+ import { useSelector } from '@adelin/store';
5
+ import { FlashList, FocusGroup, Image, LinearGradient, Pressable, StyleSheet, Text, View, theme } from '@adelin/ui';
6
+ import { Platform } from '@adelin/device';
7
+
8
+ /** Continue Watching: one numbered episode card per series that plays from the profile's saved place. Hidden while empty. */
9
+ export default function ContinueRail({ meta = '' }: { meta?: string }) {
10
+ const entries = useSelector(state => state.library.entries);
11
+ const rows = useSelector(state => state.watching.rows);
12
+ const cards = rows.map(row => ({ row, item: entries.find(entry => entry.id === row.entryId) })).filter((card): card is { row: Progress; item: ContentItem } => card.item !== undefined);
13
+ if (cards.length === 0) return null;
14
+ return (
15
+ <View style={styles.section}>
16
+ <View style={styles.heading}>
17
+ <Text style={styles.headingTitle} numberOfLines={1}>Continue watching</Text>
18
+ {meta !== '' && <Text style={styles.meta} numberOfLines={1}>{meta}</Text>}
19
+ </View>
20
+ <FocusGroup direction="horizontal" remember>
21
+ <FlashList horizontal data={cards} keyExtractor={card => card.row.entryId} showsHorizontalScrollIndicator={false} focusEntry="remember" style={styles.rail} contentContainerStyle={styles.railContent}
22
+ renderItem={({ item }) => <View style={styles.item}><ContinueCard item={item.item} position={item.row.position} duration={item.row.duration} /></View>}
23
+ />
24
+ </FocusGroup>
25
+ </View>
26
+ );
27
+ }
28
+
29
+ function ContinueCard({ item, position, duration }: { item: ContentItem; position: number; duration: number }) {
30
+ const navigation = useNavigation();
31
+ const entries = useSelector(state => state.library.entries);
32
+ const parent = entries.find(entry => entry.id === item.parentId);
33
+ const inSeason = !!parent && !!parent.parentId;
34
+ const root = entries.find(entry => entry.id === parent?.parentId) ?? parent ?? item;
35
+ const number = entries.filter(entry => entry.parentId === item.parentId && entry.kind === 'item' && Number(entry.position) < Number(item.position)).length + 1;
36
+ const seasonNumber = inSeason ? entries.filter(entry => entry.parentId === parent?.parentId && entry.kind === 'folder' && Number(entry.position) < Number(parent?.position)).length + 1 : 0;
37
+ const code = !parent ? (item.label ?? '').toUpperCase() : inSeason ? 'S' + seasonNumber + ' · E' + number : 'E' + number;
38
+ const left = Math.max(1, Math.round((duration - position) / 60));
39
+ const status = position === 0 ? 'UP NEXT' : duration > 0 ? left + ' MIN LEFT' : '';
40
+ const share = duration > 0 ? Math.min(100, Math.round(position / duration * 100)) : 0;
41
+ const picture = item.artwork.backdrop || item.artwork.poster || root.artwork.backdrop;
42
+ return (
43
+ <Pressable onPress={() => navigation.navigate('Player', { id: item.id })} style={styles.card} focusAnimation={{ border: { color: theme.colors.accent, width: 3 } }} accessibilityRole="button" accessibilityLabel={root.title + ', ' + code + (status !== '' ? ', ' + status.toLowerCase() : '')}>
44
+ <View style={styles.still}>
45
+ {picture ? <Image source={{ uri: picture }} resizeMode="cover" style={styles.image} /> : <View style={styles.image} />}
46
+ <LinearGradient colors={[theme.gradients.scrimClear, theme.gradients.numeralShade]} start={{ x: 0, y: 0.35 }} end={{ x: 0, y: 1 }} style={styles.shade} pointerEvents="none" />
47
+ {!!parent && <Text style={styles.numeral} maxFontSizeMultiplier={1}>{number < 10 ? '0' + number : '' + number}</Text>}
48
+ <View style={styles.track}>{share > 0 && <View style={[styles.fill, { width: share + '%' }]} />}</View>
49
+ </View>
50
+ <Text style={styles.title} numberOfLines={1}>{root.title}</Text>
51
+ <View style={styles.codeRow}>
52
+ <Text style={styles.code} numberOfLines={1}>{code}</Text>
53
+ {status !== '' && <Text style={styles.status} numberOfLines={1}>{status}</Text>}
54
+ </View>
55
+ </Pressable>
56
+ );
57
+ }
58
+
59
+ const styles = StyleSheet.create({
60
+ section: { marginBottom: Platform.select({ tv: 14, default: 24 }) },
61
+ heading: { paddingHorizontal: Platform.select({ tv: 32, default: 20 }), flexDirection: Platform.select({ tv: 'row', default: 'column' }), alignItems: Platform.select({ tv: 'baseline', default: 'flex-start' }) },
62
+ headingTitle: { color: theme.colors.text, fontSize: Platform.select({ tv: 13, default: 19 }), lineHeight: Platform.select({ tv: 18, default: 25 }), fontWeight: '800', letterSpacing: -0.2, marginRight: theme.spacing.md },
63
+ meta: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 12, default: 15 }), fontWeight: '700', letterSpacing: 1.2, textTransform: 'uppercase', marginTop: Platform.select({ tv: 0, default: 2 }) },
64
+ rail: { height: Platform.select({ tv: 146, default: 186 }) },
65
+ railContent: { paddingHorizontal: Platform.select({ tv: 32, default: 20 }), paddingVertical: Platform.select({ tv: 8, default: 10 }) },
66
+ item: { marginRight: Platform.select({ tv: 12, default: 12 }) },
67
+ card: { width: Platform.select({ tv: 168, default: 220 }), borderRadius: 4 },
68
+ still: { height: Platform.select({ tv: 94, default: 124 }), width: '100%', backgroundColor: theme.colors.surfaceLight, borderRadius: 4, overflow: 'hidden' },
69
+ image: { width: '100%', height: '100%' },
70
+ shade: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 },
71
+ numeral: { position: 'absolute', left: Platform.select({ tv: 8, default: 10 }), bottom: Platform.select({ tv: 5, default: 6 }), color: theme.colors.text, fontSize: Platform.select({ tv: 34, default: 42 }), lineHeight: Platform.select({ tv: 38, default: 46 }), fontWeight: '900', letterSpacing: -1.5 },
72
+ track: { position: 'absolute', left: 0, right: 0, bottom: 0, height: 3, backgroundColor: theme.colors.border },
73
+ fill: { height: 3, backgroundColor: theme.colors.accent },
74
+ title: { color: theme.colors.text, fontSize: Platform.select({ tv: 10, default: 14 }), lineHeight: Platform.select({ tv: 14, default: 19 }), fontWeight: '700', marginTop: Platform.select({ tv: 6, default: 8 }) },
75
+ codeRow: { flexDirection: 'row', alignItems: 'center', marginTop: 2 },
76
+ code: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 7, default: 11 }), lineHeight: Platform.select({ tv: 11, default: 15 }), fontWeight: '800', letterSpacing: 1.1, marginRight: Platform.select({ tv: 6, default: 8 }) },
77
+ status: { color: theme.colors.accent, fontSize: Platform.select({ tv: 7, default: 11 }), lineHeight: Platform.select({ tv: 11, default: 15 }), fontWeight: '800', letterSpacing: 1.1, flexShrink: 1 },
78
+ });
@@ -0,0 +1,26 @@
1
+ import { ActivityIndicator, StyleSheet, Text, View, theme } from '@adelin/ui';
2
+ import { Platform } from '@adelin/device';
3
+ import Action from './Action';
4
+
5
+ export default function Feedback({ title, message, loading = false, onRetry }: {
6
+ title: string;
7
+ message: string;
8
+ loading?: boolean;
9
+ onRetry?: () => void;
10
+ }) {
11
+ return (
12
+ <View style={styles.panel}>
13
+ {loading === true && <ActivityIndicator color={theme.colors.primary} />}
14
+ <Text style={styles.title}>{title}</Text>
15
+ <Text style={styles.message}>{message}</Text>
16
+ {onRetry !== undefined && <View style={styles.action}><Action label="Try again" onPress={() => onRetry()} preferred /></View>}
17
+ </View>
18
+ );
19
+ }
20
+
21
+ const styles = StyleSheet.create({
22
+ panel: { minHeight: Platform.select({ tv: 180, default: 220 }), padding: theme.spacing.lg, justifyContent: 'center', alignItems: 'center' },
23
+ title: { color: theme.colors.text, fontSize: Platform.select({ tv: 16, default: 22 }), lineHeight: Platform.select({ tv: 21, default: 28 }), fontWeight: '800', letterSpacing: -0.3, marginTop: theme.spacing.md, textAlign: 'center' },
24
+ message: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 10, default: 15 }), lineHeight: Platform.select({ tv: 15, default: 22 }), marginTop: theme.spacing.sm, textAlign: 'center', maxWidth: 420 },
25
+ action: { marginTop: theme.spacing.lg },
26
+ });
@@ -0,0 +1,34 @@
1
+ import { StyleSheet, Text, TextInput, TVKeyboard, View, theme } from '@adelin/ui';
2
+ import { Platform } from '@adelin/device';
3
+
4
+ export default function Field({ label, value, onChangeText, secret = false, email = false, disabled = false, placeholder = '' }: {
5
+ label: string;
6
+ value: string;
7
+ onChangeText: (value: string) => void;
8
+ secret?: boolean;
9
+ email?: boolean;
10
+ disabled?: boolean;
11
+ placeholder?: string;
12
+ }) {
13
+ return (
14
+ <View style={styles.field}>
15
+ <Text style={styles.label}>{label}</Text>
16
+ <TextInput value={value} onChangeText={onChangeText} accessibilityLabel={label} placeholder={placeholder} placeholderTextColor={theme.colors.textMuted} secureTextEntry={secret} keyboardType={email ? 'email-address' : 'default'} autoCapitalize="none" autoCorrect={false} editable={!disabled} style={({ focused }) => [styles.input, focused && styles.focused, disabled === true && styles.disabled]}
17
+ tvKeyboard={<TVKeyboard variant="bottom" style={styles.keyboard} keyStyle={styles.key} keyFocusedStyle={styles.keyFocused} keyLabelStyle={styles.keyLabel} keyLabelFocusedStyle={styles.keyLabelFocused} />}
18
+ />
19
+ </View>
20
+ );
21
+ }
22
+
23
+ const styles = StyleSheet.create({
24
+ field: { marginBottom: theme.spacing.md },
25
+ label: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 8, default: 12 }), lineHeight: Platform.select({ tv: 12, default: 16 }), fontWeight: '800', letterSpacing: 1.4, textTransform: 'uppercase', marginBottom: Platform.select({ tv: 6, default: 8 }) },
26
+ input: { color: theme.colors.text, backgroundColor: theme.colors.background, borderColor: theme.colors.border, borderWidth: 2, borderRadius: 4, paddingHorizontal: theme.spacing.md, paddingVertical: theme.spacing.sm, fontSize: Platform.select({ tv: 12, default: 16 }), lineHeight: Platform.select({ tv: 18, default: 24 }), minHeight: Platform.select({ tv: 34, default: 48 }) },
27
+ focused: { borderColor: theme.colors.primary },
28
+ disabled: { opacity: 0.55 },
29
+ keyboard: { backgroundColor: theme.colors.surface },
30
+ key: { backgroundColor: theme.colors.surfaceLight, borderWidth: 2, borderColor: 'transparent', borderRadius: 4 },
31
+ keyFocused: { backgroundColor: theme.colors.primary, borderWidth: 2, borderColor: theme.colors.text, borderRadius: 4 },
32
+ keyLabel: { color: theme.colors.text },
33
+ keyLabelFocused: { color: theme.colors.background },
34
+ });
@@ -0,0 +1,38 @@
1
+ import type { ContentItem } from '@adelin/content';
2
+ import { FlashList, FocusGroup, StyleSheet, Text, View, theme } from '@adelin/ui';
3
+ import { Platform } from '@adelin/device';
4
+ import TitleCard from './TitleCard';
5
+
6
+ export default function LibraryRail({ title, meta = '', entries, wide = false, watchedIds = [] }: {
7
+ title: string;
8
+ meta?: string;
9
+ entries: ContentItem[];
10
+ wide?: boolean;
11
+ watchedIds?: string[];
12
+ }) {
13
+ if (entries.length === 0) return null;
14
+ return (
15
+ <View style={styles.section}>
16
+ <View style={styles.heading}>
17
+ <Text style={styles.title} numberOfLines={1}>{title}</Text>
18
+ {meta !== '' && <Text style={styles.meta} numberOfLines={1}>{meta}</Text>}
19
+ </View>
20
+ <FocusGroup direction="horizontal" remember>
21
+ <FlashList horizontal data={entries} keyExtractor={item => item.id} showsHorizontalScrollIndicator={false} focusEntry="remember" style={wide ? styles.wideRail : styles.rail} contentContainerStyle={styles.railContent}
22
+ renderItem={({ item }) => <View style={styles.item}><TitleCard item={item} rail watched={watchedIds.includes(item.id)} /></View>}
23
+ />
24
+ </FocusGroup>
25
+ </View>
26
+ );
27
+ }
28
+
29
+ const styles = StyleSheet.create({
30
+ section: { marginBottom: Platform.select({ tv: 14, default: 24 }) },
31
+ heading: { paddingHorizontal: Platform.select({ tv: 32, default: 20 }), flexDirection: Platform.select({ tv: 'row', default: 'column' }), alignItems: Platform.select({ tv: 'baseline', default: 'flex-start' }) },
32
+ title: { color: theme.colors.text, fontSize: Platform.select({ tv: 13, default: 19 }), lineHeight: Platform.select({ tv: 18, default: 25 }), fontWeight: '800', letterSpacing: -0.2, marginRight: theme.spacing.md },
33
+ meta: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 12, default: 15 }), fontWeight: '700', letterSpacing: 1.2, textTransform: 'uppercase', marginTop: Platform.select({ tv: 0, default: 2 }) },
34
+ rail: { height: Platform.select({ tv: 146, default: 186 }) },
35
+ wideRail: { height: Platform.select({ tv: 158, default: 182 }) },
36
+ railContent: { paddingHorizontal: Platform.select({ tv: 32, default: 20 }), paddingVertical: Platform.select({ tv: 8, default: 10 }) },
37
+ item: { marginRight: Platform.select({ tv: 12, default: 12 }) },
38
+ });
@@ -0,0 +1,28 @@
1
+ import { StyleSheet, Text, View, theme } from '@adelin/ui';
2
+ import { Platform } from '@adelin/device';
3
+
4
+ /** Plain words for a purchase action's outcome and reason; `completed` shows `done`, `unavailable` shows `refused`, `cancelled` nothing. */
5
+ export default function OutcomeNote({ outcome, reason = '', done = '', refused = "This option isn't available right now." }:
6
+ { outcome: string; reason?: string; done?: string; refused?: string }) {
7
+ if (outcome === 'pending') {
8
+ return (
9
+ <View>
10
+ <Text style={[styles.note, styles.store]} accessibilityRole="alert">Waiting for approval…</Text>
11
+ <Text style={[styles.note, styles.web]} accessibilityRole="alert">Finishing your purchase…</Text>
12
+ </View>
13
+ );
14
+ }
15
+ const message = outcome === 'unavailable' ? refused
16
+ : outcome === 'failed' && reason === 'other_account' ? 'This purchase belongs to another account. Sign in with the account you used to buy it.'
17
+ : outcome === 'failed' ? 'Something went wrong. Try again.'
18
+ : outcome === 'completed' ? done : '';
19
+ if (message === '') return null;
20
+ return <Text style={[styles.note, outcome === 'failed' && styles.error]} accessibilityRole="alert">{message}</Text>;
21
+ }
22
+
23
+ const styles = StyleSheet.create({
24
+ note: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 9, default: 13 }), lineHeight: Platform.select({ tv: 13, default: 18 }), marginTop: theme.spacing.sm },
25
+ error: { color: theme.colors.error },
26
+ store: Platform.select({ native: {}, default: { display: 'none' } }),
27
+ web: Platform.select({ native: { display: 'none' }, default: {} }),
28
+ });
@@ -0,0 +1,29 @@
1
+ import type { ContentItem } from '@adelin/content';
2
+ import { useNavigation } from '@adelin/navigation';
3
+ import { useSelector } from '@adelin/store';
4
+ import Action from './Action';
5
+ import UnlockAction from './UnlockAction';
6
+
7
+ /** Plays a series or season from the profile's saved episode ("Resume S1 · E4"), else from its first episode. One button whose label changes, so focus stays on it when progress arrives. */
8
+ export default function PlayAction({ item, focusKey, preferred = false }: { item: ContentItem; focusKey: string; preferred?: boolean }) {
9
+ const navigation = useNavigation();
10
+ const entries = useSelector(state => state.library.entries);
11
+ const rows = useSelector(state => state.watching.rows);
12
+ const seasons = entries.filter(entry => entry.parentId === item.id && entry.kind === 'folder');
13
+ const inTitle = (id: string) => entries.some(entry => entry.id === id && entry.kind === 'item' && (entry.parentId === item.id || seasons.some(season => season.id === entry.parentId)));
14
+ const row = rows.find(saved => inTitle(saved.entryId));
15
+ const savedItem = entries.find(entry => entry.id === row?.entryId);
16
+ const firstSeason = seasons.find(season => !seasons.some(other => Number(other.position) < Number(season.position)));
17
+ const opening = entries.filter(entry => entry.kind === 'item' && entry.parentId === (firstSeason ? firstSeason.id : item.id));
18
+ const first = opening.find(entry => !opening.some(other => Number(other.position) < Number(entry.position)));
19
+ const savedSeason = seasons.find(season => season.id === savedItem?.parentId);
20
+ const ownNumber = item.parentId ? entries.filter(entry => entry.parentId === item.parentId && entry.kind === 'folder' && Number(entry.position) < Number(item.position)).length + 1 : 0;
21
+ const seasonNumber = savedSeason ? seasons.filter(season => Number(season.position) < Number(savedSeason.position)).length + 1 : ownNumber;
22
+ const episodeNumber = entries.filter(entry => entry.parentId === savedItem?.parentId && entry.kind === 'item' && Number(entry.position) < Number(savedItem?.position)).length + 1;
23
+ const code = (seasonNumber > 0 ? 'S' + seasonNumber + ' · ' : '') + 'E' + episodeNumber;
24
+ const target = savedItem ?? first;
25
+ const label = savedItem !== undefined && row !== undefined ? (row.position > 0 ? 'Resume ' : 'Play ') + code : firstSeason ? 'Play S1 · E1' : ownNumber > 0 ? 'Play S' + ownNumber + ' · E1' : 'Play E1';
26
+ if (target !== undefined && target.access?.open === false) return <UnlockAction item={target} preferred={preferred} focusKey={focusKey} />;
27
+ if (target === undefined || target.playbackSource?.uri == null) return null;
28
+ return <Action label={label} icon="ph:play-fill" primary preferred={preferred} focusKey={focusKey} onPress={() => navigation.navigate('Player', { id: target.id })} />;
29
+ }
@@ -0,0 +1,33 @@
1
+ import { useState } from '@adelin/react';
2
+ import { useAuth } from '@adelin/auth';
3
+ import { useAccess } from '@adelin/access';
4
+ import { useNavigation } from '@adelin/navigation';
5
+ import { useDispatch, useSelector } from '@adelin/store';
6
+ import { View } from '@adelin/ui';
7
+ import { restore } from '../store';
8
+ import Action from './Action';
9
+ import OutcomeNote from './OutcomeNote';
10
+
11
+ /** Restores the viewer's purchases; a signed-out viewer is asked to sign in first. */
12
+ export default function RestoreAction() {
13
+ const auth = useAuth();
14
+ const access = useAccess();
15
+ const navigation = useNavigation();
16
+ const dispatch = useDispatch();
17
+ const pending = useSelector(state => state.paywall.pending);
18
+ const held = access.holdings.map(holding => holding.kind + ':' + (holding.offerId ?? '') + ':' + (holding.entryId ?? '') + ':' + holding.status + ':' + (holding.endsAt ?? '')).join('|');
19
+ const [before, setBefore] = useState('');
20
+ const [result, setResult] = useState({ outcome: '', reason: '' });
21
+ const run = () => {
22
+ setResult({ outcome: '', reason: '' });
23
+ setBefore(held);
24
+ dispatch(restore()).unwrap().then(next => setResult({ outcome: next.outcome, reason: next.reason ?? '' })).catch(() => setResult({ outcome: 'failed', reason: '' }));
25
+ };
26
+ if (auth.status !== 'signed-in') return <Action label="Sign in to restore purchases" icon="ph:arrow-counter-clockwise" onPress={() => navigation.navigate('SignIn')} />;
27
+ return (
28
+ <View>
29
+ <Action label="Restore purchases" icon="ph:arrow-counter-clockwise" onPress={run} disabled={pending} />
30
+ <OutcomeNote outcome={result.outcome} reason={result.reason} done={held === before ? 'Nothing to restore.' : 'Your purchases are restored.'} />
31
+ </View>
32
+ );
33
+ }
@@ -0,0 +1,75 @@
1
+ import { useEffect } from '@adelin/react';
2
+ import { useAuth } from '@adelin/auth';
3
+ import { createNativeStackNavigator } from '@adelin/native-stack';
4
+ import { useDispatch, useSelector } from '@adelin/store';
5
+ import { SafeAreaView, StyleSheet, theme } from '@adelin/ui';
6
+ import { clearProfiles, loadLibrary, loadProfiles, loadSaved, loadWatching, resetSaved, resetWatching } from '../store';
7
+ import Feedback from './Feedback';
8
+ import Home from '../screens/portrait/Home';
9
+ import Browse from '../screens/portrait/Browse';
10
+ import Search from '../screens/portrait/Search';
11
+ import Detail from '../screens/portrait/Detail';
12
+ import Player from '../screens/portrait/Player';
13
+ import Account from '../screens/portrait/Account';
14
+ import SignIn from '../screens/portrait/SignIn';
15
+ import SignUp from '../screens/portrait/SignUp';
16
+ import MyList from '../screens/portrait/MyList';
17
+ import Profiles from '../screens/portrait/Profiles';
18
+ import Plans from '../screens/portrait/Plans';
19
+
20
+ const Stack = createNativeStackNavigator();
21
+
22
+ export default function Root() {
23
+ const auth = useAuth();
24
+ if (auth.signInRequired && auth.status === 'loading') return <Splash />;
25
+ if (auth.signInRequired && auth.status === 'signed-out') return <SignInFlow />;
26
+ return <Main />;
27
+ }
28
+
29
+ function Main() {
30
+ const auth = useAuth();
31
+ const dispatch = useDispatch();
32
+ const status = useSelector(state => state.library.status);
33
+ const profileId = useSelector(state => state.profiles.activeId);
34
+ const userId = auth.currentuser?.id ?? '';
35
+ useEffect(() => { if (status === 'idle') dispatch(loadLibrary()); }, [dispatch, status]);
36
+ useEffect(() => { dispatch(clearProfiles()); dispatch(resetSaved('')); dispatch(resetWatching('')); if (userId !== '') dispatch(loadProfiles()); }, [dispatch, userId]);
37
+ useEffect(() => {
38
+ dispatch(resetSaved(profileId));
39
+ dispatch(resetWatching(profileId));
40
+ if (profileId !== '') {
41
+ dispatch(loadSaved(profileId));
42
+ dispatch(loadWatching(profileId));
43
+ }
44
+ }, [dispatch, profileId]);
45
+ return (
46
+ <Stack.Navigator initialRouteName="Home">
47
+ <Stack.Screen name="Home" component={Home} options={{ animation: 'none' }} />
48
+ <Stack.Screen name="Browse" component={Browse} options={{ animation: 'none' }} />
49
+ <Stack.Screen name="Search" component={Search} options={{ animation: 'none' }} />
50
+ <Stack.Screen name="Detail" component={Detail} />
51
+ <Stack.Screen name="Player" component={Player} />
52
+ <Stack.Screen name="Account" component={Account} options={{ animation: 'none' }} />
53
+ <Stack.Screen name="SignIn" component={SignIn} />
54
+ <Stack.Screen name="SignUp" component={SignUp} />
55
+ <Stack.Screen name="MyList" component={MyList} options={{ animation: 'none' }} />
56
+ <Stack.Screen name="Profiles" component={Profiles} />
57
+ <Stack.Screen name="Plans" component={Plans} />
58
+ </Stack.Navigator>
59
+ );
60
+ }
61
+
62
+ function SignInFlow() {
63
+ return (
64
+ <Stack.Navigator initialRouteName="SignIn">
65
+ <Stack.Screen name="SignIn" component={SignIn} />
66
+ <Stack.Screen name="SignUp" component={SignUp} />
67
+ </Stack.Navigator>
68
+ );
69
+ }
70
+
71
+ function Splash() {
72
+ return <SafeAreaView style={styles.splash}><Feedback title="Arc" message="Finding your place in the story." loading /></SafeAreaView>;
73
+ }
74
+
75
+ const styles = StyleSheet.create({ splash: { flex: 1, justifyContent: 'center', backgroundColor: theme.colors.background } });
@@ -0,0 +1,34 @@
1
+ import { useAuth } from '@adelin/auth';
2
+ import { useNavigation } from '@adelin/navigation';
3
+ import { useDispatch, useSelector } from '@adelin/store';
4
+ import { StyleSheet, Text, View, theme } from '@adelin/ui';
5
+ import { Platform } from '@adelin/device';
6
+ import { loadSaved, markSaved, markUnsaved, saveTitle, unsaveTitle } from '../store';
7
+ import Action from './Action';
8
+
9
+ export default function SaveTitle({ id }: { id: string }) {
10
+ const auth = useAuth();
11
+ const navigation = useNavigation();
12
+ const dispatch = useDispatch();
13
+ const profileId = useSelector(state => state.profiles.activeId);
14
+ const ids = useSelector(state => state.saved.ids);
15
+ const status = useSelector(state => state.saved.status);
16
+ const error = useSelector(state => state.saved.error);
17
+ const lastId = useSelector(state => state.saved.lastId);
18
+ const isSaved = ids.includes(id);
19
+ if (auth.status !== 'signed-in') return <Action label="Sign in to save" icon="ph:plus" onPress={() => navigation.navigate('SignIn')} />;
20
+ if (profileId === '') return <Action label="Choose a profile" icon="ph:user" onPress={() => navigation.navigate('Profiles')} />;
21
+ if (status === 'failed') return <Action label="Retry My List" icon="ph:arrow-clockwise" onPress={() => dispatch(loadSaved(profileId))} />;
22
+ const flip = () => {
23
+ if (isSaved) { dispatch(markUnsaved(id)); dispatch(unsaveTitle({ profileId, entryId: id })); }
24
+ else { dispatch(markSaved(id)); dispatch(saveTitle({ profileId, entryId: id })); }
25
+ };
26
+ return (
27
+ <View>
28
+ <Action label={isSaved ? 'In My List' : 'My List'} icon={isSaved ? 'ph:check' : 'ph:plus'} disabled={status !== 'ready'} onPress={flip} />
29
+ {error !== '' && lastId === id && <Text style={styles.error} accessibilityRole="alert">{error}</Text>}
30
+ </View>
31
+ );
32
+ }
33
+
34
+ const styles = StyleSheet.create({ error: { color: theme.colors.error, fontSize: Platform.select({ tv: 9, default: 13 }), lineHeight: Platform.select({ tv: 13, default: 18 }), marginTop: theme.spacing.sm } });
@@ -0,0 +1,75 @@
1
+ import { useAuth } from '@adelin/auth';
2
+ import { useNavigation, useRoute } from '@adelin/navigation';
3
+ import { useSelector } from '@adelin/store';
4
+ import { FocusGroup, Icon, Pressable, SafeAreaView, StyleSheet, Text, View, theme, useWindowDimensions } from '@adelin/ui';
5
+ import { Platform } from '@adelin/device';
6
+
7
+ export default function Shell({ active, children, contentAutoFocus = false }: { active: string; children?: {} | null; contentAutoFocus?: boolean }) {
8
+ const auth = useAuth();
9
+ const navigation = useNavigation();
10
+ const route = useRoute();
11
+ const profiles = useSelector(state => state.profiles.list);
12
+ const activeId = useSelector(state => state.profiles.activeId);
13
+ const { width, height } = useWindowDimensions();
14
+ const wide = width >= 840 && height >= 480;
15
+ const viewer = profiles.find(profile => profile.id === activeId);
16
+ const destinations = [
17
+ { route: 'Home', label: 'Home', icon: 'ph:house', selectedIcon: 'ph:house-fill' },
18
+ { route: 'Browse', label: 'Browse', icon: 'ph:squares-four', selectedIcon: 'ph:squares-four-fill' },
19
+ { route: 'Search', label: 'Search', icon: 'ph:magnifying-glass', selectedIcon: 'ph:magnifying-glass-fill' },
20
+ { route: 'MyList', label: 'My List', icon: 'ph:bookmark-simple', selectedIcon: 'ph:bookmark-simple-fill' },
21
+ { route: 'Account', label: 'Account', icon: 'ph:user-circle', selectedIcon: 'ph:user-circle-fill' },
22
+ ];
23
+ const go = (target: string) => { if (target === 'Home') navigation.popTo('Home'); else if (target === 'Browse') navigation.navigate('Browse', undefined, { pop: true }); else if (target === 'Search') navigation.navigate('Search', undefined, { pop: true }); else if (target === 'MyList') navigation.navigate('MyList', undefined, { pop: true }); else navigation.navigate('Account', undefined, { pop: true }); };
24
+ return (
25
+ <View style={styles.page}>
26
+ <FocusGroup direction={wide ? 'horizontal' : 'vertical'} remember>
27
+ <View style={[styles.layout, wide && styles.layoutWide]}>
28
+ <SafeAreaView edges={wide ? ['top', 'bottom', 'left'] : ['bottom', 'left', 'right']} style={wide ? styles.rail : styles.tabBar}>
29
+ <FocusGroup direction={wide ? 'vertical' : 'horizontal'} remember>
30
+ <View style={wide ? styles.railLinks : styles.tabLinks}>
31
+ {wide && <Text style={styles.mark}>ARC</Text>}
32
+ {destinations.map(destination => (
33
+ <Pressable key={destination.route} onPress={() => go(destination.route)} style={wide ? styles.railLink : styles.tabLink} focusAnimation={{ backgroundColor: theme.colors.surfaceLight, border: { color: theme.colors.accent, width: 2 } }} focusKey={route.key + '-nav-' + destination.route} accessibilityRole="button" accessibilityLabel={destination.label} accessibilityState={{ selected: active === destination.route }}>
34
+ <Icon icon={active === destination.route ? destination.selectedIcon : destination.icon} size={wide ? 16 : 22} color={active === destination.route ? theme.colors.accent : theme.colors.textSecondary} />
35
+ <Text style={[styles.linkText, active === destination.route && styles.linkActive]} numberOfLines={1} maxFontSizeMultiplier={1.2}>{destination.label}</Text>
36
+ </Pressable>
37
+ ))}
38
+ {wide && <View style={styles.spacer} />}
39
+ {wide && (
40
+ <Pressable onPress={() => auth.status === 'signed-in' ? navigation.navigate('Profiles') : navigation.navigate('SignIn')} style={styles.avatarButton} focusAnimation={{ border: { color: theme.colors.accent, width: 2 } }} focusKey={route.key + '-nav-profile'} accessibilityRole="button" accessibilityLabel={auth.status !== 'signed-in' ? 'Sign in' : viewer ? 'Profile ' + viewer.name + ', switch profile' : 'Choose a profile'}>
41
+ <View style={[styles.avatar, auth.status !== 'signed-in' && styles.avatarEmpty]}>{viewer ? <Text style={styles.avatarText} maxFontSizeMultiplier={1}>{viewer.name.slice(0, 1).toUpperCase()}</Text> : <Icon icon="ph:user" size={14} color={auth.status === 'signed-in' ? theme.colors.background : theme.colors.textSecondary} />}</View>
42
+ </Pressable>
43
+ )}
44
+ </View>
45
+ </FocusGroup>
46
+ </SafeAreaView>
47
+ <FocusGroup direction="vertical" remember autoFocus={contentAutoFocus}>
48
+ <SafeAreaView edges={wide ? ['top', 'right', 'bottom'] : ['top', 'left', 'right']} style={styles.content}>{children}</SafeAreaView>
49
+ </FocusGroup>
50
+ </View>
51
+ </FocusGroup>
52
+ </View>
53
+ );
54
+ }
55
+
56
+ const styles = StyleSheet.create({
57
+ page: { flex: 1, backgroundColor: theme.colors.background },
58
+ layout: { flex: 1, flexDirection: 'column-reverse' },
59
+ layoutWide: { flexDirection: 'row' },
60
+ rail: { width: 64, backgroundColor: theme.colors.background, borderRightWidth: 1, borderRightColor: theme.colors.border },
61
+ railLinks: { flex: 1, flexDirection: 'column', alignItems: 'center', paddingTop: 24, paddingBottom: 28 },
62
+ mark: { color: theme.colors.text, fontSize: 10, lineHeight: 14, fontWeight: '900', letterSpacing: 2.5, marginLeft: 2.5, marginBottom: 58 },
63
+ spacer: { flex: 1 },
64
+ avatarButton: { width: 36, height: 36, borderRadius: 18, alignItems: 'center', justifyContent: 'center' },
65
+ avatar: { width: 28, height: 28, borderRadius: 14, backgroundColor: theme.colors.primary, alignItems: 'center', justifyContent: 'center' },
66
+ avatarEmpty: { backgroundColor: theme.colors.surfaceLight },
67
+ avatarText: { color: theme.colors.background, fontSize: 13, lineHeight: 16, fontWeight: '900' },
68
+ railLink: { width: 52, height: 46, borderRadius: 4, alignItems: 'center', justifyContent: 'center', marginBottom: 6 },
69
+ tabBar: { backgroundColor: theme.colors.surface, borderTopWidth: 1, borderTopColor: theme.colors.border },
70
+ tabLinks: { flexDirection: 'row', paddingHorizontal: 4, paddingTop: 6, paddingBottom: 4 },
71
+ tabLink: { flex: 1, minHeight: 52, alignItems: 'center', justifyContent: 'center', borderRadius: 6 },
72
+ linkText: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 7, default: 11 }), lineHeight: Platform.select({ tv: 10, default: 14 }), fontWeight: '700', marginTop: Platform.select({ tv: 4, default: 3 }) },
73
+ linkActive: { color: theme.colors.accent },
74
+ content: { flex: 1 },
75
+ });