uitheme-rn 0.1.0-alpha → 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 +139 -253
- 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 +28 -29
package/README.md
CHANGED
|
@@ -1,100 +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
|
-
|
|
21
|
+
npm install uitheme-rn
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Want the native pickers? Add Expo UI too:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
12
27
|
npx expo install @expo/ui
|
|
13
28
|
```
|
|
14
29
|
|
|
15
|
-
|
|
16
|
-
in progress.
|
|
17
|
-
The reference app uses SDK 57, React 19.2.3, and React Native 0.86.3. The declared
|
|
18
|
-
React Native range begins at 0.83; older versions in that range still need device
|
|
19
|
-
verification. Expo is required only for the `/expo` entry point.
|
|
30
|
+
## Use
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
Wrap your app in the provider, then read the colors anywhere:
|
|
22
33
|
|
|
23
34
|
```tsx
|
|
35
|
+
import { Pressable, Text, View } from 'react-native';
|
|
24
36
|
import { UIThemeProvider, useUITheme } from 'uitheme-rn';
|
|
25
|
-
import { UIThemeSelector, UIColorThemeSelector } from 'uitheme-rn/expo';
|
|
26
|
-
import Storage from 'expo-sqlite/kv-store';
|
|
27
37
|
|
|
28
38
|
export default function App() {
|
|
29
39
|
return (
|
|
30
|
-
<UIThemeProvider
|
|
31
|
-
<
|
|
40
|
+
<UIThemeProvider>
|
|
41
|
+
<Home />
|
|
32
42
|
</UIThemeProvider>
|
|
33
43
|
);
|
|
34
44
|
}
|
|
35
45
|
|
|
36
|
-
function
|
|
46
|
+
function Home() {
|
|
47
|
+
const { colors, toggleTheme } = useUITheme();
|
|
48
|
+
|
|
37
49
|
return (
|
|
38
|
-
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
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>
|
|
42
55
|
);
|
|
43
56
|
}
|
|
44
57
|
```
|
|
45
58
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
and `setItem`; each may be synchronous or asynchronous. AsyncStorage also
|
|
49
|
-
implements this contract. For MMKV, map `getString(key) ?? null` and `set(key, value)`.
|
|
50
|
-
Theme preferences are not secrets and do not need SecureStore.
|
|
51
|
-
|
|
52
|
-
`fallback` is optional. Omit it to render defaults during restoration; pass
|
|
53
|
-
`null` to delay the app and retain your launch screen until preferences restore.
|
|
54
|
-
Call `SplashScreen.hideAsync()` in a mounted descendant after `isHydrated` is
|
|
55
|
-
true, as the reference app does. A failed storage read also completes hydration.
|
|
59
|
+
That's it. Every palette gives you `background`, `surface`, `text`,
|
|
60
|
+
`secondaryText`, `separator`, `accent` and `onAccent`, in light and dark.
|
|
56
61
|
|
|
57
|
-
|
|
58
|
-
palettes, storage, defaults, or the error handler. Each provider owns its state.
|
|
59
|
-
The package never overrides the app-wide `Appearance` setting.
|
|
62
|
+
## Remember the choice
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
Pass any storage with `getItem` and `setItem`. AsyncStorage, MMKV and Expo's
|
|
65
|
+
key-value store all work:
|
|
62
66
|
|
|
63
67
|
```tsx
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
colors,
|
|
70
|
-
palettes,
|
|
71
|
-
colorThemes,
|
|
72
|
-
isHydrated,
|
|
73
|
-
setTheme,
|
|
74
|
-
setColorTheme,
|
|
75
|
-
toggleTheme,
|
|
76
|
-
toggleColorTheme,
|
|
77
|
-
flush,
|
|
78
|
-
} = useUITheme();
|
|
68
|
+
import Storage from 'expo-sqlite/kv-store';
|
|
69
|
+
|
|
70
|
+
<UIThemeProvider storage={Storage} fallback={null}>
|
|
71
|
+
<App />
|
|
72
|
+
</UIThemeProvider>;
|
|
79
73
|
```
|
|
80
74
|
|
|
81
|
-
`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
unknown choices. `flush()` waits for restoration and queued writes; storage
|
|
85
|
-
failures reach `onStorageError` while in-memory changes stay usable. Setters do
|
|
86
|
-
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.
|
|
87
78
|
|
|
88
|
-
|
|
89
|
-
with `storageKey`. Unknown versions and invalid fields fall back to defaults.
|
|
90
|
-
User input wins over a late read, independently for each preference. Writes
|
|
91
|
-
are serialized. Call `flush()` before an app-owned shutdown flow when possible;
|
|
92
|
-
JavaScript cannot guarantee a write completes after the OS kills the process.
|
|
79
|
+
## Native pickers
|
|
93
80
|
|
|
94
|
-
|
|
81
|
+
Drop in real platform controls. They're SwiftUI on iOS and Jetpack Compose on
|
|
82
|
+
Android:
|
|
95
83
|
|
|
96
84
|
```tsx
|
|
97
|
-
import {
|
|
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:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { defaultPalettes } from 'uitheme-rn';
|
|
98
102
|
|
|
99
103
|
const palettes = {
|
|
100
104
|
...defaultPalettes,
|
|
@@ -103,45 +107,19 @@ const palettes = {
|
|
|
103
107
|
light: { ...defaultPalettes.default.light, accent: '#216E46' },
|
|
104
108
|
dark: { ...defaultPalettes.default.dark, accent: '#80D6A5' },
|
|
105
109
|
},
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Pass `palettes` and optionally `defaultColorTheme` to the provider. Without an
|
|
110
|
-
explicit default, the first palette is used. Each palette supplies `background`,
|
|
111
|
-
`surface`, `text`, `secondaryText`, `separator`, `accent`, and `onAccent` in both
|
|
112
|
-
modes. Values are React Native `ColorValue`; opaque platform colors are accepted.
|
|
113
|
-
Explicit mode colors are useful when the app's mode differs from the OS.
|
|
114
|
-
Platform semantic colors follow the native host's appearance, so coordinate
|
|
115
|
-
them with app-wide appearance if using them outside an Expo UI Host.
|
|
116
|
-
|
|
117
|
-
`themeTokens` supplies a 4-point spacing scale, continuous corner radii, and
|
|
118
|
-
system-font text styles. Text still scales with the device. `useThemeColors()`
|
|
119
|
-
returns the active palette. Custom app-specific tokens belong in the app's
|
|
120
|
-
theme module, composed with these tokens.
|
|
121
|
-
|
|
122
|
-
## Native controls
|
|
123
|
-
|
|
124
|
-
Each control owns an Expo UI Host with the resolved color scheme:
|
|
125
|
-
|
|
126
|
-
- `UIThemeSelector`: appearance picker; supports `label`, translated `labels`,
|
|
127
|
-
`disabled`, and `testID`.
|
|
128
|
-
- `UIColorThemeSelector`: palette picker with palette labels; supports `label`,
|
|
129
|
-
`disabled`, and `testID`.
|
|
130
|
-
- `UIThemeSwitcher`: native button for light/dark; supports `label` and `disabled`.
|
|
110
|
+
};
|
|
131
111
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
enabled until the first native query finishes. Use it for custom app motion.
|
|
112
|
+
<UIThemeProvider palettes={palettes}>
|
|
113
|
+
<App />
|
|
114
|
+
</UIThemeProvider>;
|
|
115
|
+
```
|
|
137
116
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
`useSyncExternalStore`.
|
|
117
|
+
Then switch with `setColorTheme('forest')`. The palette stays the same when the
|
|
118
|
+
mode changes.
|
|
141
119
|
|
|
142
|
-
##
|
|
120
|
+
## Animate the colors
|
|
143
121
|
|
|
144
|
-
Install the
|
|
122
|
+
Install Reanimated, then spread the transition styles onto any animated view:
|
|
145
123
|
|
|
146
124
|
```sh
|
|
147
125
|
npx expo install react-native-reanimated react-native-worklets
|
|
@@ -158,197 +136,105 @@ function Card() {
|
|
|
158
136
|
|
|
159
137
|
return (
|
|
160
138
|
<Animated.View
|
|
161
|
-
style={{
|
|
162
|
-
...transition.view,
|
|
163
|
-
backgroundColor: colors.surface,
|
|
164
|
-
borderColor: colors.separator,
|
|
165
|
-
borderWidth: 1,
|
|
166
|
-
padding: 16,
|
|
167
|
-
}}
|
|
139
|
+
style={{ ...transition.view, backgroundColor: colors.surface }}
|
|
168
140
|
>
|
|
169
141
|
<Animated.Text style={{ ...transition.text, color: colors.text }}>
|
|
170
|
-
|
|
142
|
+
Hello
|
|
171
143
|
</Animated.Text>
|
|
172
144
|
</Animated.View>
|
|
173
145
|
);
|
|
174
146
|
}
|
|
175
147
|
```
|
|
176
148
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
180 ms and an ease-out curve. Apply the styles to Reanimated components; ordinary
|
|
180
|
-
React Native components cannot run these transitions. Existing screens opt in
|
|
181
|
-
without changing their tree, scroll position, or focus.
|
|
182
|
-
|
|
183
|
-
The hook arms after the hydrated colors commit to a frame. Mounting and preference
|
|
184
|
-
restoration stay immediate. Live Reduce Motion changes remove the transition
|
|
185
|
-
configuration and apply the final colors. Rapid changes are handled by
|
|
186
|
-
Reanimated's transition engine; there is no completion callback that can restore
|
|
187
|
-
an old preference. Setters and persistence remain synchronous and independent
|
|
188
|
-
of animation completion. Unmounting cancels the pending frame used to arm motion.
|
|
189
|
-
|
|
190
|
-
Interpolating light and dark text against an interpolating background can briefly
|
|
191
|
-
reduce contrast. The recorded example shows this in intermediate frames. For
|
|
192
|
-
screens that need continuous reading, apply `transition.view` to surfaces and
|
|
193
|
-
set text colors immediately. Text transitions are opt-in through `transition.text`.
|
|
194
|
-
|
|
195
|
-
Use explicit string colors for predictable interpolation. Native semantic colors
|
|
196
|
-
remain useful for platform-owned controls; do not assume their internal appearance
|
|
197
|
-
animates through these styles. Expo UI Hosts, native navigation headers, and status
|
|
198
|
-
bars update to the resolved theme through their own APIs. The reference app keeps
|
|
199
|
-
those native elements outside the Reanimated color transition.
|
|
200
|
-
|
|
201
|
-
The animation entry requires the New Architecture, Reanimated 4.5.1 and compatible
|
|
202
|
-
Worklets. The reference app verifies the SDK 57 pair, Reanimated 4.5.1 and Worklets
|
|
203
|
-
0.10.1. Bare React Native apps must configure the Worklets Babel plugin as described
|
|
204
|
-
in Reanimated's installation guide. The root, core, and Expo entries do not import
|
|
205
|
-
animation peers.
|
|
206
|
-
|
|
207
|
-
See [the transition acceptance cases](../../apps/examples/example-expo/TRANSITION-CHECKS.md)
|
|
208
|
-
and [the recorded checks](../../apps/examples/example-expo/VERIFICATION.md).
|
|
209
|
-
|
|
210
|
-
## Workspace verification
|
|
149
|
+
Backgrounds, borders and text fade to the new theme. Your screens keep their
|
|
150
|
+
scroll position and focus.
|
|
211
151
|
|
|
212
|
-
|
|
213
|
-
pnpm --filter uitheme-rn test
|
|
214
|
-
pnpm --filter uitheme-rn typecheck
|
|
215
|
-
pnpm --filter uitheme-rn build
|
|
216
|
-
pnpm --filter uitheme-rn test:package
|
|
217
|
-
pnpm --filter example-expo typecheck
|
|
218
|
-
pnpm --filter example-expo start
|
|
219
|
-
```
|
|
152
|
+
## Full-screen transitions
|
|
220
153
|
|
|
221
|
-
|
|
222
|
-
|
|
154
|
+
Want the whole screen to change at once? Add Skia, and wrap your app in the
|
|
155
|
+
transition provider:
|
|
223
156
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
[reference Snack](https://snack.expo.dev/@mariops03/react-native-theme-transition?platform=ios),
|
|
228
|
-
use the optional `uitheme-rn/transitions` entry. Install SDK-compatible Skia,
|
|
229
|
-
Reanimated, and Worklets through Expo. The tested pair uses Skia 2.6.2,
|
|
230
|
-
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
|
+
```
|
|
231
160
|
|
|
232
161
|
```tsx
|
|
162
|
+
import { Button } from 'react-native';
|
|
233
163
|
import { UIThemeProvider } from 'uitheme-rn';
|
|
234
164
|
import {
|
|
235
165
|
UIThemeTransitionProvider,
|
|
236
166
|
useAnimatedUITheme,
|
|
237
167
|
} from 'uitheme-rn/transitions';
|
|
238
168
|
|
|
239
|
-
function App() {
|
|
169
|
+
export default function App() {
|
|
240
170
|
return (
|
|
241
171
|
<UIThemeProvider>
|
|
242
172
|
<UIThemeTransitionProvider defaults={{ transition: 'circularReveal' }}>
|
|
243
|
-
<
|
|
173
|
+
<Home />
|
|
244
174
|
</UIThemeTransitionProvider>
|
|
245
175
|
</UIThemeProvider>
|
|
246
176
|
);
|
|
247
177
|
}
|
|
248
178
|
|
|
249
|
-
function
|
|
179
|
+
function Home() {
|
|
250
180
|
const { setTheme, setColorTheme, isTransitioning } = useAnimatedUITheme();
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<>
|
|
184
|
+
<Button
|
|
185
|
+
title="Dark mode"
|
|
186
|
+
disabled={isTransitioning}
|
|
187
|
+
onPress={() => setTheme('dark')}
|
|
188
|
+
/>
|
|
189
|
+
<Button
|
|
190
|
+
title="Forest"
|
|
191
|
+
disabled={isTransitioning}
|
|
192
|
+
onPress={() => setColorTheme('forest', { transition: 'heart' })}
|
|
193
|
+
/>
|
|
194
|
+
</>
|
|
195
|
+
);
|
|
257
196
|
}
|
|
258
197
|
```
|
|
259
198
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
Available effects are `fade`, `circularReveal`, `wipe`, `slide`, `split`, `heart`,
|
|
267
|
-
`star`, `pixelize`, and `dissolve`. Options include `duration`, `origin` (a view ref
|
|
268
|
-
or a provider-relative point), `inverted` for shape/split reveals, `direction`,
|
|
269
|
-
`split`, `blockSize`, `noiseSize`, and `animated`. The default duration is 350 ms.
|
|
270
|
-
Busy requests are rejected before preferences change. Immediate root commands
|
|
271
|
-
remain available through `useUITheme`; use the animated hook for screen effects.
|
|
272
|
-
Expo selectors accept `onValueChange`, and the switcher accepts `onPress`, so the
|
|
273
|
-
native controls can call animated commands without taking ownership of preferences.
|
|
274
|
-
|
|
275
|
-
Reduce Motion skips capture. Live Reduce Motion, backgrounding, rotation, and
|
|
276
|
-
unmount cancel the overlay. A capture failure falls back to an immediate change;
|
|
277
|
-
`onError` reports it. Restoration and system appearance updates use the existing
|
|
278
|
-
provider and do not trigger screen captures. Snapshot layers are hidden from the
|
|
279
|
-
accessibility tree. Touch input is blocked while capture/playback is active.
|
|
280
|
-
|
|
281
|
-
Set the transition provider's `enabled` prop to `false` while native navigation
|
|
282
|
-
or another movement changes the captured tree. This cancels an active overlay and
|
|
283
|
-
applies new choices immediately. Re-enable when movement ends. The Expo example
|
|
284
|
-
connects this prop to the stack's `transitionStart` and `transitionEnd` events.
|
|
285
|
-
Commands also skip capture while the app is not active.
|
|
286
|
-
|
|
287
|
-
The capture boundary is the provider's view tree, including navigation inside it.
|
|
288
|
-
System status bars, keyboards, alerts, and separate native windows remain under OS
|
|
289
|
-
control. Two screen images require memory proportional to their pixel dimensions.
|
|
290
|
-
Run [SCREEN-TRANSITION-CHECKS.md](./SCREEN-TRANSITION-CHECKS.md) before claiming
|
|
291
|
-
release performance or accessibility verification.
|
|
292
|
-
|
|
293
|
-
The browser fallback changes preferences immediately; it does not mount Skia or
|
|
294
|
-
require CanvasKit initialization. Native screen effects target iOS and Android.
|
|
295
|
-
|
|
296
|
-
## Styling systems and CSS themes
|
|
297
|
-
|
|
298
|
-
Plain `StyleSheet`, inline native styles, and TypeScript palettes remain the
|
|
299
|
-
base API. Neither Tailwind nor a styling engine is required by the root entry.
|
|
300
|
-
Optional `uitheme-rn/nativewind` and `uitheme-rn/uniwind` adapters connect utility
|
|
301
|
-
classes to the same appearance and palette store. Install one engine in an app.
|
|
302
|
-
|
|
303
|
-
The NativeWind example targets `nativewind@5.0.0-rc.0` and
|
|
304
|
-
`react-native-css@3.1.0-rc.0` with Tailwind 4.3.1. NativeWind v5 is a release
|
|
305
|
-
candidate; v4 is not supported by this adapter. The Uniwind example targets
|
|
306
|
-
Uniwind 1.12.2 with Tailwind 4.3.1. Follow each example's Metro configuration;
|
|
307
|
-
NativeWind also needs the Tailwind v4 PostCSS plugin and Lightning CSS 1.30.1.
|
|
308
|
-
|
|
309
|
-
For existing TypeScript palettes, place `<NativeWindTheme>` or `<UniwindTheme>`
|
|
310
|
-
inside `<UIThemeProvider>`. The adapter provides scoped semantic variables.
|
|
311
|
-
`bg-primary`, `text-primary-foreground`, `bg-card`, `bg-background`,
|
|
312
|
-
`text-foreground`, `text-muted-foreground`, and `border-border` then use the
|
|
313
|
-
same colors as `useThemeColors()`. Native dynamic color objects remain available
|
|
314
|
-
with native styles; CSS conversion requires string colors.
|
|
315
|
-
|
|
316
|
-
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:
|
|
317
205
|
|
|
318
206
|
```tsx
|
|
319
|
-
import { UIThemeProvider } from 'uitheme-rn';
|
|
320
207
|
import { NativeWindTheme } from 'uitheme-rn/nativewind';
|
|
321
208
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
<UIThemeProvider palettes={palettes} defaultColorTheme="supabase">
|
|
328
|
-
<NativeWindTheme themes={themes}>{/* Your app */}</NativeWindTheme>
|
|
209
|
+
<UIThemeProvider>
|
|
210
|
+
<NativeWindTheme>
|
|
211
|
+
<App />
|
|
212
|
+
</NativeWindTheme>
|
|
329
213
|
</UIThemeProvider>;
|
|
330
214
|
```
|
|
331
215
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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": "0.1
|
|
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,23 +99,14 @@
|
|
|
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.
|
|
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 <
|
|
117
|
-
"react-native-worklets": ">=0.10.1 <0.
|
|
118
|
-
"nativewind": "
|
|
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",
|
|
109
|
+
"nativewind": "5.0.0-rc.0",
|
|
119
110
|
"uniwind": ">=1.12.2 <2"
|
|
120
111
|
},
|
|
121
112
|
"peerDependenciesMeta": {
|
|
@@ -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
|
+
}
|