@adelin-io/cli 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +263 -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 +1667 -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 +74 -0
- package/skill/authoring/player/platforms.md +47 -0
- package/skill/authoring/player/playback.md +43 -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 +120 -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,213 @@
|
|
|
1
|
+
# Profiles, saved titles and watch progress
|
|
2
|
+
|
|
3
|
+
Use this guide when an app saves titles for viewers ("My List"), shows Continue Watching or
|
|
4
|
+
Resume, or offers profiles, the "Who's watching?" choice of a shared account.
|
|
5
|
+
|
|
6
|
+
A signed-in viewer can have up to five profiles, like the people sharing one account. Each
|
|
7
|
+
profile keeps its own saved titles and watch progress. Profiles come from `@adelin/profiles`
|
|
8
|
+
and need a signed-in viewer, so call them only after sign-in ([auth.md](auth.md)). When the app does not require
|
|
9
|
+
sign-in and the viewer is signed out, offer "Sign in to save" instead of a save button.
|
|
10
|
+
|
|
11
|
+
## Profile calls
|
|
12
|
+
|
|
13
|
+
Call them inside `createAsyncThunk`, never from a component:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { createAsyncThunk } from "@adelin/store";
|
|
17
|
+
import { profiles } from "@adelin/profiles";
|
|
18
|
+
|
|
19
|
+
export const loadProfiles = createAsyncThunk("profiles/loadProfiles", async () => {
|
|
20
|
+
const list = await profiles.list();
|
|
21
|
+
const active = await profiles.active();
|
|
22
|
+
return { list: list, active: active ?? "" };
|
|
23
|
+
});
|
|
24
|
+
export const chooseProfile = createAsyncThunk("profiles/chooseProfile", async (id: string) => {
|
|
25
|
+
await profiles.select(id);
|
|
26
|
+
return id;
|
|
27
|
+
});
|
|
28
|
+
export const addProfile = createAsyncThunk("profiles/addProfile", async (input: { name: string; avatar: string }) => profiles.create({ name: input.name, avatar: input.avatar }));
|
|
29
|
+
export const editProfile = createAsyncThunk("profiles/editProfile", async (input: { id: string; name: string; avatar: string }) => profiles.update(input.id, { name: input.name, avatar: input.avatar }));
|
|
30
|
+
export const deleteProfile = createAsyncThunk("profiles/deleteProfile", async (id: string) => {
|
|
31
|
+
await profiles.remove(id);
|
|
32
|
+
return id;
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- `profiles.list()` returns the viewer's profiles, oldest first, each
|
|
37
|
+
`{ id, name, avatar, isDefault, language }` (`type Profile` from `@adelin/profiles`). A new
|
|
38
|
+
viewer has none.
|
|
39
|
+
- `profiles.create({ name, avatar })` adds one. The viewer's first profile becomes the default.
|
|
40
|
+
- `profiles.update(id, { name, avatar })` renames a profile or changes its avatar.
|
|
41
|
+
- `language` is the profile's app language, or `null` to follow the device. `create` and
|
|
42
|
+
`update` accept it, and the app uses it by itself ([i18n.md](i18n.md#choosing-the-language)).
|
|
43
|
+
- `profiles.remove(id)` deletes a profile and its saved titles.
|
|
44
|
+
- `profiles.select(id)` makes a profile active and remembers it on this device.
|
|
45
|
+
- `profiles.active()` returns the remembered profile id, or `null` when none is remembered or
|
|
46
|
+
that profile is gone.
|
|
47
|
+
|
|
48
|
+
A rejected profile call's `error.message` is a code. Read it in
|
|
49
|
+
`dispatch(thunk(input)).unwrap().catch((error) => …)` and show a plain sentence:
|
|
50
|
+
`PROFILE_LIMIT` ("This account already has 5 profiles"), `PROFILE_DEFAULT` ("The main profile
|
|
51
|
+
can't be deleted"), `PROFILE_NAME_INVALID`, `PROFILE_AVATAR_INVALID` and `PROFILE_LANGUAGE_INVALID`
|
|
52
|
+
(the language is not a valid language tag; `null` follows the device).
|
|
53
|
+
|
|
54
|
+
## Saved titles
|
|
55
|
+
|
|
56
|
+
Saved titles belong to a profile, never to the device. Use `favorites` from `@adelin/profiles`:
|
|
57
|
+
`favorites.list(profileId)` returns the saved content ids (newest first),
|
|
58
|
+
`favorites.add(profileId, entryId)` and `favorites.remove(profileId, entryId)` change them. Load
|
|
59
|
+
them whenever the active profile changes, and join the ids against the loaded content. Return
|
|
60
|
+
the profile id with the ids and ignore a response for a profile that is no longer active.
|
|
61
|
+
|
|
62
|
+
Show a save at once, then confirm it: keep what the server holds beside what the viewer sees,
|
|
63
|
+
and put the viewer's list back when the call is rejected. While the builder previews draft
|
|
64
|
+
content, saving a title that is not published yet is refused, so handle a rejected save quietly
|
|
65
|
+
with a short note such as "Couldn't save this title right now", never an error screen.
|
|
66
|
+
|
|
67
|
+
## Watch progress
|
|
68
|
+
|
|
69
|
+
Apps with explicit offline support also keep durable local progress and replay it
|
|
70
|
+
conditionally on reconnect. See [offline watch history](offline/history-sync.md).
|
|
71
|
+
|
|
72
|
+
The [player playback guide](player/playback.md) owns automatic resume and history saving.
|
|
73
|
+
Use `progress` from `@adelin/profiles` to show what was saved; each row is
|
|
74
|
+
`{ entryId, position, duration, finished, watched }`, positions in seconds (`type Progress`).
|
|
75
|
+
|
|
76
|
+
- `progress.list(profileId)` is Continue Watching: up to 20 rows, newest first, one per title.
|
|
77
|
+
For a series it already points at the episode to play next, at position 0 when the last one
|
|
78
|
+
was finished (`duration` is 0 when not known yet). Join the ids against the loaded content
|
|
79
|
+
and skip ids the content does not have.
|
|
80
|
+
- `progress.get(profileId, entryId)` is one title's place, or `null` when there is none. Use it on
|
|
81
|
+
a detail page to label the play button "Resume" with the time left, instead of "Play". It
|
|
82
|
+
also returns a finished place; label the button "Resume" only when `finished` is false and
|
|
83
|
+
`position` is above 0. Keep one play button and change its label when the place arrives
|
|
84
|
+
([language.md](language.md#tv-scroll-remote-back-and-device)).
|
|
85
|
+
- `progress.clear(profileId, entryId)` removes the whole title from Continue Watching.
|
|
86
|
+
- `progress.watched(profileId, entryId)` returns the ids watched within a title: the title itself
|
|
87
|
+
and its watched episodes. Use it for checkmarks on a series' episodes and a "Watched" state on
|
|
88
|
+
a detail page. It answers for one title, so never call it once per card.
|
|
89
|
+
- `progress.watchedAmong(profileId, entryIds)` returns which of up to 100 given films or episodes
|
|
90
|
+
are watched, in one request; it does not look inside a series. Use it for watched marks on a
|
|
91
|
+
screen of cards: call it once with the ids the screen shows, merge the answer into the watched
|
|
92
|
+
list, and ask again when the shown ids change.
|
|
93
|
+
- `progress.markWatched(profileId, entryId)` and `progress.markUnwatched(profileId, entryId)` back a
|
|
94
|
+
"Mark as watched" toggle on a film or an episode, never on a series or season.
|
|
95
|
+
|
|
96
|
+
Watched stays when a title leaves Continue Watching and when it is watched again; finishing a
|
|
97
|
+
title marks it by itself.
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { createAsyncThunk, createSlice, type PayloadAction } from "@adelin/store";
|
|
101
|
+
import { progress, type Progress } from "@adelin/profiles";
|
|
102
|
+
|
|
103
|
+
export const loadWatching = createAsyncThunk("watching/loadWatching", async (profileId: string) => {
|
|
104
|
+
const rows = await progress.list(profileId);
|
|
105
|
+
return { profileId: profileId, rows: rows };
|
|
106
|
+
});
|
|
107
|
+
export const loadResume = createAsyncThunk("watching/loadResume", async (input: { profileId: string; entryId: string }) => progress.get(input.profileId, input.entryId));
|
|
108
|
+
export const removeWatching = createAsyncThunk("watching/removeWatching", async (input: { profileId: string; entryId: string }) => {
|
|
109
|
+
await progress.clear(input.profileId, input.entryId);
|
|
110
|
+
return input.entryId;
|
|
111
|
+
});
|
|
112
|
+
export const loadWatched = createAsyncThunk("watching/loadWatched", async (input: { profileId: string; entryId: string }) => {
|
|
113
|
+
const ids = await progress.watched(input.profileId, input.entryId);
|
|
114
|
+
return { profileId: input.profileId, ids: ids };
|
|
115
|
+
});
|
|
116
|
+
export const toggleWatched = createAsyncThunk("watching/toggleWatched", async (input: { profileId: string; entryId: string; watched: boolean }) => {
|
|
117
|
+
if (input.watched) {
|
|
118
|
+
await progress.markUnwatched(input.profileId, input.entryId);
|
|
119
|
+
} else {
|
|
120
|
+
await progress.markWatched(input.profileId, input.entryId);
|
|
121
|
+
}
|
|
122
|
+
return { entryId: input.entryId, watched: !input.watched };
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export const watching = createSlice({
|
|
126
|
+
name: "watching",
|
|
127
|
+
initialState: { profileId: "", rows: [] as Progress[], resume: null as Progress | null, watched: [] as string[] },
|
|
128
|
+
reducers: {
|
|
129
|
+
resetWatching(state, action: PayloadAction<string>) {
|
|
130
|
+
state.profileId = action.payload;
|
|
131
|
+
state.rows = [];
|
|
132
|
+
state.resume = null;
|
|
133
|
+
state.watched = [];
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
extraReducers: (builder) => {
|
|
137
|
+
builder.addCase(loadWatching.fulfilled, (state, action) => {
|
|
138
|
+
if (state.profileId !== action.payload.profileId) return;
|
|
139
|
+
state.rows = action.payload.rows;
|
|
140
|
+
});
|
|
141
|
+
builder.addCase(loadResume.pending, (state) => { state.resume = null; });
|
|
142
|
+
builder.addCase(loadResume.fulfilled, (state, action) => { state.resume = action.payload; });
|
|
143
|
+
builder.addCase(removeWatching.fulfilled, (state, action) => {
|
|
144
|
+
state.rows = state.rows.filter((row) => row.entryId !== action.payload);
|
|
145
|
+
});
|
|
146
|
+
builder.addCase(loadWatched.fulfilled, (state, action) => {
|
|
147
|
+
if (state.profileId !== action.payload.profileId) return;
|
|
148
|
+
state.watched = action.payload.ids;
|
|
149
|
+
});
|
|
150
|
+
builder.addCase(toggleWatched.fulfilled, (state, action) => {
|
|
151
|
+
const others = state.watched.filter((id) => id !== action.payload.entryId);
|
|
152
|
+
state.watched = action.payload.watched ? [action.payload.entryId, ...others] : others;
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
When the active profile changes, dispatch `resetWatching(profileId)` and then `loadWatching(profileId)`;
|
|
159
|
+
the guard drops a reply that belongs to the previous profile. Screens under the player stay mounted, so
|
|
160
|
+
also reload it when the player closes: in the component that calls `useVideoPlayer`, add
|
|
161
|
+
`useEffect(() => () => { if (profileId.length > 0) dispatch(loadWatching(profileId)); }, [profileId]);`.
|
|
162
|
+
The player sends its last save before that reload reads. Hide the row while it is empty. Draw
|
|
163
|
+
each card's progress bar from `position / duration` when `duration` is above 0. A "Resume" button
|
|
164
|
+
opens the same player as "Play"; the player seeks to the saved place itself. App code cannot save
|
|
165
|
+
a position. A rejected progress call leaves the row as it was, never an error screen.
|
|
166
|
+
|
|
167
|
+
## Choosing a profile
|
|
168
|
+
|
|
169
|
+
Pick one approach per app from its brief; the platform supports both and neither is required.
|
|
170
|
+
|
|
171
|
+
- **Always the default profile.** No picker. After sign-in, load the profiles and use the one
|
|
172
|
+
with `isDefault === true`; when the viewer has none yet, create one. This suits apps one
|
|
173
|
+
person uses, such as a course or a workout app. There is no need to call `profiles.select`:
|
|
174
|
+
the player saves to the default profile when none is chosen.
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
export const loadProfile = createAsyncThunk("profile/loadProfile", async () => {
|
|
178
|
+
const list = await profiles.list();
|
|
179
|
+
const main = list.find((profile) => profile.isDefault);
|
|
180
|
+
if (main) return main.id;
|
|
181
|
+
const created = await profiles.create({ name: "Me" });
|
|
182
|
+
return created.id;
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Name the created profile after the app's voice ("Me", "Reader"); the viewer never picks it.
|
|
187
|
+
- **"Who's watching?"** Show a picker after sign-in as one more early return in the root,
|
|
188
|
+
after the sign-in gate: while signed in with no active profile, return a component that owns
|
|
189
|
+
its own stack with the picker screen. One rule that works well: use the remembered profile
|
|
190
|
+
when there is one, use the only profile directly when there is exactly one, and show the
|
|
191
|
+
picker otherwise; with no profiles, ask for the first profile's name. Clearing the active
|
|
192
|
+
profile ("Switch profile") brings the picker back.
|
|
193
|
+
|
|
194
|
+
With a picker, add a manage-profiles page reachable from the account area: add, rename, change
|
|
195
|
+
the avatar and delete, with delete hidden for the default profile.
|
|
196
|
+
|
|
197
|
+
## Limits
|
|
198
|
+
|
|
199
|
+
- At most five profiles per viewer. Hide "Add profile" at five.
|
|
200
|
+
- Names are 1 to 40 characters after trimming.
|
|
201
|
+
- An avatar is a short key the app defines and draws itself, such as `sunset-2`: lowercase
|
|
202
|
+
letters, digits and hyphens, up to 32 characters. There are no photo uploads, and a profile
|
|
203
|
+
may have no avatar.
|
|
204
|
+
- The default profile cannot be deleted.
|
|
205
|
+
|
|
206
|
+
## When the viewer changes
|
|
207
|
+
|
|
208
|
+
When the signed-in viewer changes (sign-out, or another account signs in), clear the profile
|
|
209
|
+
list, the active profile, the saved titles and Continue Watching, then load them again for the
|
|
210
|
+
new viewer. An effect on `useAuth().currentuser?.id` in the root component does this.
|
|
211
|
+
|
|
212
|
+
Add the picker and profile store flow described here when the builder wants multiple viewer
|
|
213
|
+
profiles.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Remote keys
|
|
2
|
+
|
|
3
|
+
Use this guide when a screen reacts to remote keys beyond moving focus and pressing: colour
|
|
4
|
+
buttons, media keys, channel keys, digits, Info, Guide, Search and the rest. Focus movement and
|
|
5
|
+
Select need no code; focusable controls handle them. Back has its own handler, `useBackHandler`,
|
|
6
|
+
described in [language.md](language.md). Player keys (play, pause, rewind, fast-forward and
|
|
7
|
+
scrubbing) follow the pattern in [player controls](player/controls.md).
|
|
8
|
+
|
|
9
|
+
## Reading a key
|
|
10
|
+
|
|
11
|
+
`useTVEventHandler((event) => …)` from `@adelin/device` sees every remote key while its screen
|
|
12
|
+
is mounted.
|
|
13
|
+
|
|
14
|
+
- Compare `event.eventType` with a `Keys` name from `@adelin/device`, such as `Keys.ChannelUp`.
|
|
15
|
+
Never compare it with a raw key code or a string you made up.
|
|
16
|
+
- `event.eventKeyAction` is `"down"` when the key is pressed, `"up"` when it is released, and
|
|
17
|
+
`"longPress"` once after a short hold while it is still down. A held key sends one `"down"`,
|
|
18
|
+
not a stream of them.
|
|
19
|
+
- Act on one action, usually `"down"`; acting on both `"down"` and `"up"` runs the action twice.
|
|
20
|
+
- The hold time before `"longPress"` differs per device. Use it only for an extra, never as the
|
|
21
|
+
only way to reach something.
|
|
22
|
+
- `event.velocity` is always 0 for keys.
|
|
23
|
+
- Return `true` to keep the key: focus does not move and Select does not press. The key stays
|
|
24
|
+
kept until it is released. Return `false` or nothing and the key does its usual job.
|
|
25
|
+
Keeping `"longPress"` also cancels the focused control's pending long-press action.
|
|
26
|
+
- Back can arrive here too, but returning `true` never keeps it. Handle Back with
|
|
27
|
+
`useBackHandler`.
|
|
28
|
+
|
|
29
|
+
## Pressable controls
|
|
30
|
+
|
|
31
|
+
On TV, a focused `Pressable` without `onLongPress` activates on Select key-down.
|
|
32
|
+
With `onLongPress`, a short Select press activates on release; holding Select for
|
|
33
|
+
500 ms calls `onLongPress` once and releasing it does not call `onPress`.
|
|
34
|
+
This control hold threshold is separate from the platform timing of remote-key events.
|
|
35
|
+
|
|
36
|
+
## Key names
|
|
37
|
+
|
|
38
|
+
- Arrows and Select: `Keys.Left`, `Keys.Right`, `Keys.Up`, `Keys.Down`, `Keys.Select`.
|
|
39
|
+
- Menu: `Keys.Menu`.
|
|
40
|
+
- Media: `Keys.PlayPause`, `Keys.Play`, `Keys.Pause`, `Keys.Stop`, `Keys.Rewind`,
|
|
41
|
+
`Keys.FastForward`, `Keys.Previous`, `Keys.Next`, `Keys.Record`. Some remotes send
|
|
42
|
+
`Keys.PlayPause` and others separate `Keys.Play` and `Keys.Pause`; a video screen maps every
|
|
43
|
+
media key as [Controls and seeking](player/controls.md) shows.
|
|
44
|
+
- Channel: `Keys.ChannelUp`, `Keys.ChannelDown`, `Keys.PreviousChannel`, `Keys.ChannelList`.
|
|
45
|
+
- Digits: `Keys.Digit0` to `Keys.Digit9`.
|
|
46
|
+
- Colour keys: `Keys.ColorRed`, `Keys.ColorGreen`, `Keys.ColorYellow`, `Keys.ColorBlue`.
|
|
47
|
+
- Others: `Keys.Info`, `Keys.Guide`, `Keys.Exit`, `Keys.Search`, `Keys.Captions`,
|
|
48
|
+
`Keys.Bookmark`.
|
|
49
|
+
- Volume and mute (`Keys.VolumeUp`, `Keys.VolumeDown`, `Keys.Mute`) usually stay with the TV.
|
|
50
|
+
Never build a feature on them.
|
|
51
|
+
|
|
52
|
+
## Which platforms send which keys
|
|
53
|
+
|
|
54
|
+
| Platform | Arrows, Select, Back | Menu | Media | Channel up and down | Previous channel | Digits | Colour keys | Info | Guide | Exit | Search | Captions | Record |
|
|
55
|
+
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
56
|
+
| Android TV | yes | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | no | remote-dependent | remote-dependent | remote-dependent |
|
|
57
|
+
| Fire TV | yes | yes | yes | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | no | remote-dependent | remote-dependent | remote-dependent |
|
|
58
|
+
| Apple TV | yes | no | play/pause only | remote-dependent | no | no | no | no | no | no | no | no | no |
|
|
59
|
+
| Samsung (Tizen) | yes | no | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | no |
|
|
60
|
+
| LG (webOS) | yes | no | yes | yes | no | yes | yes | yes | no | no | no | no | no |
|
|
61
|
+
| Hisense (Vidaa) | yes | no | yes | yes | no | yes | yes | no | no | no | no | no | no |
|
|
62
|
+
| Philips (TitanOS) | yes | no | yes | yes | no | yes | yes | no | no | no | no | no | no |
|
|
63
|
+
| Vega | yes | remote-dependent | yes | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | remote-dependent | no |
|
|
64
|
+
| Xbox | yes | yes | rewind and fast-forward only | yes | no | no | no | yes | no | no | no | no | no |
|
|
65
|
+
| Roku | yes | no | yes | no | no | no | no | no | no | no | no | no | no |
|
|
66
|
+
| Browser | yes | no | remote-dependent | yes | no | yes | no | no | no | no | no | no | no |
|
|
67
|
+
|
|
68
|
+
- **yes**: the platform's usual remote has the key. **remote-dependent**: only some remotes or
|
|
69
|
+
keyboards have it. **no**: it never arrives.
|
|
70
|
+
- The hardware decides, even for "yes": a viewer's remote can still lack a key. Check
|
|
71
|
+
`event.eventType` as keys arrive; never decide from `Platform.OS` that a key exists.
|
|
72
|
+
- On Apple TV the remote's Menu button is Back. Its channel keys come only from remotes with
|
|
73
|
+
page up and page down.
|
|
74
|
+
- On Xbox the gamepad is the remote: A is Select, B is Back, the D-pad and left stick are the
|
|
75
|
+
arrows, Menu is `Keys.Menu`, View is `Keys.Info`, the bumpers are channel down and up, and the
|
|
76
|
+
triggers are rewind and fast-forward. X and Y send nothing.
|
|
77
|
+
- On a browser, Enter is Select, Escape is Back, Page Up and Page Down are the channel keys, and
|
|
78
|
+
the number row gives the digits.
|
|
79
|
+
- On Android, number-pad keys give digits with Num Lock on; otherwise they may act as navigation.
|
|
80
|
+
|
|
81
|
+
## Never gate a feature on a key
|
|
82
|
+
|
|
83
|
+
Never put a feature only behind keys a platform lacks. Every feature a key reaches also has an
|
|
84
|
+
on-screen control that the arrows and Select reach. A key is a shortcut to that control, never
|
|
85
|
+
the only way to it.
|
|
86
|
+
|
|
87
|
+
- Colour-key hints, such as a red dot beside Favourites, are extras next to a visible control.
|
|
88
|
+
- Show the on-screen control on every platform, including those that have the key.
|
|
89
|
+
- The same holds for `"longPress"`: it can offer a shortcut, never the only path.
|
|
90
|
+
|
|
91
|
+
## Example: channel keys with on-screen buttons
|
|
92
|
+
|
|
93
|
+
The channel keys switch channel, and two buttons on screen do the same for remotes without them.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import { useState } from '@adelin/react';
|
|
97
|
+
import { Keys, useTVEventHandler } from '@adelin/device';
|
|
98
|
+
import { Pressable, StyleSheet, Text, View, theme } from '@adelin/ui';
|
|
99
|
+
|
|
100
|
+
export default function ChannelSwitcher({ titles }: { titles: string[] }) {
|
|
101
|
+
const [index, setIndex] = useState(0);
|
|
102
|
+
const next = () => setIndex((index + 1) % titles.length);
|
|
103
|
+
const previous = () => setIndex((index + titles.length - 1) % titles.length);
|
|
104
|
+
|
|
105
|
+
useTVEventHandler((event) => {
|
|
106
|
+
if (event.eventKeyAction !== 'down') return false;
|
|
107
|
+
if (event.eventType === Keys.ChannelUp) {
|
|
108
|
+
next();
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
if (event.eventType === Keys.ChannelDown) {
|
|
112
|
+
previous();
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<View style={styles.row}>
|
|
120
|
+
<Pressable accessibilityLabel="Previous channel" onPress={previous} style={styles.button}>
|
|
121
|
+
<Text style={styles.label}>Previous</Text>
|
|
122
|
+
</Pressable>
|
|
123
|
+
<Text style={styles.title}>{titles[index]}</Text>
|
|
124
|
+
<Pressable accessibilityLabel="Next channel" onPress={next} style={styles.button}>
|
|
125
|
+
<Text style={styles.label}>Next</Text>
|
|
126
|
+
</Pressable>
|
|
127
|
+
</View>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const styles = StyleSheet.create({
|
|
132
|
+
row: { flexDirection: 'row', alignItems: 'center' },
|
|
133
|
+
button: { paddingHorizontal: theme.spacing.md, paddingVertical: theme.spacing.sm, backgroundColor: theme.colors.surface, borderRadius: 8 },
|
|
134
|
+
label: { color: theme.colors.text },
|
|
135
|
+
title: { color: theme.colors.text, marginHorizontal: theme.spacing.md },
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
In a real app the titles come from the content library, never from a hardcoded list.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Search
|
|
2
|
+
|
|
3
|
+
Every search screen uses `useSearch` from `@adelin/content`. It waits until the viewer stops
|
|
4
|
+
typing, then keeps the rows whose title has a word starting with each word of the query,
|
|
5
|
+
ignoring case and accents, with titles that start with the query first. Never filter or rank titles by hand with
|
|
6
|
+
`filter`, `includes` or `toLowerCase`, and never write your own debounce.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { useState } from '@adelin/react';
|
|
10
|
+
import { useSearch } from '@adelin/content';
|
|
11
|
+
|
|
12
|
+
const [query, setQuery] = useState('');
|
|
13
|
+
const searchable = entries.filter(item => item.parentId == null || item.kind === 'item');
|
|
14
|
+
const { results, active, pending } = useSearch(searchable, query);
|
|
15
|
+
const shown = active ? results : entries.filter(item => item.parentId == null);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- Pass the rows the viewer may find as the first argument: whole titles, and episodes when the
|
|
19
|
+
library has them. Choose the rows; leave the matching to `useSearch`.
|
|
20
|
+
- `active` turns true once a typed query has settled. Until then, show the screen's default
|
|
21
|
+
list, such as all titles or a collection, rather than an empty grid.
|
|
22
|
+
- `results` keeps the last settled matches while `pending` is true, so the grid does not
|
|
23
|
+
flash empty between keystrokes. Clearing the field resets at once.
|
|
24
|
+
- When `active` is true and `results` is empty, show a "Nothing matches" message that repeats
|
|
25
|
+
the query and suggests a shorter word.
|
|
26
|
+
- Feed `query` from a `TextInput` on phones and from `TVKeyboard` on TV
|
|
27
|
+
([tv-text-entry.md](tv-text-entry.md)); both call `setQuery` on every key.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# The store
|
|
2
|
+
|
|
3
|
+
`store.tsx` is written with `createSlice` and `createAsyncThunk` from `@adelin/store`, as in
|
|
4
|
+
Redux Toolkit. You define the store's shape; the content in it always comes from the builder's
|
|
5
|
+
content library at runtime. Never put titles, images or lists in it.
|
|
6
|
+
|
|
7
|
+
## Content
|
|
8
|
+
|
|
9
|
+
- A thunk loads content with `content.list()` from `@adelin/content`. Each row is an `item`
|
|
10
|
+
(something playable) or a `folder` holding the parts of one title: a series' seasons, a
|
|
11
|
+
season's episodes, a course's modules. A row's `parentId` is its folder, and `label` says what
|
|
12
|
+
it is ("Series", "Season", "Episode").
|
|
13
|
+
- Discovery collections come from `content.collections()`. Load both sources in one thunk when they need to update together, or use separate thunks with explicit loading state. Join their
|
|
14
|
+
`entryIds` against the `content.list()` rows, and `parentId` against other collections.
|
|
15
|
+
Genres, rails and "All Movies" are collections: one row can sit in many of them, while it
|
|
16
|
+
lives in at most one folder.
|
|
17
|
+
- Content fields read as text or lists. Convert with `Number(item.durationSec)` before
|
|
18
|
+
arithmetic or a numeric comparison.
|
|
19
|
+
- Search runs on the loaded list with `useSearch` ([search.md](search.md)).
|
|
20
|
+
|
|
21
|
+
## Reducers
|
|
22
|
+
|
|
23
|
+
Reducers follow Redux Toolkit's rules. A reducer may declare scoped `const` values, including
|
|
24
|
+
one that holds part of the draft (`const ids = state.ids; ids.push(id);`), assign or `delete`
|
|
25
|
+
draft fields (`state.status = "loading"`, `delete state.marks[id]`) and change a draft list in
|
|
26
|
+
place: `push`, `pop`, `shift`, `unshift`, `splice`, `sort`, `reverse`, `fill` and
|
|
27
|
+
`copyWithin`, their results included (`const last = state.ids.pop();`). Those values evaluate
|
|
28
|
+
once, in order. A slice's state may also be a list.
|
|
29
|
+
|
|
30
|
+
Instead of changing the draft, a reducer may return a new state
|
|
31
|
+
(`return { ...state, page: 0 }`), or assign `state = …` and return it; reassigning `state`
|
|
32
|
+
alone changes nothing. Change the draft or return a new state, never both: a reducer that does
|
|
33
|
+
both, or otherwise fails, leaves the state unchanged and makes `dispatch(...)` throw where it
|
|
34
|
+
was called. A reducer may use
|
|
35
|
+
`let` values, `while`, `do…while`, `for`, `for…of` and `for…in` loops with `break` and
|
|
36
|
+
`continue`, `switch`, `throw` and `try`/`catch`/`finally`, and reassign a name it destructured
|
|
37
|
+
from the action. An uncaught `throw` leaves the state unchanged and makes `dispatch(...)` throw
|
|
38
|
+
it. Labelled loops and `...rest` in a reducer's destructuring are not available.
|
|
39
|
+
|
|
40
|
+
Thunk results are handled in `extraReducers` with
|
|
41
|
+
`builder.addCase(thunk.pending | fulfilled | rejected, (state, action) => { … })`. Each case gets
|
|
42
|
+
the thunk's argument as `action.meta.arg`, so a late result can check it still belongs to the
|
|
43
|
+
current profile, or roll back only the entry that failed.
|
|
44
|
+
|
|
45
|
+
Export the action creators (`export const { clearSaved } = savedSlice.actions`) and the thunks.
|
|
46
|
+
A screen imports them from `"../store"` and calls `dispatch(clearSaved())` or
|
|
47
|
+
`dispatch(loadSaved(profileId))`.
|
|
48
|
+
|
|
49
|
+
## Async thunks
|
|
50
|
+
|
|
51
|
+
Thunk bodies support ordered `const` values, `if`/`else` and `return`, with awaited
|
|
52
|
+
`content.list()`, `content.collections()`, the `@adelin/profiles` calls ([profiles.md](profiles.md))
|
|
53
|
+
and `storage.get`, `storage.set` and `storage.remove` from `@adelin/storage`. Storage keeps JSON
|
|
54
|
+
values on this device only, so use it for device preferences such as a chosen layout:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
export const loadLayout = createAsyncThunk("prefs/loadLayout", async () => {
|
|
58
|
+
const layout = await storage.get("prefs.layout");
|
|
59
|
+
return layout ?? "grid";
|
|
60
|
+
});
|
|
61
|
+
export const saveLayout = createAsyncThunk("prefs/saveLayout", async (layout: string) => {
|
|
62
|
+
await storage.set("prefs.layout", layout);
|
|
63
|
+
return layout;
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
For saved titles ("My List"), see [profiles.md](profiles.md).
|
|
68
|
+
|
|
69
|
+
A thunk's type is its slice and its export name: `export const loadSaved = createAsyncThunk("saved/loadSaved", …)`.
|
|
70
|
+
|
|
71
|
+
Handle the pending, fulfilled and rejected cases, and await `.unwrap()` before an action that
|
|
72
|
+
must only happen on success.
|
|
73
|
+
|
|
74
|
+
When the catalogue updates, read-only thunks rerun. Thunks that also change stored values,
|
|
75
|
+
profiles or saved titles are invalidated without replaying those writes: their data-derived fulfilled fields
|
|
76
|
+
reset to initial values until the app dispatches again. Cancellation or disposal stops later
|
|
77
|
+
steps.
|
|
78
|
+
|
|
79
|
+
Sign-in and account thunks use the `@adelin/auth` operations; see [auth.md](auth.md). Purchase
|
|
80
|
+
thunks use the `@adelin/access` actions; see [access.md](access.md).
|
|
81
|
+
Passwords stay in component state, never in the store or storage. General network calls and
|
|
82
|
+
arbitrary npm imports are not available. Which calls a component's handlers can `await` is in
|
|
83
|
+
[language.md](language.md#async-handlers).
|
|
84
|
+
|
|
85
|
+
Build `store.tsx` from the slices and thunks this app needs.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Typing on TV
|
|
2
|
+
|
|
3
|
+
Use this guide when a TV screen has fields viewers type into: sign-in and sign-up, search,
|
|
4
|
+
a profile name, a PIN or any other form. Phones, tablets and the desktop web keep their own
|
|
5
|
+
keyboards; nothing here changes them.
|
|
6
|
+
|
|
7
|
+
## Typing on TV
|
|
8
|
+
|
|
9
|
+
A viewer moves to a field with the remote and presses Select. A keyboard opens, they pick
|
|
10
|
+
keys with the arrows, and the text appears in the field as they type. Done closes the keyboard,
|
|
11
|
+
and Back closes it too, keeping what they typed. A second Back is the screen's normal Back.
|
|
12
|
+
|
|
13
|
+
Every TV field gets this for free from `TextInput` in `@adelin/ui`. Write the same field you
|
|
14
|
+
would write for a phone; the TV build adds the remote handling and the keyboard.
|
|
15
|
+
|
|
16
|
+
## Fields
|
|
17
|
+
|
|
18
|
+
- Focus alone opens nothing. Landing on a field only shows its focused look; Select opens the
|
|
19
|
+
keyboard. Never open a keyboard from code when a screen appears.
|
|
20
|
+
- Leaving the screen or sending the app to the background closes an open keyboard and keeps
|
|
21
|
+
the text. Returning does not reopen it.
|
|
22
|
+
- Done closes the keyboard and nothing else: it does not submit the form or move to the next
|
|
23
|
+
field, and `onSubmitEditing` never fires on TV. Always put a visible button (Sign in, Save,
|
|
24
|
+
Search) after the fields.
|
|
25
|
+
- On TV, `onFocus` means the keyboard opened and `onBlur` means it closed (after
|
|
26
|
+
`onEndEditing`). They are not remote focus.
|
|
27
|
+
- Style the focused look with a function: `style={({ focused }) => [styles.input, focused && styles.inputFocused]}`.
|
|
28
|
+
`focused` is true while the remote is on the field or the keyboard is open. A function
|
|
29
|
+
style replaces the built-in focus border, so always give the focused state a clear change
|
|
30
|
+
(border colour and width, or background). A plain style object keeps the built-in look.
|
|
31
|
+
Keep the field's outer size the same when focused: if the border grows by 1, take 1 off
|
|
32
|
+
the padding. For Roku targets, follow the [Roku focus style profile](platform-files.md#roku-capability-profile).
|
|
33
|
+
- `secureTextEntry` fields are always shown as dots, on the field and in the keyboard.
|
|
34
|
+
- A field with `editable={false}` still takes remote focus but Select does nothing. Show it
|
|
35
|
+
with a dimmed style so viewers can tell.
|
|
36
|
+
- `focusKey="email"` names the field so a screen can start with focus on it.
|
|
37
|
+
- `maxLength` dims the character keys once the text reaches it, and the keyboard says so.
|
|
38
|
+
- `keyboardType` picks the keys: `"email-address"` (and `"url"`) adds `.com` and the address
|
|
39
|
+
punctuation; `"number-pad"`, `"numeric"`, `"decimal-pad"` and `"phone-pad"` give a number pad.
|
|
40
|
+
|
|
41
|
+
## The app keyboard
|
|
42
|
+
|
|
43
|
+
Use the keyboard designed for the app on every TV. Leave `tvKeyboard` out of `app.tsx`;
|
|
44
|
+
`TextInput` supplies the default bottom panel. Do not offer a choice between that keyboard
|
|
45
|
+
and the TV's own keyboard. Style the keyboard where the design calls for it, and use the
|
|
46
|
+
inline search variant when results should update beside the keys.
|
|
47
|
+
|
|
48
|
+
For sign-in and sign-up, assemble separate screens with the fields and auth actions in
|
|
49
|
+
[auth.md](auth.md).
|
|
50
|
+
|
|
51
|
+
## The prebuilt keyboards
|
|
52
|
+
|
|
53
|
+
Prefer a prebuilt keyboard styled to the app over building one. Pass it to a field with
|
|
54
|
+
`tvKeyboard`; a field without the prop gets the bottom panel.
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<TextInput accessibilityLabel="Display name" value={name} onChangeText={setName} maxLength={24}
|
|
58
|
+
style={({ focused }) => [styles.input, focused && styles.inputFocused]}
|
|
59
|
+
tvKeyboard={<TVKeyboard variant="bottom" style={styles.panel} keyStyle={styles.key}
|
|
60
|
+
keyFocusedStyle={styles.keyFocused} keyLabelStyle={styles.keyLabel} doneKeyStyle={styles.done} />} />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- `variant="bottom"`: a panel across the bottom of the screen; the page scrolls so the field
|
|
64
|
+
stays visible above it. Good for most forms.
|
|
65
|
+
- `variant="side"` with `side="left" | "right"` (default right): a panel down one edge. Put
|
|
66
|
+
the form in the other half of the screen so the field stays in view.
|
|
67
|
+
- `variant="full"`: the whole screen, with the field's name and an echo of the text. Good
|
|
68
|
+
for a single important entry such as a password or a long name.
|
|
69
|
+
- `variant="search"`: a compact keyboard that sits in the layout; see the next section.
|
|
70
|
+
|
|
71
|
+
Restyle with theme tokens through these props: `style` (the panel), `contentStyle` (the key
|
|
72
|
+
column; its width is the grid width), `keyStyle` (its height sets every key's height),
|
|
73
|
+
`keyFocusedStyle`, `keyPressedStyle`, `keyActiveStyle`, `keyDimmedStyle`, `keyLabelStyle`,
|
|
74
|
+
`keyLabelFocusedStyle`, `keyLabelActiveStyle`, `keyLabelDimmedStyle`, `specialKeyLabelStyle`,
|
|
75
|
+
`doneKeyStyle`, `doneKeyLabelStyle`, `echoStyle`, `echoTextStyle`, `labelStyle` and
|
|
76
|
+
`micListeningColor`. `keyFocusScale` and `wideKeyFocusScale` set how much a focused key grows.
|
|
77
|
+
|
|
78
|
+
`layouts` sets the pages, in order: `["latin", "symbols"]` by default. Add `"arabic"` for an
|
|
79
|
+
Arabic letter page, reached with a key labelled in its own script:
|
|
80
|
+
`layouts={["latin", "arabic", "symbols"]}`.
|
|
81
|
+
|
|
82
|
+
Never use flex `gap` in a keyboard's styles or the layout around it; space keys and columns
|
|
83
|
+
with margins. Older TV browsers ignore `gap`.
|
|
84
|
+
|
|
85
|
+
## The search keyboard
|
|
86
|
+
|
|
87
|
+
On a TV search screen, put the keyboard in the layout beside the results, which follow the
|
|
88
|
+
query through `useSearch` ([search.md](search.md)):
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
<View style={styles.row}>
|
|
92
|
+
<View style={styles.keys}>
|
|
93
|
+
<TVKeyboard variant="search" value={query} onChangeText={setQuery} placeholder="Search titles" />
|
|
94
|
+
</View>
|
|
95
|
+
<View style={styles.results}>{/* shown from useSearch(titles, query) */}</View>
|
|
96
|
+
</View>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
It has no Done and traps no focus: Right from its last column moves into the results, Left
|
|
100
|
+
from its first column moves to whatever sits on the left. It owns its text through `value`
|
|
101
|
+
and `onChangeText`, so no `TextInput` is needed. Give its column a fixed width (about 272).
|
|
102
|
+
It is a TV layout, so place it in the screen's TV version ([platform-files.md](platform-files.md));
|
|
103
|
+
the phone version keeps a plain `TextInput` above the same results.
|
|
104
|
+
|
|
105
|
+
## Building your own keyboard
|
|
106
|
+
|
|
107
|
+
Build one only when no prebuilt keyboard fits, such as a four-digit PIN pad. Write it in the
|
|
108
|
+
TV version of the component (`components/PinPad.tv.tsx`, with `PinPad.tsx` for phones) and
|
|
109
|
+
give both files the same props.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
const [typing, setTyping] = useState(false);
|
|
113
|
+
return (
|
|
114
|
+
<View>
|
|
115
|
+
<TextInput accessibilityLabel="PIN" value={value} onChangeText={onChangeText} secureTextEntry maxLength={4}
|
|
116
|
+
showSoftInputOnFocus={false} caretHidden={!typing} onPress={() => setTyping(true)}
|
|
117
|
+
style={({ focused }) => [styles.field, focused && styles.fieldFocused]} />
|
|
118
|
+
<Portal open={typing} onClose={() => setTyping(false)}>
|
|
119
|
+
<FocusGroup direction="horizontal">
|
|
120
|
+
<View style={styles.row}>
|
|
121
|
+
{["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"].map(digit => (
|
|
122
|
+
<Pressable key={digit} accessibilityLabel={digit} onPress={() => onChangeText((value + digit).slice(0, 4))}
|
|
123
|
+
style={({ focused }) => [styles.key, focused && styles.keyFocused]}><Text style={styles.keyLabel}>{digit}</Text></Pressable>
|
|
124
|
+
))}
|
|
125
|
+
<Pressable accessibilityLabel="Delete" onPress={() => onChangeText(value.slice(0, -1))} style={({ focused }) => [styles.key, focused && styles.keyFocused]}><Text style={styles.keyLabel}>Delete</Text></Pressable>
|
|
126
|
+
<Pressable accessibilityLabel="Done" onPress={() => setTyping(false)} style={({ focused }) => [styles.key, focused && styles.keyFocused]}><Text style={styles.keyLabel}>Done</Text></Pressable>
|
|
127
|
+
</View>
|
|
128
|
+
</FocusGroup>
|
|
129
|
+
</Portal>
|
|
130
|
+
</View>
|
|
131
|
+
);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- `showSoftInputOnFocus={false}` tells the field to open nothing; Select calls your `onPress`.
|
|
135
|
+
- `Portal` with `onClose` makes Back close your keyboard, keep the text and return to the field.
|
|
136
|
+
- Insert and delete with plain string operations, and cut to the field's limit yourself.
|
|
137
|
+
- `caretHidden={!typing}` shows the caret only while your keyboard is open. The field shows no
|
|
138
|
+
editing look of its own, so style one from `typing` if you want it.
|
|
139
|
+
- For a secret, show dots in your keyboard and give the echo a label with only the count.
|
|
140
|
+
|
|
141
|
+
## Voice
|
|
142
|
+
|
|
143
|
+
On TVs that support speech, the prebuilt keyboards show a mic key by themselves. Viewers
|
|
144
|
+
press it, speak, and the words are added to the text. There is nothing to write. The mic
|
|
145
|
+
key never appears on password fields; `micListeningColor` sets its colour while listening.
|
|
146
|
+
The native iOS and tvOS builds do not offer this keyboard's speech recognition.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Approved references
|
|
2
|
+
|
|
3
|
+
Screens the product owner accepted as the quality bar. Measure a new design against them: hero
|
|
4
|
+
size, artwork, density, legibility and focus should be at least this good. Match the bar, not
|
|
5
|
+
the screen. Each app still chooses its own layout pattern and identity from the
|
|
6
|
+
[streaming playbook](../streaming-playbook.md).
|
|
7
|
+
|
|
8
|
+
| Screen | What makes it right |
|
|
9
|
+
|---|---|
|
|
10
|
+
| [TV Home](vesper-tv-home.jpg) | The backdrop fills the screen from the top-right, with no bar above it. The nav sits over the art. Copy sits bottom-left on the left and bottom scrims, and the subject is whole and clear of the copy. The first rail is fully in view and the next heading shows. |
|
|
11
|
+
| [TV series detail](vesper-tv-detail.jpg) | Same frame as Home, so moving into a title feels continuous. Play is the brightest control. Season tabs and the first episode row fit in the first viewport. |
|
|
12
|
+
| [Phone Home](vesper-phone-home.jpg) | A tall hero with the wordmark on a top scrim and the copy on a bottom scrim. The subject sits between the two. The first rail's next card peeks at the edge, and the next heading shows above the tab bar. |
|
|
13
|
+
|
|
14
|
+
Captures are 1920×1080 for TV and 390×844 for phone. Review new work at the same sizes.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|