@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,62 @@
|
|
|
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 { clearProfile, loadLibrary, loadProfile, loadWatching, 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
|
+
|
|
17
|
+
const Stack = createNativeStackNavigator();
|
|
18
|
+
|
|
19
|
+
export default function Root() {
|
|
20
|
+
const auth = useAuth();
|
|
21
|
+
if (auth.signInRequired && auth.status === 'loading') return <Splash />;
|
|
22
|
+
if (auth.signInRequired && auth.status === 'signed-out') return <SignInFlow />;
|
|
23
|
+
return <Main />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function Main() {
|
|
27
|
+
const auth = useAuth();
|
|
28
|
+
const dispatch = useDispatch();
|
|
29
|
+
const status = useSelector(state => state.library.status);
|
|
30
|
+
const profileId = useSelector(state => state.profile.id);
|
|
31
|
+
const userId = auth.currentuser?.id ?? '';
|
|
32
|
+
useEffect(() => { if (status === 'idle') dispatch(loadLibrary()); }, [dispatch, status]);
|
|
33
|
+
useEffect(() => { dispatch(clearProfile()); if (userId !== '') dispatch(loadProfile()); }, [dispatch, userId]);
|
|
34
|
+
useEffect(() => { dispatch(resetWatching(profileId)); if (profileId !== '') dispatch(loadWatching(profileId)); }, [dispatch, profileId]);
|
|
35
|
+
return (
|
|
36
|
+
<Stack.Navigator initialRouteName="Home">
|
|
37
|
+
<Stack.Screen name="Home" component={Home} options={{ animation: 'none' }} />
|
|
38
|
+
<Stack.Screen name="Browse" component={Browse} options={{ animation: 'none' }} />
|
|
39
|
+
<Stack.Screen name="Search" component={Search} options={{ animation: 'none' }} />
|
|
40
|
+
<Stack.Screen name="Detail" component={Detail} />
|
|
41
|
+
<Stack.Screen name="Player" component={Player} />
|
|
42
|
+
<Stack.Screen name="Account" component={Account} options={{ animation: 'none' }} />
|
|
43
|
+
<Stack.Screen name="SignIn" component={SignIn} />
|
|
44
|
+
<Stack.Screen name="SignUp" component={SignUp} />
|
|
45
|
+
</Stack.Navigator>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function SignInFlow() {
|
|
50
|
+
return (
|
|
51
|
+
<Stack.Navigator initialRouteName="SignIn">
|
|
52
|
+
<Stack.Screen name="SignIn" component={SignIn} />
|
|
53
|
+
<Stack.Screen name="SignUp" component={SignUp} />
|
|
54
|
+
</Stack.Navigator>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function Splash() {
|
|
59
|
+
return <SafeAreaView style={styles.splash}><Feedback title="Atlas" message="Opening the journal." loading /></SafeAreaView>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const styles = StyleSheet.create({ splash: { flex: 1, justifyContent: 'center', backgroundColor: theme.colors.background } });
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useState } from '@adelin/react';
|
|
2
|
+
import { useNavigation, useRoute } from '@adelin/navigation';
|
|
3
|
+
import { FocusGroup, Icon, Pressable, SafeAreaView, StyleSheet, Text, View, theme, useWindowDimensions } from '@adelin/ui';
|
|
4
|
+
import { Platform } from '@adelin/device';
|
|
5
|
+
|
|
6
|
+
export default function Shell({ active, children, contentAutoFocus = false }: { active: string; children?: {} | null; contentAutoFocus?: boolean }) {
|
|
7
|
+
const route = useRoute();
|
|
8
|
+
const { width, height } = useWindowDimensions();
|
|
9
|
+
const wide = width >= 840 && height >= 480;
|
|
10
|
+
const destinations = [
|
|
11
|
+
{ route: 'Home', label: 'Home', icon: 'ph:newspaper' },
|
|
12
|
+
{ route: 'Browse', label: 'Films', icon: 'ph:film-strip' },
|
|
13
|
+
{ route: 'Search', label: 'Search', icon: 'ph:magnifying-glass' },
|
|
14
|
+
{ route: 'Account', label: 'Account', icon: 'ph:user-circle' },
|
|
15
|
+
];
|
|
16
|
+
return (
|
|
17
|
+
<View style={styles.page}>
|
|
18
|
+
<FocusGroup direction="vertical" remember>
|
|
19
|
+
<View style={styles.layout}>
|
|
20
|
+
<SafeAreaView edges={['top', 'left', 'right']} style={styles.mastheadSafe}>
|
|
21
|
+
<View style={[styles.masthead, wide && styles.mastheadWide]}>
|
|
22
|
+
<Text style={[styles.wordmark, wide && styles.wordmarkWide]}>Atlas</Text>
|
|
23
|
+
{wide && (
|
|
24
|
+
<FocusGroup direction="horizontal" remember>
|
|
25
|
+
<View style={styles.links}>
|
|
26
|
+
{destinations.map(destination => <MastheadLink key={destination.route} target={destination.route} label={destination.label} selected={active === destination.route} focusKey={route.key + '-nav-' + destination.route} />)}
|
|
27
|
+
</View>
|
|
28
|
+
</FocusGroup>
|
|
29
|
+
)}
|
|
30
|
+
</View>
|
|
31
|
+
</SafeAreaView>
|
|
32
|
+
<FocusGroup direction="vertical" remember autoFocus={contentAutoFocus}>
|
|
33
|
+
<SafeAreaView edges={wide ? ['left', 'right', 'bottom'] : ['left', 'right']} style={styles.content}>{children}</SafeAreaView>
|
|
34
|
+
</FocusGroup>
|
|
35
|
+
{!wide && (
|
|
36
|
+
<SafeAreaView edges={['bottom', 'left', 'right']} style={styles.tabsSafe}>
|
|
37
|
+
<FocusGroup direction="horizontal" remember>
|
|
38
|
+
<View style={styles.tabs}>
|
|
39
|
+
{destinations.map(destination => <Tab key={destination.route} target={destination.route} label={destination.label} icon={destination.icon} selected={active === destination.route} />)}
|
|
40
|
+
</View>
|
|
41
|
+
</FocusGroup>
|
|
42
|
+
</SafeAreaView>
|
|
43
|
+
)}
|
|
44
|
+
</View>
|
|
45
|
+
</FocusGroup>
|
|
46
|
+
</View>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function MastheadLink({ target, label, selected, focusKey }: { target: string; label: string; selected: boolean; focusKey: string }) {
|
|
51
|
+
const navigation = useNavigation();
|
|
52
|
+
const [focused, setFocused] = useState(false);
|
|
53
|
+
return (
|
|
54
|
+
<Pressable onPress={() => { 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 navigation.navigate('Account', undefined, { pop: true }); }} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)} focusKey={focusKey} style={[styles.link, focused && styles.linkFocused]} accessibilityRole="button" accessibilityLabel={label} accessibilityState={{ selected }}>
|
|
55
|
+
<Text style={[styles.linkText, selected && styles.linkSelected, focused && styles.linkTextFocused]}>{label.toUpperCase()}</Text>
|
|
56
|
+
<View style={[styles.marker, selected && !focused && styles.markerOn]} />
|
|
57
|
+
</Pressable>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function Tab({ target, label, icon, selected }: { target: string; label: string; icon: string; selected: boolean }) {
|
|
62
|
+
const navigation = useNavigation();
|
|
63
|
+
return (
|
|
64
|
+
<Pressable onPress={() => { 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 navigation.navigate('Account', undefined, { pop: true }); }} style={styles.tab} focusAnimation={{ backgroundColor: theme.colors.surfaceLight }} accessibilityRole="button" accessibilityLabel={label} accessibilityState={{ selected }}>
|
|
65
|
+
<Icon icon={selected ? icon + '-fill' : icon} size={22} color={selected ? theme.colors.text : theme.colors.textMuted} />
|
|
66
|
+
<Text style={[styles.tabText, selected && styles.tabTextSelected]}>{label}</Text>
|
|
67
|
+
</Pressable>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const styles = StyleSheet.create({
|
|
72
|
+
page: { flex: 1, backgroundColor: theme.colors.background },
|
|
73
|
+
layout: { flex: 1, flexDirection: 'column' },
|
|
74
|
+
mastheadSafe: { backgroundColor: theme.colors.background },
|
|
75
|
+
masthead: { minHeight: 52, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 18, borderBottomWidth: 1, borderBottomColor: theme.colors.text },
|
|
76
|
+
mastheadWide: { minHeight: 42, paddingHorizontal: theme.spacing.lg },
|
|
77
|
+
wordmark: { color: theme.colors.text, fontSize: 25, lineHeight: 30, fontWeight: '900', letterSpacing: -1.2 },
|
|
78
|
+
wordmarkWide: { fontSize: 21, lineHeight: 26, letterSpacing: -1.1 },
|
|
79
|
+
links: { flexDirection: 'row', alignItems: 'center' },
|
|
80
|
+
link: { minHeight: 24, paddingHorizontal: 9, justifyContent: 'center', alignItems: 'center', marginLeft: 4 },
|
|
81
|
+
linkFocused: { backgroundColor: theme.colors.text },
|
|
82
|
+
linkText: { color: theme.colors.textSecondary, fontSize: 8, lineHeight: 12, fontWeight: '700', letterSpacing: 1.4, marginTop: 2 },
|
|
83
|
+
linkSelected: { color: theme.colors.text },
|
|
84
|
+
linkTextFocused: { color: theme.colors.surface },
|
|
85
|
+
marker: { width: 14, height: 2, marginTop: 2, backgroundColor: 'transparent' },
|
|
86
|
+
markerOn: { backgroundColor: theme.colors.primary },
|
|
87
|
+
content: { flex: 1 },
|
|
88
|
+
tabsSafe: { backgroundColor: theme.colors.surface, borderTopWidth: 1, borderTopColor: theme.colors.border },
|
|
89
|
+
tabs: { flexDirection: 'row' },
|
|
90
|
+
tab: { flex: 1, minHeight: 54, alignItems: 'center', justifyContent: 'center', paddingTop: 6, paddingBottom: 4 },
|
|
91
|
+
tabText: { color: theme.colors.textMuted, fontSize: 11, lineHeight: 14, fontWeight: '600', marginTop: 3 },
|
|
92
|
+
tabTextSelected: { color: theme.colors.text, fontWeight: '800' },
|
|
93
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useNavigation } from '@adelin/navigation';
|
|
2
|
+
import { useSelector } from '@adelin/store';
|
|
3
|
+
import { Image, Pressable, StyleSheet, Text, View, theme } from '@adelin/ui';
|
|
4
|
+
import { Platform } from '@adelin/device';
|
|
5
|
+
|
|
6
|
+
/** A portrait still, headline and standfirst; `resume` swaps the standfirst for a progress rule and time left, and opens the player. */
|
|
7
|
+
export default function StoryCard({ item, width = 0, imageHeight = 0, resume = false }: {
|
|
8
|
+
item: { id: string; kind?: string; title: string; description?: string; artwork: { backdrop?: string; poster?: string } };
|
|
9
|
+
width?: number;
|
|
10
|
+
imageHeight?: number;
|
|
11
|
+
resume?: boolean;
|
|
12
|
+
}) {
|
|
13
|
+
const navigation = useNavigation();
|
|
14
|
+
const rows = useSelector(state => state.watching.rows);
|
|
15
|
+
const watched = useSelector(state => state.watching.watched);
|
|
16
|
+
const picture = item.artwork.poster || item.artwork.backdrop;
|
|
17
|
+
const text = item.description ?? '';
|
|
18
|
+
const end = text.indexOf('. ');
|
|
19
|
+
const standfirst = end >= 0 ? text.slice(0, end + 1) : text;
|
|
20
|
+
const place = resume ? rows.find(row => row.entryId === item.id) : undefined;
|
|
21
|
+
const share = place !== undefined && place.duration > 0 ? Math.min(100, Math.round(place.position / place.duration * 100)) : 0;
|
|
22
|
+
const left = place !== undefined && place.duration > 0 ? Math.max(1, Math.round((place.duration - place.position) / 60)) : 0;
|
|
23
|
+
const caption = left > 0 ? left + ' MIN LEFT' : 'PICK UP AGAIN';
|
|
24
|
+
const seen = resume !== true && watched.includes(item.id);
|
|
25
|
+
const open = () => {
|
|
26
|
+
if (resume) navigation.navigate('Player', { id: item.id });
|
|
27
|
+
else navigation.push('Detail', { id: item.id });
|
|
28
|
+
};
|
|
29
|
+
return (
|
|
30
|
+
<Pressable onPress={open} style={[styles.card, width > 0 && { width: width }]} focusAnimation={{ backgroundColor: theme.colors.surface, border: { color: theme.colors.text, width: 2 } }} accessibilityRole="button" accessibilityLabel={resume ? item.title + ', resume, ' + caption.toLowerCase() : seen ? item.title + ', seen' : item.title}>
|
|
31
|
+
<View style={[styles.still, imageHeight > 0 && { height: imageHeight }]}>
|
|
32
|
+
{picture ? <Image source={{ uri: picture }} resizeMode="cover" style={styles.image} /> : <Text style={styles.missing} numberOfLines={3}>{item.title}</Text>}
|
|
33
|
+
{seen === true && <Text style={styles.seen}>SEEN</Text>}
|
|
34
|
+
</View>
|
|
35
|
+
{resume === true && <View style={styles.track}><View style={[styles.fill, { width: share + '%' }]} /></View>}
|
|
36
|
+
<Text style={styles.title} numberOfLines={1}>{item.title}</Text>
|
|
37
|
+
{resume ? <Text style={styles.caption} numberOfLines={1}>{caption}</Text> : standfirst.length > 0 && <Text style={styles.standfirst} numberOfLines={2}>{standfirst}</Text>}
|
|
38
|
+
</Pressable>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const styles = StyleSheet.create({
|
|
43
|
+
seen: { position: 'absolute', top: 0, left: 0, color: theme.colors.text, backgroundColor: theme.colors.surface, fontSize: Platform.select({ tv: 6, default: 9 }), lineHeight: Platform.select({ tv: 9, default: 13 }), fontWeight: '800', letterSpacing: Platform.select({ tv: 1.4, default: 1.6 }), paddingHorizontal: Platform.select({ tv: 5, default: 7 }), paddingTop: Platform.select({ tv: 3, default: 4 }), paddingBottom: Platform.select({ tv: 2, default: 3 }), borderBottomWidth: 1, borderRightWidth: 1, borderColor: theme.colors.text },
|
|
44
|
+
card: { width: Platform.select({ tv: 118, default: 156 }), padding: Platform.select({ tv: 5, default: 6 }), backgroundColor: 'transparent' },
|
|
45
|
+
still: { width: '100%', height: Platform.select({ tv: 144, default: 200 }), backgroundColor: theme.colors.surfaceLight, overflow: 'hidden', justifyContent: 'flex-end' },
|
|
46
|
+
image: { position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' },
|
|
47
|
+
missing: { color: theme.colors.text, fontSize: Platform.select({ tv: 11, default: 16 }), lineHeight: Platform.select({ tv: 13, default: 19 }), fontWeight: '800', letterSpacing: -0.3, padding: theme.spacing.sm },
|
|
48
|
+
track: { height: Platform.select({ tv: 2, default: 3 }), backgroundColor: theme.colors.border },
|
|
49
|
+
fill: { height: Platform.select({ tv: 2, default: 3 }), backgroundColor: theme.colors.primary },
|
|
50
|
+
title: { color: theme.colors.text, fontSize: Platform.select({ tv: 10, default: 15 }), lineHeight: Platform.select({ tv: 13, default: 19 }), fontWeight: '800', letterSpacing: Platform.select({ tv: -0.2, default: -0.3 }), marginTop: Platform.select({ tv: 7, default: 10 }) },
|
|
51
|
+
standfirst: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 8, default: 13 }), lineHeight: Platform.select({ tv: 11, default: 18 }), fontWeight: '300', marginTop: Platform.select({ tv: 2, default: 3 }) },
|
|
52
|
+
caption: { color: theme.colors.primary, fontSize: Platform.select({ tv: 7, default: 10 }), lineHeight: Platform.select({ tv: 10, default: 14 }), fontWeight: '800', letterSpacing: Platform.select({ tv: 1.4, default: 1.4 }), marginTop: Platform.select({ tv: 3, default: 4 }) },
|
|
53
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StyleSheet, Text, theme } from '@adelin/ui';
|
|
2
|
+
import type { StyleProp, TextStyle } from '@adelin/ui';
|
|
3
|
+
import { Platform } from '@adelin/device';
|
|
4
|
+
|
|
5
|
+
export default function StoryMeta({ technical, style }: {
|
|
6
|
+
technical?: { duration?: number | string; resolution?: string; hdr?: boolean } | null;
|
|
7
|
+
style?: StyleProp<TextStyle>;
|
|
8
|
+
}) {
|
|
9
|
+
const seconds = Number(technical?.duration ?? 0);
|
|
10
|
+
const hours = Math.floor(seconds / 3600);
|
|
11
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
12
|
+
const runtime = seconds >= 60 ? hours > 0 ? hours + ' h ' + minutes + ' min' : minutes + ' min' : '';
|
|
13
|
+
const resolution = technical?.resolution ?? '';
|
|
14
|
+
const quality = resolution.indexOf('2160') >= 0 ? '4K' : resolution.indexOf('1080') >= 0 || resolution.indexOf('720') >= 0 ? 'HD' : '';
|
|
15
|
+
const parts = [runtime, quality, technical?.hdr === true ? 'HDR' : ''].filter(part => part.length > 0);
|
|
16
|
+
if (parts.length === 0) return null;
|
|
17
|
+
return <Text style={[styles.meta, style]}>{parts.join(' · ')}</Text>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const styles = StyleSheet.create({
|
|
21
|
+
meta: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 8, default: 12 }), lineHeight: Platform.select({ tv: 12, default: 17 }), fontWeight: '700', letterSpacing: Platform.select({ tv: 1.2, default: 1 }) },
|
|
22
|
+
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,97 @@
|
|
|
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, Pressable, ScrollView, StyleSheet, Text, View, theme, useWindowDimensions, Screen } from '@adelin/ui';
|
|
6
|
+
import { Platform } from '@adelin/device';
|
|
7
|
+
import { logout } from '../../store';
|
|
8
|
+
import Shell from '../../components/Shell';
|
|
9
|
+
import Action from '../../components/Action';
|
|
10
|
+
import Feedback from '../../components/Feedback';
|
|
11
|
+
|
|
12
|
+
export default function Account() {
|
|
13
|
+
const auth = useAuth();
|
|
14
|
+
const dispatch = useDispatch();
|
|
15
|
+
const navigation = useNavigation();
|
|
16
|
+
const pending = useSelector(state => state.account.pending);
|
|
17
|
+
const entries = useSelector(state => state.library.entries);
|
|
18
|
+
const collections = useSelector(state => state.library.collections);
|
|
19
|
+
const { width, height } = useWindowDimensions();
|
|
20
|
+
const wide = width >= 840 && height >= 480;
|
|
21
|
+
const [message, setMessage] = useState('');
|
|
22
|
+
const titles = entries.filter(entry => !entry.parentId);
|
|
23
|
+
const contents = collections.filter(collection => collection.entryIds.length < titles.length && titles.some(entry => collection.entryIds.includes(entry.id)));
|
|
24
|
+
const signOut = () => {
|
|
25
|
+
setMessage('');
|
|
26
|
+
dispatch(logout()).unwrap().catch(error => setMessage(error.message));
|
|
27
|
+
};
|
|
28
|
+
return (
|
|
29
|
+
<Screen>
|
|
30
|
+
<Shell active="Account" contentAutoFocus>
|
|
31
|
+
{auth.status === 'loading' ? <Feedback title="Opening your account" message="Checking your session." loading /> : (
|
|
32
|
+
<ScrollView style={styles.scroll} contentContainerStyle={[styles.content, wide && styles.contentWide]}>
|
|
33
|
+
<View style={[styles.intro, wide && styles.introWide]}>
|
|
34
|
+
<Text style={styles.kicker}>YOUR ACCOUNT</Text>
|
|
35
|
+
<Text style={styles.title}>{auth.status === 'signed-in' ? 'Welcome back to the journal.' : 'Read along with an account.'}</Text>
|
|
36
|
+
<Text style={styles.description}>{auth.status === 'signed-in' ? 'You are signed in on this screen. ' + (titles.length === 1 ? 'One film is' : titles.length + ' films are') + ' waiting in the journal.' : 'Sign in to watch on this screen, or create an account in a minute.'}</Text>
|
|
37
|
+
{message.length > 0 && <Text style={styles.error} accessibilityRole="alert">{message}</Text>}
|
|
38
|
+
<FocusGroup direction="horizontal" remember autoFocus>
|
|
39
|
+
<View style={styles.actions}>
|
|
40
|
+
{auth.status === 'signed-in' ? <Action label={pending ? 'Signing out…' : 'Sign out'} onPress={signOut} disabled={pending} /> : <View style={styles.action}><Action label="Sign in" primary onPress={() => navigation.navigate('SignIn')} /></View>}
|
|
41
|
+
{auth.status !== 'signed-in' && <Action label="Create an account" onPress={() => navigation.navigate('SignUp')} />}
|
|
42
|
+
</View>
|
|
43
|
+
</FocusGroup>
|
|
44
|
+
</View>
|
|
45
|
+
{contents.length > 0 && (
|
|
46
|
+
<View style={[styles.contents, wide && styles.contentsWide]}>
|
|
47
|
+
<Text style={styles.contentsLabel}>IN THIS JOURNAL</Text>
|
|
48
|
+
<FocusGroup direction="vertical" remember>
|
|
49
|
+
<View>
|
|
50
|
+
{contents.map(collection => <ContentsRow key={collection.id} name={collection.name} note={collection.note ?? ''} count={titles.filter(entry => collection.entryIds.includes(entry.id)).length} onOpen={() => navigation.navigate('Browse', { topic: collection.id })} />)}
|
|
51
|
+
</View>
|
|
52
|
+
</FocusGroup>
|
|
53
|
+
</View>
|
|
54
|
+
)}
|
|
55
|
+
</ScrollView>
|
|
56
|
+
)}
|
|
57
|
+
</Shell>
|
|
58
|
+
</Screen>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function ContentsRow({ name, note, count, onOpen }: { name: string; note: string; count: number; onOpen: () => void }) {
|
|
63
|
+
const [focused, setFocused] = useState(false);
|
|
64
|
+
return (
|
|
65
|
+
<Pressable onPress={() => onOpen()} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)} style={[styles.row, focused && styles.rowFocused]} accessibilityRole="button" accessibilityLabel={name}>
|
|
66
|
+
<View style={styles.rowCopy}>
|
|
67
|
+
<Text style={[styles.rowTitle, focused && styles.inverse]} numberOfLines={1}>{name}</Text>
|
|
68
|
+
{note.length > 0 && <Text style={[styles.rowNote, focused && styles.inverse]} numberOfLines={1}>{note}</Text>}
|
|
69
|
+
</View>
|
|
70
|
+
<Text style={[styles.rowCount, focused && styles.inverse]}>{count === 1 ? '1 FILM' : count + ' FILMS'}</Text>
|
|
71
|
+
</Pressable>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const styles = StyleSheet.create({
|
|
76
|
+
scroll: { flex: 1 },
|
|
77
|
+
content: { paddingHorizontal: Platform.select({ tv: theme.spacing.lg, default: 18 }), paddingTop: Platform.select({ tv: 40, default: 28 }), paddingBottom: theme.spacing.xl },
|
|
78
|
+
contentWide: { flexDirection: 'row' },
|
|
79
|
+
intro: { maxWidth: 560 },
|
|
80
|
+
introWide: { width: '46%', paddingRight: theme.spacing.xl },
|
|
81
|
+
kicker: { color: theme.colors.primary, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 11, default: 15 }), fontWeight: '800', letterSpacing: 1.8 },
|
|
82
|
+
title: { color: theme.colors.text, fontSize: 32, lineHeight: Platform.select({ tv: 34, default: 36 }), fontWeight: '900', letterSpacing: -1.3, marginTop: 8 },
|
|
83
|
+
description: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 11, default: 17 }), lineHeight: Platform.select({ tv: 16, default: 24 }), fontWeight: '300', marginTop: 10, maxWidth: 440 },
|
|
84
|
+
actions: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', marginTop: Platform.select({ tv: 18, default: 22 }) },
|
|
85
|
+
action: { marginRight: theme.spacing.sm },
|
|
86
|
+
error: { color: theme.colors.error, fontSize: Platform.select({ tv: 10, default: 14 }), lineHeight: Platform.select({ tv: 15, default: 21 }), marginTop: theme.spacing.md },
|
|
87
|
+
contents: { marginTop: theme.spacing.xl, borderTopWidth: 1, borderTopColor: theme.colors.text },
|
|
88
|
+
contentsWide: { flex: 1, marginTop: 4 },
|
|
89
|
+
contentsLabel: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 7, default: 11 }), lineHeight: Platform.select({ tv: 10, default: 15 }), fontWeight: '800', letterSpacing: 1.4, marginTop: 10, marginBottom: 4 },
|
|
90
|
+
row: { flexDirection: 'row', alignItems: 'center', paddingVertical: Platform.select({ tv: 9, default: 14 }), paddingHorizontal: Platform.select({ tv: 8, default: 6 }), borderBottomWidth: 1, borderBottomColor: theme.colors.border },
|
|
91
|
+
rowFocused: { backgroundColor: theme.colors.text },
|
|
92
|
+
rowCopy: { flex: 1, paddingRight: theme.spacing.md },
|
|
93
|
+
rowTitle: { color: theme.colors.text, fontSize: Platform.select({ tv: 14, default: 18 }), lineHeight: Platform.select({ tv: 17, default: 23 }), fontWeight: '900', letterSpacing: -0.4 },
|
|
94
|
+
rowNote: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 9, default: 13 }), lineHeight: Platform.select({ tv: 13, default: 18 }), fontWeight: '300', marginTop: 2 },
|
|
95
|
+
rowCount: { color: theme.colors.primary, fontSize: Platform.select({ tv: 7, default: 10 }), lineHeight: Platform.select({ tv: 10, default: 14 }), fontWeight: '800', letterSpacing: 1.4 },
|
|
96
|
+
inverse: { color: theme.colors.surface },
|
|
97
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useEffect, useState } from '@adelin/react';
|
|
2
|
+
import { useRoute } from '@adelin/navigation';
|
|
3
|
+
import { useDispatch, useSelector } from '@adelin/store';
|
|
4
|
+
import { FlashList, FocusGroup, Pressable, 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 CatalogGrid from '../../components/CatalogGrid';
|
|
9
|
+
import Feedback from '../../components/Feedback';
|
|
10
|
+
|
|
11
|
+
export default function Browse() {
|
|
12
|
+
const dispatch = useDispatch();
|
|
13
|
+
const route = useRoute();
|
|
14
|
+
const entries = useSelector(state => state.library.entries);
|
|
15
|
+
const collections = useSelector(state => state.library.collections);
|
|
16
|
+
const status = useSelector(state => state.library.status);
|
|
17
|
+
const [category, setCategory] = useState<string>(route.params.topic ?? 'all');
|
|
18
|
+
useEffect(() => { if (route.params.topic) setCategory(route.params.topic); }, [route.params.topic]);
|
|
19
|
+
const titles = entries.filter(entry => !entry.parentId);
|
|
20
|
+
const categories = [{ id: 'all', name: 'Every film', note: '' }, ...collections.filter(collection => collection.entryIds.length < titles.length && titles.some(entry => collection.entryIds.includes(entry.id)))];
|
|
21
|
+
const current = collections.find(item => item.id === category);
|
|
22
|
+
const shown = titles.filter(entry => category === 'all' || current?.entryIds.includes(entry.id));
|
|
23
|
+
return (
|
|
24
|
+
<Screen>
|
|
25
|
+
<Shell active="Browse" contentAutoFocus>
|
|
26
|
+
{status === 'idle' || status === 'loading' ? <Feedback title="Opening the index" message="Gathering every film." loading /> : status === 'failed' ? <Feedback title="The index could not load" message="Check your connection and try again." onRetry={() => dispatch(loadLibrary())} /> : (
|
|
27
|
+
<FocusGroup direction="vertical" remember>
|
|
28
|
+
<View style={styles.body}>
|
|
29
|
+
<View style={styles.intro}>
|
|
30
|
+
<Text style={styles.heading}>{current?.name ?? 'Every film'}</Text>
|
|
31
|
+
<Text style={styles.description} numberOfLines={2}>{current?.note ?? (titles.length === 1 ? 'One film in the journal.' : titles.length + ' films in the journal, by subject.')}</Text>
|
|
32
|
+
</View>
|
|
33
|
+
<FocusGroup direction="horizontal" remember>
|
|
34
|
+
<FlashList horizontal data={categories} keyExtractor={item => item.id} style={styles.filters} contentContainerStyle={styles.filterContent} showsHorizontalScrollIndicator={false}
|
|
35
|
+
renderItem={({ item }) => <Topic name={item.name} selected={category === item.id} onPick={() => setCategory(item.id)} />}
|
|
36
|
+
/>
|
|
37
|
+
</FocusGroup>
|
|
38
|
+
<CatalogGrid entries={shown} emptyTitle="Nothing filed here yet" emptyMessage="Choose another subject to keep reading." />
|
|
39
|
+
</View>
|
|
40
|
+
</FocusGroup>
|
|
41
|
+
)}
|
|
42
|
+
</Shell>
|
|
43
|
+
</Screen>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function Topic({ name, selected, onPick }: { name: string; selected: boolean; onPick: () => void }) {
|
|
48
|
+
const [focused, setFocused] = useState(false);
|
|
49
|
+
return (
|
|
50
|
+
<Pressable onPress={() => onPick()} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)} style={[styles.filter, focused && styles.filterFocused]} accessibilityRole="button" accessibilityState={{ selected }}>
|
|
51
|
+
<Text style={[styles.filterText, selected && styles.selectedText, focused && styles.focusedText]}>{name}</Text>
|
|
52
|
+
<View style={[styles.marker, selected && !focused && styles.markerOn]} />
|
|
53
|
+
</Pressable>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const styles = StyleSheet.create({
|
|
58
|
+
body: { flex: 1 },
|
|
59
|
+
intro: { paddingHorizontal: Platform.select({ tv: theme.spacing.lg, default: 18 }), paddingTop: Platform.select({ tv: 18, default: 20 }), paddingBottom: Platform.select({ tv: 6, default: 8 }) },
|
|
60
|
+
heading: { color: theme.colors.text, fontSize: Platform.select({ tv: 28, default: 32 }), lineHeight: Platform.select({ tv: 31, default: 36 }), fontWeight: '900', letterSpacing: -1.2 },
|
|
61
|
+
description: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 10, default: 15 }), lineHeight: Platform.select({ tv: 15, default: 21 }), fontWeight: '300', marginTop: 4 },
|
|
62
|
+
filters: { height: Platform.select({ tv: 34, default: 50 }), marginBottom: Platform.select({ tv: 6, default: 4 }) },
|
|
63
|
+
filterContent: { paddingHorizontal: Platform.select({ tv: 18, default: 12 }) },
|
|
64
|
+
filter: { minHeight: Platform.select({ tv: 26, default: 44 }), paddingHorizontal: Platform.select({ tv: 7, default: 8 }), justifyContent: 'center', alignItems: 'flex-start', marginRight: Platform.select({ tv: 6, default: 6 }) },
|
|
65
|
+
filterFocused: { backgroundColor: theme.colors.text },
|
|
66
|
+
filterText: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 10, default: 15 }), lineHeight: Platform.select({ tv: 14, default: 20 }), fontWeight: '600', marginTop: 2 },
|
|
67
|
+
selectedText: { color: theme.colors.text, fontWeight: '900' },
|
|
68
|
+
focusedText: { color: theme.colors.surface },
|
|
69
|
+
marker: { width: '100%', height: 2, marginTop: 2, backgroundColor: 'transparent' },
|
|
70
|
+
markerOn: { backgroundColor: theme.colors.primary },
|
|
71
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useEffect } from '@adelin/react';
|
|
2
|
+
import { useNavigation, useRoute } from '@adelin/navigation';
|
|
3
|
+
import { useDispatch, useSelector } from '@adelin/store';
|
|
4
|
+
import { FocusGroup, Icon, Image, Pressable, ScrollTarget, ScrollView, StyleSheet, Text, View, theme, useWindowDimensions, Screen } from '@adelin/ui';
|
|
5
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from '@adelin/reanimated';
|
|
6
|
+
import { Platform } from '@adelin/device';
|
|
7
|
+
import { loadLibrary, loadResume, loadSeen, loadWatching, toggleWatched } from '../../store';
|
|
8
|
+
import Shell from '../../components/Shell';
|
|
9
|
+
import Action from '../../components/Action';
|
|
10
|
+
import Feedback from '../../components/Feedback';
|
|
11
|
+
import LibraryRail from '../../components/LibraryRail';
|
|
12
|
+
import StoryMeta from '../../components/StoryMeta';
|
|
13
|
+
|
|
14
|
+
export default function Detail() {
|
|
15
|
+
const navigation = useNavigation();
|
|
16
|
+
const route = useRoute();
|
|
17
|
+
const dispatch = useDispatch();
|
|
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 { width, height } = useWindowDimensions();
|
|
22
|
+
const wide = width >= 840 && height >= 480;
|
|
23
|
+
const item = entries.find(entry => entry.id === route.params.id);
|
|
24
|
+
const image = item?.artwork.backdrop || item?.artwork.poster;
|
|
25
|
+
const parent = entries.find(entry => entry.id === item?.parentId);
|
|
26
|
+
const children = entries.filter(entry => entry.parentId === item?.id);
|
|
27
|
+
const siblings = entries.filter(entry => !!item?.parentId && entry.parentId === item?.parentId && entry.id !== item?.id);
|
|
28
|
+
const owners = collections.filter(collection => collection.entryIds.includes(item?.id ?? '') && collection.entryIds.length > 1);
|
|
29
|
+
const home = owners.reduce((best, collection) => collection.entryIds.length < best.entryIds.length ? collection : best, owners[0]);
|
|
30
|
+
const related = (home?.entryIds ?? []).filter(id => id !== item?.id).map(id => entries.find(entry => entry.id === id)).filter(entry => !!entry);
|
|
31
|
+
const canPlay = item?.kind === 'item' && item?.playbackSource?.uri != null;
|
|
32
|
+
const text = item?.description ?? '';
|
|
33
|
+
const sentenceEnd = text.indexOf('. ');
|
|
34
|
+
const standfirst = sentenceEnd >= 0 ? text.slice(0, sentenceEnd + 1) : text;
|
|
35
|
+
const body = text.slice(standfirst.length).trim();
|
|
36
|
+
const kicker = parent ? parent.title : home?.name ?? item?.label ?? '';
|
|
37
|
+
const profileId = useSelector(state => state.profile.id);
|
|
38
|
+
const rows = useSelector(state => state.watching.rows);
|
|
39
|
+
const resume = useSelector(state => state.watching.resume);
|
|
40
|
+
const watched = useSelector(state => state.watching.watched);
|
|
41
|
+
const itemId = item?.id ?? '';
|
|
42
|
+
const place = resume !== null && resume.entryId === itemId ? resume : rows.find(row => row.entryId === itemId);
|
|
43
|
+
const left = place !== undefined && !place.finished && place.duration > 0 && place.position > 0 ? Math.max(1, Math.round((place.duration - place.position) / 60)) : 0;
|
|
44
|
+
const seen = watched.includes(itemId);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (profileId.length > 0 && itemId.length > 0) {
|
|
47
|
+
dispatch(loadResume({ profileId: profileId, entryId: itemId }));
|
|
48
|
+
dispatch(loadSeen({ profileId: profileId, entryIds: [itemId] }));
|
|
49
|
+
}
|
|
50
|
+
}, [profileId, itemId, rows]);
|
|
51
|
+
const toggleSeen = () => {
|
|
52
|
+
if (profileId.length > 0 && itemId.length > 0) dispatch(toggleWatched({ profileId: profileId, entryId: itemId, watched: seen })).unwrap().then(() => dispatch(loadWatching(profileId))).catch(() => {});
|
|
53
|
+
};
|
|
54
|
+
const pictureOpacity = useSharedValue(0.4);
|
|
55
|
+
const pictureStyle = useAnimatedStyle(() => ({ opacity: pictureOpacity.value }));
|
|
56
|
+
useEffect(() => { pictureOpacity.value = 0.4; pictureOpacity.value = withTiming(1, { duration: 220 }); }, [route.params.id]);
|
|
57
|
+
return (
|
|
58
|
+
<Screen>
|
|
59
|
+
<Shell active="" contentAutoFocus>
|
|
60
|
+
{status === 'idle' || status === 'loading' ? <Feedback title="Opening this film" message="Gathering its story." loading /> : status === 'failed' ? <Feedback title="This film could not load" message="Check your connection and try again." onRetry={() => dispatch(loadLibrary())} /> : !item ? (
|
|
61
|
+
<View style={styles.missing}><Feedback title="This film has left the journal" message="Return to the library to find another story." /><Action label="Back to the journal" onPress={() => navigation.goBack()} preferred /></View>
|
|
62
|
+
) : (
|
|
63
|
+
<ScrollView style={styles.scroll} contentContainerStyle={styles.content} showsVerticalScrollIndicator={false}>
|
|
64
|
+
<ScrollTarget y={0}>
|
|
65
|
+
<View>
|
|
66
|
+
<Animated.View style={[styles.picture, wide && styles.pictureWide, pictureStyle]}>
|
|
67
|
+
{image ? <Image source={{ uri: image }} style={styles.image} resizeMode="cover" /> : <View style={styles.image} />}
|
|
68
|
+
</Animated.View>
|
|
69
|
+
{!wide && (
|
|
70
|
+
<Pressable onPress={() => navigation.goBack()} style={styles.back} focusAnimation={{ backgroundColor: theme.colors.surfaceLight }} accessibilityRole="button" accessibilityLabel="Back">
|
|
71
|
+
<Icon icon="ph:caret-left" size={20} color={theme.colors.text} />
|
|
72
|
+
</Pressable>
|
|
73
|
+
)}
|
|
74
|
+
<View style={[styles.article, wide && styles.articleWide]}>
|
|
75
|
+
<View style={[styles.headline, wide && styles.headlineWide]}>
|
|
76
|
+
<Text style={styles.kicker} numberOfLines={1}>{kicker.toUpperCase()}</Text>
|
|
77
|
+
<Text style={[styles.title, wide && styles.titleWide]}>{item.title}</Text>
|
|
78
|
+
{standfirst.length > 0 && <Text style={[styles.standfirst, wide && styles.standfirstWide]}>{standfirst}</Text>}
|
|
79
|
+
<StoryMeta technical={item.technical} />
|
|
80
|
+
<FocusGroup direction="horizontal" remember autoFocus>
|
|
81
|
+
<View style={styles.actions}>
|
|
82
|
+
{canPlay && <View style={styles.action}><Action label={left > 0 ? 'Resume · ' + left + ' min left' : 'Watch the film'} icon="ph:play-fill" primary preferred focusKey={route.key + '-play'} onPress={() => navigation.navigate('Player', { id: item.id })} /></View>}
|
|
83
|
+
{item.kind === 'item' && profileId.length > 0 && <Action label={seen ? 'Seen' : 'Mark as seen'} icon={seen ? 'ph:check-bold' : 'ph:eye'} preferred={!canPlay} focusKey={route.key + '-seen'} onPress={toggleSeen} />}
|
|
84
|
+
</View>
|
|
85
|
+
</FocusGroup>
|
|
86
|
+
{item.kind === 'item' && !canPlay && <Text style={styles.notice}>This film cannot be played right now. Try again later.</Text>}
|
|
87
|
+
</View>
|
|
88
|
+
{body.length > 0 && (
|
|
89
|
+
<View style={[styles.body, wide && styles.bodyWide]}>
|
|
90
|
+
<Text style={styles.bodyLabel}>ABOUT THE FILM</Text>
|
|
91
|
+
<Text style={[styles.bodyText, wide && styles.bodyTextWide]} numberOfLines={wide ? 9 : 14}>{body}</Text>
|
|
92
|
+
</View>
|
|
93
|
+
)}
|
|
94
|
+
</View>
|
|
95
|
+
</View>
|
|
96
|
+
</ScrollTarget>
|
|
97
|
+
{children.length > 0 && <LibraryRail title={children[0].kind === 'item' ? 'Episodes' : 'Seasons'} note={'In order, from the beginning of ' + item.title + '.'} entries={children} />}
|
|
98
|
+
{item.kind === 'folder' && children.length === 0 && <Feedback title="More to come" message="Its parts will appear here when they are added." />}
|
|
99
|
+
{siblings.length > 0 && <LibraryRail title={'More from ' + (parent?.title ?? '')} entries={siblings} />}
|
|
100
|
+
{siblings.length === 0 && related.length > 0 && <LibraryRail title={'More from ' + (home?.name ?? '')} note={home?.note} entries={related} />}
|
|
101
|
+
</ScrollView>
|
|
102
|
+
)}
|
|
103
|
+
</Shell>
|
|
104
|
+
</Screen>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const styles = StyleSheet.create({
|
|
109
|
+
scroll: { flex: 1 },
|
|
110
|
+
content: { paddingBottom: theme.spacing.xl },
|
|
111
|
+
picture: { width: '100%', height: 240, backgroundColor: theme.colors.surfaceLight },
|
|
112
|
+
pictureWide: { height: 212 },
|
|
113
|
+
image: { width: '100%', height: '100%' },
|
|
114
|
+
back: { position: 'absolute', top: 12, left: 12, width: 40, height: 40, alignItems: 'center', justifyContent: 'center', backgroundColor: theme.colors.surface },
|
|
115
|
+
article: { flexDirection: 'column', paddingHorizontal: 18, paddingTop: 18, marginBottom: theme.spacing.lg },
|
|
116
|
+
articleWide: { flexDirection: 'row', paddingHorizontal: theme.spacing.lg, paddingTop: 16, marginBottom: 14 },
|
|
117
|
+
headline: {},
|
|
118
|
+
headlineWide: { width: '52%', paddingRight: theme.spacing.xl },
|
|
119
|
+
kicker: { color: theme.colors.primary, fontSize: Platform.select({ tv: 8, default: 11 }), lineHeight: Platform.select({ tv: 11, default: 15 }), fontWeight: '800', letterSpacing: Platform.select({ tv: 1.8, default: 1.6 }) },
|
|
120
|
+
title: { color: theme.colors.text, fontSize: 32, lineHeight: 35, fontWeight: '900', letterSpacing: -1.3, marginTop: 8 },
|
|
121
|
+
titleWide: { fontSize: 30, lineHeight: 32, letterSpacing: -1.3, marginTop: 6 },
|
|
122
|
+
standfirst: { color: theme.colors.textSecondary, fontSize: 17, lineHeight: 24, fontWeight: '300', marginTop: 10, marginBottom: 10 },
|
|
123
|
+
standfirstWide: { fontSize: 11, lineHeight: 16, marginTop: 7, marginBottom: 7 },
|
|
124
|
+
actions: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', marginTop: Platform.select({ tv: 12, default: 18 }) },
|
|
125
|
+
action: { marginRight: Platform.select({ tv: 8, default: 10 }), marginBottom: Platform.select({ tv: 0, default: 8 }) },
|
|
126
|
+
notice: { color: theme.colors.textSecondary, fontSize: Platform.select({ tv: 9, default: 14 }), lineHeight: Platform.select({ tv: 13, default: 20 }), marginTop: theme.spacing.md },
|
|
127
|
+
body: { marginTop: theme.spacing.lg, paddingTop: 14, borderTopWidth: 1, borderTopColor: theme.colors.border },
|
|
128
|
+
bodyWide: { flex: 1, marginTop: 4, paddingTop: 0, paddingLeft: theme.spacing.lg, borderTopWidth: 0, borderLeftWidth: 1, borderLeftColor: theme.colors.border },
|
|
129
|
+
bodyLabel: { color: theme.colors.textMuted, fontSize: Platform.select({ tv: 7, default: 11 }), lineHeight: Platform.select({ tv: 10, default: 15 }), fontWeight: '800', letterSpacing: 1.4, marginBottom: 6 },
|
|
130
|
+
bodyText: { color: theme.colors.text, fontSize: 16, lineHeight: 25, maxWidth: 620 },
|
|
131
|
+
bodyTextWide: { fontSize: 10, lineHeight: 16 },
|
|
132
|
+
missing: { padding: theme.spacing.lg, alignItems: 'center' },
|
|
133
|
+
});
|