@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,503 @@
|
|
|
1
|
+
# Portable React and TypeScript
|
|
2
|
+
|
|
3
|
+
Write plain React Native TSX, as close to ordinary React as possible, through the `@adelin/*`
|
|
4
|
+
packages. The compiler translates it into the shared renderer format; it does not execute
|
|
5
|
+
arbitrary JavaScript packages. Check the workspace after each coherent chunk, especially the
|
|
6
|
+
store, before writing all of the screens. The examples below show individual syntax patterns;
|
|
7
|
+
compose the app's screens from its own design brief.
|
|
8
|
+
|
|
9
|
+
## Imports and exports
|
|
10
|
+
|
|
11
|
+
Use the familiar React, React Native, React Navigation and Redux names, but always import them
|
|
12
|
+
from the `@adelin/*` packages listed in [packages.md](../reference/packages.md), never from
|
|
13
|
+
`react`, `react-native` or `react-redux`. That list is complete: a name that is not in it does
|
|
14
|
+
not exist. Your own components and `store.tsx` are imported by relative path and must exist.
|
|
15
|
+
Saved images are imported by relative path from the root `assets/` folder; see
|
|
16
|
+
[assets.md](assets.md).
|
|
17
|
+
|
|
18
|
+
Each screen or component is the default export of its file, named after it.
|
|
19
|
+
|
|
20
|
+
## Components and styles
|
|
21
|
+
|
|
22
|
+
A file has one importable default entry. It may also declare module-local function or arrow
|
|
23
|
+
components. Those components have independent hooks and state, accept props and children,
|
|
24
|
+
share module helpers and styles, and may register navigator screens. Separate files remain
|
|
25
|
+
useful for reuse across modules. Do not create components dynamically inside another
|
|
26
|
+
component or shadow a component name with a local value.
|
|
27
|
+
|
|
28
|
+
Components take props like any React component: destructure them in the parameter list, and
|
|
29
|
+
call a handler prop from an arrow, `onPress={() => onPick()}`. Event handlers receive what React
|
|
30
|
+
Native passes: one event for most props, and `(width, height)` for a `ScrollView`'s
|
|
31
|
+
`onContentSizeChange`. A component that takes a
|
|
32
|
+
`style` prop merges it last, `style={[styles.chip, style]}`, typed `StyleProp<ViewStyle>`
|
|
33
|
+
from `@adelin/ui`.
|
|
34
|
+
|
|
35
|
+
Inline fixed and changing style objects are supported, including conditional object branches
|
|
36
|
+
and component style props. Use `StyleSheet.create` at the bottom of the file for reused
|
|
37
|
+
styles, reading `theme.colors.*` and `theme.spacing.*`, and combine with arrays for state:
|
|
38
|
+
`style={[styles.chip, active && styles.chipOn]}`. Numeric spacing arithmetic such as
|
|
39
|
+
`marginRight: -theme.spacing.md` works in the style table. Values depending on props, state
|
|
40
|
+
or window dimensions belong in the rendered style expression. A style holds no callbacks:
|
|
41
|
+
compute `items.some((item) => item.done)` in a `const` above the return and use that `const`
|
|
42
|
+
in the style. Unknown props, unsafe keys and unsupported platform features produce
|
|
43
|
+
diagnostics.
|
|
44
|
+
|
|
45
|
+
When returning a dashed or dotted border to solid, set `borderStyle: 'solid'`
|
|
46
|
+
explicitly; Android can retain the previous pattern after a null or undefined reset.
|
|
47
|
+
|
|
48
|
+
Sizes are in stable logical units on phone, tablet and browser; TV uses a proportional
|
|
49
|
+
960-wide canvas. Window dimensions use the same units. Reflow at window breakpoints and never
|
|
50
|
+
multiply by pixel density; see [responsive-layout.md](../design/responsive-layout.md). For
|
|
51
|
+
shadows, `aspectRatio` and `inset`, see the last section of the
|
|
52
|
+
[design guide](../design/design-guide.md).
|
|
53
|
+
|
|
54
|
+
Font features (`fontVariant`) and variation axes (`fontVariationSettings`) are unsupported
|
|
55
|
+
on every platform. Use `fontFamily`, `fontSize`, `fontWeight` and `fontStyle` for typography.
|
|
56
|
+
|
|
57
|
+
## Background styles
|
|
58
|
+
|
|
59
|
+
Background styles use `backgroundImage`, `backgroundSize`, `backgroundPosition` and
|
|
60
|
+
`backgroundRepeat`. The `experimental_` spellings are unsupported and rejected when their
|
|
61
|
+
keys are known at build time; incoming style objects are checked when the renderer resolves
|
|
62
|
+
them. Computed style keys are outside the portable style syntax; write the canonical
|
|
63
|
+
property names directly.
|
|
64
|
+
|
|
65
|
+
## Hooks and navigation
|
|
66
|
+
|
|
67
|
+
`useState`, `useReducer` (with the reducer declared at module level), `useRef`, `useMemo`,
|
|
68
|
+
`useCallback` and `useEffect` with a dependency list (return a cleanup; `setTimeout` and
|
|
69
|
+
`setInterval` are fine inside it), imported by name or through `import React from
|
|
70
|
+
'@adelin/react'` as `React.useState`. A hook's result may be read in place, as in
|
|
71
|
+
`const status = useAuth().status`, destructured, as in `const { items, status } =
|
|
72
|
+
useSelector((s) => s.library)` or `const { navigate, goBack } = useNavigation()`, or bound
|
|
73
|
+
whole and read later, as in `const dims = useWindowDimensions()` with `dims.width`, or
|
|
74
|
+
`const count = useState(0)` with `count[0]` and `count[1]`. A destructured navigation method
|
|
75
|
+
is called like `navigate('Details')`; `goBack` and `popToTop` may also be passed as a handler,
|
|
76
|
+
`onPress={goBack}`. Read the store with `useSelector` and change it with
|
|
77
|
+
`useDispatch`. Navigation is React Navigation's; [app-structure.md](app-structure.md) lists the
|
|
78
|
+
API and where its hooks work. Move between screens with `useNavigation()` (`navigate`, `push`,
|
|
79
|
+
`replace`, `goBack`, …) and read `useRoute().params` and `route.name`; `route.key` is the mounted
|
|
80
|
+
instance's identity.
|
|
81
|
+
|
|
82
|
+
Run work when a screen gains focus with `useFocusEffect` around a `useCallback` with its
|
|
83
|
+
dependencies, returning a cleanup for blur. Subscribe to navigation events in a `useEffect` and
|
|
84
|
+
return the unsubscribe:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
useFocusEffect(useCallback(() => {
|
|
88
|
+
setVisits((n) => n + 1);
|
|
89
|
+
return () => setPlaying(false);
|
|
90
|
+
}, []));
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const unsubscribe = navigation.addListener('blur', () => setOpen(false));
|
|
94
|
+
return unsubscribe;
|
|
95
|
+
}, [navigation]);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`useIsFocused()` re-renders the screen when it gains or loses focus, and
|
|
99
|
+
`useNavigationState((state) => state.routes.length)` reads the navigator's state through a
|
|
100
|
+
selector, which may read state declared above it.
|
|
101
|
+
|
|
102
|
+
Follow the Rules of Hooks. Handlers and effects read data and dispatch actions, set state or
|
|
103
|
+
navigate. State and props hold plain values (text, numbers, lists, objects). There is no
|
|
104
|
+
custom context (`createContext`): `useContext` reads only the navigation contexts. There is no
|
|
105
|
+
layout effect. `Portal` from `@adelin/ui` keeps the caller's providers and ordinary Back
|
|
106
|
+
ordering; a boolean `open` with `onClose` controls it without adding a route.
|
|
107
|
+
|
|
108
|
+
## Async handlers
|
|
109
|
+
|
|
110
|
+
Handlers, `useCallback` callbacks, `.then` callbacks and functions declared in a component may be
|
|
111
|
+
`async` and `await` these calls: `storage.get`, `storage.set` and `storage.remove`; the
|
|
112
|
+
`DeviceInfo` promise calls; `dispatch(thunk(arg)).unwrap()` for the thunk's value or its
|
|
113
|
+
rejection, or `dispatch(thunk(arg))` to wait without a value; `i18n.changeLanguage(lng)`
|
|
114
|
+
([i18n.md](i18n.md)); and the component's own async functions.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
const readLayout = async () => {
|
|
118
|
+
const saved = await storage.get("prefs.layout");
|
|
119
|
+
return saved ?? "grid";
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const save = async (layout: string) => {
|
|
123
|
+
setSaving(true);
|
|
124
|
+
try {
|
|
125
|
+
await storage.set("prefs.layout", layout);
|
|
126
|
+
await dispatch(saveProfileLayout(layout)).unwrap();
|
|
127
|
+
setLayout(await readLayout());
|
|
128
|
+
} catch {
|
|
129
|
+
setFailed(true);
|
|
130
|
+
} finally {
|
|
131
|
+
setSaving(false);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- Awaits run one after another. They may sit inside expressions and in `if`/`else`, bind values
|
|
137
|
+
with `const` (destructured too), and your own async functions return values to the `await`.
|
|
138
|
+
- `try`/`catch`/`finally` catches a failed await or a `throw`. `.then`, `.catch` and `.finally`
|
|
139
|
+
chains also work, in any shape.
|
|
140
|
+
- Call an async function without `await` to start it and go straight on. An effect starts
|
|
141
|
+
async work the same way, with an inner async function it calls:
|
|
142
|
+
`useEffect(() => { const load = async () => { … }; load(); }, [id]);`.
|
|
143
|
+
- A state value read after an await is the value from the render the handler came from, as in
|
|
144
|
+
React.
|
|
145
|
+
|
|
146
|
+
Not available:
|
|
147
|
+
|
|
148
|
+
- `async` worklets: the animation thread cannot wait.
|
|
149
|
+
- `useEffect(async …)`: an effect returns its cleanup, not a promise; call an inner async function.
|
|
150
|
+
- async `useTVEventHandler` and `useBackHandler` callbacks: they must answer at once whether they
|
|
151
|
+
used the key; call an async function from them.
|
|
152
|
+
- `Promise.all`, the other `Promise` helpers and `new Promise`: nothing waits for several calls at
|
|
153
|
+
once; await them one after another.
|
|
154
|
+
- keeping a promise in a const or passing it on: only a call you await or chain can be waited for.
|
|
155
|
+
- awaiting a function from props, route params or refs: the app calls it but cannot wait for it.
|
|
156
|
+
- `async` functions outside components: functions at file level are plain helpers.
|
|
157
|
+
- awaits in loops: handlers have no loops.
|
|
158
|
+
- a `try` that waits for nothing: its catch could never run.
|
|
159
|
+
- a `throw` that no catch in the same function receives: nothing would handle it.
|
|
160
|
+
- reading the value of `await dispatch(thunk())` without `.unwrap()`: the settled action is not
|
|
161
|
+
handed back; use `.unwrap()` for the value.
|
|
162
|
+
- a handler that waits in many branches can grow past the size limit; split it into smaller
|
|
163
|
+
functions.
|
|
164
|
+
|
|
165
|
+
Differences from JavaScript:
|
|
166
|
+
|
|
167
|
+
- An error in the code itself, such as reading a field of `undefined`, is reported, not caught,
|
|
168
|
+
unless it happens after an await inside the try.
|
|
169
|
+
- The catch of a failed storage call receives the error message as text, not an `Error`.
|
|
170
|
+
- When the app is checked out, awaits print back as `await`, with the same meaning but sometimes
|
|
171
|
+
other spelling: an await inside an expression becomes its own `const _a0 = await …` line, your
|
|
172
|
+
own async functions appear written out where they are called, the code after a branch that
|
|
173
|
+
waits is copied into each branch, and an unused catch parameter is dropped.
|
|
174
|
+
|
|
175
|
+
## Rendering
|
|
176
|
+
|
|
177
|
+
`{cond && <Node />}`, ternaries between elements (nested ones too), and
|
|
178
|
+
`{rows.map((row) => <Node key={row.id} … />)}` for short lists. Long or horizontal lists are a
|
|
179
|
+
`FlashList` with `data`, `keyExtractor` and `renderItem`. A grid is the same `FlashList` with
|
|
180
|
+
`numColumns={columns}` and `gap` (or `rowGap` and `columnGap`); never split the data into rows
|
|
181
|
+
yourself. The list owns the cells' spacing and remote focus: Left and Right stay in the row, Up
|
|
182
|
+
and Down keep the column. Size each item to `(listWidth - gap * (columns - 1)) / columns`. Ids
|
|
183
|
+
are strings. Never give a horizontal `FlashList` a height: it sizes itself to its items and adds
|
|
184
|
+
room for the focused item's scale, which a fixed height would cut off. Give the items a fixed
|
|
185
|
+
width and height instead, so the row measures before artwork loads.
|
|
186
|
+
|
|
187
|
+
Many identical rows, such as one row of the same landscape cards per genre, are one vertical
|
|
188
|
+
`FlashList` that fills the screen (`flex: 1`) and whose `renderItem` draws a whole row: its
|
|
189
|
+
header and a horizontal `FlashList` of cards. Only rows near the screen mount, and each row returns
|
|
190
|
+
focus to the card the viewer last left on it. Use it only when every row has the same card shape,
|
|
191
|
+
size and row height: the outer list reuses one row's cells for the next. Rows that differ, such
|
|
192
|
+
as Continue watching, a numbered top ten or a poster row, stay their own horizontal `FlashList`s.
|
|
193
|
+
Put them and the hero above the identical rows, in the outer list's `ListHeaderComponent`, so the
|
|
194
|
+
page scrolls as one.
|
|
195
|
+
|
|
196
|
+
Wrap each row in a horizontal `FocusGroup` with `remember` and a `focusKey` made from the row's id
|
|
197
|
+
and the route key. The outer list reuses a scrolled-away row's cell for another row; the key
|
|
198
|
+
lets the row put back its own scroll position and last focused card when it returns, instead of
|
|
199
|
+
taking them from whichever row last used that cell.
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
<FlashList data={genres} keyExtractor={shelf => shelf.id}
|
|
203
|
+
ListHeaderComponent={<View><Hero /><ContinueRail /><TopTenRail /></View>}
|
|
204
|
+
renderItem={({ item: shelf }) => (
|
|
205
|
+
<FocusGroup focusKey={route.key + '-row-' + shelf.id} direction="horizontal" remember>
|
|
206
|
+
<View style={styles.shelf}>
|
|
207
|
+
<Text style={styles.shelfTitle}>{shelf.name}</Text>
|
|
208
|
+
<FlashList horizontal data={shelf.entries} keyExtractor={entry => entry.id}
|
|
209
|
+
contentContainerStyle={styles.cardsContent} renderItem={({ item }) => <TitleCard item={item} />} />
|
|
210
|
+
</View>
|
|
211
|
+
</FocusGroup>
|
|
212
|
+
)} />
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Do not render many identical rows with `{genres.map(…)}` inside a `ScrollView`: every row and
|
|
216
|
+
every card mounts at once.
|
|
217
|
+
|
|
218
|
+
`slides[index]?.title` selects the actual active item, including `undefined` for an absent or
|
|
219
|
+
out-of-range entry; never substitute the first item. Typed props may receive `[]`; inferred
|
|
220
|
+
arrays, `slice(0, 0)` and typed empty constants (`const none: ContentItem[] = []`) are valid.
|
|
221
|
+
|
|
222
|
+
## Carousel
|
|
223
|
+
|
|
224
|
+
Pick by what is featured. One featured item is a hero, such as `BillboardHero` or your own hero
|
|
225
|
+
`View`. Several featured items shown one at a time are a `Carousel` from `@adelin/ui`: it slides by
|
|
226
|
+
default, `mode="parallax"` lets the neighbours peek in scaled down, and `mode="horizontal-stack"` or
|
|
227
|
+
`"vertical-stack"` deals the items as a deck of cards. A row of many posters is a horizontal
|
|
228
|
+
`FlashList` rail, never a `Carousel`.
|
|
229
|
+
|
|
230
|
+
Props, with defaults (distances and sizes are canvas units):
|
|
231
|
+
|
|
232
|
+
- Data: `data`, `itemKey`, `renderItem` (required); `loop` (false); `autoFillData` (true) repeats
|
|
233
|
+
one or two looping items so the loop has neighbours; `defaultIndex` (0).
|
|
234
|
+
- Look: `mode` (slide), `modeConfig` for the chosen mode, `customAnimation` (replaces `mode`),
|
|
235
|
+
`width` (the carousel's width), `height` (the tallest item), `vertical` (false), `style`,
|
|
236
|
+
`contentContainerStyle`, `windowSize` (every item rendered).
|
|
237
|
+
- Motion: `pagingEnabled` (true), `snapEnabled` (true), `overscrollEnabled` (true), `enabled`
|
|
238
|
+
(true, swipes), `autoPlay` (false), `autoPlayReverse` (false), `autoPlayInterval` (1000 ms),
|
|
239
|
+
`scrollAnimationDuration` (500 ms), `minScrollDistancePerSwipe`, `maxScrollDistancePerSwipe`,
|
|
240
|
+
`fixedDirection` (`"positive"` or `"negative"`).
|
|
241
|
+
- Events: `onActiveIndexChange`, `onSnapToItem`, `onScrollStart`, `onScrollEnd`,
|
|
242
|
+
`onProgressChange(offsetProgress, absoluteProgress)`.
|
|
243
|
+
- Dots and focus: `pagination`, `focusMode` (`"content"`), `focusEntry` (`"remember"`), `ref`.
|
|
244
|
+
|
|
245
|
+
`pagination` is on whenever there is more than one item; `pagination={false}` hides it. An object
|
|
246
|
+
styles it: `{ dotSize: 8, gap: 8, color, activeColor, position, overlay: false }`. The colours default
|
|
247
|
+
to `theme.colors.primary` for the active dot and `theme.colors.textMuted` for the rest; pass theme
|
|
248
|
+
tokens, never hex. `position` is `"bottom"` (`"right"` when `vertical`), `"top"`, `"left"` or
|
|
249
|
+
`"right"`; `overlay` floats the dots inside the cards' edge. Each dot is announced as "Slide 2 of 5"
|
|
250
|
+
and the active one as selected. On phone and desktop, pressing a dot jumps to its item.
|
|
251
|
+
|
|
252
|
+
On TV, `focusMode="content"` makes only the centred card's own controls focusable. Left and Right
|
|
253
|
+
move between them and never page; past the card's edge, focus leaves the carousel. Down or Up
|
|
254
|
+
reaches the dots, one focusable row: moving focus onto a dot slides to its item, wrapping at the
|
|
255
|
+
ends with `loop`. When the carousel moves for any reason, focus inside the card follows to the new
|
|
256
|
+
centred card. `focusMode="card"` makes each card one focus stop that the carousel follows (wrapping
|
|
257
|
+
with `loop`); use it only when each card's root is a single `Pressable` with no buttons inside, such
|
|
258
|
+
as a poster. `focusEntry="remember"` returns to the active dot, last control or active card;
|
|
259
|
+
`"first"` starts at the first.
|
|
260
|
+
|
|
261
|
+
Drive it from your own buttons through a ref:
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
import type { ContentItem } from "@adelin/content";
|
|
265
|
+
import { useTranslation } from "@adelin/i18n";
|
|
266
|
+
import { useRef } from "@adelin/react";
|
|
267
|
+
import { Carousel, Pressable, Text, View, type CarouselRef } from "@adelin/ui";
|
|
268
|
+
|
|
269
|
+
export function Featured({ items }: { items: ContentItem[] }) {
|
|
270
|
+
const { t } = useTranslation();
|
|
271
|
+
const carousel = useRef<CarouselRef>(null);
|
|
272
|
+
return (
|
|
273
|
+
<View>
|
|
274
|
+
<Carousel ref={carousel} data={items} itemKey={(item) => item.id}
|
|
275
|
+
renderItem={({ item }) => <Text>{item.title}</Text>} />
|
|
276
|
+
<Pressable onPress={() => carousel.current?.prev()}><Text>{t("home.previous")}</Text></Pressable>
|
|
277
|
+
<Pressable onPress={() => carousel.current?.next()}><Text>{t("home.next")}</Text></Pressable>
|
|
278
|
+
<Pressable onPress={() => carousel.current?.scrollTo({ index: 0, animated: true })}>
|
|
279
|
+
<Text>{t("home.first")}</Text>
|
|
280
|
+
</Pressable>
|
|
281
|
+
</View>
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
`next`, `prev` and `scrollTo` also take `count` and `onFinished`; `getCurrentIndex()` returns the
|
|
287
|
+
centred index. With `animated: false`, an executed command commits its position before `onFinished`
|
|
288
|
+
and immediate index reads. Endpoint or same-index commands can return without invoking completion.
|
|
289
|
+
`customAnimation` is a `'worklet'` of `(value, index)` returning a style, where
|
|
290
|
+
`value` is the item's offset from the centred item (-1, 0, 1). It replaces `mode`; this one fades
|
|
291
|
+
and shrinks the neighbours:
|
|
292
|
+
|
|
293
|
+
```tsx
|
|
294
|
+
import { Extrapolation, interpolate } from "@adelin/reanimated";
|
|
295
|
+
|
|
296
|
+
<Carousel data={items} itemKey={(item) => item.id} width={320} renderItem={({ item }) => <Text>{item.title}</Text>}
|
|
297
|
+
customAnimation={(value) => {
|
|
298
|
+
'worklet';
|
|
299
|
+
return {
|
|
300
|
+
opacity: interpolate(value, [-1, 0, 1], [0.4, 1, 0.4], Extrapolation.CLAMP),
|
|
301
|
+
transform: [{ translateX: value * 320 }, { scale: interpolate(value, [-1, 0, 1], [0.85, 1, 0.85], Extrapolation.CLAMP) }],
|
|
302
|
+
};
|
|
303
|
+
}} />
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
On web TVs (Tizen, webOS, VIDAA, Titan OS and Vega browser builds) every prop works, with these
|
|
307
|
+
differences: each step is one CSS transition; a jump of more than one item lands beside the target
|
|
308
|
+
and animates the last step; `onProgressChange` reports at the start and end of each step, not per
|
|
309
|
+
frame; dragging works only with the webOS Magic Remote pointer; a reduced-motion system setting
|
|
310
|
+
makes moves instant; and without `windowSize` only the cards that fit, plus their neighbours,
|
|
311
|
+
render. Roku differs further; see [platform-files.md](platform-files.md).
|
|
312
|
+
|
|
313
|
+
## Expressions
|
|
314
|
+
|
|
315
|
+
Supported methods include `map`, `filter`, `find`, `findIndex`, `some`, `reduce`, `includes`,
|
|
316
|
+
`indexOf`, the copying `toSorted`, `toReversed`, `toSpliced` and `with`, string case conversion
|
|
317
|
+
and slicing. String `indexOf` uses JavaScript UTF-16
|
|
318
|
+
offsets; array `indexOf` uses strict equality. `localeCompare`, `normalize` and
|
|
319
|
+
`toLocaleString` are not available, called or read, on any value, so name your own fields
|
|
320
|
+
differently. `match()` and `search()` cannot be called; fields of your own data named
|
|
321
|
+
`match` or `search` are fine. Compare text with `<` and `>`, test it with `includes`,
|
|
322
|
+
`startsWith` or `indexOf`, and format numbers with `toFixed` or `String(n)`. `Math.round`, `Math.floor` and friends work.
|
|
323
|
+
Pure callback blocks may declare ordered `const` values and return an expression. `typeof`
|
|
324
|
+
supports bound values and property expressions; unknown identifiers are compile errors.
|
|
325
|
+
TypeScript annotations are kept: parameter and return types (destructured and defaulted
|
|
326
|
+
parameters too), type predicates such as `(e): e is ContentItem => …`, const annotations in
|
|
327
|
+
components, handlers and effects, type arguments (`useState<ContentItem | null>(null)`,
|
|
328
|
+
`useRef<T>`, `items.map<T>`, generic helpers), slice state types (`initialState: { … } as
|
|
329
|
+
CartState`), file-level `type` and `interface` declarations (generic, recursive and `extends`
|
|
330
|
+
included), and `as`, `satisfies` and `!`. Declare types at file level, not inside a function,
|
|
331
|
+
and import the `@adelin/*` types you name with `import type` under their own names.
|
|
332
|
+
React's types come from `@adelin/react`, by name or as `React.ReactNode`: `ReactNode`,
|
|
333
|
+
`ReactElement`, `FC`, `PropsWithChildren`, `ComponentProps`, `Dispatch`, `SetStateAction`,
|
|
334
|
+
`RefObject` and the rest. `const Card: FC<Props> = ({ title }) => …` types its props from
|
|
335
|
+
`Props`, and `PropsWithChildren<Props>` adds an optional `children`. `ComponentProps<typeof
|
|
336
|
+
Text>['numberOfLines']` works inside a props type; a props type that is all of
|
|
337
|
+
`ComponentProps<typeof Text>` does not, so list the props you take.
|
|
338
|
+
`"key" in value` narrows a union as usual.
|
|
339
|
+
|
|
340
|
+
Content fields read as text or lists: convert with `Number(item.durationSec)` before
|
|
341
|
+
arithmetic or a numeric comparison.
|
|
342
|
+
|
|
343
|
+
## TV scroll, remote, Back and device
|
|
344
|
+
|
|
345
|
+
- For a TV route's initial action, put that action first in a `<FocusGroup autoFocus>`.
|
|
346
|
+
A `FocusGroup` moves along one axis, horizontal unless you say otherwise: controls stacked
|
|
347
|
+
top to bottom need `<FocusGroup direction="vertical">`, or Down and Up go nowhere.
|
|
348
|
+
`hasTVPreferredFocus` on a `Pressable` does not establish route-entry focus on web TVs;
|
|
349
|
+
verify the first focused control after navigation in the target preview.
|
|
350
|
+
- Focus lands once, when the screen draws. A control whose text depends on data that arrives
|
|
351
|
+
later, such as Play becoming "Resume · 12 min left", stays one mounted element whose label,
|
|
352
|
+
icon or target changes. Never swap it for a different component or add a new preferred
|
|
353
|
+
control once the data arrives: focus stays on whatever it landed on first.
|
|
354
|
+
- Every focusable hero pressable inside a `ScrollView` must inherit `<ScrollTarget y={0}>`
|
|
355
|
+
from `@adelin/ui`. Place the wrapper around the hero root or each pressable, so
|
|
356
|
+
returning focus from lower content scrolls the page all the way to the top.
|
|
357
|
+
`ScrollTarget` takes exactly one child element, such as the hero's root `View`.
|
|
358
|
+
- Remote, Back and device come from `@adelin/device`, as in React Native TV. Remote keys
|
|
359
|
+
(`useTVEventHandler`, `Keys` and which platforms send which keys) are in
|
|
360
|
+
[remote-keys.md](remote-keys.md).
|
|
361
|
+
- `useBackHandler(() => …)` registers only while its screen is in the foreground, so it needs
|
|
362
|
+
no `useFocusEffect` and no check for the top route. Handlers run newest first: `true`
|
|
363
|
+
consumes Back, `false` passes it to older handlers and then navigation.
|
|
364
|
+
`BackHandler.exitApp()` closes the app.
|
|
365
|
+
- On Apple TV, Menu reaches your Back handlers while one is registered, a panel is open or
|
|
366
|
+
there is a screen to go back to. Otherwise, on a top page, it goes to the TV's Home screen.
|
|
367
|
+
`TVEventControl.enableTVMenuKey()` keeps Menu in the app until a matching
|
|
368
|
+
`TVEventControl.disableTVMenuKey()`; call them in an effect and its cleanup, or in a handler.
|
|
369
|
+
Other devices ignore both calls.
|
|
370
|
+
- `DeviceInfo` has the usual calls: plain reads like `DeviceInfo.getSystemName()`, promise
|
|
371
|
+
calls with `await` or `.then(…).catch(…)`, and `use…` hooks that return `{ loading, result }`.
|
|
372
|
+
|
|
373
|
+
## Video
|
|
374
|
+
|
|
375
|
+
Read the [player index](player/index.md) for playback, controls, tracks, casting, downloads
|
|
376
|
+
and platform behavior.
|
|
377
|
+
|
|
378
|
+
## Animation
|
|
379
|
+
|
|
380
|
+
Animate with Reanimated 4 as you know it. Import it from `@adelin/reanimated` where you would
|
|
381
|
+
use `react-native-reanimated`, and the worklets functions from `@adelin/worklets`:
|
|
382
|
+
|
|
383
|
+
```tsx
|
|
384
|
+
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing, FadeIn } from "@adelin/reanimated";
|
|
385
|
+
import { scheduleOnRN } from "@adelin/worklets";
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Reanimated 4 code compiles with only the import path changed; [packages.md](../reference/packages.md)
|
|
389
|
+
lists every name. What to animate, and for how long, is in the
|
|
390
|
+
[design guide](../design/design-guide.md).
|
|
391
|
+
|
|
392
|
+
**Shared values and worklets**
|
|
393
|
+
|
|
394
|
+
- `useSharedValue` makes a shared value in a component; `makeMutable` makes one outside any
|
|
395
|
+
component, from a starting value that never changes. `isSharedValue(x)` tests for one. Use
|
|
396
|
+
`.value`, or `.get()`, `.set(v)`, `.set((v) => next)` and `.modify(fn)`.
|
|
397
|
+
- Write a shared value in a handler, effect, worklet or callback, never while rendering. Reading
|
|
398
|
+
`.value` while rendering only warns, but the screen does not redraw when it changes.
|
|
399
|
+
- Animated styles, derived values, reactions, scroll handlers, frame callbacks and completion
|
|
400
|
+
callbacks are worklets: they run on the animation thread. They may read props, state, store
|
|
401
|
+
values, theme values and shared values, and call helpers whose body starts with `'worklet'`.
|
|
402
|
+
They may not read a ref's `.current`, `DeviceInfo`, the video player or search results.
|
|
403
|
+
- Worklet bodies are plain JavaScript: `const`, `let` and `var`, destructuring (in parameters
|
|
404
|
+
too, with defaults), rest parameters, `if`/`else`, `switch`, `for`, `for…of`, `for…in`,
|
|
405
|
+
`while`, `do…while`, labelled and plain `break`/`continue`, `return` anywhere, `throw` and
|
|
406
|
+
`try`/`catch`/`finally`, and `function` declarations or arrows, called before or after they
|
|
407
|
+
are declared, recursively, or stored and called later. Every kind of worklet may build and
|
|
408
|
+
change arrays and objects of its own (`list.push(v)`, `box.x = 1`), write shared values, log
|
|
409
|
+
and call `scheduleOnRN`; writing to an object captured from the component changes only the
|
|
410
|
+
worklet's own copy. An uncaught `throw` surfaces as the worklet's error. Not available in
|
|
411
|
+
worklets: `async`.
|
|
412
|
+
- From a worklet, change state, dispatch, navigate or call a prop with `scheduleOnRN(fn, ...args)`.
|
|
413
|
+
`fn` is a function written in place, a state setter, `dispatch`, a prop function or a handler
|
|
414
|
+
declared in the component. `scheduleOnUI(worklet, ...args)` runs a worklet from a handler;
|
|
415
|
+
inside a worklet, call the other worklet directly. On web, an uncaught error in a scheduled
|
|
416
|
+
UI worklet is logged; the remaining queued worklets still run.
|
|
417
|
+
- `useDerivedValue(() => …)` computes a read-only shared value, which may be an animation.
|
|
418
|
+
`useAnimatedReaction(() => input, (current, previous) => …)` responds when the input changes.
|
|
419
|
+
|
|
420
|
+
**Animations**
|
|
421
|
+
|
|
422
|
+
- `withTiming`, `withSpring`, `withDelay`, `withSequence`, `withRepeat` and `withClamp` are
|
|
423
|
+
assigned to `.value`, returned from an animated style or derived value, or nested in one
|
|
424
|
+
another. `cancelAnimation(sv)` stops one. Settings may be written in place, held in a const or
|
|
425
|
+
chosen with `?:`. A const in the component, a handler or a worklet may hold the animation
|
|
426
|
+
itself, list it or pass it to a function (`const pop = withSpring(1.1); scale.value = pop;`);
|
|
427
|
+
React state never holds one. One animation assigned to two values moves both together;
|
|
428
|
+
write it once per value to animate each from its own start.
|
|
429
|
+
- An animated style re-runs whenever a value it reads changes: `withSequence`, `withRepeat` and
|
|
430
|
+
`withDelay` start again. A `withTiming` or `withSpring` to the target a running one already
|
|
431
|
+
heads for continues that run (on its own, inside `withDelay`, or as the first step of a
|
|
432
|
+
`withSequence` or `withRepeat`), whether a style re-runs or it is assigned to `.value`; a new
|
|
433
|
+
`duration` or easing applies to the rest of the curve. A `withSpring` that replaces a running
|
|
434
|
+
spring keeps its speed. While a `withDelay` waits, whatever ran before keeps moving, also when
|
|
435
|
+
it opens a `withSequence` or `withRepeat`. Assigning a `withTiming` or `withSpring` whose target is already the
|
|
436
|
+
value only calls its callback with `true`.
|
|
437
|
+
- A completion callback is the last argument of `withTiming`, `withSpring` and `withRepeat`:
|
|
438
|
+
`(finished) => { if (finished) scheduleOnRN(setShown, true); }`. `finished` is false when
|
|
439
|
+
the animation was cancelled or replaced.
|
|
440
|
+
- Springs take `damping`, `stiffness` and `mass`, or `duration` with `dampingRatio`, and may
|
|
441
|
+
spread a preset such as `GentleSpringConfig` or `SnappySpringConfig`. An easing is an `Easing`
|
|
442
|
+
member (`Easing.out(Easing.cubic)`, `Easing.bezier(…)`, `Easing.steps(4)`) or a worklet of `t`.
|
|
443
|
+
- `interpolate(x, input, output, Extrapolation.CLAMP)`, also with
|
|
444
|
+
`{ extrapolateLeft, extrapolateRight }`; `interpolateColor(x, input, colors, "HSV")` with
|
|
445
|
+
`"RGB"`, `"HSV"` or `"LAB"`; `clamp(x, min, max)`. Animated colours may be hex (`#rgb`,
|
|
446
|
+
`#rgba`, `#rrggbb`, `#rrggbbaa`), `rgb()`/`rgba()`, `hsl()`/`hsla()`, `hwb()` or a CSS colour
|
|
447
|
+
name; `transparent` next to a colour fades that colour. `contrastColor(bg)` gives `"white"` or
|
|
448
|
+
`"black"` for text on `bg`, `convertToRGBA(c)` gives `[r, g, b, a]` from 0 to 1, and
|
|
449
|
+
`isColor(value)` checks a colour string; they work in render and in worklets.
|
|
450
|
+
- Animations follow the device's reduce-motion setting and jump to their end while it is on.
|
|
451
|
+
`reduceMotion: ReduceMotion.Never` (or `.Always`) overrides one animation, `useReducedMotion()`
|
|
452
|
+
reads the setting, and `<ReducedMotionConfig mode={ReduceMotion.Never} />` sets it for the
|
|
453
|
+
whole app while it is shown.
|
|
454
|
+
|
|
455
|
+
**Animated components**
|
|
456
|
+
|
|
457
|
+
- `Animated.View`, `Animated.Text`, `Animated.Image` and `Animated.ScrollView` take an animated
|
|
458
|
+
style alone or in a style array. `Animated.createAnimatedComponent(Component)` wraps any other
|
|
459
|
+
component, from `@adelin/ui` or your own. Wrap it at the top of the file: inside a component
|
|
460
|
+
it makes a new component every render, which remounts it.
|
|
461
|
+
- Prefer `useAnimatedStyle`. `useAnimatedProps` drives a prop that is not a style, such as a
|
|
462
|
+
wrapped `TextInput`'s `value`, but on web it redraws the component every frame, so keep it
|
|
463
|
+
to a few elements.
|
|
464
|
+
- `entering`, `exiting` and `layout` take a ready-made animation (`FadeIn`, `SlideInLeft`,
|
|
465
|
+
`ZoomOut`, `LinearTransition` and the rest in the package list) with chained settings,
|
|
466
|
+
`FadeIn.duration(300).delay(100).springify()`, or
|
|
467
|
+
`new Keyframe({ 0: { opacity: 0 }, 100: { opacity: 1 } })`. `<LayoutAnimationConfig skipEntering>`
|
|
468
|
+
skips its children's entering animations when it first appears.
|
|
469
|
+
- CSS animations and transitions go in an animated component's style: `animationName` (steps
|
|
470
|
+
written in place or from `css.keyframes`), `animationDuration`, `animationIterationCount`,
|
|
471
|
+
`transitionProperty`, `transitionDuration` and the other `animation*` and `transition*` keys,
|
|
472
|
+
timed with `cubicBezier`, `linear` or `steps`. Pseudo-selector styles such as `:focus` are not
|
|
473
|
+
available; give focus its look through the `Pressable` focus feedback in the design guide.
|
|
474
|
+
|
|
475
|
+
**Scrolling and frames**
|
|
476
|
+
|
|
477
|
+
- To fade or move a scroll view, wrap it in `Animated.View` and animate the wrapper. Use
|
|
478
|
+
`Animated.ScrollView` only for scroll-linked work, with `ref` from `useAnimatedRef()`:
|
|
479
|
+
`useAnimatedScrollHandler` as its `onScroll` (one function, or `onScroll`, `onBeginDrag`,
|
|
480
|
+
`onEndDrag`, `onMomentumBegin` and `onMomentumEnd` sharing a context object),
|
|
481
|
+
`useScrollOffset(ref)`, `scrollTo(ref, x, y, true)` and, inside a worklet, `measure(ref)`.
|
|
482
|
+
- `useComposedEventHandler([a, b])` runs several scroll handlers, in order, on one `onScroll`.
|
|
483
|
+
`useEvent((event) => …, ["onScroll", "onMomentumScrollEnd"])` runs one worklet for the named
|
|
484
|
+
scroll events, with `event.eventName` saying which.
|
|
485
|
+
- `useScrollOffset(ref, scrollY)` writes the offset into a shared value made with
|
|
486
|
+
`useSharedValue` or `makeMutable`; several refs may write one value.
|
|
487
|
+
- Long lists stay a `FlashList`; `Animated.FlatList` is not available.
|
|
488
|
+
- `useFrameCallback((frame) => …, autostart)` runs every frame; `.setActive(on)` starts or stops
|
|
489
|
+
it and `.isActive` reads it.
|
|
490
|
+
|
|
491
|
+
Deprecated names still compile, with a warning where they are used: `runOnJS` and `runOnUI` become `scheduleOnRN` and
|
|
492
|
+
`scheduleOnUI`, `useScrollViewOffset` becomes `useScrollOffset`, `Extrapolate` becomes
|
|
493
|
+
`Extrapolation`, `Layout` becomes `LinearTransition`, `createAnimatedPropAdapter(fn)` becomes
|
|
494
|
+
`fn`, `.randomDelay()` becomes `.delay(…)`, and `.restDisplacementThreshold()` and
|
|
495
|
+
`.restSpeedThreshold()` become `.energyThreshold()`. `enableLayoutAnimations`, `isReanimated3`,
|
|
496
|
+
`isConfigured` and `Animated.addWhitelisted…` do nothing; leave them out. React Native's own
|
|
497
|
+
`Animated.Value` is not available.
|
|
498
|
+
|
|
499
|
+
## Platform capabilities
|
|
500
|
+
|
|
501
|
+
Platform capabilities come only from `@adelin/*`. Store and storage rules are in
|
|
502
|
+
[store.md](store.md), sign-in in [auth.md](auth.md), and per-platform implementations in
|
|
503
|
+
[platform-files.md](platform-files.md).
|