@adelin-io/cli 0.0.0-stage → 0.1.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 +76 -2
- package/authoring-release.json +174 -0
- package/package.json +30 -4
- package/runtime-integrity.json +9 -0
- package/scripts/adelin.mjs +7768 -0
- package/scripts/assemble-checkout.mjs +93 -0
- package/scripts/local-save.mjs +513 -0
- package/scripts/materialize.mjs +319 -0
- package/scripts/runtime.mjs +8950 -0
- package/scripts/typecheck.mjs +72 -0
- package/scripts/workspace-state.mjs +183 -0
- package/skill/README.md +77 -0
- package/skill/SKILL.md +100 -0
- package/skill/authoring/access.md +193 -0
- package/skill/authoring/analytics.md +20 -0
- package/skill/authoring/app-memory.md +128 -0
- package/skill/authoring/app-requirements.md +99 -0
- package/skill/authoring/app-structure.md +265 -0
- package/skill/authoring/assets.md +117 -0
- package/skill/authoring/auth.md +261 -0
- package/skill/authoring/content-binding.md +26 -0
- package/skill/authoring/i18n.md +184 -0
- package/skill/authoring/language.md +503 -0
- package/skill/authoring/local-workflow.md +1665 -0
- package/skill/authoring/offline/connectivity.md +50 -0
- package/skill/authoring/offline/example.md +102 -0
- package/skill/authoring/offline/history-sync.md +39 -0
- package/skill/authoring/offline/index.md +29 -0
- package/skill/authoring/offline/package-storage.md +37 -0
- package/skill/authoring/offline/platforms.md +35 -0
- package/skill/authoring/offline/startup-navigation.md +53 -0
- package/skill/authoring/platform-files.md +616 -0
- package/skill/authoring/player/casting.md +47 -0
- package/skill/authoring/player/controls.md +95 -0
- package/skill/authoring/player/downloads.md +90 -0
- package/skill/authoring/player/drm.md +31 -0
- package/skill/authoring/player/index.md +39 -0
- package/skill/authoring/player/live-dvr.md +33 -0
- package/skill/authoring/player/platforms.md +47 -0
- package/skill/authoring/player/playback.md +42 -0
- package/skill/authoring/player/tracks-subtitles.md +32 -0
- package/skill/authoring/profiles.md +213 -0
- package/skill/authoring/remote-keys.md +139 -0
- package/skill/authoring/search.md +27 -0
- package/skill/authoring/store.md +85 -0
- package/skill/authoring/tv-text-entry.md +146 -0
- package/skill/design/approved/README.md +14 -0
- package/skill/design/approved/vesper-phone-home.jpg +0 -0
- package/skill/design/approved/vesper-tv-detail.jpg +0 -0
- package/skill/design/approved/vesper-tv-home.jpg +0 -0
- package/skill/design/design-guide.md +610 -0
- package/skill/design/edge-to-edge.md +66 -0
- package/skill/design/icons.md +50 -0
- package/skill/design/responsive-layout.md +175 -0
- package/skill/design/safe-area.md +221 -0
- package/skill/design/streaming-playbook.md +131 -0
- package/skill/design/visual-review.md +150 -0
- package/skill/examples/README.md +24 -0
- package/skill/examples/cinema/DESIGN.md +58 -0
- package/skill/examples/cinema/app.tsx +17 -0
- package/skill/examples/cinema/assets/logo.png +0 -0
- package/skill/examples/cinema/components/Action.tsx +40 -0
- package/skill/examples/cinema/components/Action.tv.tsx +44 -0
- package/skill/examples/cinema/components/CatalogGrid.tsx +31 -0
- package/skill/examples/cinema/components/ContinueRail.tsx +98 -0
- package/skill/examples/cinema/components/Feedback.tsx +28 -0
- package/skill/examples/cinema/components/Field.tsx +41 -0
- package/skill/examples/cinema/components/LibraryRail.tsx +46 -0
- package/skill/examples/cinema/components/PlayAction.tsx +29 -0
- package/skill/examples/cinema/components/Root.tsx +59 -0
- package/skill/examples/cinema/components/Shell.tsx +70 -0
- package/skill/examples/cinema/components/Tab.tsx +22 -0
- package/skill/examples/cinema/components/TitleCard.tsx +68 -0
- package/skill/examples/cinema/components/TitleMeta.tsx +36 -0
- package/skill/examples/cinema/locales/en.ts +211 -0
- package/skill/examples/cinema/locales/lt.ts +211 -0
- package/skill/examples/cinema/preview/phone-home.jpg +0 -0
- package/skill/examples/cinema/preview/tv-detail.jpg +0 -0
- package/skill/examples/cinema/preview/tv-home.jpg +0 -0
- package/skill/examples/cinema/screens/portrait/Account.tsx +110 -0
- package/skill/examples/cinema/screens/portrait/Browse.tsx +73 -0
- package/skill/examples/cinema/screens/portrait/Detail.tsx +159 -0
- package/skill/examples/cinema/screens/portrait/Home.tsx +196 -0
- package/skill/examples/cinema/screens/portrait/Player.tsx +299 -0
- package/skill/examples/cinema/screens/portrait/Search.tsx +46 -0
- package/skill/examples/cinema/screens/portrait/Search.tv.tsx +55 -0
- package/skill/examples/cinema/screens/portrait/SignIn.tsx +101 -0
- package/skill/examples/cinema/screens/portrait/SignUp.tsx +106 -0
- package/skill/examples/cinema/store.tsx +132 -0
- package/skill/examples/cinema/theme.ts +32 -0
- package/skill/examples/documentary/DESIGN.md +33 -0
- package/skill/examples/documentary/app.tsx +17 -0
- package/skill/examples/documentary/components/Action.tsx +43 -0
- package/skill/examples/documentary/components/CatalogGrid.tsx +47 -0
- package/skill/examples/documentary/components/Feedback.tsx +27 -0
- package/skill/examples/documentary/components/Field.tsx +33 -0
- package/skill/examples/documentary/components/LibraryRail.tsx +47 -0
- package/skill/examples/documentary/components/Root.tsx +62 -0
- package/skill/examples/documentary/components/Shell.tsx +93 -0
- package/skill/examples/documentary/components/StoryCard.tsx +53 -0
- package/skill/examples/documentary/components/StoryMeta.tsx +22 -0
- package/skill/examples/documentary/preview/phone-home.jpg +0 -0
- package/skill/examples/documentary/preview/tv-detail.jpg +0 -0
- package/skill/examples/documentary/preview/tv-home.jpg +0 -0
- package/skill/examples/documentary/screens/portrait/Account.tsx +97 -0
- package/skill/examples/documentary/screens/portrait/Browse.tsx +71 -0
- package/skill/examples/documentary/screens/portrait/Detail.tsx +133 -0
- package/skill/examples/documentary/screens/portrait/Home.tsx +89 -0
- package/skill/examples/documentary/screens/portrait/Player.tsx +116 -0
- package/skill/examples/documentary/screens/portrait/Search.tsx +48 -0
- package/skill/examples/documentary/screens/portrait/SignIn.tsx +96 -0
- package/skill/examples/documentary/screens/portrait/SignUp.tsx +101 -0
- package/skill/examples/documentary/store.tsx +115 -0
- package/skill/examples/documentary/theme.ts +20 -0
- package/skill/examples/series/DESIGN.md +55 -0
- package/skill/examples/series/app.tsx +17 -0
- package/skill/examples/series/components/Action.tsx +42 -0
- package/skill/examples/series/components/CatalogGrid.tsx +43 -0
- package/skill/examples/series/components/ContinueRail.tsx +78 -0
- package/skill/examples/series/components/Feedback.tsx +26 -0
- package/skill/examples/series/components/Field.tsx +34 -0
- package/skill/examples/series/components/LibraryRail.tsx +38 -0
- package/skill/examples/series/components/OutcomeNote.tsx +28 -0
- package/skill/examples/series/components/PlayAction.tsx +29 -0
- package/skill/examples/series/components/RestoreAction.tsx +33 -0
- package/skill/examples/series/components/Root.tsx +75 -0
- package/skill/examples/series/components/SaveTitle.tsx +34 -0
- package/skill/examples/series/components/Shell.tsx +75 -0
- package/skill/examples/series/components/TitleCard.tsx +62 -0
- package/skill/examples/series/components/UnlockAction.tsx +10 -0
- package/skill/examples/series/preview/phone-home.jpg +0 -0
- package/skill/examples/series/preview/tv-detail.jpg +0 -0
- package/skill/examples/series/preview/tv-home.jpg +0 -0
- package/skill/examples/series/screens/portrait/Account.tsx +125 -0
- package/skill/examples/series/screens/portrait/Browse.tsx +61 -0
- package/skill/examples/series/screens/portrait/Detail.tsx +231 -0
- package/skill/examples/series/screens/portrait/Home.tsx +109 -0
- package/skill/examples/series/screens/portrait/MyList.tsx +44 -0
- package/skill/examples/series/screens/portrait/Plans.tsx +131 -0
- package/skill/examples/series/screens/portrait/Player.tsx +138 -0
- package/skill/examples/series/screens/portrait/Profiles.tsx +103 -0
- package/skill/examples/series/screens/portrait/Search.tsx +50 -0
- package/skill/examples/series/screens/portrait/SignIn.tsx +94 -0
- package/skill/examples/series/screens/portrait/SignUp.tsx +100 -0
- package/skill/examples/series/store.tsx +192 -0
- package/skill/examples/series/theme.ts +32 -0
- package/skill/guides/final-pricing-capabilities.md +13 -0
- package/skill/reference/api.md +842 -0
- package/skill/reference/components.md +1782 -0
- package/skill/reference/packages.md +24 -0
- package/skill/scripts/assemble-checkout.mjs +93 -0
- package/skill/scripts/local-save.mjs +513 -0
- package/skill/scripts/materialize.mjs +319 -0
- package/skill/scripts/workspace-state.mjs +183 -0
- package/types/adelin-access.d.ts +70 -0
- package/types/adelin-analytics.d.ts +5 -0
- package/types/adelin-assets.d.ts +26 -0
- package/types/adelin-auth.d.ts +37 -0
- package/types/adelin-content.d.ts +112 -0
- package/types/adelin-device.d.ts +195 -0
- package/types/adelin-downloads.d.ts +47 -0
- package/types/adelin-env.d.ts +8 -0
- package/types/adelin-globals.d.ts +19 -0
- package/types/adelin-i18n.d.ts +31 -0
- package/types/adelin-native-stack.d.ts +178 -0
- package/types/adelin-navigation.d.ts +264 -0
- package/types/adelin-profiles.d.ts +51 -0
- package/types/adelin-react.d.ts +49 -0
- package/types/adelin-reanimated.d.ts +376 -0
- package/types/adelin-storage.d.ts +9 -0
- package/types/adelin-store.d.ts +74 -0
- package/types/adelin-ui.d.ts +1518 -0
- package/types/adelin-utils.d.ts +7 -0
- package/types/adelin-worklets.d.ts +15 -0
- package/workspace-tsconfig.json +53 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { useAuth } from '@adelin/auth';
|
|
2
|
+
import { useNavigation } from '@adelin/navigation';
|
|
3
|
+
import { useDispatch, useSelector } from '@adelin/store';
|
|
4
|
+
import { Platform } from '@adelin/device';
|
|
5
|
+
import { FocusGroup, Image, LinearGradient, Pressable, ScrollTarget, ScrollView, StyleSheet, Text, View, theme, useWindowDimensions, Screen } from '@adelin/ui';
|
|
6
|
+
import { loadLibrary } from '../../store';
|
|
7
|
+
import Shell from '../../components/Shell';
|
|
8
|
+
import Feedback from '../../components/Feedback';
|
|
9
|
+
import Action from '../../components/Action';
|
|
10
|
+
import LibraryRail from '../../components/LibraryRail';
|
|
11
|
+
import ContinueRail from '../../components/ContinueRail';
|
|
12
|
+
import PlayAction from '../../components/PlayAction';
|
|
13
|
+
|
|
14
|
+
export default function Home() {
|
|
15
|
+
const auth = useAuth();
|
|
16
|
+
const dispatch = useDispatch();
|
|
17
|
+
const navigation = useNavigation();
|
|
18
|
+
const entries = useSelector(state => state.library.entries);
|
|
19
|
+
const collections = useSelector(state => state.library.collections);
|
|
20
|
+
const status = useSelector(state => state.library.status);
|
|
21
|
+
const savedIds = useSelector(state => state.saved.ids);
|
|
22
|
+
const profiles = useSelector(state => state.profiles.list);
|
|
23
|
+
const activeId = useSelector(state => state.profiles.activeId);
|
|
24
|
+
const { width, height } = useWindowDimensions();
|
|
25
|
+
const wide = width >= 840 && height >= 480;
|
|
26
|
+
const series = entries.filter(entry => !entry.parentId && entry.kind === 'folder' && entries.some(child => child.parentId === entry.id));
|
|
27
|
+
const hero = series[0] ?? entries.find(entry => !entry.parentId);
|
|
28
|
+
const others = series.filter(entry => entry.id !== hero?.id);
|
|
29
|
+
const seasons = entries.filter(entry => entry.parentId === hero?.id && entry.kind === 'folder');
|
|
30
|
+
const episodeCount = entries.filter(entry => entry.kind === 'item' && (entry.parentId === hero?.id || seasons.some(season => season.id === entry.parentId))).length;
|
|
31
|
+
const genre = collections.find(collection => !!collection.parentId && collection.entryIds.includes(hero?.id ?? ''));
|
|
32
|
+
const kicker = [genre ? genre.name : hero?.label ?? '', seasons.length > 0 ? seasons.length + (seasons.length === 1 ? ' season' : ' seasons') : '', episodeCount > 0 ? episodeCount + (episodeCount === 1 ? ' episode' : ' episodes') : ''].filter(part => part !== '').join(' · ').toUpperCase();
|
|
33
|
+
const saved = savedIds.map(id => entries.find(entry => entry.id === id)).filter(entry => !!entry);
|
|
34
|
+
const viewer = profiles.find(profile => profile.id === activeId);
|
|
35
|
+
const synopsis = hero?.description ?? '';
|
|
36
|
+
const sentenceEnd = synopsis.indexOf('. ');
|
|
37
|
+
const teaser = sentenceEnd >= 0 ? synopsis.slice(0, sentenceEnd + 1) : synopsis;
|
|
38
|
+
const picture = wide ? hero?.artwork.backdrop || hero?.artwork.poster : hero?.artwork.poster || hero?.artwork.backdrop;
|
|
39
|
+
return (
|
|
40
|
+
<Screen>
|
|
41
|
+
<Shell active="Home" contentAutoFocus>
|
|
42
|
+
{status === 'idle' || status === 'loading' ? <Feedback title="Finding your place" message="Gathering series and episodes." loading /> : status === 'failed' ? <Feedback title="The library could not load" message="Check your connection and try again." onRetry={() => dispatch(loadLibrary())} /> : !hero ? <Feedback title="The first story is on its way" message="Series will appear here as soon as they are added." /> : (
|
|
43
|
+
<ScrollView style={styles.scroll} contentContainerStyle={styles.content} showsVerticalScrollIndicator={false}>
|
|
44
|
+
<ScrollTarget y={0}>
|
|
45
|
+
<View style={[styles.hero, wide && styles.heroWide]}>
|
|
46
|
+
{picture ? <Image source={{ uri: picture }} resizeMode="cover" style={styles.fill} /> : <View style={styles.fill} />}
|
|
47
|
+
{wide && <LinearGradient colors={[theme.gradients.scrimDeep, theme.gradients.scrimSoft, theme.gradients.scrimClear]} start={{ x: 0, y: 0 }} end={{ x: 0.62, y: 0 }} style={styles.fill} pointerEvents="none" />}
|
|
48
|
+
<LinearGradient colors={[theme.gradients.scrimClear, theme.gradients.scrimMiddle, theme.gradients.scrimSolid]} start={{ x: 0, y: wide ? 0.5 : 0.4 }} end={{ x: 0, y: 1 }} style={styles.fill} pointerEvents="none" />
|
|
49
|
+
<View style={[styles.topLine, wide && styles.topLineWide]}>
|
|
50
|
+
{!wide && <Text style={styles.wordmark}>ARC</Text>}
|
|
51
|
+
{!wide && auth.status === 'signed-in' && (
|
|
52
|
+
<Pressable onPress={() => navigation.navigate('Profiles')} style={styles.avatar} focusAnimation={{ border: { color: theme.colors.text, width: 2 } }} accessibilityRole="button" accessibilityLabel={viewer ? 'Profile ' + viewer.name + ', switch profile' : 'Choose a profile'}>
|
|
53
|
+
<Text style={styles.avatarText} maxFontSizeMultiplier={1}>{viewer ? viewer.name.slice(0, 1).toUpperCase() : '+'}</Text>
|
|
54
|
+
</Pressable>
|
|
55
|
+
)}
|
|
56
|
+
</View>
|
|
57
|
+
<View style={[styles.copy, wide && styles.copyWide]}>
|
|
58
|
+
<Text style={styles.kicker} numberOfLines={1}>{kicker}</Text>
|
|
59
|
+
<Text style={[styles.title, wide && styles.titleWide]} numberOfLines={2}>{hero.title}</Text>
|
|
60
|
+
<Text style={styles.synopsis} numberOfLines={wide ? 2 : 3}>{teaser}</Text>
|
|
61
|
+
<FocusGroup direction="horizontal" remember>
|
|
62
|
+
<View style={styles.actions}>
|
|
63
|
+
<View style={styles.action}><PlayAction item={hero} preferred focusKey="arc-play" /></View>
|
|
64
|
+
<View style={styles.action}><Action label="View series" focusKey="arc-series" onPress={() => navigation.push('Detail', { id: hero.id })} /></View>
|
|
65
|
+
</View>
|
|
66
|
+
</FocusGroup>
|
|
67
|
+
</View>
|
|
68
|
+
</View>
|
|
69
|
+
</ScrollTarget>
|
|
70
|
+
<ContinueRail meta={viewer ? 'Where ' + viewer.name + ' left off' : ''} />
|
|
71
|
+
<BeginRail root={hero} />
|
|
72
|
+
{saved.length > 0 && <LibraryRail title="My List" meta={viewer ? 'Saved by ' + viewer.name : ''} entries={saved} />}
|
|
73
|
+
{others.length > 0 && <LibraryRail title="More series" entries={others} wide />}
|
|
74
|
+
{others.map(root => <BeginRail key={root.id} root={root} />)}
|
|
75
|
+
</ScrollView>
|
|
76
|
+
)}
|
|
77
|
+
</Shell>
|
|
78
|
+
</Screen>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function BeginRail({ root }: { root: { id: string; title: string } }) {
|
|
83
|
+
const entries = useSelector(state => state.library.entries);
|
|
84
|
+
const seasons = entries.filter(entry => entry.parentId === root.id && entry.kind === 'folder');
|
|
85
|
+
const first = seasons.find(season => !seasons.some(other => Number(other.position) < Number(season.position)));
|
|
86
|
+
const episodes = entries.filter(entry => entry.kind === 'item' && entry.parentId === (first ? first.id : root.id));
|
|
87
|
+
return <LibraryRail title={'Begin ' + root.title} meta={first ? first.title : ''} entries={episodes} />;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const styles = StyleSheet.create({
|
|
91
|
+
scroll: { flex: 1 },
|
|
92
|
+
content: { paddingBottom: theme.spacing.xl },
|
|
93
|
+
hero: { height: 500, marginBottom: theme.spacing.md, backgroundColor: theme.colors.surface, overflow: 'hidden', justifyContent: 'flex-end' },
|
|
94
|
+
heroWide: { height: 300, marginBottom: 6 },
|
|
95
|
+
fill: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0, width: '100%', height: '100%' },
|
|
96
|
+
topLine: { position: 'absolute', top: 12, left: 20, right: 20, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
|
|
97
|
+
topLineWide: { top: 22, left: 32, right: 32 },
|
|
98
|
+
wordmark: { color: theme.colors.text, fontSize: Platform.select({ tv: 12, default: 17 }), lineHeight: Platform.select({ tv: 16, default: 22 }), fontWeight: '900', letterSpacing: Platform.select({ tv: 3, default: 4 }) },
|
|
99
|
+
avatar: { width: 36, height: 36, borderRadius: 18, backgroundColor: theme.colors.primary, alignItems: 'center', justifyContent: 'center' },
|
|
100
|
+
avatarText: { color: theme.colors.background, fontSize: 16, lineHeight: 20, fontWeight: '900' },
|
|
101
|
+
copy: { paddingHorizontal: 20, paddingBottom: 8 },
|
|
102
|
+
copyWide: { width: 470, paddingHorizontal: 32, paddingBottom: 22 },
|
|
103
|
+
kicker: { color: theme.colors.accent, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 12, default: 15 }), fontWeight: '800', letterSpacing: Platform.select({ tv: 1.6, default: 1.4 }) },
|
|
104
|
+
title: { color: theme.colors.text, fontSize: 36, lineHeight: 39, fontWeight: '900', letterSpacing: -1.2, marginTop: theme.spacing.sm },
|
|
105
|
+
titleWide: { fontSize: 40, lineHeight: 42, letterSpacing: -1.6 },
|
|
106
|
+
synopsis: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 11, default: 15 }), lineHeight: Platform.select({ tv: 16, default: 21 }), marginTop: Platform.select({ tv: 8, default: 10 }), maxWidth: 400 },
|
|
107
|
+
actions: { flexDirection: 'row', alignItems: 'flex-start', marginTop: Platform.select({ tv: 14, default: 18 }) },
|
|
108
|
+
action: { marginRight: Platform.select({ tv: 10, default: 10 }) },
|
|
109
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
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, Screen } from '@adelin/ui';
|
|
5
|
+
import { Platform } from '@adelin/device';
|
|
6
|
+
import { loadSaved } from '../../store';
|
|
7
|
+
import Shell from '../../components/Shell';
|
|
8
|
+
import CatalogGrid from '../../components/CatalogGrid';
|
|
9
|
+
import Feedback from '../../components/Feedback';
|
|
10
|
+
import Action from '../../components/Action';
|
|
11
|
+
|
|
12
|
+
export default function MyList() {
|
|
13
|
+
const auth = useAuth();
|
|
14
|
+
const navigation = useNavigation();
|
|
15
|
+
const dispatch = useDispatch();
|
|
16
|
+
const entries = useSelector(state => state.library.entries);
|
|
17
|
+
const profiles = useSelector(state => state.profiles.list);
|
|
18
|
+
const profileId = useSelector(state => state.profiles.activeId);
|
|
19
|
+
const ids = useSelector(state => state.saved.ids);
|
|
20
|
+
const status = useSelector(state => state.saved.status);
|
|
21
|
+
const viewer = profiles.find(profile => profile.id === profileId);
|
|
22
|
+
const chosen = ids.map(id => entries.find(entry => entry.id === id)).filter(entry => !!entry);
|
|
23
|
+
return (
|
|
24
|
+
<Screen>
|
|
25
|
+
<Shell active="MyList" contentAutoFocus>
|
|
26
|
+
<View style={styles.page}>
|
|
27
|
+
<View style={styles.header}>
|
|
28
|
+
<Text style={styles.title}>My List</Text>
|
|
29
|
+
{!!viewer && <Text style={styles.meta}>{'SAVED BY ' + viewer.name.toUpperCase()}</Text>}
|
|
30
|
+
</View>
|
|
31
|
+
{auth.status !== 'signed-in' ? <View style={styles.state}><Feedback title="Keep a story close" message="Sign in to save series and episodes for later." /><Action label="Sign in" primary onPress={() => navigation.navigate('SignIn')} /></View> : profileId === '' ? <View style={styles.state}><Feedback title="Who is watching?" message="Each profile keeps its own list." /><Action label="Choose a profile" primary onPress={() => navigation.navigate('Profiles')} /></View> : status === 'failed' ? <View style={styles.state}><Feedback title="Your list could not load" message="Check your connection and try again." /><Action label="Try again" primary onPress={() => dispatch(loadSaved(profileId))} /></View> : status !== 'ready' ? <Feedback title="Opening My List" message="Gathering your saved stories." loading /> : <CatalogGrid entries={chosen} emptyTitle="Nothing saved yet" emptyMessage="Choose My List on any series or episode and it will wait for you here." />}
|
|
32
|
+
</View>
|
|
33
|
+
</Shell>
|
|
34
|
+
</Screen>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
page: { flex: 1 },
|
|
40
|
+
header: { flexDirection: 'row', alignItems: 'baseline', paddingHorizontal: Platform.select({ tv: 32, default: 20 }), paddingTop: Platform.select({ tv: 28, default: 16 }), paddingBottom: Platform.select({ tv: 12, default: 12 }) },
|
|
41
|
+
title: { color: theme.colors.text, fontSize: Platform.select({ tv: 26, default: 30 }), lineHeight: Platform.select({ tv: 30, default: 36 }), fontWeight: '900', letterSpacing: -0.8, marginRight: theme.spacing.md },
|
|
42
|
+
meta: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 12, default: 15 }), fontWeight: '800', letterSpacing: 1.3 },
|
|
43
|
+
state: { alignItems: 'center', paddingHorizontal: theme.spacing.lg },
|
|
44
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Offer } from '@adelin/access';
|
|
2
|
+
import { useAccess } from '@adelin/access';
|
|
3
|
+
import { useState } from '@adelin/react';
|
|
4
|
+
import { useAuth } from '@adelin/auth';
|
|
5
|
+
import { useNavigation, useRoute } from '@adelin/navigation';
|
|
6
|
+
import { useDispatch, useSelector } from '@adelin/store';
|
|
7
|
+
import { FocusGroup, ScrollView, StyleSheet, Text, View, theme, Screen } from '@adelin/ui';
|
|
8
|
+
import { Platform } from '@adelin/device';
|
|
9
|
+
import { buyTitle, rentTitle, startPlan, startPlanTrial } from '../../store';
|
|
10
|
+
import Shell from '../../components/Shell';
|
|
11
|
+
import Action from '../../components/Action';
|
|
12
|
+
import Feedback from '../../components/Feedback';
|
|
13
|
+
import OutcomeNote from '../../components/OutcomeNote';
|
|
14
|
+
import RestoreAction from '../../components/RestoreAction';
|
|
15
|
+
|
|
16
|
+
/** The paywall: every offer that opens the title it was opened for, or every plan. */
|
|
17
|
+
export default function Plans() {
|
|
18
|
+
const navigation = useNavigation();
|
|
19
|
+
const route = useRoute();
|
|
20
|
+
const access = useAccess();
|
|
21
|
+
const entries = useSelector(state => state.library.entries);
|
|
22
|
+
const title = entries.find(entry => entry.id === route.params.id);
|
|
23
|
+
const lock = title ? access.item(title.id) : null;
|
|
24
|
+
const offers = access.offers.filter(offer => lock ? lock.offerIds.includes(offer.id) : offer.kind === 'plan');
|
|
25
|
+
return (
|
|
26
|
+
<Screen>
|
|
27
|
+
<Shell active="" contentAutoFocus>
|
|
28
|
+
<ScrollView style={styles.scroll} contentContainerStyle={styles.content}>
|
|
29
|
+
<Text style={styles.kicker}>{title ? 'WAYS TO WATCH' : 'PLANS'}</Text>
|
|
30
|
+
<Text style={styles.heading} numberOfLines={2}>{title ? title.title : 'Choose how you watch'}</Text>
|
|
31
|
+
{access.status === 'loading' ? <Feedback title="Finding your options" message="Checking what you can watch." loading /> : title !== undefined && lock !== null && lock.open ? (
|
|
32
|
+
<View style={styles.panel}>
|
|
33
|
+
<Text style={styles.name}>You can watch this now</Text>
|
|
34
|
+
<View style={styles.cta}><Action label="Watch now" icon="ph:play-fill" primary preferred onPress={() => title.kind === 'item' ? navigation.navigate('Player', { id: title.id }) : navigation.push('Detail', { id: title.id })} /></View>
|
|
35
|
+
</View>
|
|
36
|
+
) : offers.length === 0 ? <Feedback title="Nothing to choose yet" message="Plans for this library will appear here." /> : (
|
|
37
|
+
<FocusGroup direction="vertical" remember autoFocus>
|
|
38
|
+
<View>
|
|
39
|
+
{offers.map(offer => <OfferPanel key={offer.id} offer={offer} entryId={title ? title.id : ''} />)}
|
|
40
|
+
</View>
|
|
41
|
+
</FocusGroup>
|
|
42
|
+
)}
|
|
43
|
+
<View style={styles.restore}>
|
|
44
|
+
<Text style={styles.label}>ALREADY PAID?</Text>
|
|
45
|
+
<RestoreAction />
|
|
46
|
+
</View>
|
|
47
|
+
</ScrollView>
|
|
48
|
+
</Shell>
|
|
49
|
+
</Screen>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function OfferPanel({ offer, entryId }: { offer: Offer; entryId: string }) {
|
|
54
|
+
const auth = useAuth();
|
|
55
|
+
const navigation = useNavigation();
|
|
56
|
+
const dispatch = useDispatch();
|
|
57
|
+
const pending = useSelector(state => state.paywall.pending);
|
|
58
|
+
const access = useAccess();
|
|
59
|
+
const otherPlan = offer.kind === 'plan' ? access.holdings.find(holding => holding.kind === 'subscription' && holding.offerId !== offer.id && holding.status !== 'cancelled') : undefined;
|
|
60
|
+
const [period, setPeriod] = useState('');
|
|
61
|
+
const [result, setResult] = useState({ outcome: '', reason: '' });
|
|
62
|
+
const show = (next: { outcome: string; reason?: string }) => setResult({ outcome: next.outcome, reason: next.reason ?? '' });
|
|
63
|
+
const fail = () => setResult({ outcome: 'failed', reason: '' });
|
|
64
|
+
const choices = choicesOf(offer);
|
|
65
|
+
const price = choices.find(choice => choice.period === period) ?? choices[0];
|
|
66
|
+
const trial = offer.kind === 'plan' && offer.trialAvailable === true;
|
|
67
|
+
const days = offer.trialDays ?? 0;
|
|
68
|
+
const verb = offer.kind === 'plan' ? 'Subscribe' : offer.kind === 'rental' ? 'Rent' : 'Buy';
|
|
69
|
+
const label = price === undefined ? '' : trial ? (days > 0 ? 'Start your ' + days + '-day free trial' : 'Start your free trial') : price.priceLabel === '' ? verb : verb + ' for ' + priceText(price);
|
|
70
|
+
const covers = offer.covers.wholeLibrary ? 'Every series in the library' : [offer.covers.collections > 0 ? offer.covers.collections + (offer.covers.collections === 1 ? ' collection' : ' collections') : '', offer.covers.titles > 0 ? offer.covers.titles + (offer.covers.titles === 1 ? ' title' : ' titles') : ''].filter(part => part !== '').join(' · ');
|
|
71
|
+
const run = () => {
|
|
72
|
+
if (price === undefined) return;
|
|
73
|
+
setResult({ outcome: '', reason: '' });
|
|
74
|
+
if (offer.kind === 'rental') { dispatch(rentTitle({ offerId: offer.id, entryId })).unwrap().then(show).catch(fail); return; }
|
|
75
|
+
if (offer.kind === 'purchase') { dispatch(buyTitle({ offerId: offer.id })).unwrap().then(show).catch(fail); return; }
|
|
76
|
+
const chosen = price.period === 'year' ? 'year' : 'month';
|
|
77
|
+
if (trial) { dispatch(startPlanTrial({ offerId: offer.id, period: chosen })).unwrap().then(show).catch(fail); return; }
|
|
78
|
+
dispatch(startPlan({ offerId: offer.id, period: chosen })).unwrap().then(show).catch(fail);
|
|
79
|
+
};
|
|
80
|
+
if (offer.kind === 'rental' && entryId === '') return null;
|
|
81
|
+
return (
|
|
82
|
+
<View style={styles.panel}>
|
|
83
|
+
<Text style={styles.name}>{offer.name}</Text>
|
|
84
|
+
{offer.description !== '' && <Text style={styles.body}>{offer.description}</Text>}
|
|
85
|
+
{covers !== '' && <Text style={styles.label}>{covers.toUpperCase()}</Text>}
|
|
86
|
+
{offer.kind === 'rental' && offer.rentalStartHours !== null && offer.rentalViewHours !== null && <Text style={styles.body}>{offer.rentalStartHours + ' hours to start watching, then ' + offer.rentalViewHours + ' hours to finish.'}</Text>}
|
|
87
|
+
{price !== undefined && price.priceLabel !== '' && !(offer.kind === 'plan' && choices.length > 1) && <Text style={styles.body}>{priceText(price)}</Text>}
|
|
88
|
+
{offer.kind === 'plan' && choices.length > 1 && (
|
|
89
|
+
<FocusGroup direction="horizontal" remember>
|
|
90
|
+
<View style={styles.periods}>
|
|
91
|
+
{choices.map(choice => <View key={choice.period} style={styles.period}><Action label={priceText(choice)} icon={choice.period === price?.period ? 'ph:check-circle-fill' : ''} onPress={() => setPeriod(choice.period)} /></View>)}
|
|
92
|
+
</View>
|
|
93
|
+
</FocusGroup>
|
|
94
|
+
)}
|
|
95
|
+
{!offer.purchasable ? <Text style={styles.body}>Not available on this device</Text> : otherPlan !== undefined ? <Text style={styles.body}>{"You're on " + (otherPlan.offerName ?? 'another plan') + '. To switch, cancel it under Manage subscription first.'}</Text> : auth.status !== 'signed-in' ? <View style={styles.cta}><Action label="Sign in to continue" primary onPress={() => navigation.navigate('SignIn')} /></View> : label !== '' && (
|
|
96
|
+
<View style={styles.cta}>
|
|
97
|
+
<Action label={label} primary disabled={pending} onPress={run} />
|
|
98
|
+
{trial && price !== undefined && price.priceLabel !== '' && <Text style={styles.body}>{'Then ' + priceText(price) + '.'}</Text>}
|
|
99
|
+
</View>
|
|
100
|
+
)}
|
|
101
|
+
<OutcomeNote outcome={result.outcome} reason={result.reason} />
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Web prices where there are any; on phones and TVs the store's periods, labelled with the store's price once it answers. */
|
|
107
|
+
function choicesOf(offer: Offer) {
|
|
108
|
+
if (offer.prices.length > 0) return offer.prices.map(price => ({ period: price.period, priceLabel: price.priceLabel }));
|
|
109
|
+
const periods = offer.kind === 'plan' ? offer.billingPeriods ?? [] : ['once'];
|
|
110
|
+
return periods.map(period => ({ period, priceLabel: offer.storePrices?.find(price => price.period === period)?.priceLabel ?? '' }));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function priceText(price: { period: string; priceLabel: string }) {
|
|
114
|
+
if (price.priceLabel === '') return price.period === 'year' ? 'Yearly' : price.period === 'month' ? 'Monthly' : '';
|
|
115
|
+
return price.priceLabel + (price.period === 'month' ? ' a month' : price.period === 'year' ? ' a year' : '');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const styles = StyleSheet.create({
|
|
119
|
+
scroll: { flex: 1 },
|
|
120
|
+
content: { paddingHorizontal: Platform.select({ tv: 32, default: 20 }), paddingTop: Platform.select({ tv: 28, default: 16 }), paddingBottom: theme.spacing.xl },
|
|
121
|
+
kicker: { color: theme.colors.accent, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 12, default: 15 }), fontWeight: '800', letterSpacing: 1.3 },
|
|
122
|
+
heading: { color: theme.colors.text, fontSize: Platform.select({ tv: 26, default: 30 }), lineHeight: Platform.select({ tv: 30, default: 36 }), fontWeight: '900', letterSpacing: -0.8, marginTop: theme.spacing.xs, marginBottom: Platform.select({ tv: 18, default: 18 }) },
|
|
123
|
+
panel: { maxWidth: 640, backgroundColor: theme.colors.surface, borderRadius: 6, padding: Platform.select({ tv: 18, default: 16 }), marginBottom: theme.spacing.md },
|
|
124
|
+
name: { color: theme.colors.text, fontSize: Platform.select({ tv: 16, default: 20 }), lineHeight: Platform.select({ tv: 21, default: 26 }), fontWeight: '900', letterSpacing: -0.3 },
|
|
125
|
+
body: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 10, default: 14 }), lineHeight: Platform.select({ tv: 15, default: 20 }), marginTop: theme.spacing.xs },
|
|
126
|
+
label: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 7, default: 10 }), lineHeight: Platform.select({ tv: 11, default: 14 }), fontWeight: '800', letterSpacing: 1.3, marginTop: theme.spacing.sm, marginBottom: theme.spacing.xs },
|
|
127
|
+
periods: { flexDirection: 'row', flexWrap: 'wrap', marginTop: theme.spacing.sm },
|
|
128
|
+
period: { marginRight: theme.spacing.sm, marginBottom: theme.spacing.xs },
|
|
129
|
+
cta: { marginTop: theme.spacing.md },
|
|
130
|
+
restore: { maxWidth: 640, marginTop: theme.spacing.md },
|
|
131
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { useEffect, useState } from '@adelin/react';
|
|
2
|
+
import type { VideoSource } from '@adelin/ui';
|
|
3
|
+
import { useNavigation, useRoute } from '@adelin/navigation';
|
|
4
|
+
import { useDispatch, useSelector } from '@adelin/store';
|
|
5
|
+
import { ActivityIndicator, FocusGroup, LinearGradient, SafeAreaView, StyleSheet, Text, VideoView, View, theme, useVideoPlayer, Screen } from '@adelin/ui';
|
|
6
|
+
import { Keys, Platform, useTVEventHandler } from '@adelin/device';
|
|
7
|
+
import Action from '../../components/Action';
|
|
8
|
+
import Feedback from '../../components/Feedback';
|
|
9
|
+
import { loadWatching } from '../../store';
|
|
10
|
+
|
|
11
|
+
export default function Player() {
|
|
12
|
+
const navigation = useNavigation();
|
|
13
|
+
const route = useRoute();
|
|
14
|
+
const entries = useSelector(state => state.library.entries);
|
|
15
|
+
const item = entries.find(entry => entry.id === route.params.id);
|
|
16
|
+
const parent = entries.find(entry => entry.id === item?.parentId);
|
|
17
|
+
const grand = entries.find(entry => entry.id === parent?.parentId);
|
|
18
|
+
const number = entries.filter(entry => entry.parentId === item?.parentId && entry.kind === 'item' && Number(entry.position) < Number(item?.position)).length + 1;
|
|
19
|
+
const seasonNumber = entries.filter(entry => entry.parentId === parent?.parentId && entry.kind === 'folder' && Number(entry.position) < Number(parent?.position)).length + 1;
|
|
20
|
+
const later = entries.filter(entry => entry.kind === 'item' && entry.parentId === item?.parentId && Number(entry.position) > Number(item?.position));
|
|
21
|
+
const next = later.find(entry => !later.some(other => Number(other.position) < Number(entry.position)));
|
|
22
|
+
const context = !parent ? item?.label ?? '' : [grand ? grand.title : parent.title, grand ? 'Season ' + seasonNumber : '', 'Episode ' + number].filter(part => part !== '').join(' · ');
|
|
23
|
+
const source = item?.playbackSource;
|
|
24
|
+
return (
|
|
25
|
+
<Screen>
|
|
26
|
+
<View style={styles.page}>
|
|
27
|
+
{source?.uri ? (
|
|
28
|
+
<Playback source={source} entryId={item?.id ?? ''} title={item?.title ?? 'Playback'} context={context.toUpperCase()} numeral={parent ? (number < 10 ? '0' + number : '' + number) : ''} nextLabel={next ? 'Next · E' + (number + 1) : ''} onNext={() => navigation.replace('Player', { id: next?.id })} onRetry={() => navigation.replace('Player', { id: item?.id })} onBack={() => navigation.goBack()} />
|
|
29
|
+
) : (
|
|
30
|
+
<SafeAreaView style={styles.unavailable}><Feedback title="This episode cannot play yet" message="Return to the series and choose another episode." /><Action label="Back to the series" icon="ph:caret-left" onPress={() => navigation.goBack()} preferred /></SafeAreaView>
|
|
31
|
+
)}
|
|
32
|
+
</View>
|
|
33
|
+
</Screen>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Playback({ source, entryId, title, context, numeral, nextLabel, onNext, onRetry, onBack }: {
|
|
38
|
+
source: VideoSource;
|
|
39
|
+
entryId: string;
|
|
40
|
+
title: string;
|
|
41
|
+
context: string;
|
|
42
|
+
numeral: string;
|
|
43
|
+
nextLabel: string;
|
|
44
|
+
onNext: () => void;
|
|
45
|
+
onRetry: () => void;
|
|
46
|
+
onBack: () => void;
|
|
47
|
+
}) {
|
|
48
|
+
const player = useVideoPlayer(source, { entryId });
|
|
49
|
+
const dispatch = useDispatch();
|
|
50
|
+
const profileId = useSelector(state => state.profiles.activeId);
|
|
51
|
+
useEffect(() => () => { if (profileId !== '') dispatch(loadWatching(profileId)); }, [profileId]);
|
|
52
|
+
const [timedOut, setTimedOut] = useState(false);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const timer = setTimeout(() => { if (player.duration <= 0) setTimedOut(true); }, 15000);
|
|
55
|
+
return () => clearTimeout(timer);
|
|
56
|
+
}, [player.duration]);
|
|
57
|
+
useTVEventHandler(event => {
|
|
58
|
+
if (event.eventKeyAction !== 'down') return false;
|
|
59
|
+
if (event.eventType === Keys.PlayPause) player.togglePlay();
|
|
60
|
+
else if (event.eventType === Keys.Play) player.play();
|
|
61
|
+
else if (event.eventType === Keys.Pause) player.pause();
|
|
62
|
+
else if (event.eventType === Keys.Stop) player.stop();
|
|
63
|
+
else if (event.eventType === Keys.Rewind) player.scrubBackward();
|
|
64
|
+
else if (event.eventType === Keys.FastForward) player.scrubForward();
|
|
65
|
+
else return false;
|
|
66
|
+
return true;
|
|
67
|
+
});
|
|
68
|
+
const position = Math.floor(player.position);
|
|
69
|
+
const duration = Math.floor(player.duration);
|
|
70
|
+
return (
|
|
71
|
+
<View style={styles.layout}>
|
|
72
|
+
<VideoView player={player} style={styles.video} resizeMode="contain" />
|
|
73
|
+
{player.duration <= 0 && (
|
|
74
|
+
<View style={styles.loading}>
|
|
75
|
+
{timedOut ? <Feedback title="The episode has not loaded" message="Check your connection and try again." onRetry={onRetry} /> : <View style={styles.loadingNote}><ActivityIndicator color={theme.colors.primary} /><Text style={styles.loadingText}>Starting {title}</Text></View>}
|
|
76
|
+
</View>
|
|
77
|
+
)}
|
|
78
|
+
<LinearGradient colors={[theme.gradients.playerChrome, theme.gradients.scrimClear]} start={{ x: 0, y: 0 }} end={{ x: 0, y: 1 }} style={styles.topShade} pointerEvents="none" />
|
|
79
|
+
<LinearGradient colors={[theme.gradients.scrimClear, theme.gradients.playerChrome, theme.gradients.numeralShade]} start={{ x: 0, y: 0 }} end={{ x: 0, y: 1 }} style={styles.bottomShade} pointerEvents="none" />
|
|
80
|
+
<SafeAreaView edges={['top', 'left', 'right']} style={styles.topSafe}>
|
|
81
|
+
<View style={styles.top}>
|
|
82
|
+
<Action label="Back" icon="ph:caret-left" onPress={onBack} />
|
|
83
|
+
</View>
|
|
84
|
+
</SafeAreaView>
|
|
85
|
+
<SafeAreaView edges={['left', 'right', 'bottom']} style={styles.bottomSafe}>
|
|
86
|
+
<View style={styles.controls}>
|
|
87
|
+
<View style={styles.heading}>
|
|
88
|
+
{numeral !== '' && <Text style={styles.numeral} maxFontSizeMultiplier={1}>{numeral}</Text>}
|
|
89
|
+
<View style={styles.headingCopy}>
|
|
90
|
+
<Text style={styles.context} numberOfLines={1}>{context}</Text>
|
|
91
|
+
<Text style={styles.title} numberOfLines={1}>{title}</Text>
|
|
92
|
+
</View>
|
|
93
|
+
</View>
|
|
94
|
+
<View style={styles.progressTrack}><View style={[styles.progressFill, { width: (player.duration > 0 ? Math.min(100, player.position / player.duration * 100) : 0) + '%' }]} /></View>
|
|
95
|
+
<View style={styles.timeRow}>
|
|
96
|
+
<Text style={styles.time}>{Math.floor(position / 60)}:{position % 60 < 10 ? '0' : ''}{position % 60}</Text>
|
|
97
|
+
<Text style={styles.time}>{Math.floor(duration / 60)}:{duration % 60 < 10 ? '0' : ''}{duration % 60}</Text>
|
|
98
|
+
</View>
|
|
99
|
+
<FocusGroup direction="horizontal" remember autoFocus>
|
|
100
|
+
<View style={styles.buttons}>
|
|
101
|
+
<View style={styles.action}><Action label={player.playing ? 'Pause' : 'Play'} icon={player.playing ? 'ph:pause-fill' : 'ph:play-fill'} primary preferred onPress={() => player.togglePlay()} /></View>
|
|
102
|
+
<View style={styles.action}><Action label="−10 s" icon="ph:arrow-counter-clockwise" onPress={() => player.seekBy(-10)} /></View>
|
|
103
|
+
<View style={styles.action}><Action label="+10 s" icon="ph:arrow-clockwise" onPress={() => player.seekBy(10)} /></View>
|
|
104
|
+
{nextLabel !== '' && <View style={styles.action}><Action label={nextLabel} icon="ph:skip-forward-fill" onPress={onNext} /></View>}
|
|
105
|
+
</View>
|
|
106
|
+
</FocusGroup>
|
|
107
|
+
</View>
|
|
108
|
+
</SafeAreaView>
|
|
109
|
+
</View>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const styles = StyleSheet.create({
|
|
114
|
+
page: { flex: 1, backgroundColor: theme.gradients.screen },
|
|
115
|
+
layout: { flex: 1 },
|
|
116
|
+
video: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 },
|
|
117
|
+
loading: { position: 'absolute', left: 0, right: 0, top: '30%' },
|
|
118
|
+
loadingNote: { padding: theme.spacing.lg, alignItems: 'center' },
|
|
119
|
+
loadingText: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 11, default: 15 }), lineHeight: Platform.select({ tv: 16, default: 21 }), marginTop: theme.spacing.sm },
|
|
120
|
+
topShade: { position: 'absolute', top: 0, left: 0, right: 0, height: Platform.select({ tv: 90, default: 120 }) },
|
|
121
|
+
bottomShade: { position: 'absolute', bottom: 0, left: 0, right: 0, height: Platform.select({ tv: 250, default: 300 }) },
|
|
122
|
+
topSafe: { position: 'absolute', left: 0, right: 0, top: 0 },
|
|
123
|
+
top: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: Platform.select({ tv: 32, default: 16 }), paddingTop: Platform.select({ tv: 24, default: 8 }) },
|
|
124
|
+
bottomSafe: { position: 'absolute', left: 0, right: 0, bottom: 0 },
|
|
125
|
+
controls: { paddingHorizontal: Platform.select({ tv: 32, default: 16 }), paddingBottom: Platform.select({ tv: 26, default: 12 }) },
|
|
126
|
+
heading: { flexDirection: 'row', alignItems: 'flex-end' },
|
|
127
|
+
numeral: { color: theme.colors.accent, fontSize: Platform.select({ tv: 40, default: 44 }), lineHeight: Platform.select({ tv: 42, default: 46 }), fontWeight: '900', letterSpacing: -1.5, marginRight: Platform.select({ tv: 12, default: 12 }) },
|
|
128
|
+
headingCopy: { flex: 1, paddingBottom: 3 },
|
|
129
|
+
context: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 12, default: 15 }), fontWeight: '800', letterSpacing: 1.4 },
|
|
130
|
+
title: { color: theme.colors.text, fontSize: Platform.select({ tv: 18, default: 20 }), lineHeight: Platform.select({ tv: 23, default: 26 }), fontWeight: '900', letterSpacing: -0.4, marginTop: 2 },
|
|
131
|
+
progressTrack: { height: 3, backgroundColor: theme.colors.border, borderRadius: 2, marginTop: Platform.select({ tv: 14, default: 14 }) },
|
|
132
|
+
progressFill: { height: 3, backgroundColor: theme.colors.primary, borderRadius: 2 },
|
|
133
|
+
timeRow: { flexDirection: 'row', justifyContent: 'space-between', marginTop: 6, marginBottom: Platform.select({ tv: 12, default: 12 }) },
|
|
134
|
+
time: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 8, default: 12 }), lineHeight: Platform.select({ tv: 12, default: 16 }), fontWeight: '700' },
|
|
135
|
+
buttons: { flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap' },
|
|
136
|
+
action: { marginRight: Platform.select({ tv: 10, default: 8 }), marginBottom: theme.spacing.sm },
|
|
137
|
+
unavailable: { flex: 1, backgroundColor: theme.colors.background, padding: theme.spacing.lg, alignItems: 'center', justifyContent: 'center' },
|
|
138
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useState } from '@adelin/react';
|
|
2
|
+
import { useAuth } from '@adelin/auth';
|
|
3
|
+
import { useNavigation } from '@adelin/navigation';
|
|
4
|
+
import { useDispatch, useSelector } from '@adelin/store';
|
|
5
|
+
import { FocusGroup, Icon, Pressable, SafeAreaView, ScrollView, StyleSheet, Text, View, theme, useWindowDimensions, Screen } from '@adelin/ui';
|
|
6
|
+
import { Platform } from '@adelin/device';
|
|
7
|
+
import { addProfile, chooseProfile, loadProfiles } from '../../store';
|
|
8
|
+
import Feedback from '../../components/Feedback';
|
|
9
|
+
import Action from '../../components/Action';
|
|
10
|
+
import Field from '../../components/Field';
|
|
11
|
+
|
|
12
|
+
export default function Profiles() {
|
|
13
|
+
const auth = useAuth();
|
|
14
|
+
const navigation = useNavigation();
|
|
15
|
+
const dispatch = useDispatch();
|
|
16
|
+
const profiles = useSelector(state => state.profiles.list);
|
|
17
|
+
const activeId = useSelector(state => state.profiles.activeId);
|
|
18
|
+
const status = useSelector(state => state.profiles.status);
|
|
19
|
+
const { width, height } = useWindowDimensions();
|
|
20
|
+
const wide = width >= 840 && height >= 480;
|
|
21
|
+
const [adding, setAdding] = useState(false);
|
|
22
|
+
const [name, setName] = useState('');
|
|
23
|
+
const [message, setMessage] = useState('');
|
|
24
|
+
const tones = [theme.colors.primary, theme.gradients.toneSea, theme.gradients.toneMoss, theme.gradients.toneSand];
|
|
25
|
+
const create = () => {
|
|
26
|
+
const trimmed = name.trim();
|
|
27
|
+
if (trimmed.length === 0 || trimmed.length > 40) { setMessage('Use a name between 1 and 40 characters.'); return; }
|
|
28
|
+
setMessage('');
|
|
29
|
+
dispatch(addProfile({ name: trimmed, avatar: 'arc-profile' })).unwrap().then(() => { setName(''); setAdding(false); }).catch(() => setMessage('The profile could not be created. Try again.'));
|
|
30
|
+
};
|
|
31
|
+
const choose = (id: string) => dispatch(chooseProfile(id)).unwrap().then(() => navigation.goBack()).catch(() => setMessage('That profile could not be opened. Try again.'));
|
|
32
|
+
return (
|
|
33
|
+
<Screen>
|
|
34
|
+
<SafeAreaView style={styles.page}>
|
|
35
|
+
{!wide && <Pressable onPress={() => navigation.goBack()} style={styles.back} focusAnimation={{ border: { color: theme.colors.accent, width: 2 } }} accessibilityRole="button" accessibilityLabel="Back"><Icon icon="ph:caret-left" size={20} color={theme.colors.text} /></Pressable>}
|
|
36
|
+
{auth.status !== 'signed-in' ? <View style={styles.center}><Feedback title="Sign in to use profiles" message="Profiles keep each viewer's list separate." /><Action label="Sign in" primary onPress={() => navigation.navigate('SignIn')} /></View> : status === 'failed' ? <View style={styles.center}><Feedback title="Profiles could not load" message="Check your connection and try again." /><Action label="Try again" primary onPress={() => dispatch(loadProfiles())} /></View> : status !== 'ready' ? <Feedback title="Opening profiles" message="Finding who is watching." loading /> : (
|
|
37
|
+
<ScrollView style={styles.scroll} contentContainerStyle={styles.content} keyboardShouldPersistTaps="handled">
|
|
38
|
+
<Text style={styles.title}>Who's watching?</Text>
|
|
39
|
+
<Text style={styles.description}>Each profile keeps its own My List.</Text>
|
|
40
|
+
<FocusGroup direction="horizontal" remember autoFocus>
|
|
41
|
+
<View style={styles.people}>
|
|
42
|
+
{profiles.map((profile, index) => (
|
|
43
|
+
<View key={profile.id} style={styles.person}>
|
|
44
|
+
<Pressable onPress={() => choose(profile.id)} style={[styles.avatar, { backgroundColor: tones[index % 4] }]} focusAnimation={{ border: { color: theme.colors.text, width: 3 } }} accessibilityRole="button" accessibilityLabel={profile.name + (profile.id === activeId ? ', watching now' : '')} accessibilityState={{ selected: profile.id === activeId }}>
|
|
45
|
+
<Text style={styles.initial} maxFontSizeMultiplier={1}>{profile.name.slice(0, 1).toUpperCase()}</Text>
|
|
46
|
+
</Pressable>
|
|
47
|
+
<Text style={styles.name} numberOfLines={1}>{profile.name}</Text>
|
|
48
|
+
<Text style={[styles.state, profile.id === activeId && styles.stateOn]}>{profile.id === activeId ? 'WATCHING NOW' : ' '}</Text>
|
|
49
|
+
</View>
|
|
50
|
+
))}
|
|
51
|
+
{profiles.length < 5 && (
|
|
52
|
+
<View style={styles.person}>
|
|
53
|
+
<Pressable onPress={() => setAdding(true)} style={[styles.avatar, styles.addAvatar]} focusAnimation={{ border: { color: theme.colors.accent, width: 3 } }} accessibilityRole="button" accessibilityLabel="Add a profile">
|
|
54
|
+
<Icon icon="ph:plus" size={28} color={theme.colors.textSecondary} />
|
|
55
|
+
</Pressable>
|
|
56
|
+
<Text style={styles.name}>Add profile</Text>
|
|
57
|
+
<Text style={styles.state}> </Text>
|
|
58
|
+
</View>
|
|
59
|
+
)}
|
|
60
|
+
</View>
|
|
61
|
+
</FocusGroup>
|
|
62
|
+
{adding && (
|
|
63
|
+
<FocusGroup direction="vertical" autoFocus>
|
|
64
|
+
<View style={styles.create}>
|
|
65
|
+
<Field label="Profile name" value={name} onChangeText={setName} placeholder="Who is this for?" />
|
|
66
|
+
<FocusGroup direction="horizontal">
|
|
67
|
+
<View style={styles.createActions}>
|
|
68
|
+
<View style={styles.createAction}><Action label="Create profile" primary onPress={create} /></View>
|
|
69
|
+
<Action label="Cancel" onPress={() => { setAdding(false); setName(''); setMessage(''); }} />
|
|
70
|
+
</View>
|
|
71
|
+
</FocusGroup>
|
|
72
|
+
</View>
|
|
73
|
+
</FocusGroup>
|
|
74
|
+
)}
|
|
75
|
+
{message.length > 0 && <Text style={styles.error} accessibilityRole="alert">{message}</Text>}
|
|
76
|
+
</ScrollView>
|
|
77
|
+
)}
|
|
78
|
+
</SafeAreaView>
|
|
79
|
+
</Screen>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const styles = StyleSheet.create({
|
|
84
|
+
page: { flex: 1, backgroundColor: theme.colors.background },
|
|
85
|
+
back: { width: 40, height: 40, borderRadius: 20, marginTop: 8, marginLeft: 16, backgroundColor: theme.colors.surface, alignItems: 'center', justifyContent: 'center' },
|
|
86
|
+
center: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: theme.spacing.lg },
|
|
87
|
+
scroll: { flex: 1 },
|
|
88
|
+
content: { flexGrow: 1, alignItems: 'center', justifyContent: 'center', padding: theme.spacing.lg },
|
|
89
|
+
title: { color: theme.colors.text, fontSize: Platform.select({ tv: 30, default: 30 }), lineHeight: Platform.select({ tv: 34, default: 36 }), fontWeight: '900', letterSpacing: -0.8, textAlign: 'center' },
|
|
90
|
+
description: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 11, default: 15 }), lineHeight: Platform.select({ tv: 16, default: 21 }), marginTop: theme.spacing.sm, textAlign: 'center' },
|
|
91
|
+
people: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'center', marginTop: Platform.select({ tv: 32, default: 28 }) },
|
|
92
|
+
person: { width: Platform.select({ tv: 104, default: 112 }), alignItems: 'center', marginHorizontal: Platform.select({ tv: 8, default: 4 }), marginBottom: theme.spacing.md },
|
|
93
|
+
avatar: { width: Platform.select({ tv: 80, default: 84 }), height: Platform.select({ tv: 80, default: 84 }), borderRadius: Platform.select({ tv: 40, default: 42 }), alignItems: 'center', justifyContent: 'center' },
|
|
94
|
+
addAvatar: { backgroundColor: theme.colors.surface, borderWidth: 2, borderColor: theme.colors.border },
|
|
95
|
+
initial: { color: theme.colors.background, fontSize: Platform.select({ tv: 32, default: 34 }), lineHeight: Platform.select({ tv: 38, default: 40 }), fontWeight: '900' },
|
|
96
|
+
name: { color: theme.colors.text, fontSize: Platform.select({ tv: 11, default: 15 }), lineHeight: Platform.select({ tv: 15, default: 20 }), fontWeight: '800', marginTop: Platform.select({ tv: 10, default: 10 }) },
|
|
97
|
+
state: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 7, default: 10 }), lineHeight: Platform.select({ tv: 11, default: 14 }), fontWeight: '800', letterSpacing: 1.2, marginTop: 2 },
|
|
98
|
+
stateOn: { color: theme.colors.accent },
|
|
99
|
+
create: { width: '100%', maxWidth: 420, marginTop: theme.spacing.md, padding: theme.spacing.md, backgroundColor: theme.colors.surface, borderRadius: 6 },
|
|
100
|
+
createActions: { flexDirection: 'row', alignItems: 'center' },
|
|
101
|
+
createAction: { marginRight: theme.spacing.sm },
|
|
102
|
+
error: { color: theme.colors.error, fontSize: Platform.select({ tv: 10, default: 14 }), lineHeight: Platform.select({ tv: 14, default: 20 }), marginTop: theme.spacing.md, textAlign: 'center' },
|
|
103
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState } from '@adelin/react';
|
|
2
|
+
import { useDispatch, useSelector } from '@adelin/store';
|
|
3
|
+
import { useSearch } from '@adelin/content';
|
|
4
|
+
import { FocusGroup, StyleSheet, Text, View, theme, Screen } from '@adelin/ui';
|
|
5
|
+
import { Platform } from '@adelin/device';
|
|
6
|
+
import { loadLibrary } from '../../store';
|
|
7
|
+
import Shell from '../../components/Shell';
|
|
8
|
+
import Field from '../../components/Field';
|
|
9
|
+
import Action from '../../components/Action';
|
|
10
|
+
import Feedback from '../../components/Feedback';
|
|
11
|
+
import CatalogGrid from '../../components/CatalogGrid';
|
|
12
|
+
|
|
13
|
+
export default function Search() {
|
|
14
|
+
const dispatch = useDispatch();
|
|
15
|
+
const entries = useSelector(state => state.library.entries);
|
|
16
|
+
const status = useSelector(state => state.library.status);
|
|
17
|
+
const [query, setQuery] = useState('');
|
|
18
|
+
const pool = entries.filter(item => item.parentId == null || item.kind === 'item');
|
|
19
|
+
const { results, active } = useSearch(pool, query);
|
|
20
|
+
const shown = active ? results : entries.filter(item => item.parentId == null);
|
|
21
|
+
return (
|
|
22
|
+
<Screen>
|
|
23
|
+
<Shell active="Search" contentAutoFocus>
|
|
24
|
+
<View style={styles.body}>
|
|
25
|
+
<View style={styles.form}>
|
|
26
|
+
<Text style={styles.heading}>Search</Text>
|
|
27
|
+
<FocusGroup direction="horizontal">
|
|
28
|
+
<View style={styles.searchRow}>
|
|
29
|
+
<View style={styles.field}><Field label="Series or episode" value={query} onChangeText={setQuery} placeholder="Type a title" /></View>
|
|
30
|
+
{query.length > 0 && <View style={styles.clear}><Action label="Clear" icon="ph:x" onPress={() => setQuery('')} /></View>}
|
|
31
|
+
</View>
|
|
32
|
+
</FocusGroup>
|
|
33
|
+
<Text style={styles.summary}>{active ? (results.length === 1 ? '1 MATCH' : results.length + ' MATCHES') + ' FOR “' + query.trim().toUpperCase() + '”' : 'EVERY SERIES'}</Text>
|
|
34
|
+
</View>
|
|
35
|
+
{status === 'idle' || status === 'loading' ? <Feedback title="Opening the library" message="Search will be ready in a moment." loading /> : status === 'failed' ? <Feedback title="Search could not load" message="Check your connection and try again." onRetry={() => dispatch(loadLibrary())} /> : <CatalogGrid entries={shown} emptyTitle={active ? 'No series or episode matches' : 'No series yet'} emptyMessage={active ? 'Try fewer letters or another word from the title.' : 'Series will appear here as soon as they are added.'} />}
|
|
36
|
+
</View>
|
|
37
|
+
</Shell>
|
|
38
|
+
</Screen>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const styles = StyleSheet.create({
|
|
43
|
+
body: { flex: 1 },
|
|
44
|
+
form: { paddingHorizontal: Platform.select({ tv: 32, default: 20 }), paddingTop: Platform.select({ tv: 28, default: 16 }), paddingBottom: Platform.select({ tv: 6, default: 8 }) },
|
|
45
|
+
heading: { color: theme.colors.text, fontSize: Platform.select({ tv: 26, default: 30 }), lineHeight: Platform.select({ tv: 30, default: 36 }), fontWeight: '900', letterSpacing: -0.8, marginBottom: Platform.select({ tv: 12, default: 14 }) },
|
|
46
|
+
searchRow: { flexDirection: 'row', alignItems: 'flex-end', maxWidth: 620 },
|
|
47
|
+
field: { flex: 1 },
|
|
48
|
+
clear: { marginLeft: theme.spacing.sm, marginBottom: theme.spacing.md },
|
|
49
|
+
summary: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 12, default: 15 }), fontWeight: '800', letterSpacing: 1.3 },
|
|
50
|
+
});
|