@rubixscript/react-native-onboarding 1.0.0 → 1.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/LICENSE +21 -21
- package/README.md +383 -383
- package/dist/components/NavigationButtons.d.ts +23 -0
- package/dist/components/NavigationButtons.d.ts.map +1 -0
- package/dist/components/NavigationButtons.js +106 -0
- package/dist/components/Onboarding.d.ts +11 -0
- package/dist/components/Onboarding.d.ts.map +1 -0
- package/dist/components/Onboarding.js +219 -0
- package/dist/components/Pagination.d.ts +5 -0
- package/dist/components/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination.js +269 -0
- package/dist/components/SimpleOnboardingScreen.d.ts +54 -0
- package/dist/components/SimpleOnboardingScreen.d.ts.map +1 -0
- package/dist/components/SimpleOnboardingScreen.js +184 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/presets/index.d.ts +27 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +370 -0
- package/dist/slides/FormSlide.d.ts +12 -0
- package/dist/slides/FormSlide.d.ts.map +1 -0
- package/dist/slides/FormSlide.js +227 -0
- package/dist/slides/IconSlide.d.ts +10 -0
- package/dist/slides/IconSlide.d.ts.map +1 -0
- package/dist/slides/IconSlide.js +133 -0
- package/dist/slides/ImageSlide.d.ts +10 -0
- package/dist/slides/ImageSlide.d.ts.map +1 -0
- package/dist/slides/ImageSlide.js +99 -0
- package/dist/slides/VideoSlide.d.ts +10 -0
- package/dist/slides/VideoSlide.d.ts.map +1 -0
- package/dist/slides/VideoSlide.js +101 -0
- package/dist/slides/index.d.ts +14 -0
- package/dist/slides/index.d.ts.map +1 -0
- package/dist/slides/index.js +25 -0
- package/dist/themes/index.d.ts +35 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +547 -0
- package/dist/types/index.d.ts +191 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +73 -60
- package/src/components/NavigationButtons.tsx +198 -198
- package/src/components/Onboarding.tsx +337 -340
- package/src/components/Pagination.tsx +337 -337
- package/src/components/SimpleOnboardingScreen.tsx +266 -0
- package/src/components/index.ts +7 -5
- package/src/index.ts +69 -65
- package/src/presets/index.ts +391 -394
- package/src/slides/FormSlide.tsx +314 -314
- package/src/slides/IconSlide.tsx +166 -166
- package/src/slides/ImageSlide.tsx +132 -132
- package/src/slides/VideoSlide.tsx +146 -146
- package/src/slides/{index.ts → index.tsx} +37 -44
- package/src/themes/index.ts +576 -574
- package/src/types/index.ts +247 -247
package/README.md
CHANGED
|
@@ -1,383 +1,383 @@
|
|
|
1
|
-
# @rubixscript/react-native-onboarding
|
|
2
|
-
|
|
3
|
-
A comprehensive React Native onboarding library with customizable slide types, animations, and themes. Built for React Native 0.70+ with Expo.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Multiple Slide Types**: Image, Icon, Form, Video, and Custom slides
|
|
8
|
-
- **Pre-built Themes**: onepage, zaprecipe, pomodo, modern, minimal, gradient presets
|
|
9
|
-
- **Customizable Navigation**: Dots, progress bar, steps, numbers, or no pagination
|
|
10
|
-
- **Smooth Animations**: Slide, fade, scale, parallax transitions with react-native-reanimated
|
|
11
|
-
- **Storage Integration**: AsyncStorage persistence for onboarding completion
|
|
12
|
-
- **Form Support**: Built-in form validation and data collection
|
|
13
|
-
- **Dark Mode**: Full dark mode support
|
|
14
|
-
- **TypeScript**: Fully typed for better developer experience
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install @rubixscript/react-native-onboarding
|
|
20
|
-
# or
|
|
21
|
-
yarn add @rubixscript/react-native-onboarding
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Peer Dependencies
|
|
25
|
-
|
|
26
|
-
Ensure you have these installed:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm install react-native-reanimated @react-native-async-storage/async-storage expo-linear-gradient expo-blur @expo/vector-icons
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Quick Start
|
|
33
|
-
|
|
34
|
-
### Basic Usage
|
|
35
|
-
|
|
36
|
-
```tsx
|
|
37
|
-
import React, { useState } from 'react';
|
|
38
|
-
import { View } from 'react-native';
|
|
39
|
-
import { Onboarding, useOnboarding } from '@rubixscript/react-native-onboarding';
|
|
40
|
-
|
|
41
|
-
const App = () => {
|
|
42
|
-
const { hasCompletedOnboarding, isLoading } = useOnboarding('@myapp:onboarding_complete');
|
|
43
|
-
const [showOnboarding, setShowOnboarding] = useState(!hasCompletedOnboarding);
|
|
44
|
-
|
|
45
|
-
if (isLoading) return null;
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<>
|
|
49
|
-
{showOnboarding ? (
|
|
50
|
-
<Onboarding
|
|
51
|
-
visible={showOnboarding}
|
|
52
|
-
slides={mySlides}
|
|
53
|
-
onboardingComplete={(data) => {
|
|
54
|
-
setShowOnboarding(false);
|
|
55
|
-
console.log('Onboarding data:', data);
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
) : (
|
|
59
|
-
<YourMainApp />
|
|
60
|
-
)}
|
|
61
|
-
</>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Using Presets
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
import { Onboarding } from '@rubixscript/react-native-onboarding';
|
|
70
|
-
import { onepageConfig, onepagePreset } from '@rubixscript/react-native-onboarding/presets';
|
|
71
|
-
|
|
72
|
-
// Use a complete preset
|
|
73
|
-
<Onboarding
|
|
74
|
-
visible={true}
|
|
75
|
-
{...onepageConfig}
|
|
76
|
-
theme={onepagePreset.theme}
|
|
77
|
-
navigation={onepagePreset.navigation}
|
|
78
|
-
animation={onepagePreset.animation}
|
|
79
|
-
onboardingComplete={() => console.log('Done!')}
|
|
80
|
-
/>
|
|
81
|
-
|
|
82
|
-
// Or just use the theme with custom slides
|
|
83
|
-
<Onboarding
|
|
84
|
-
visible={true}
|
|
85
|
-
slides={myCustomSlides}
|
|
86
|
-
theme={onepagePreset.theme}
|
|
87
|
-
onboardingComplete={() => console.log('Done!')}
|
|
88
|
-
/>
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Slide Types
|
|
92
|
-
|
|
93
|
-
### Image Slide
|
|
94
|
-
|
|
95
|
-
```tsx
|
|
96
|
-
{
|
|
97
|
-
id: 'welcome',
|
|
98
|
-
type: 'image',
|
|
99
|
-
title: 'Welcome',
|
|
100
|
-
description: 'Your description here',
|
|
101
|
-
image: require('./assets/welcome.png'),
|
|
102
|
-
imageResizeMode: 'cover',
|
|
103
|
-
gradientColors: ['#667EEA', '#764BA2'],
|
|
104
|
-
overlayIcon: {
|
|
105
|
-
name: 'heart',
|
|
106
|
-
size: 40,
|
|
107
|
-
color: '#FFFFFF'
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Icon Slide
|
|
113
|
-
|
|
114
|
-
```tsx
|
|
115
|
-
{
|
|
116
|
-
id: 'features',
|
|
117
|
-
type: 'icon',
|
|
118
|
-
title: 'Powerful Features',
|
|
119
|
-
description: 'Discover what we offer',
|
|
120
|
-
icon: {
|
|
121
|
-
name: 'rocket',
|
|
122
|
-
type: 'ionicons', // or 'material', 'material-community', 'font-awesome', 'octicons', 'feather'
|
|
123
|
-
size: 64,
|
|
124
|
-
color: '#FFFFFF',
|
|
125
|
-
backgroundColor: '#8B5CF6',
|
|
126
|
-
backgroundSize: 160
|
|
127
|
-
},
|
|
128
|
-
backgroundColor: '#F6F6F6'
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Form Slide
|
|
133
|
-
|
|
134
|
-
```tsx
|
|
135
|
-
{
|
|
136
|
-
id: 'profile',
|
|
137
|
-
type: 'form',
|
|
138
|
-
title: 'Tell us about yourself',
|
|
139
|
-
description: 'We\'ll personalize your experience',
|
|
140
|
-
fields: [
|
|
141
|
-
{
|
|
142
|
-
key: 'name',
|
|
143
|
-
label: 'Your Name',
|
|
144
|
-
placeholder: 'Enter your name',
|
|
145
|
-
type: 'text',
|
|
146
|
-
required: true
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
key: 'level',
|
|
150
|
-
label: 'Experience Level',
|
|
151
|
-
placeholder: 'Select level',
|
|
152
|
-
type: 'select',
|
|
153
|
-
required: true,
|
|
154
|
-
options: [
|
|
155
|
-
{ value: 'beginner', label: 'Beginner', icon: 'leaf' },
|
|
156
|
-
{ value: 'advanced', label: 'Advanced', icon: 'star' }
|
|
157
|
-
]
|
|
158
|
-
}
|
|
159
|
-
],
|
|
160
|
-
submitLabel: 'Get Started',
|
|
161
|
-
onSubmit: async (data) => {
|
|
162
|
-
console.log('Form data:', data);
|
|
163
|
-
// Save to backend, etc.
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Video Slide
|
|
169
|
-
|
|
170
|
-
```tsx
|
|
171
|
-
{
|
|
172
|
-
id: 'intro',
|
|
173
|
-
type: 'video',
|
|
174
|
-
title: 'Watch Our Story',
|
|
175
|
-
description: 'A quick introduction',
|
|
176
|
-
videoSource: require('./assets/intro.mp4'),
|
|
177
|
-
autoPlay: true,
|
|
178
|
-
loop: true,
|
|
179
|
-
muted: true,
|
|
180
|
-
poster: require('./assets/poster.png')
|
|
181
|
-
}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Customization
|
|
185
|
-
|
|
186
|
-
### Theme
|
|
187
|
-
|
|
188
|
-
```tsx
|
|
189
|
-
import { mergeTheme, modernTheme } from '@rubixscript/react-native-onboarding';
|
|
190
|
-
|
|
191
|
-
const customTheme = mergeTheme(modernTheme, {
|
|
192
|
-
colors: {
|
|
193
|
-
primary: '#FF6B6B',
|
|
194
|
-
secondary: '#4ECDC4',
|
|
195
|
-
},
|
|
196
|
-
typography: {
|
|
197
|
-
title: {
|
|
198
|
-
fontSize: 32,
|
|
199
|
-
fontWeight: '800',
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
<Onboarding theme={customTheme} {...otherProps} />
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Navigation
|
|
208
|
-
|
|
209
|
-
```tsx
|
|
210
|
-
<Onboarding
|
|
211
|
-
navigation={{
|
|
212
|
-
style: 'dots', // 'dots' | 'progress-bar' | 'steps' | 'numbers' | 'none'
|
|
213
|
-
position: 'bottom', // 'top' | 'bottom' | 'floating'
|
|
214
|
-
showSkip: true,
|
|
215
|
-
showBack: true,
|
|
216
|
-
skipLabel: 'Skip',
|
|
217
|
-
backLabel: 'Back',
|
|
218
|
-
nextLabel: 'Continue',
|
|
219
|
-
doneLabel: 'Get Started',
|
|
220
|
-
}}
|
|
221
|
-
{...otherProps}
|
|
222
|
-
/>
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### Animation
|
|
226
|
-
|
|
227
|
-
```tsx
|
|
228
|
-
<Onboarding
|
|
229
|
-
animation={{
|
|
230
|
-
type: 'slide', // 'slide' | 'fade' | 'scale' | 'parallax' | 'cube' | 'none'
|
|
231
|
-
duration: 300,
|
|
232
|
-
parallaxFactor: 0.3
|
|
233
|
-
}}
|
|
234
|
-
{...otherProps}
|
|
235
|
-
/>
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Storage
|
|
239
|
-
|
|
240
|
-
```tsx
|
|
241
|
-
<Onboarding
|
|
242
|
-
storage={{
|
|
243
|
-
key: '@myapp:onboarding_complete',
|
|
244
|
-
enabled: true,
|
|
245
|
-
onComplete: async () => {
|
|
246
|
-
// Called after saving completion status
|
|
247
|
-
console.log('Onboarding saved!');
|
|
248
|
-
}
|
|
249
|
-
}}
|
|
250
|
-
{...otherProps}
|
|
251
|
-
/>
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## Hooks
|
|
255
|
-
|
|
256
|
-
### useOnboarding
|
|
257
|
-
|
|
258
|
-
```tsx
|
|
259
|
-
import { useOnboarding } from '@rubixscript/react-native-onboarding';
|
|
260
|
-
|
|
261
|
-
const MyComponent = () => {
|
|
262
|
-
const {
|
|
263
|
-
hasCompletedOnboarding, // boolean | null
|
|
264
|
-
isLoading, // boolean
|
|
265
|
-
markComplete, // () => Promise<void>
|
|
266
|
-
reset // () => Promise<void>
|
|
267
|
-
} = useOnboarding('@myapp:onboarding_key');
|
|
268
|
-
|
|
269
|
-
if (isLoading) return <LoadingScreen />;
|
|
270
|
-
|
|
271
|
-
return hasCompletedOnboarding ? <App /> : <Onboarding ... />;
|
|
272
|
-
};
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
## Available Presets
|
|
276
|
-
|
|
277
|
-
| Preset | Style | Best For |
|
|
278
|
-
|--------|-------|----------|
|
|
279
|
-
| `onepage` | Gradient backgrounds, images, forms | Reading apps, content apps |
|
|
280
|
-
| `zaprecipe` | Rich images, overlay icons, gradients | Lifestyle, food, travel apps |
|
|
281
|
-
| `pomodo` | Clean icons, minimal design | Productivity, utility apps |
|
|
282
|
-
| `modern` | Contemporary, rounded, vibrant | Modern consumer apps |
|
|
283
|
-
| `minimal` | Simple, monochrome, clean | Professional, business apps |
|
|
284
|
-
| `gradient` | Full-screen gradients, immersive | Creative, artistic apps |
|
|
285
|
-
|
|
286
|
-
## Integration Examples
|
|
287
|
-
|
|
288
|
-
### Expo Router
|
|
289
|
-
|
|
290
|
-
```tsx
|
|
291
|
-
// app/onboarding.tsx
|
|
292
|
-
import { View } from 'react-native';
|
|
293
|
-
import { Onboarding } from '@rubixscript/react-native-onboarding';
|
|
294
|
-
import { router } from 'expo-router';
|
|
295
|
-
import { onepageConfig } from '@rubixscript/react-native-onboarding/presets';
|
|
296
|
-
|
|
297
|
-
export default function OnboardingScreen() {
|
|
298
|
-
return (
|
|
299
|
-
<Onboarding
|
|
300
|
-
visible={true}
|
|
301
|
-
{...onepageConfig}
|
|
302
|
-
onboardingComplete={() => router.replace('/(tabs)')}
|
|
303
|
-
/>
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// app/_layout.tsx
|
|
308
|
-
import { useOnboarding } from '@rubixscript/react-native-onboarding';
|
|
309
|
-
import { router } from 'expo-router';
|
|
310
|
-
|
|
311
|
-
export default function Layout() {
|
|
312
|
-
const { hasCompletedOnboarding, isLoading } = useOnboarding();
|
|
313
|
-
|
|
314
|
-
useEffect(() => {
|
|
315
|
-
if (!isLoading && !hasCompletedOnboarding) {
|
|
316
|
-
router.replace('/onboarding');
|
|
317
|
-
}
|
|
318
|
-
}, [hasCompletedOnboarding, isLoading]);
|
|
319
|
-
|
|
320
|
-
return <Slot />;
|
|
321
|
-
}
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
### React Navigation
|
|
325
|
-
|
|
326
|
-
```tsx
|
|
327
|
-
import { Onboarding, useOnboarding } from '@rubixscript/react-native-onboarding';
|
|
328
|
-
|
|
329
|
-
const OnboardingScreen = ({ navigation }: any) => (
|
|
330
|
-
<Onboarding
|
|
331
|
-
visible={true}
|
|
332
|
-
slides={slides}
|
|
333
|
-
onboardingComplete={() => navigation.navigate('Home')}
|
|
334
|
-
/>
|
|
335
|
-
);
|
|
336
|
-
|
|
337
|
-
const RootNavigator = () => {
|
|
338
|
-
const { hasCompletedOnboarding, isLoading } = useOnboarding();
|
|
339
|
-
|
|
340
|
-
if (isLoading) return null;
|
|
341
|
-
|
|
342
|
-
return (
|
|
343
|
-
<Stack.Navigator screenOptions={{ headerShown: false }}>
|
|
344
|
-
{!hasCompletedOnboarding && (
|
|
345
|
-
<Stack.Screen name="Onboarding" component={OnboardingScreen} />
|
|
346
|
-
)}
|
|
347
|
-
<Stack.Screen name="Home" component={HomeScreen} />
|
|
348
|
-
</Stack.Navigator>
|
|
349
|
-
);
|
|
350
|
-
};
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
## API Reference
|
|
354
|
-
|
|
355
|
-
### Onboarding Component
|
|
356
|
-
|
|
357
|
-
| Prop | Type | Default | Description |
|
|
358
|
-
|------|------|---------|-------------|
|
|
359
|
-
| `visible` | `boolean` | *required* | Controls visibility of onboarding |
|
|
360
|
-
| `slides` | `SlideData[]` | `[]` | Array of slide configurations |
|
|
361
|
-
| `theme` | `Partial<OnboardingTheme>` | `modernTheme` | Custom theme configuration |
|
|
362
|
-
| `navigation` | `Partial<NavigationConfig>` | See below | Navigation options |
|
|
363
|
-
| `animation` | `Partial<AnimationConfig>` | See below | Animation settings |
|
|
364
|
-
| `storage` | `Partial<StorageConfig>` | See below | AsyncStorage configuration |
|
|
365
|
-
| `onboardingComplete` | `(data?) => void \| Promise<void>` | - | Called when onboarding completes |
|
|
366
|
-
| `onSlideChange` | `(index: number) => void` | - | Called on slide change |
|
|
367
|
-
| `onSkip` | `() => void \| Promise<void>` | - | Called when user skips |
|
|
368
|
-
| `initialSlide` | `number` | `0` | Starting slide index |
|
|
369
|
-
| `swipeEnabled` | `boolean` | `true` | Enable swipe navigation |
|
|
370
|
-
| `safeAreaEnabled` | `boolean` | `true` | Use SafeAreaView |
|
|
371
|
-
| `darkMode` | `boolean` | `false` | Enable dark mode styling |
|
|
372
|
-
|
|
373
|
-
## License
|
|
374
|
-
|
|
375
|
-
MIT
|
|
376
|
-
|
|
377
|
-
## Author
|
|
378
|
-
|
|
379
|
-
RubixScript Team
|
|
380
|
-
|
|
381
|
-
---
|
|
382
|
-
|
|
383
|
-
For more examples and updates, visit [GitHub](https://github.com/rubixscript/react-native-onboarding).
|
|
1
|
+
# @rubixscript/react-native-onboarding
|
|
2
|
+
|
|
3
|
+
A comprehensive React Native onboarding library with customizable slide types, animations, and themes. Built for React Native 0.70+ with Expo.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Multiple Slide Types**: Image, Icon, Form, Video, and Custom slides
|
|
8
|
+
- **Pre-built Themes**: onepage, zaprecipe, pomodo, modern, minimal, gradient presets
|
|
9
|
+
- **Customizable Navigation**: Dots, progress bar, steps, numbers, or no pagination
|
|
10
|
+
- **Smooth Animations**: Slide, fade, scale, parallax transitions with react-native-reanimated
|
|
11
|
+
- **Storage Integration**: AsyncStorage persistence for onboarding completion
|
|
12
|
+
- **Form Support**: Built-in form validation and data collection
|
|
13
|
+
- **Dark Mode**: Full dark mode support
|
|
14
|
+
- **TypeScript**: Fully typed for better developer experience
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @rubixscript/react-native-onboarding
|
|
20
|
+
# or
|
|
21
|
+
yarn add @rubixscript/react-native-onboarding
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Peer Dependencies
|
|
25
|
+
|
|
26
|
+
Ensure you have these installed:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install react-native-reanimated @react-native-async-storage/async-storage expo-linear-gradient expo-blur @expo/vector-icons
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### Basic Usage
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import React, { useState } from 'react';
|
|
38
|
+
import { View } from 'react-native';
|
|
39
|
+
import { Onboarding, useOnboarding } from '@rubixscript/react-native-onboarding';
|
|
40
|
+
|
|
41
|
+
const App = () => {
|
|
42
|
+
const { hasCompletedOnboarding, isLoading } = useOnboarding('@myapp:onboarding_complete');
|
|
43
|
+
const [showOnboarding, setShowOnboarding] = useState(!hasCompletedOnboarding);
|
|
44
|
+
|
|
45
|
+
if (isLoading) return null;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
{showOnboarding ? (
|
|
50
|
+
<Onboarding
|
|
51
|
+
visible={showOnboarding}
|
|
52
|
+
slides={mySlides}
|
|
53
|
+
onboardingComplete={(data) => {
|
|
54
|
+
setShowOnboarding(false);
|
|
55
|
+
console.log('Onboarding data:', data);
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
) : (
|
|
59
|
+
<YourMainApp />
|
|
60
|
+
)}
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Using Presets
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { Onboarding } from '@rubixscript/react-native-onboarding';
|
|
70
|
+
import { onepageConfig, onepagePreset } from '@rubixscript/react-native-onboarding/presets';
|
|
71
|
+
|
|
72
|
+
// Use a complete preset
|
|
73
|
+
<Onboarding
|
|
74
|
+
visible={true}
|
|
75
|
+
{...onepageConfig}
|
|
76
|
+
theme={onepagePreset.theme}
|
|
77
|
+
navigation={onepagePreset.navigation}
|
|
78
|
+
animation={onepagePreset.animation}
|
|
79
|
+
onboardingComplete={() => console.log('Done!')}
|
|
80
|
+
/>
|
|
81
|
+
|
|
82
|
+
// Or just use the theme with custom slides
|
|
83
|
+
<Onboarding
|
|
84
|
+
visible={true}
|
|
85
|
+
slides={myCustomSlides}
|
|
86
|
+
theme={onepagePreset.theme}
|
|
87
|
+
onboardingComplete={() => console.log('Done!')}
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Slide Types
|
|
92
|
+
|
|
93
|
+
### Image Slide
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
{
|
|
97
|
+
id: 'welcome',
|
|
98
|
+
type: 'image',
|
|
99
|
+
title: 'Welcome',
|
|
100
|
+
description: 'Your description here',
|
|
101
|
+
image: require('./assets/welcome.png'),
|
|
102
|
+
imageResizeMode: 'cover',
|
|
103
|
+
gradientColors: ['#667EEA', '#764BA2'],
|
|
104
|
+
overlayIcon: {
|
|
105
|
+
name: 'heart',
|
|
106
|
+
size: 40,
|
|
107
|
+
color: '#FFFFFF'
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Icon Slide
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
{
|
|
116
|
+
id: 'features',
|
|
117
|
+
type: 'icon',
|
|
118
|
+
title: 'Powerful Features',
|
|
119
|
+
description: 'Discover what we offer',
|
|
120
|
+
icon: {
|
|
121
|
+
name: 'rocket',
|
|
122
|
+
type: 'ionicons', // or 'material', 'material-community', 'font-awesome', 'octicons', 'feather'
|
|
123
|
+
size: 64,
|
|
124
|
+
color: '#FFFFFF',
|
|
125
|
+
backgroundColor: '#8B5CF6',
|
|
126
|
+
backgroundSize: 160
|
|
127
|
+
},
|
|
128
|
+
backgroundColor: '#F6F6F6'
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Form Slide
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
{
|
|
136
|
+
id: 'profile',
|
|
137
|
+
type: 'form',
|
|
138
|
+
title: 'Tell us about yourself',
|
|
139
|
+
description: 'We\'ll personalize your experience',
|
|
140
|
+
fields: [
|
|
141
|
+
{
|
|
142
|
+
key: 'name',
|
|
143
|
+
label: 'Your Name',
|
|
144
|
+
placeholder: 'Enter your name',
|
|
145
|
+
type: 'text',
|
|
146
|
+
required: true
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
key: 'level',
|
|
150
|
+
label: 'Experience Level',
|
|
151
|
+
placeholder: 'Select level',
|
|
152
|
+
type: 'select',
|
|
153
|
+
required: true,
|
|
154
|
+
options: [
|
|
155
|
+
{ value: 'beginner', label: 'Beginner', icon: 'leaf' },
|
|
156
|
+
{ value: 'advanced', label: 'Advanced', icon: 'star' }
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
submitLabel: 'Get Started',
|
|
161
|
+
onSubmit: async (data) => {
|
|
162
|
+
console.log('Form data:', data);
|
|
163
|
+
// Save to backend, etc.
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Video Slide
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
{
|
|
172
|
+
id: 'intro',
|
|
173
|
+
type: 'video',
|
|
174
|
+
title: 'Watch Our Story',
|
|
175
|
+
description: 'A quick introduction',
|
|
176
|
+
videoSource: require('./assets/intro.mp4'),
|
|
177
|
+
autoPlay: true,
|
|
178
|
+
loop: true,
|
|
179
|
+
muted: true,
|
|
180
|
+
poster: require('./assets/poster.png')
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Customization
|
|
185
|
+
|
|
186
|
+
### Theme
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { mergeTheme, modernTheme } from '@rubixscript/react-native-onboarding';
|
|
190
|
+
|
|
191
|
+
const customTheme = mergeTheme(modernTheme, {
|
|
192
|
+
colors: {
|
|
193
|
+
primary: '#FF6B6B',
|
|
194
|
+
secondary: '#4ECDC4',
|
|
195
|
+
},
|
|
196
|
+
typography: {
|
|
197
|
+
title: {
|
|
198
|
+
fontSize: 32,
|
|
199
|
+
fontWeight: '800',
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
<Onboarding theme={customTheme} {...otherProps} />
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Navigation
|
|
208
|
+
|
|
209
|
+
```tsx
|
|
210
|
+
<Onboarding
|
|
211
|
+
navigation={{
|
|
212
|
+
style: 'dots', // 'dots' | 'progress-bar' | 'steps' | 'numbers' | 'none'
|
|
213
|
+
position: 'bottom', // 'top' | 'bottom' | 'floating'
|
|
214
|
+
showSkip: true,
|
|
215
|
+
showBack: true,
|
|
216
|
+
skipLabel: 'Skip',
|
|
217
|
+
backLabel: 'Back',
|
|
218
|
+
nextLabel: 'Continue',
|
|
219
|
+
doneLabel: 'Get Started',
|
|
220
|
+
}}
|
|
221
|
+
{...otherProps}
|
|
222
|
+
/>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Animation
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
<Onboarding
|
|
229
|
+
animation={{
|
|
230
|
+
type: 'slide', // 'slide' | 'fade' | 'scale' | 'parallax' | 'cube' | 'none'
|
|
231
|
+
duration: 300,
|
|
232
|
+
parallaxFactor: 0.3
|
|
233
|
+
}}
|
|
234
|
+
{...otherProps}
|
|
235
|
+
/>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Storage
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
<Onboarding
|
|
242
|
+
storage={{
|
|
243
|
+
key: '@myapp:onboarding_complete',
|
|
244
|
+
enabled: true,
|
|
245
|
+
onComplete: async () => {
|
|
246
|
+
// Called after saving completion status
|
|
247
|
+
console.log('Onboarding saved!');
|
|
248
|
+
}
|
|
249
|
+
}}
|
|
250
|
+
{...otherProps}
|
|
251
|
+
/>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Hooks
|
|
255
|
+
|
|
256
|
+
### useOnboarding
|
|
257
|
+
|
|
258
|
+
```tsx
|
|
259
|
+
import { useOnboarding } from '@rubixscript/react-native-onboarding';
|
|
260
|
+
|
|
261
|
+
const MyComponent = () => {
|
|
262
|
+
const {
|
|
263
|
+
hasCompletedOnboarding, // boolean | null
|
|
264
|
+
isLoading, // boolean
|
|
265
|
+
markComplete, // () => Promise<void>
|
|
266
|
+
reset // () => Promise<void>
|
|
267
|
+
} = useOnboarding('@myapp:onboarding_key');
|
|
268
|
+
|
|
269
|
+
if (isLoading) return <LoadingScreen />;
|
|
270
|
+
|
|
271
|
+
return hasCompletedOnboarding ? <App /> : <Onboarding ... />;
|
|
272
|
+
};
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Available Presets
|
|
276
|
+
|
|
277
|
+
| Preset | Style | Best For |
|
|
278
|
+
|--------|-------|----------|
|
|
279
|
+
| `onepage` | Gradient backgrounds, images, forms | Reading apps, content apps |
|
|
280
|
+
| `zaprecipe` | Rich images, overlay icons, gradients | Lifestyle, food, travel apps |
|
|
281
|
+
| `pomodo` | Clean icons, minimal design | Productivity, utility apps |
|
|
282
|
+
| `modern` | Contemporary, rounded, vibrant | Modern consumer apps |
|
|
283
|
+
| `minimal` | Simple, monochrome, clean | Professional, business apps |
|
|
284
|
+
| `gradient` | Full-screen gradients, immersive | Creative, artistic apps |
|
|
285
|
+
|
|
286
|
+
## Integration Examples
|
|
287
|
+
|
|
288
|
+
### Expo Router
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
// app/onboarding.tsx
|
|
292
|
+
import { View } from 'react-native';
|
|
293
|
+
import { Onboarding } from '@rubixscript/react-native-onboarding';
|
|
294
|
+
import { router } from 'expo-router';
|
|
295
|
+
import { onepageConfig } from '@rubixscript/react-native-onboarding/presets';
|
|
296
|
+
|
|
297
|
+
export default function OnboardingScreen() {
|
|
298
|
+
return (
|
|
299
|
+
<Onboarding
|
|
300
|
+
visible={true}
|
|
301
|
+
{...onepageConfig}
|
|
302
|
+
onboardingComplete={() => router.replace('/(tabs)')}
|
|
303
|
+
/>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// app/_layout.tsx
|
|
308
|
+
import { useOnboarding } from '@rubixscript/react-native-onboarding';
|
|
309
|
+
import { router } from 'expo-router';
|
|
310
|
+
|
|
311
|
+
export default function Layout() {
|
|
312
|
+
const { hasCompletedOnboarding, isLoading } = useOnboarding();
|
|
313
|
+
|
|
314
|
+
useEffect(() => {
|
|
315
|
+
if (!isLoading && !hasCompletedOnboarding) {
|
|
316
|
+
router.replace('/onboarding');
|
|
317
|
+
}
|
|
318
|
+
}, [hasCompletedOnboarding, isLoading]);
|
|
319
|
+
|
|
320
|
+
return <Slot />;
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### React Navigation
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
import { Onboarding, useOnboarding } from '@rubixscript/react-native-onboarding';
|
|
328
|
+
|
|
329
|
+
const OnboardingScreen = ({ navigation }: any) => (
|
|
330
|
+
<Onboarding
|
|
331
|
+
visible={true}
|
|
332
|
+
slides={slides}
|
|
333
|
+
onboardingComplete={() => navigation.navigate('Home')}
|
|
334
|
+
/>
|
|
335
|
+
);
|
|
336
|
+
|
|
337
|
+
const RootNavigator = () => {
|
|
338
|
+
const { hasCompletedOnboarding, isLoading } = useOnboarding();
|
|
339
|
+
|
|
340
|
+
if (isLoading) return null;
|
|
341
|
+
|
|
342
|
+
return (
|
|
343
|
+
<Stack.Navigator screenOptions={{ headerShown: false }}>
|
|
344
|
+
{!hasCompletedOnboarding && (
|
|
345
|
+
<Stack.Screen name="Onboarding" component={OnboardingScreen} />
|
|
346
|
+
)}
|
|
347
|
+
<Stack.Screen name="Home" component={HomeScreen} />
|
|
348
|
+
</Stack.Navigator>
|
|
349
|
+
);
|
|
350
|
+
};
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## API Reference
|
|
354
|
+
|
|
355
|
+
### Onboarding Component
|
|
356
|
+
|
|
357
|
+
| Prop | Type | Default | Description |
|
|
358
|
+
|------|------|---------|-------------|
|
|
359
|
+
| `visible` | `boolean` | *required* | Controls visibility of onboarding |
|
|
360
|
+
| `slides` | `SlideData[]` | `[]` | Array of slide configurations |
|
|
361
|
+
| `theme` | `Partial<OnboardingTheme>` | `modernTheme` | Custom theme configuration |
|
|
362
|
+
| `navigation` | `Partial<NavigationConfig>` | See below | Navigation options |
|
|
363
|
+
| `animation` | `Partial<AnimationConfig>` | See below | Animation settings |
|
|
364
|
+
| `storage` | `Partial<StorageConfig>` | See below | AsyncStorage configuration |
|
|
365
|
+
| `onboardingComplete` | `(data?) => void \| Promise<void>` | - | Called when onboarding completes |
|
|
366
|
+
| `onSlideChange` | `(index: number) => void` | - | Called on slide change |
|
|
367
|
+
| `onSkip` | `() => void \| Promise<void>` | - | Called when user skips |
|
|
368
|
+
| `initialSlide` | `number` | `0` | Starting slide index |
|
|
369
|
+
| `swipeEnabled` | `boolean` | `true` | Enable swipe navigation |
|
|
370
|
+
| `safeAreaEnabled` | `boolean` | `true` | Use SafeAreaView |
|
|
371
|
+
| `darkMode` | `boolean` | `false` | Enable dark mode styling |
|
|
372
|
+
|
|
373
|
+
## License
|
|
374
|
+
|
|
375
|
+
MIT
|
|
376
|
+
|
|
377
|
+
## Author
|
|
378
|
+
|
|
379
|
+
RubixScript Team
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
For more examples and updates, visit [GitHub](https://github.com/rubixscript/react-native-onboarding).
|