react-native-theme-transition 1.0.0 → 1.0.2
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 +113 -107
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,107 +1,113 @@
|
|
|
1
|
-
<h1 align="center">
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
Smooth, animated theme transitions for React Native. Expo Go compatible, powered by Reanimated.
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/react-native-theme-transition"><img src="https://img.shields.io/npm/v/react-native-theme-transition.svg" alt="npm version" /></a>
|
|
9
|
-
<a href="https://bundlephobia.com/package/react-native-theme-transition"><img src="https://img.shields.io/
|
|
10
|
-
<img src="https://img.shields.io/badge/Expo_Go-compatible-000.svg?logo=expo&logoColor=white" alt="expo compatible" />
|
|
11
|
-
<img src="https://img.shields.io/badge/React_Compiler-compatible-
|
|
12
|
-
<a href="https://github.com/marioprieta/react-native-theme-transition/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/react-native-theme-transition" alt="license" /></a>
|
|
13
|
-
</p>
|
|
14
|
-
|
|
15
|
-
<table align="center">
|
|
16
|
-
<tr>
|
|
17
|
-
<td align="center"><b>iOS</b></td>
|
|
18
|
-
<td align="center"><b>Android</b></td>
|
|
19
|
-
</tr>
|
|
20
|
-
<tr>
|
|
21
|
-
<td
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
</
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- **
|
|
35
|
-
- **
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
</
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
<h1 align="center">React Native Theme Transition</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
Smooth, animated theme transitions for React Native. Expo Go compatible, powered by Reanimated.
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/react-native-theme-transition"><img src="https://img.shields.io/npm/v/react-native-theme-transition.svg?t=1" alt="npm version" /></a>
|
|
9
|
+
<a href="https://bundlephobia.com/package/react-native-theme-transition"><img src="https://img.shields.io/badge/gzip%20size-2.5%20kB-brightgreen" alt="bundle size" /></a>
|
|
10
|
+
<img src="https://img.shields.io/badge/Expo_Go-compatible-000.svg?logo=expo&logoColor=white" alt="expo compatible" />
|
|
11
|
+
<img src="https://img.shields.io/badge/React_Compiler-compatible-blueviolet.svg" alt="react compiler" />
|
|
12
|
+
<a href="https://github.com/marioprieta/react-native-theme-transition/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/react-native-theme-transition?t=1" alt="license" /></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<table align="center">
|
|
16
|
+
<tr>
|
|
17
|
+
<td align="center"><b>iOS</b></td>
|
|
18
|
+
<td align="center"><b>Android</b></td>
|
|
19
|
+
</tr>
|
|
20
|
+
<tr>
|
|
21
|
+
<td>
|
|
22
|
+
<video src="https://github.com/user-attachments/assets/449220b3-50b1-417e-b2c3-13d815d575d7" width="260" autoplay loop muted playsinline></video>
|
|
23
|
+
<img src="https://github.com/user-attachments/assets/056ce86b-11f0-410b-8fd0-598dbf6ca518" width="260" alt="iOS demo" />
|
|
24
|
+
</td>
|
|
25
|
+
<td>
|
|
26
|
+
<video src="https://github.com/user-attachments/assets/9c55de09-41d2-4581-9463-eb315156dca3" width="260" autoplay loop muted playsinline></video>
|
|
27
|
+
<img src="https://github.com/user-attachments/assets/8b6218d5-87d5-449b-a61d-b9adc78389d9" width="260" alt="Android demo" />
|
|
28
|
+
</td>
|
|
29
|
+
</tr>
|
|
30
|
+
</table>
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- **Smooth cross-fade transitions** — powered by Reanimated on the native UI thread (60-120 FPS)
|
|
35
|
+
- **Expo Go compatible** — no native code, no prebuilds required
|
|
36
|
+
- **Multi-theme support** — define as many themes as you need with full TypeScript inference
|
|
37
|
+
- **System theme sync** — follows OS appearance automatically with zero-flash startup
|
|
38
|
+
- **Native UI sync** — alerts, keyboards, and date pickers automatically match your active theme
|
|
39
|
+
- **Transition safe** — blocks concurrent transitions and exposes `isTransitioning`
|
|
40
|
+
- **React Compiler ready** — all hooks follow the [Rules of React](https://react.dev/reference/rules)
|
|
41
|
+
- **Lightweight** — ~2.5 kB gzipped, zero runtime dependencies
|
|
42
|
+
|
|
43
|
+
## Documentation
|
|
44
|
+
|
|
45
|
+
For full docs, API reference, examples, and recipes, visit **[react-native-theme-transition.vercel.app](https://react-native-theme-transition.vercel.app)**.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Expo (SDK 54+ already has reanimated and view-shot)
|
|
51
|
+
npx expo install react-native-theme-transition react-native-worklets
|
|
52
|
+
|
|
53
|
+
# React Native CLI
|
|
54
|
+
npm install react-native-theme-transition react-native-reanimated react-native-view-shot react-native-worklets
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Add `react-native-worklets/plugin` as the **last plugin** in your `babel.config.js`.
|
|
58
|
+
|
|
59
|
+
## Quick start
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// theme.ts
|
|
63
|
+
import { createThemeTransition } from 'react-native-theme-transition';
|
|
64
|
+
|
|
65
|
+
export const { ThemeTransitionProvider, useTheme } = createThemeTransition({
|
|
66
|
+
themes: {
|
|
67
|
+
light: { background: '#ffffff', text: '#000000', primary: '#007AFF' },
|
|
68
|
+
dark: { background: '#000000', text: '#ffffff', primary: '#0A84FF' },
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
// App.tsx
|
|
75
|
+
import { ThemeTransitionProvider } from './theme';
|
|
76
|
+
|
|
77
|
+
export default function App() {
|
|
78
|
+
return (
|
|
79
|
+
<ThemeTransitionProvider initialTheme="system">
|
|
80
|
+
<MyApp />
|
|
81
|
+
</ThemeTransitionProvider>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
// MyScreen.tsx
|
|
88
|
+
import { useTheme } from './theme';
|
|
89
|
+
|
|
90
|
+
function MyScreen() {
|
|
91
|
+
const { colors, name, setTheme, isTransitioning } = useTheme();
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<View style={{ flex: 1, backgroundColor: colors.background }}>
|
|
95
|
+
<Text style={{ color: colors.text }}>Current: {name}</Text>
|
|
96
|
+
<Pressable
|
|
97
|
+
onPress={() => setTheme(name === 'light' ? 'dark' : 'light')}
|
|
98
|
+
disabled={isTransitioning}
|
|
99
|
+
>
|
|
100
|
+
<Text style={{ color: colors.primary }}>Toggle theme</Text>
|
|
101
|
+
</Pressable>
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Contributing
|
|
108
|
+
|
|
109
|
+
Contributions are welcome! Please read the [contributing guide](./CONTRIBUTING.md) and open an issue first to discuss what you'd like to change.
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-theme-transition",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Smooth, animated theme and dark mode transitions for React Native. Expo Go compatible, powered by Reanimated.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|