uitheme-rn 1.0.0 → 1.0.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 +130 -293
- package/dist/core.d.cts +2 -1
- package/dist/core.d.ts +2 -1
- package/dist/expo.d.cts +3 -2
- package/dist/expo.d.ts +3 -2
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/nativewind.js +4 -1
- package/dist/reanimated.d.cts +2 -1
- package/dist/reanimated.d.ts +2 -1
- package/dist/transitions.cjs +4 -1
- package/dist/transitions.d.cts +5 -4
- package/dist/transitions.d.ts +5 -4
- package/dist/transitions.js +11 -2
- package/package.json +27 -28
package/README.md
CHANGED
|
@@ -1,107 +1,104 @@
|
|
|
1
1
|
# uitheme-rn
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
and
|
|
5
|
-
|
|
3
|
+
uitheme-rn is UI-Theme for React Native. It brings light and dark mode support
|
|
4
|
+
to Android and iOS, and also support for color themes, so that apps can use
|
|
5
|
+
several design systems along with theme transitions. uitheme-rn comes with
|
|
6
|
+
native pickers for Android and iOS.
|
|
7
|
+
|
|
8
|
+
- Light, dark and system modes, plus palettes that work on top of either
|
|
9
|
+
- Nine full-screen transitions: fade, circular reveal, wipe, slide, split,
|
|
10
|
+
heart, star, pixelize and dissolve
|
|
11
|
+
- Smooth color changes on any view with Reanimated
|
|
12
|
+
- Native SwiftUI and Jetpack Compose pickers through Expo UI
|
|
13
|
+
- Works with plain `StyleSheet`, NativeWind 5 or Uniwind
|
|
14
|
+
- Remembers the choice with any storage you already use
|
|
15
|
+
- Respects Reduce Motion
|
|
16
|
+
- The core has no Expo, Reanimated or storage dependency
|
|
6
17
|
|
|
7
18
|
## Install
|
|
8
19
|
|
|
9
20
|
```sh
|
|
10
|
-
|
|
11
|
-
# Optional native controls in an Expo SDK 56 or 57 app:
|
|
12
|
-
npx expo install @expo/ui
|
|
21
|
+
npm install uitheme-rn
|
|
13
22
|
```
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
Want the native pickers? Add Expo UI too:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npx expo install @expo/ui
|
|
28
|
+
```
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
2.11.x. These ranges prevent npm from selecting incompatible animation engines.
|
|
23
|
-
NativeWind support targets exactly `5.0.0-rc.0`. Newer engine versions need a
|
|
24
|
-
separate compatibility check. See
|
|
25
|
-
[the release review](https://github.com/tonyedgal/ui-theme/blob/main/docs/native-stable-release-readiness.md) for the current
|
|
26
|
-
validation scope and remaining gates.
|
|
30
|
+
## Use
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
Wrap your app in the provider, then read the colors anywhere:
|
|
29
33
|
|
|
30
34
|
```tsx
|
|
35
|
+
import { Pressable, Text, View } from 'react-native';
|
|
31
36
|
import { UIThemeProvider, useUITheme } from 'uitheme-rn';
|
|
32
|
-
import { UIThemeSelector, UIColorThemeSelector } from 'uitheme-rn/expo';
|
|
33
|
-
import Storage from 'expo-sqlite/kv-store';
|
|
34
37
|
|
|
35
38
|
export default function App() {
|
|
36
39
|
return (
|
|
37
|
-
<UIThemeProvider
|
|
38
|
-
<
|
|
40
|
+
<UIThemeProvider>
|
|
41
|
+
<Home />
|
|
39
42
|
</UIThemeProvider>
|
|
40
43
|
);
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
function
|
|
46
|
+
function Home() {
|
|
47
|
+
const { colors, toggleTheme } = useUITheme();
|
|
48
|
+
|
|
44
49
|
return (
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
<View style={{ flex: 1, backgroundColor: colors.background }}>
|
|
51
|
+
<Pressable onPress={toggleTheme}>
|
|
52
|
+
<Text style={{ color: colors.text }}>Toggle theme</Text>
|
|
53
|
+
</Pressable>
|
|
54
|
+
</View>
|
|
49
55
|
);
|
|
50
56
|
}
|
|
51
57
|
```
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
and `setItem`; each may be synchronous or asynchronous. AsyncStorage also
|
|
56
|
-
implements this contract. For MMKV, map `getString(key) ?? null` and `set(key, value)`.
|
|
57
|
-
Theme preferences are not secrets and do not need SecureStore.
|
|
59
|
+
That's it. Every palette gives you `background`, `surface`, `text`,
|
|
60
|
+
`secondaryText`, `separator`, `accent` and `onAccent`, in light and dark.
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
`null` to delay the app and retain your launch screen until preferences restore.
|
|
61
|
-
Call `SplashScreen.hideAsync()` in a mounted descendant after `isHydrated` is
|
|
62
|
-
true, as the reference app does. A failed storage read also completes hydration.
|
|
62
|
+
## Remember the choice
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
The package never overrides the app-wide `Appearance` setting.
|
|
67
|
-
|
|
68
|
-
## State and actions
|
|
64
|
+
Pass any storage with `getItem` and `setItem`. AsyncStorage, MMKV and Expo's
|
|
65
|
+
key-value store all work:
|
|
69
66
|
|
|
70
67
|
```tsx
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
colors,
|
|
77
|
-
palettes,
|
|
78
|
-
colorThemes,
|
|
79
|
-
isHydrated,
|
|
80
|
-
setTheme,
|
|
81
|
-
setColorTheme,
|
|
82
|
-
toggleTheme,
|
|
83
|
-
toggleColorTheme,
|
|
84
|
-
flush,
|
|
85
|
-
} = useUITheme();
|
|
68
|
+
import Storage from 'expo-sqlite/kv-store';
|
|
69
|
+
|
|
70
|
+
<UIThemeProvider storage={Storage} fallback={null}>
|
|
71
|
+
<App />
|
|
72
|
+
</UIThemeProvider>;
|
|
86
73
|
```
|
|
87
74
|
|
|
88
|
-
`
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
not await disk or pretend to run a browser-style transition.
|
|
75
|
+
`fallback={null}` holds rendering until the saved theme loads, so your splash
|
|
76
|
+
screen stays up and nothing flickers. Without storage, the choice lives in
|
|
77
|
+
memory.
|
|
78
|
+
|
|
79
|
+
## Native pickers
|
|
94
80
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
User input wins over a late read, independently for each preference. Writes
|
|
98
|
-
are serialized. Call `flush()` before an app-owned shutdown flow when possible;
|
|
99
|
-
JavaScript cannot guarantee a write completes after the OS kills the process.
|
|
81
|
+
Drop in real platform controls. They're SwiftUI on iOS and Jetpack Compose on
|
|
82
|
+
Android:
|
|
100
83
|
|
|
101
|
-
|
|
84
|
+
```tsx
|
|
85
|
+
import {
|
|
86
|
+
UIThemeSelector,
|
|
87
|
+
UIColorThemeSelector,
|
|
88
|
+
UIThemeSwitcher,
|
|
89
|
+
} from 'uitheme-rn/expo';
|
|
90
|
+
|
|
91
|
+
<UIThemeSelector />;
|
|
92
|
+
<UIColorThemeSelector />;
|
|
93
|
+
<UIThemeSwitcher />;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Add your own palettes
|
|
97
|
+
|
|
98
|
+
Start from the defaults and change what you need:
|
|
102
99
|
|
|
103
100
|
```tsx
|
|
104
|
-
import { defaultPalettes
|
|
101
|
+
import { defaultPalettes } from 'uitheme-rn';
|
|
105
102
|
|
|
106
103
|
const palettes = {
|
|
107
104
|
...defaultPalettes,
|
|
@@ -110,46 +107,19 @@ const palettes = {
|
|
|
110
107
|
light: { ...defaultPalettes.default.light, accent: '#216E46' },
|
|
111
108
|
dark: { ...defaultPalettes.default.dark, accent: '#80D6A5' },
|
|
112
109
|
},
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
Pass `palettes` and optionally `defaultColorTheme` to the provider. Without an
|
|
117
|
-
explicit default, the first palette is used. Each palette supplies `background`,
|
|
118
|
-
`surface`, `text`, `secondaryText`, `separator`, `accent`, and `onAccent` in both
|
|
119
|
-
modes. Values are React Native `ColorValue`; opaque platform colors are accepted.
|
|
120
|
-
Explicit mode colors are useful when the app's mode differs from the OS.
|
|
121
|
-
Platform semantic colors follow the native host's appearance, so coordinate
|
|
122
|
-
them with app-wide appearance if using them outside an Expo UI Host.
|
|
123
|
-
|
|
124
|
-
`themeTokens` supplies a 4-point spacing scale, continuous corner radii, and
|
|
125
|
-
system-font text styles. Text still scales with the device. `useThemeColors()`
|
|
126
|
-
returns the active palette. Custom app-specific tokens belong in the app's
|
|
127
|
-
theme module, composed with these tokens.
|
|
128
|
-
|
|
129
|
-
## Native controls
|
|
130
|
-
|
|
131
|
-
Each control owns an Expo UI Host with the resolved color scheme:
|
|
132
|
-
|
|
133
|
-
- `UIThemeSelector`: appearance picker; supports `label`, translated `labels`,
|
|
134
|
-
`disabled`, and `testID`.
|
|
135
|
-
- `UIColorThemeSelector`: palette picker with palette labels; supports `label`,
|
|
136
|
-
`disabled`, and `testID`.
|
|
137
|
-
- `UIThemeSwitcher`: native button for light/dark; supports `label` and `disabled`.
|
|
110
|
+
};
|
|
138
111
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
`useReducedMotion()` observes the accessibility setting and starts conservatively
|
|
144
|
-
enabled until the first native query finishes. Use it for custom app motion.
|
|
112
|
+
<UIThemeProvider palettes={palettes}>
|
|
113
|
+
<App />
|
|
114
|
+
</UIThemeProvider>;
|
|
115
|
+
```
|
|
145
116
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
`useSyncExternalStore`.
|
|
117
|
+
Then switch with `setColorTheme('forest')`. The palette stays the same when the
|
|
118
|
+
mode changes.
|
|
149
119
|
|
|
150
|
-
##
|
|
120
|
+
## Animate the colors
|
|
151
121
|
|
|
152
|
-
Install the
|
|
122
|
+
Install Reanimated, then spread the transition styles onto any animated view:
|
|
153
123
|
|
|
154
124
|
```sh
|
|
155
125
|
npx expo install react-native-reanimated react-native-worklets
|
|
@@ -166,238 +136,105 @@ function Card() {
|
|
|
166
136
|
|
|
167
137
|
return (
|
|
168
138
|
<Animated.View
|
|
169
|
-
style={{
|
|
170
|
-
...transition.view,
|
|
171
|
-
backgroundColor: colors.surface,
|
|
172
|
-
borderColor: colors.separator,
|
|
173
|
-
borderWidth: 1,
|
|
174
|
-
padding: 16,
|
|
175
|
-
}}
|
|
139
|
+
style={{ ...transition.view, backgroundColor: colors.surface }}
|
|
176
140
|
>
|
|
177
141
|
<Animated.Text style={{ ...transition.text, color: colors.text }}>
|
|
178
|
-
|
|
142
|
+
Hello
|
|
179
143
|
</Animated.Text>
|
|
180
144
|
</Animated.View>
|
|
181
145
|
);
|
|
182
146
|
}
|
|
183
147
|
```
|
|
184
148
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
180 ms and an ease-out curve. Apply the styles to Reanimated components; ordinary
|
|
188
|
-
React Native components cannot run these transitions. Existing screens opt in
|
|
189
|
-
without changing their tree, scroll position, or focus.
|
|
190
|
-
|
|
191
|
-
The hook arms after the hydrated colors commit to a frame. Mounting and preference
|
|
192
|
-
restoration stay immediate. Live Reduce Motion changes remove the transition
|
|
193
|
-
configuration and apply the final colors. Rapid changes are handled by
|
|
194
|
-
Reanimated's transition engine; there is no completion callback that can restore
|
|
195
|
-
an old preference. Setters and persistence remain synchronous and independent
|
|
196
|
-
of animation completion. Unmounting cancels the pending frame used to arm motion.
|
|
197
|
-
|
|
198
|
-
Interpolating light and dark text against an interpolating background can briefly
|
|
199
|
-
reduce contrast. The recorded example shows this in intermediate frames. For
|
|
200
|
-
screens that need continuous reading, apply `transition.view` to surfaces and
|
|
201
|
-
set text colors immediately. Text transitions are opt-in through `transition.text`.
|
|
202
|
-
|
|
203
|
-
Use explicit string colors for predictable interpolation. Native semantic colors
|
|
204
|
-
remain useful for platform-owned controls; do not assume their internal appearance
|
|
205
|
-
animates through these styles. Expo UI Hosts, native navigation headers, and status
|
|
206
|
-
bars update to the resolved theme through their own APIs. The reference app keeps
|
|
207
|
-
those native elements outside the Reanimated color transition.
|
|
208
|
-
|
|
209
|
-
The animation entry requires the New Architecture, Reanimated 4.5.1 and compatible
|
|
210
|
-
Worklets. The reference app verifies the SDK 57 pair, Reanimated 4.5.1 and Worklets
|
|
211
|
-
0.10.1. Bare React Native apps must configure the Worklets Babel plugin as described
|
|
212
|
-
in Reanimated's installation guide. The root, core, and Expo entries do not import
|
|
213
|
-
animation peers.
|
|
214
|
-
|
|
215
|
-
See [the transition acceptance cases](../../apps/examples/example-expo/TRANSITION-CHECKS.md)
|
|
216
|
-
and [the recorded checks](../../apps/examples/example-expo/VERIFICATION.md).
|
|
217
|
-
|
|
218
|
-
## Workspace verification
|
|
149
|
+
Backgrounds, borders and text fade to the new theme. Your screens keep their
|
|
150
|
+
scroll position and focus.
|
|
219
151
|
|
|
220
|
-
|
|
221
|
-
pnpm --filter uitheme-rn test
|
|
222
|
-
pnpm --filter uitheme-rn typecheck
|
|
223
|
-
pnpm --filter uitheme-rn build
|
|
224
|
-
pnpm --filter uitheme-rn test:package
|
|
225
|
-
pnpm --filter example-expo typecheck
|
|
226
|
-
pnpm --filter example-expo start
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
Use a release build on the slowest supported device to judge native feel. See
|
|
230
|
-
the example README for the native acceptance checklist and repeatable flows.
|
|
152
|
+
## Full-screen transitions
|
|
231
153
|
|
|
232
|
-
|
|
154
|
+
Want the whole screen to change at once? Add Skia, and wrap your app in the
|
|
155
|
+
transition provider:
|
|
233
156
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
Reanimated, and Worklets through Expo. Pin Skia to `2.11.1` or a supported
|
|
238
|
-
2.11 patch release; SDK 57's bundled Skia 2.6.2 has a broken Android overflow
|
|
239
|
-
capture path. This override requires a custom native build and does not claim
|
|
240
|
-
Expo Go compatibility. See the
|
|
241
|
-
[upstream fix](https://github.com/wcandillon/react-native-skia/pull/4004). The tested pair uses Skia 2.11.1,
|
|
242
|
-
Reanimated 4.5.1, and Worklets 0.10.1 on Expo SDK 57.
|
|
157
|
+
```sh
|
|
158
|
+
npx expo install @shopify/react-native-skia react-native-reanimated react-native-worklets
|
|
159
|
+
```
|
|
243
160
|
|
|
244
161
|
```tsx
|
|
245
|
-
import { Button
|
|
246
|
-
import { UIThemeProvider
|
|
162
|
+
import { Button } from 'react-native';
|
|
163
|
+
import { UIThemeProvider } from 'uitheme-rn';
|
|
247
164
|
import {
|
|
248
165
|
UIThemeTransitionProvider,
|
|
249
166
|
useAnimatedUITheme,
|
|
250
167
|
} from 'uitheme-rn/transitions';
|
|
251
168
|
|
|
252
|
-
const palettes = {
|
|
253
|
-
...defaultPalettes,
|
|
254
|
-
forest: {
|
|
255
|
-
label: 'Forest',
|
|
256
|
-
light: { ...defaultPalettes.default.light, accent: '#216E46' },
|
|
257
|
-
dark: { ...defaultPalettes.default.dark, accent: '#80D6A5' },
|
|
258
|
-
},
|
|
259
|
-
};
|
|
260
|
-
|
|
261
169
|
export default function App() {
|
|
262
170
|
return (
|
|
263
|
-
<UIThemeProvider
|
|
171
|
+
<UIThemeProvider>
|
|
264
172
|
<UIThemeTransitionProvider defaults={{ transition: 'circularReveal' }}>
|
|
265
|
-
<
|
|
173
|
+
<Home />
|
|
266
174
|
</UIThemeTransitionProvider>
|
|
267
175
|
</UIThemeProvider>
|
|
268
176
|
);
|
|
269
177
|
}
|
|
270
178
|
|
|
271
|
-
function
|
|
179
|
+
function Home() {
|
|
272
180
|
const { setTheme, setColorTheme, isTransitioning } = useAnimatedUITheme();
|
|
273
181
|
|
|
274
182
|
return (
|
|
275
|
-
|
|
183
|
+
<>
|
|
276
184
|
<Button
|
|
277
185
|
title="Dark mode"
|
|
278
186
|
disabled={isTransitioning}
|
|
279
|
-
onPress={() =>
|
|
280
|
-
void setTheme('dark');
|
|
281
|
-
}}
|
|
187
|
+
onPress={() => setTheme('dark')}
|
|
282
188
|
/>
|
|
283
189
|
<Button
|
|
284
|
-
title="Forest
|
|
190
|
+
title="Forest"
|
|
285
191
|
disabled={isTransitioning}
|
|
286
|
-
onPress={() => {
|
|
287
|
-
void setColorTheme('forest', { transition: 'wipe' });
|
|
288
|
-
}}
|
|
192
|
+
onPress={() => setColorTheme('forest', { transition: 'heart' })}
|
|
289
193
|
/>
|
|
290
|
-
|
|
194
|
+
</>
|
|
291
195
|
);
|
|
292
196
|
}
|
|
293
197
|
```
|
|
294
198
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
Available effects are `fade`, `circularReveal`, `wipe`, `slide`, `split`, `heart`,
|
|
302
|
-
`star`, `pixelize`, and `dissolve`. Options include `duration`, `origin` (a view ref
|
|
303
|
-
or a provider-relative point), `inverted` for shape/split reveals, `direction`,
|
|
304
|
-
`split`, `blockSize`, `noiseSize`, and `animated`. The default duration is 350 ms.
|
|
305
|
-
Busy requests are rejected before preferences change. Immediate root commands
|
|
306
|
-
remain available through `useUITheme`; use the animated hook for screen effects.
|
|
307
|
-
Expo selectors accept `onValueChange`, and the switcher accepts `onPress`, so the
|
|
308
|
-
native controls can call animated commands without taking ownership of preferences.
|
|
309
|
-
|
|
310
|
-
Reduce Motion skips capture. Live Reduce Motion, backgrounding, rotation, and
|
|
311
|
-
unmount cancel the overlay. A capture failure falls back to an immediate change;
|
|
312
|
-
`onError` reports it. Restoration and system appearance updates use the existing
|
|
313
|
-
provider and do not trigger screen captures. Snapshot layers are hidden from the
|
|
314
|
-
accessibility tree. Touch input is blocked while capture/playback is active.
|
|
315
|
-
|
|
316
|
-
Set the transition provider's `enabled` prop to `false` while native navigation
|
|
317
|
-
or another movement changes the captured tree. This cancels an active overlay and
|
|
318
|
-
applies new choices immediately. Re-enable when movement ends. The Expo example
|
|
319
|
-
connects this prop to the stack's `transitionStart` and `transitionEnd` events.
|
|
320
|
-
Commands also skip capture while the app is not active.
|
|
321
|
-
|
|
322
|
-
The capture boundary is the provider's view tree, including navigation inside it.
|
|
323
|
-
System status bars, keyboards, alerts, and separate native windows remain under OS
|
|
324
|
-
control. Two screen images require memory proportional to their pixel dimensions.
|
|
325
|
-
Run [SCREEN-TRANSITION-CHECKS.md](./SCREEN-TRANSITION-CHECKS.md) before claiming
|
|
326
|
-
release performance or accessibility verification.
|
|
327
|
-
|
|
328
|
-
The browser fallback changes preferences immediately; it does not mount Skia or
|
|
329
|
-
require CanvasKit initialization. Native screen effects target iOS and Android.
|
|
330
|
-
|
|
331
|
-
## Styling systems and CSS themes
|
|
332
|
-
|
|
333
|
-
Plain `StyleSheet`, inline native styles, and TypeScript palettes remain the
|
|
334
|
-
base API. Neither Tailwind nor a styling engine is required by the root entry.
|
|
335
|
-
Optional `uitheme-rn/nativewind` and `uitheme-rn/uniwind` adapters connect utility
|
|
336
|
-
classes to the same appearance and palette store. Install one engine in an app.
|
|
337
|
-
|
|
338
|
-
The NativeWind example targets `nativewind@5.0.0-rc.0` and
|
|
339
|
-
`react-native-css@3.1.0-rc.0` with Tailwind 4.3.1. NativeWind v5 is a release
|
|
340
|
-
candidate; v4 is not supported by this adapter. The Uniwind example targets
|
|
341
|
-
Uniwind 1.12.2 with Tailwind 4.3.1. Follow each example's Metro configuration;
|
|
342
|
-
NativeWind also needs the Tailwind v4 PostCSS plugin and Lightning CSS 1.30.1.
|
|
343
|
-
|
|
344
|
-
For existing TypeScript palettes, place `<NativeWindTheme>` or `<UniwindTheme>`
|
|
345
|
-
inside `<UIThemeProvider>`. The adapter provides scoped semantic variables.
|
|
346
|
-
`bg-primary`, `text-primary-foreground`, `bg-card`, `bg-background`,
|
|
347
|
-
`text-foreground`, `text-muted-foreground`, and `border-border` then use the
|
|
348
|
-
same colors as `useThemeColors()`. Native dynamic color objects remain available
|
|
349
|
-
with native styles; CSS conversion requires string colors.
|
|
350
|
-
|
|
351
|
-
For CSS-authored palettes, use label-only metadata and map each palette's modes:
|
|
199
|
+
Pick any of the nine effects per call, and tune `duration`, `origin` and
|
|
200
|
+
`direction`. With Reduce Motion on, the theme changes at once.
|
|
201
|
+
|
|
202
|
+
## Using NativeWind or Uniwind?
|
|
203
|
+
|
|
204
|
+
Put the adapter inside the provider, and your utility classes follow the theme:
|
|
352
205
|
|
|
353
206
|
```tsx
|
|
354
|
-
import { UIThemeProvider } from 'uitheme-rn';
|
|
355
207
|
import { NativeWindTheme } from 'uitheme-rn/nativewind';
|
|
356
208
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
<UIThemeProvider palettes={palettes} defaultColorTheme="supabase">
|
|
363
|
-
<NativeWindTheme themes={themes}>{/* Your app */}</NativeWindTheme>
|
|
209
|
+
<UIThemeProvider>
|
|
210
|
+
<NativeWindTheme>
|
|
211
|
+
<App />
|
|
212
|
+
</NativeWindTheme>
|
|
364
213
|
</UIThemeProvider>;
|
|
365
214
|
```
|
|
366
215
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
Screen effects take two snapshots of the provider's content. On the tested
|
|
394
|
-
Android flagship, each awaited view capture takes 113–133 ms. Capture can pause
|
|
395
|
-
the UI before the shader animation begins. Reanimated color transitions avoid
|
|
396
|
-
this snapshot path. Do not assume full-screen effects meet the same frame budget.
|
|
397
|
-
|
|
398
|
-
Disable snapshot transitions with `enabled={false}` around trees containing
|
|
399
|
-
Android `SurfaceView` content, such as some video and camera views. The tested
|
|
400
|
-
Skia capture path waits on the main thread for a callback scheduled on that
|
|
401
|
-
same thread, which can time out and produce incomplete capture. Such trees are
|
|
402
|
-
not verified for these effects. Keep system windows and native chrome outside
|
|
403
|
-
the capture boundary. See the stable release review for current device limits.
|
|
216
|
+
`bg-background`, `text-foreground`, `bg-primary` and friends now use the same
|
|
217
|
+
colors as `useUITheme()`. For Uniwind, use `UniwindTheme` from
|
|
218
|
+
`uitheme-rn/uniwind`.
|
|
219
|
+
|
|
220
|
+
The guides cover the setup for
|
|
221
|
+
[NativeWind](https://www.ui-theme.dev/docs/guides/nativewind) and
|
|
222
|
+
[Uniwind](https://www.ui-theme.dev/docs/guides/uniwind), including palettes
|
|
223
|
+
written in CSS.
|
|
224
|
+
|
|
225
|
+
## Good to know
|
|
226
|
+
|
|
227
|
+
- Full-screen transitions need a development build. They don't run in Expo Go.
|
|
228
|
+
- Turn them off with `enabled={false}` while a navigation animation runs, and
|
|
229
|
+
around Android `SurfaceView` content such as video or camera previews.
|
|
230
|
+
- The status bar, keyboard and alerts belong to the OS, so they aren't part of
|
|
231
|
+
the screen transition.
|
|
232
|
+
- The provider never changes the app-wide `Appearance` setting.
|
|
233
|
+
|
|
234
|
+
## Documentation
|
|
235
|
+
|
|
236
|
+
Start with the [Expo guide](https://www.ui-theme.dev/docs/guides/expo).
|
|
237
|
+
|
|
238
|
+
## License
|
|
239
|
+
|
|
240
|
+
MIT
|
package/dist/core.d.cts
CHANGED
|
@@ -16,4 +16,5 @@ declare function createThemeStore(options: ThemeStoreOptions): {
|
|
|
16
16
|
};
|
|
17
17
|
type ThemeStore = ReturnType<typeof createThemeStore>;
|
|
18
18
|
|
|
19
|
-
export { ResolvedTheme, Theme, ThemeSnapshot,
|
|
19
|
+
export { ResolvedTheme, Theme, ThemeSnapshot, ThemeStoreOptions, createThemeStore, isTheme };
|
|
20
|
+
export type { ThemeStore };
|
package/dist/core.d.ts
CHANGED
|
@@ -16,4 +16,5 @@ declare function createThemeStore(options: ThemeStoreOptions): {
|
|
|
16
16
|
};
|
|
17
17
|
type ThemeStore = ReturnType<typeof createThemeStore>;
|
|
18
18
|
|
|
19
|
-
export { ResolvedTheme, Theme, ThemeSnapshot,
|
|
19
|
+
export { ResolvedTheme, Theme, ThemeSnapshot, ThemeStoreOptions, createThemeStore, isTheme };
|
|
20
|
+
export type { ThemeStore };
|
package/dist/expo.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Theme } from './core.cjs';
|
|
3
3
|
|
|
4
4
|
interface UIThemeSelectorProps {
|
|
5
5
|
label?: string;
|
|
@@ -19,4 +19,5 @@ declare function UIThemeSwitcher({ disabled, label, onPress, }: {
|
|
|
19
19
|
onPress?: () => void;
|
|
20
20
|
}): react.JSX.Element;
|
|
21
21
|
|
|
22
|
-
export { UIColorThemeSelector, UIThemeSelector,
|
|
22
|
+
export { UIColorThemeSelector, UIThemeSelector, UIThemeSwitcher };
|
|
23
|
+
export type { UIThemeSelectorProps };
|
package/dist/expo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Theme } from './core.js';
|
|
3
3
|
|
|
4
4
|
interface UIThemeSelectorProps {
|
|
5
5
|
label?: string;
|
|
@@ -19,4 +19,5 @@ declare function UIThemeSwitcher({ disabled, label, onPress, }: {
|
|
|
19
19
|
onPress?: () => void;
|
|
20
20
|
}): react.JSX.Element;
|
|
21
21
|
|
|
22
|
-
export { UIColorThemeSelector, UIThemeSelector,
|
|
22
|
+
export { UIColorThemeSelector, UIThemeSelector, UIThemeSwitcher };
|
|
23
|
+
export type { UIThemeSelectorProps };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { b as Theme, R as ResolvedTheme } from './types-BkuOLauF.cjs';
|
|
4
|
+
import { ThemeStoreOptions } from './core.cjs';
|
|
4
5
|
export { a as ThemeSnapshot, c as ThemeStorage } from './types-BkuOLauF.cjs';
|
|
5
6
|
import { ColorValue } from 'react-native';
|
|
6
7
|
|
|
@@ -146,4 +147,5 @@ declare function toThemeVariables(colors: ThemeColors): {
|
|
|
146
147
|
'--color-primary-foreground': string;
|
|
147
148
|
};
|
|
148
149
|
|
|
149
|
-
export {
|
|
150
|
+
export { ResolvedTheme, Theme, UIThemeColorsProvider, UIThemeProvider, defaultPalettes, themeTokens, themeVariableNames, toThemeVariables, useReducedMotion, useThemeColors, useUITheme };
|
|
151
|
+
export type { CSSThemePalette, ThemeColors, ThemePalette, ThemePaletteDefinition, UIThemeProviderProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { b as Theme, R as ResolvedTheme } from './types-BkuOLauF.js';
|
|
4
|
+
import { ThemeStoreOptions } from './core.js';
|
|
4
5
|
export { a as ThemeSnapshot, c as ThemeStorage } from './types-BkuOLauF.js';
|
|
5
6
|
import { ColorValue } from 'react-native';
|
|
6
7
|
|
|
@@ -146,4 +147,5 @@ declare function toThemeVariables(colors: ThemeColors): {
|
|
|
146
147
|
'--color-primary-foreground': string;
|
|
147
148
|
};
|
|
148
149
|
|
|
149
|
-
export {
|
|
150
|
+
export { ResolvedTheme, Theme, UIThemeColorsProvider, UIThemeProvider, defaultPalettes, themeTokens, themeVariableNames, toThemeVariables, useReducedMotion, useThemeColors, useUITheme };
|
|
151
|
+
export type { CSSThemePalette, ThemeColors, ThemePalette, ThemePaletteDefinition, UIThemeProviderProps };
|
package/dist/nativewind.js
CHANGED
package/dist/reanimated.d.cts
CHANGED
|
@@ -8,4 +8,5 @@ interface ThemeTransitionStyles {
|
|
|
8
8
|
/** Apply to Reanimated components alongside the current theme colors. */
|
|
9
9
|
declare function useThemeTransition(): ThemeTransitionStyles;
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export { useThemeTransition };
|
|
12
|
+
export type { ThemeTransitionStyles };
|
package/dist/reanimated.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ interface ThemeTransitionStyles {
|
|
|
8
8
|
/** Apply to Reanimated components alongside the current theme colors. */
|
|
9
9
|
declare function useThemeTransition(): ThemeTransitionStyles;
|
|
10
10
|
|
|
11
|
-
export {
|
|
11
|
+
export { useThemeTransition };
|
|
12
|
+
export type { ThemeTransitionStyles };
|
package/dist/transitions.cjs
CHANGED
|
@@ -118,7 +118,10 @@ half4 main(float2 xy) {
|
|
|
118
118
|
`);
|
|
119
119
|
var frame = () => new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
120
120
|
async function capture(ref) {
|
|
121
|
-
const
|
|
121
|
+
const target = (0, import_react_native.findNodeHandle)(ref.current);
|
|
122
|
+
if (target === null || target === void 0)
|
|
123
|
+
throw new Error("Screen capture target is not mounted.");
|
|
124
|
+
const texture = await (0, import_react_native_skia.makeImageFromView)({ current: target });
|
|
122
125
|
if (!texture) throw new Error("Screen capture returned no image.");
|
|
123
126
|
try {
|
|
124
127
|
const image = texture.makeNonTextureImage();
|
package/dist/transitions.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as uitheme_rn from 'uitheme-rn';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { RefObject, ReactNode } from 'react';
|
|
3
|
+
import { RefObject, ComponentRef, ReactNode } from 'react';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
|
-
import {
|
|
5
|
+
import { Theme } from './core.cjs';
|
|
6
6
|
|
|
7
7
|
declare const screenTransitionTypes: readonly ["fade", "circularReveal", "wipe", "slide", "split", "heart", "star", "pixelize", "dissolve"];
|
|
8
8
|
type ScreenTransitionType = (typeof screenTransitionTypes)[number];
|
|
@@ -12,7 +12,7 @@ interface ScreenTransitionOptions {
|
|
|
12
12
|
origin?: {
|
|
13
13
|
x: number;
|
|
14
14
|
y: number;
|
|
15
|
-
} | RefObject<View | null>;
|
|
15
|
+
} | RefObject<ComponentRef<typeof View> | null>;
|
|
16
16
|
inverted?: boolean;
|
|
17
17
|
direction?: 'left' | 'right' | 'up' | 'down';
|
|
18
18
|
split?: 'left-right' | 'top-bottom';
|
|
@@ -46,4 +46,5 @@ declare function useAnimatedUITheme(): {
|
|
|
46
46
|
isHydrated: boolean;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
export {
|
|
49
|
+
export { UIThemeTransitionProvider, screenTransitionTypes, useAnimatedUITheme };
|
|
50
|
+
export type { ScreenTransitionOptions, ScreenTransitionType };
|
package/dist/transitions.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as uitheme_rn from 'uitheme-rn';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { RefObject, ReactNode } from 'react';
|
|
3
|
+
import { RefObject, ComponentRef, ReactNode } from 'react';
|
|
4
4
|
import { View } from 'react-native';
|
|
5
|
-
import {
|
|
5
|
+
import { Theme } from './core.js';
|
|
6
6
|
|
|
7
7
|
declare const screenTransitionTypes: readonly ["fade", "circularReveal", "wipe", "slide", "split", "heart", "star", "pixelize", "dissolve"];
|
|
8
8
|
type ScreenTransitionType = (typeof screenTransitionTypes)[number];
|
|
@@ -12,7 +12,7 @@ interface ScreenTransitionOptions {
|
|
|
12
12
|
origin?: {
|
|
13
13
|
x: number;
|
|
14
14
|
y: number;
|
|
15
|
-
} | RefObject<View | null>;
|
|
15
|
+
} | RefObject<ComponentRef<typeof View> | null>;
|
|
16
16
|
inverted?: boolean;
|
|
17
17
|
direction?: 'left' | 'right' | 'up' | 'down';
|
|
18
18
|
split?: 'left-right' | 'top-bottom';
|
|
@@ -46,4 +46,5 @@ declare function useAnimatedUITheme(): {
|
|
|
46
46
|
isHydrated: boolean;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
export {
|
|
49
|
+
export { UIThemeTransitionProvider, screenTransitionTypes, useAnimatedUITheme };
|
|
50
|
+
export type { ScreenTransitionOptions, ScreenTransitionType };
|
package/dist/transitions.js
CHANGED
|
@@ -7,7 +7,13 @@ import {
|
|
|
7
7
|
useRef,
|
|
8
8
|
useState
|
|
9
9
|
} from "react";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
AppState,
|
|
12
|
+
Platform,
|
|
13
|
+
StyleSheet,
|
|
14
|
+
View,
|
|
15
|
+
findNodeHandle
|
|
16
|
+
} from "react-native";
|
|
11
17
|
import {
|
|
12
18
|
Canvas,
|
|
13
19
|
Fill,
|
|
@@ -112,7 +118,10 @@ half4 main(float2 xy) {
|
|
|
112
118
|
`);
|
|
113
119
|
var frame = () => new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
114
120
|
async function capture(ref) {
|
|
115
|
-
const
|
|
121
|
+
const target = findNodeHandle(ref.current);
|
|
122
|
+
if (target === null || target === void 0)
|
|
123
|
+
throw new Error("Screen capture target is not mounted.");
|
|
124
|
+
const texture = await makeImageFromView({ current: target });
|
|
116
125
|
if (!texture) throw new Error("Screen capture returned no image.");
|
|
117
126
|
try {
|
|
118
127
|
const image = texture.makeNonTextureImage();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uitheme-rn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Native appearance and color palettes for React Native and Expo",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -99,22 +99,13 @@
|
|
|
99
99
|
"provenance": true,
|
|
100
100
|
"tag": "alpha"
|
|
101
101
|
},
|
|
102
|
-
"scripts": {
|
|
103
|
-
"build": "tsup",
|
|
104
|
-
"dev": "tsup --watch",
|
|
105
|
-
"typecheck": "tsc --noEmit",
|
|
106
|
-
"lint": "eslint .",
|
|
107
|
-
"test": "vitest run",
|
|
108
|
-
"test:package": "node scripts/smoke-package.mjs",
|
|
109
|
-
"prepublishOnly": "pnpm build && pnpm test:package"
|
|
110
|
-
},
|
|
111
102
|
"peerDependencies": {
|
|
112
|
-
"@expo/ui": ">=56.0.0 <
|
|
113
|
-
"@shopify/react-native-skia": ">=2.11.1 <2.
|
|
103
|
+
"@expo/ui": ">=56.0.0 <59",
|
|
104
|
+
"@shopify/react-native-skia": ">=2.11.1 <2.15",
|
|
114
105
|
"react": ">=19.2.0 <20",
|
|
115
|
-
"react-native": ">=0.83.0 <0.
|
|
116
|
-
"react-native-reanimated": ">=4.5.1 <4.
|
|
117
|
-
"react-native-worklets": ">=0.10.1 <0.
|
|
106
|
+
"react-native": ">=0.83.0 <0.89",
|
|
107
|
+
"react-native-reanimated": ">=4.5.1 <4.8",
|
|
108
|
+
"react-native-worklets": ">=0.10.1 <0.14",
|
|
118
109
|
"nativewind": "5.0.0-rc.0",
|
|
119
110
|
"uniwind": ">=1.12.2 <2"
|
|
120
111
|
},
|
|
@@ -139,23 +130,31 @@
|
|
|
139
130
|
}
|
|
140
131
|
},
|
|
141
132
|
"devDependencies": {
|
|
142
|
-
"@expo/ui": "~
|
|
143
|
-
"@shopify/react-native-skia": "2.
|
|
144
|
-
"@types/react": "~19.
|
|
145
|
-
"@types/react-dom": "~19.
|
|
133
|
+
"@expo/ui": "~58.0.23",
|
|
134
|
+
"@shopify/react-native-skia": "2.14.0",
|
|
135
|
+
"@types/react": "~19.3.0",
|
|
136
|
+
"@types/react-dom": "~19.3.0",
|
|
146
137
|
"nativewind": "5.0.0-rc.0",
|
|
147
|
-
"react": "19.
|
|
148
|
-
"react-dom": "19.
|
|
149
|
-
"react-native": "0.
|
|
150
|
-
"react-native-reanimated": "4.
|
|
151
|
-
"react-native-worklets": "0.
|
|
138
|
+
"react": "19.3.0",
|
|
139
|
+
"react-dom": "19.3.0",
|
|
140
|
+
"react-native": "0.88.0",
|
|
141
|
+
"react-native-reanimated": "4.7.1",
|
|
142
|
+
"react-native-worklets": "0.13.0",
|
|
152
143
|
"typescript": "~6.0.3",
|
|
153
|
-
"uniwind": "1.
|
|
144
|
+
"uniwind": "1.13.0",
|
|
154
145
|
"react-native-css": "3.1.0-rc.0",
|
|
155
|
-
"tailwindcss": "4.3.
|
|
146
|
+
"tailwindcss": "4.3.3",
|
|
156
147
|
"lightningcss": "1.30.1"
|
|
157
148
|
},
|
|
158
149
|
"dependencies": {
|
|
159
|
-
"zod": "^4.6.
|
|
150
|
+
"zod": "^4.6.7"
|
|
151
|
+
},
|
|
152
|
+
"scripts": {
|
|
153
|
+
"build": "tsup",
|
|
154
|
+
"dev": "tsup --watch",
|
|
155
|
+
"typecheck": "tsc --noEmit",
|
|
156
|
+
"lint": "eslint .",
|
|
157
|
+
"test": "vitest run",
|
|
158
|
+
"test:package": "node scripts/smoke-package.mjs"
|
|
160
159
|
}
|
|
161
|
-
}
|
|
160
|
+
}
|