react-native-lumen 1.0.1 → 1.1.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.
Files changed (49) hide show
  1. package/README.md +770 -231
  2. package/lib/module/components/TourOverlay.js +45 -45
  3. package/lib/module/components/TourOverlay.js.map +1 -1
  4. package/lib/module/components/TourProvider.js +345 -80
  5. package/lib/module/components/TourProvider.js.map +1 -1
  6. package/lib/module/components/TourTooltip.js +113 -73
  7. package/lib/module/components/TourTooltip.js.map +1 -1
  8. package/lib/module/components/TourZone.js +229 -125
  9. package/lib/module/components/TourZone.js.map +1 -1
  10. package/lib/module/constants/defaults.js +43 -0
  11. package/lib/module/constants/defaults.js.map +1 -1
  12. package/lib/module/context/TourContext.js +5 -0
  13. package/lib/module/context/TourContext.js.map +1 -0
  14. package/lib/module/hooks/useTour.js +1 -1
  15. package/lib/module/hooks/useTour.js.map +1 -1
  16. package/lib/module/hooks/useTourScrollView.js +74 -0
  17. package/lib/module/hooks/useTourScrollView.js.map +1 -0
  18. package/lib/module/index.js +6 -0
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/module/utils/storage.js +188 -0
  21. package/lib/module/utils/storage.js.map +1 -0
  22. package/lib/typescript/src/components/TourOverlay.d.ts.map +1 -1
  23. package/lib/typescript/src/components/TourProvider.d.ts +21 -4
  24. package/lib/typescript/src/components/TourProvider.d.ts.map +1 -1
  25. package/lib/typescript/src/components/TourTooltip.d.ts.map +1 -1
  26. package/lib/typescript/src/components/TourZone.d.ts +19 -1
  27. package/lib/typescript/src/components/TourZone.d.ts.map +1 -1
  28. package/lib/typescript/src/constants/defaults.d.ts +10 -0
  29. package/lib/typescript/src/constants/defaults.d.ts.map +1 -1
  30. package/lib/typescript/src/context/TourContext.d.ts +3 -0
  31. package/lib/typescript/src/context/TourContext.d.ts.map +1 -0
  32. package/lib/typescript/src/hooks/useTourScrollView.d.ts +76 -0
  33. package/lib/typescript/src/hooks/useTourScrollView.d.ts.map +1 -0
  34. package/lib/typescript/src/index.d.ts +4 -0
  35. package/lib/typescript/src/index.d.ts.map +1 -1
  36. package/lib/typescript/src/types/index.d.ts +316 -1
  37. package/lib/typescript/src/types/index.d.ts.map +1 -1
  38. package/lib/typescript/src/utils/storage.d.ts +51 -0
  39. package/lib/typescript/src/utils/storage.d.ts.map +1 -0
  40. package/package.json +169 -171
  41. package/src/components/TourOverlay.tsx +0 -153
  42. package/src/components/TourProvider.tsx +0 -361
  43. package/src/components/TourTooltip.tsx +0 -256
  44. package/src/components/TourZone.tsx +0 -371
  45. package/src/constants/animations.ts +0 -71
  46. package/src/constants/defaults.ts +0 -15
  47. package/src/hooks/useTour.ts +0 -10
  48. package/src/index.tsx +0 -8
  49. package/src/types/index.ts +0 -142
package/README.md CHANGED
@@ -1,231 +1,770 @@
1
- # React Native Lumen 💡
2
-
3
- > A high-performance, fully customizable app tour library for React Native, powered by Reanimated 3.
4
-
5
- ![Banner](./assets/banner.png)
6
-
7
- ## Demo
8
-
9
- <p>
10
- <img src="./assets/showcase.gif" width="220" alt="App Tour Demo" />
11
- </p>
12
-
13
- ## Features
14
-
15
- - ⚡ **High Performance**: Built with `react-native-reanimated` worklets for 60fps animations.
16
- - 🎨 **Fully Customizable**: Custom Renderers for tooltips, customizable shapes, and backdrops.
17
- - 📱 **Expo Compatible**: Works seamlessly with Expo and bare React Native projects.
18
- - 🤸 **Smooth Transitions**: Fluid morphing animations between steps.
19
- - **Animation Presets**: Ships with beautiful bouncy, gentle, and snappy spring presets.
20
- - 📜 **Auto Scrolling**: Automatically scrolls to next steps.
21
- - 👆 **Interaction Control**: Choose to block or allow interactions with the underlying app.
22
-
23
- ## Requirements
24
-
25
- This library relies on strict peer dependencies to ensure performance:
26
-
27
- - `react-native` >= 0.70.0
28
- - `react-native-reanimated` >= 3.0.0
29
- - `react-native-svg` >= 12.0.0
30
- - `react-native-gesture-handler` >= 2.0.0
31
-
32
- ## Installation
33
-
34
- ```sh
35
- npm install react-native-lumen react-native-reanimated react-native-svg react-native-gesture-handler react-native-worklets
36
- ```
37
-
38
- ## Usage
39
-
40
- 1. **Wrap your App with `TourProvider`**:
41
-
42
- ```tsx
43
- import { TourProvider } from 'react-native-lumen';
44
-
45
- export default function App() {
46
- return (
47
- <TourProvider>
48
- <YourAppContent />
49
- </TourProvider>
50
- );
51
- }
52
- ```
53
-
54
- 2. **Highlight Elements with `TourZone`**:
55
-
56
- ```tsx
57
- import { TourZone } from 'react-native-lumen';
58
-
59
- <TourZone
60
- stepKey="step-1"
61
- name="My Feature"
62
- description="This is an awesome feature you should know about."
63
- order={1}
64
- borderRadius={10}
65
- >
66
- <MyButton />
67
- </TourZone>;
68
- ```
69
-
70
- 3. **Control the Tour**:
71
-
72
- ```tsx
73
- import { useTour } from 'react-native-lumen';
74
-
75
- const MyComponent = () => {
76
- const { start } = useTour();
77
- return <Button title="Start Tour" onPress={() => start()} />;
78
- };
79
- ```
80
-
81
- ## API Documentation
82
-
83
- ### `TourProvider`
84
-
85
- The main context provider. Place this at the root of your application.
86
-
87
- | Prop | Type | Default | Description |
88
- | :---------------- | :---------------- | :---------- | :------------------------------------------------------- |
89
- | `children` | `React.ReactNode` | Required | Application content. |
90
- | `stepsOrder` | `string[]` | `undefined` | Optional array of step keys to define a forced sequence. |
91
- | `backdropOpacity` | `number` | `0.5` | Opacity of the dark background overlay (0-1). |
92
- | `config` | `TourConfig` | `undefined` | Global configuration options. |
93
-
94
- ### `TourZone`
95
-
96
- Wrapper component to register an element as a tour step.
97
-
98
- | Prop | Type | Default | Description |
99
- | :------------- | :------------------- | :---------- | :---------------------------------------------- |
100
- | `stepKey` | `string` | Required | Unique identifier for the step. |
101
- | `name` | `string` | `undefined` | Title of the step. |
102
- | `description` | `string` | Required | Description text shown in the tooltip. |
103
- | `order` | `number` | `undefined` | Order of appearance (if `stepsOrder` not used). |
104
- | `shape` | `'rect' \| 'circle'` | `'rect'` | Shape of the spotlight. |
105
- | `borderRadius` | `number` | `10` | Border radius of the spotlight. |
106
- | `clickable` | `boolean` | `false` | If `true`, the step remains interactive. |
107
- | `style` | `ViewStyle` | `undefined` | Style for the wrapping container. |
108
-
109
- ### `TourConfig`
110
-
111
- Configuration object needed for `TourProvider`.
112
-
113
- ```tsx
114
- interface TourConfig {
115
- /**
116
- * Animation configuration for the spotlight movement.
117
- * You can use presets like WigglySpringConfig, GentleSpringConfig etc.
118
- */
119
- springConfig?: WithSpringConfig;
120
- /**
121
- * If true, prevents interaction with the underlying app while tour is active.
122
- */
123
- preventInteraction?: boolean;
124
- /**
125
- * Custom labels for buttons.
126
- */
127
- labels?: {
128
- next?: string;
129
- previous?: string;
130
- finish?: string;
131
- skip?: string;
132
- };
133
- /**
134
- * Custom renderer for the card/tooltip.
135
- */
136
- renderCard?: (props: CardProps) => React.ReactNode;
137
- /**
138
- * Initial overlay opacity. Default 0.5
139
- */
140
- backdropOpacity?: number;
141
- }
142
- ```
143
-
144
- ## Customization Guide
145
-
146
- ### Animation Presets
147
-
148
- React Native Lumen comes with built-in Reanimated spring configs for easy usage.
149
-
150
- ```tsx
151
- import { TourProvider, WigglySpringConfig } from 'react-native-lumen';
152
-
153
- <TourProvider config={{ springConfig: WigglySpringConfig }}>...</TourProvider>;
154
- ```
155
-
156
- ### Auto Scroll Support
157
-
158
- React Native Lumen supports auto-scrolling to steps that are off-screen. To enable this, simply attach the `scrollViewRef` provided by the hook to your scroll container.
159
-
160
- ```tsx
161
- import { useTour } from 'react-native-lumen';
162
- import Animated from 'react-native-reanimated';
163
-
164
- const MyScrollableScreen = () => {
165
- const { scrollViewRef } = useTour();
166
-
167
- return (
168
- <Animated.ScrollView ref={scrollViewRef}>
169
- {/* ... content with TourZones ... */}
170
- </Animated.ScrollView>
171
- );
172
- };
173
- ```
174
-
175
- > **Note:** The scroll view must be compatible with Reanimated refs (e.g. `Animated.ScrollView`).
176
-
177
- Available presets:
178
-
179
- - `Reanimated3DefaultSpringConfig`
180
- - `WigglySpringConfig` (Bouncy)
181
- - `GentleSpringConfig` (Smooth)
182
- - `SnappySpringConfig` (Fast & Responsive)
183
- - `and more!`
184
-
185
- ### Custom Tooltip Card
186
-
187
- You can fully replace the default tooltip with your own beautiful UI using the `renderCard` prop in `config`.
188
-
189
- ```tsx
190
- import { TourProvider, CardProps } from 'react-native-lumen';
191
-
192
- const CustomCard = ({
193
- step,
194
- next,
195
- prev,
196
- stop,
197
- isLast,
198
- currentStepIndex,
199
- totalSteps,
200
- }: CardProps) => (
201
- <View style={{ padding: 20, backgroundColor: 'white', borderRadius: 20 }}>
202
- <Text style={{ fontWeight: 'bold', fontSize: 20 }}>{step.name}</Text>
203
- <Text>{step.description}</Text>
204
- <Text style={{ color: 'gray' }}>
205
- Step {currentStepIndex + 1} of {totalSteps}
206
- </Text>
207
-
208
- <View style={{ flexDirection: 'row', marginTop: 10 }}>
209
- <Button onPress={stop} title="Close" />
210
- <View style={{ flex: 1 }} />
211
- {!isLast ? (
212
- <Button onPress={next} title="Next" />
213
- ) : (
214
- <Button onPress={stop} title="Finish" />
215
- )}
216
- </View>
217
- </View>
218
- );
219
-
220
- export default function App() {
221
- return (
222
- <TourProvider config={{ renderCard: (props) => <CustomCard {...props} /> }}>
223
- <AppContent />
224
- </TourProvider>
225
- );
226
- }
227
- ```
228
-
229
- ## License
230
-
231
- MIT
1
+ # React Native Lumen 💡
2
+
3
+ [![npm version](https://img.shields.io/npm/v/react-native-lumen.svg)](https://www.npmjs.com/package/react-native-lumen)
4
+
5
+ > A high-performance, fully customizable app tour library for React Native, powered by Reanimated 3.
6
+
7
+ ![Banner](./assets/banner.png)
8
+
9
+ ## Demo
10
+
11
+ <p>
12
+ <img src="./assets/showcase1.gif" width="220" alt="App Tour Demo" />
13
+ <img src="./assets/showcase2.gif" width="220" alt="App Tour Demo" />
14
+ </p>
15
+
16
+ ## Features
17
+
18
+ - **High Performance**: Built with `react-native-reanimated` worklets for 60fps animations.
19
+ - 🎨 **Fully Customizable**: Custom Renderers for tooltips, customizable shapes, and backdrops.
20
+ - 🌟 **Glow Effects**: Beautiful, customizable glow effects around your highlighted elements.
21
+ - 📱 **Expo Compatible**: Works seamlessly with Expo and bare React Native projects.
22
+ - 🤸 **Smooth Transitions**: Fluid morphing animations between steps.
23
+ - ✨ **Animation Presets**: Ships with beautiful bouncy, gentle, and snappy spring presets.
24
+ - 📜 **Auto Scrolling**: Automatically scrolls to next steps.
25
+ - 👆 **Interaction Control**: Choose to block or allow interactions with the underlying app.
26
+ - 🔒 **Step Enforcement**: Gate step progression with `required` and `completed` props.
27
+ - 📱 **Multi-Screen Tours**: Seamlessly run tours across multiple screens/tabs with screen-grouped step ordering.
28
+
29
+ ## Requirements
30
+
31
+ This library relies on strict peer dependencies to ensure performance:
32
+
33
+ - `react-native` >= 0.70.0
34
+ - `react-native-reanimated` >= 3.0.0
35
+ - `react-native-svg` >= 12.0.0
36
+ - `react-native-gesture-handler` >= 2.0.0
37
+
38
+ ## Installation
39
+
40
+ ```sh
41
+ npm install react-native-lumen react-native-reanimated react-native-svg react-native-gesture-handler react-native-worklets
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ > **Note**: For a complete, running example showcasing different configurations and styles, check out the `example` folder in this repository.
47
+
48
+ 1. **Wrap your App with `TourProvider`**:
49
+
50
+ ```tsx
51
+ import { TourProvider, SnappySpringConfig } from 'react-native-lumen';
52
+
53
+ export default function App() {
54
+ return (
55
+ <TourProvider
56
+ stepsOrder={['bio', 'prompt', 'poll']}
57
+ config={{
58
+ springConfig: SnappySpringConfig,
59
+ enableGlow: true, // Enable the glow effect globally
60
+ // See config details below
61
+ }}
62
+ >
63
+ <YourComponentThatNeedsTouring />
64
+ </TourProvider>
65
+ );
66
+ }
67
+ ```
68
+
69
+ 2. **Highlight Elements with `TourZone`**:
70
+
71
+ ```tsx
72
+ import { TourZone } from 'react-native-lumen';
73
+
74
+ <TourZone
75
+ stepKey="step-1"
76
+ name="My Feature"
77
+ description="This is an awesome feature you should know about."
78
+ order={1}
79
+ borderRadius={10}
80
+ >
81
+ <MyButton />
82
+ </TourZone>;
83
+ ```
84
+
85
+ 3. **Control the Tour**:
86
+
87
+ ```tsx
88
+ import { useTour } from 'react-native-lumen';
89
+
90
+ const MyComponent = () => {
91
+ const { start } = useTour();
92
+ return <Button title="Start Tour" onPress={() => start()} />;
93
+ };
94
+ ```
95
+
96
+ ## API Documentation
97
+
98
+ ### `TourProvider`
99
+
100
+ The main context provider. Place this at the root of your application.
101
+
102
+ | Prop | Type | Default | Description |
103
+ | :---------------- | :------------------------------------- | :---------- | :---------------------------------------------------- |
104
+ | `children` | `React.ReactNode` | Required | Application content. |
105
+ | `stepsOrder` | `string[] \| Record<string, string[]>` | `undefined` | Step ordering. Flat array or screen-grouped object. |
106
+ | `backdropOpacity` | `number` | `0.5` | Opacity of the dark background overlay (0-1). |
107
+ | `config` | `TourConfig` | `undefined` | Global configuration options, including `enableGlow`. |
108
+
109
+ ### `TourZone`
110
+
111
+ Wrapper component to register an element as a tour step. All styling props can also be passed via the `zoneStyle` object prop.
112
+
113
+ | Prop | Type | Default | Description |
114
+ | :------------------- | :------------------------------------- | :--------------- | :--------------------------------------------------- |
115
+ | `stepKey` | `string` | Required | Unique identifier for the step. |
116
+ | `name` | `string` | `undefined` | Title of the step. |
117
+ | `description` | `string` | Required | Description text shown in the tooltip. |
118
+ | `order` | `number` | `undefined` | Order of appearance (if `stepsOrder` not used). |
119
+ | `shape` | `'rounded-rect' \| 'circle' \| 'pill'` | `'rounded-rect'` | Shape of the zone cutout. |
120
+ | `borderRadius` | `number` | `10` | Border radius of the zone (for rounded-rect). |
121
+ | `clickable` | `boolean` | `false` | If `true`, the step remains interactive. |
122
+ | `preventInteraction` | `boolean` | `undefined` | Overrides global `preventInteraction` for this step. |
123
+ | `required` | `boolean` | `false` | If `true`, hides the skip button for this step. |
124
+ | `completed` | `boolean` | `undefined` | If `false`, disables the next button until `true`. |
125
+ | `style` | `ViewStyle` | `undefined` | Style for the wrapping container. |
126
+ | `zonePadding` | `number` | `0` | Uniform padding around the highlighted element. |
127
+ | `zonePaddingTop` | `number` | `undefined` | Top padding override. |
128
+ | `zonePaddingRight` | `number` | `undefined` | Right padding override. |
129
+ | `zonePaddingBottom` | `number` | `undefined` | Bottom padding override. |
130
+ | `zonePaddingLeft` | `number` | `undefined` | Left padding override. |
131
+ | `zoneBorderWidth` | `number` | `0` | Width of the zone border. |
132
+ | `zoneBorderColor` | `string` | `'transparent'` | Color of the zone border. |
133
+ | `zoneGlowColor` | `string` | `'#FFFFFF'` | Color of the outer glow effect. |
134
+ | `zoneGlowRadius` | `number` | `10` | Blur radius of the glow effect. |
135
+ | `zoneGlowSpread` | `number` | `5` | Spread radius of the glow effect. |
136
+ | `zoneGlowOffsetX` | `number` | `0` | Horizontal offset of the glow effect. |
137
+ | `zoneGlowOffsetY` | `number` | `0` | Vertical offset of the glow effect. |
138
+ | `zoneStyle` | `ZoneStyle` | `undefined` | Complete zone style object (groups above props). |
139
+ | `renderCustomCard` | `(props) => ReactNode` | `undefined` | Custom render function for this step's card. |
140
+
141
+ ### `TourConfig`
142
+
143
+ Configuration object needed for `TourProvider`.
144
+
145
+ ```tsx
146
+ import { SnappySpringConfig, WigglySpringConfig } from 'react-native-lumen';
147
+
148
+ interface TourConfig {
149
+ /**
150
+ * Animation configuration for the zone movement.
151
+ * You can use presets like WigglySpringConfig, GentleSpringConfig etc.
152
+ */
153
+ springConfig?: WithSpringConfig;
154
+ /**
155
+ * If true, prevents interaction with the underlying app while tour is active.
156
+ */
157
+ preventInteraction?: boolean;
158
+ /**
159
+ * Custom labels for buttons.
160
+ */
161
+ labels?: {
162
+ next?: string;
163
+ previous?: string;
164
+ finish?: string;
165
+ skip?: string;
166
+ };
167
+ /**
168
+ * Custom renderer for the card/tooltip.
169
+ */
170
+ renderCard?: (props: CardProps) => React.ReactNode;
171
+ /**
172
+ * Initial overlay opacity. Default 0.5
173
+ */
174
+ backdropOpacity?: number;
175
+ /**
176
+ * Global zone style settings.
177
+ * Can be overridden per-step via TourZone props.
178
+ */
179
+ zoneStyle?: ZoneStyle;
180
+ /**
181
+ * Persistence configuration for saving/restoring tour progress.
182
+ */
183
+ persistence?: TourPersistenceConfig;
184
+ /**
185
+ * Defines whether to apply a shadow/glow effect to the active tour zone highlight.
186
+ */
187
+ enableGlow?: boolean;
188
+ /**
189
+ * Custom styles for the default tooltip appearance.
190
+ */
191
+ tooltipStyles?: TooltipStyles;
192
+ }
193
+ ```
194
+
195
+ ### `ZoneStyle`
196
+
197
+ Customization options for the zone appearance.
198
+
199
+ ```tsx
200
+ interface ZoneStyle {
201
+ padding?: number; // Uniform padding around the element
202
+ paddingTop?: number; // Top padding override
203
+ paddingRight?: number; // Right padding override
204
+ paddingBottom?: number; // Bottom padding override
205
+ paddingLeft?: number; // Left padding override
206
+ borderRadius?: number; // Border radius for 'rounded-rect' shape
207
+ shape?: 'rounded-rect' | 'circle' | 'pill'; // Zone shape
208
+ borderWidth?: number; // Border ring width
209
+ borderColor?: string; // Border color
210
+ glowColor?: string; // Outer glow color (use rgba/hex-alpha for opacity) (requires enableGlow: true)
211
+ glowRadius?: number; // Glow blur radius (requires enableGlow: true)
212
+ glowSpread?: number; // Glow spread radius (requires enableGlow: true)
213
+ glowOffsetX?: number; // Horizontal offset for the glow (requires enableGlow: true)
214
+ glowOffsetY?: number; // Vertical offset for the glow (requires enableGlow: true)
215
+ springDamping?: number; // Per-step spring damping override
216
+ springStiffness?: number; // Per-step spring stiffness override
217
+ }
218
+ ```
219
+
220
+ ### `CardProps`
221
+
222
+ Props passed to custom card render functions (`renderCard`, `renderCustomCard`).
223
+
224
+ ```tsx
225
+ interface CardProps {
226
+ step: TourStep;
227
+ currentStepIndex: number;
228
+ totalSteps: number;
229
+ next: () => void;
230
+ prev: () => void;
231
+ stop: () => void;
232
+ isFirst: boolean;
233
+ isLast: boolean;
234
+ labels?: TourLabels;
235
+ required?: boolean; // Whether skip should be hidden
236
+ completed?: boolean; // Whether next should be disabled (false = disabled)
237
+ }
238
+ ```
239
+
240
+ ## Step Enforcement
241
+
242
+ Use `required` and `completed` props on `TourZone` to control how users progress through the tour.
243
+
244
+ ### `required` - Hide the Skip Button
245
+
246
+ When `required={true}`, the skip button is hidden. The user must complete the step or press next to continue.
247
+
248
+ ```tsx
249
+ <TourZone
250
+ stepKey="bio"
251
+ order={1}
252
+ description="Edit your bio before continuing."
253
+ required={true}
254
+ >
255
+ <Bio user={user} />
256
+ </TourZone>
257
+ ```
258
+
259
+ ### `completed` - Gate the Next Button
260
+
261
+ When `completed` is set to `false`, the next/finish button is disabled (grayed out, non-pressable). Once the condition is met and `completed` becomes `true`, the button enables.
262
+
263
+ ```tsx
264
+ const [tourComplete, setTourComplete] = useState(false);
265
+
266
+ <TourZone
267
+ stepKey="bio"
268
+ order={1}
269
+ description="Double tap to edit your bio and tell others about yourself."
270
+ required={true}
271
+ completed={tourComplete}
272
+ >
273
+ <Bio
274
+ user={User}
275
+ onUpdateBio={(newBio) => {
276
+ updateBio(newBio);
277
+ setTourComplete(true);
278
+ }}
279
+ />
280
+ </TourZone>;
281
+ ```
282
+
283
+ ### Combining `required` and `completed`
284
+
285
+ Use both props together for full enforcement:
286
+
287
+ - `required={true}` - No skip button, user cannot bypass the step.
288
+ - `completed={tourComplete}` - Next button is disabled until `tourComplete` is `true`.
289
+
290
+ This is useful for onboarding flows where you need the user to perform an action (e.g., edit their bio, upload a photo) before proceeding.
291
+
292
+ ### Enforcement in Custom Cards
293
+
294
+ When using `renderCard` or `renderCustomCard`, the `required` and `completed` values are passed through `CardProps`. You can use them to control your custom UI:
295
+
296
+ ```tsx
297
+ const MyCustomCard = ({ step, next, stop, required, completed }: CardProps) => (
298
+ <View style={styles.card}>
299
+ <Text>{step.description}</Text>
300
+ <View style={styles.buttons}>
301
+ {!required && <Button onPress={stop} title="Skip" />}
302
+ <Button
303
+ onPress={next}
304
+ title="Next"
305
+ disabled={completed === false}
306
+ color={completed === false ? '#ccc' : '#007AFF'}
307
+ />
308
+ </View>
309
+ </View>
310
+ );
311
+ ```
312
+
313
+ ## Multi-Screen Tours
314
+
315
+ React Native Lumen supports tours that span multiple screens (e.g., tabs in a bottom navigation bar). This is common when your app has separate screens for profile, home, settings, etc.
316
+
317
+ ### The Problem
318
+
319
+ When using a navigator (e.g., `BottomTabNavigator`, `CurvedBottomBar`), TourZones on inactive screens are not mounted. If the tour tries to advance to a step on an unmounted screen, it would fail because that step hasn't been registered or measured.
320
+
321
+ ### The Solution: Screen-Grouped `stepsOrder`
322
+
323
+ Pass `stepsOrder` as an object where keys are screen names and values are arrays of step keys:
324
+
325
+ ```tsx
326
+ <TourProvider
327
+ stepsOrder={{
328
+ ProfileSelf: ['bio', 'prompt', 'poll'],
329
+ HomeSwipe: ['filters'],
330
+ SwipeableCards: ['swipeableCards'],
331
+ }}
332
+ config={{
333
+ springConfig: SnappySpringConfig,
334
+ preventInteraction: true,
335
+ persistence: {
336
+ enabled: true,
337
+ tourId: 'main-tour',
338
+ autoResume: true,
339
+ clearOnComplete: true,
340
+ },
341
+ }}
342
+ >
343
+ <CurvedBottomBar.Navigator ...>
344
+ {/* screens */}
345
+ </CurvedBottomBar.Navigator>
346
+ </TourProvider>
347
+ ```
348
+
349
+ This is equivalent to a flat array in terms of step ordering:
350
+
351
+ ```tsx
352
+ stepsOrder={['bio', 'prompt', 'poll', 'filters', 'swipeableCards']}
353
+ ```
354
+
355
+ But with the screen-grouped format, the library knows which steps belong to which screen. When the tour advances to a step on a different screen:
356
+
357
+ 1. The overlay hides automatically.
358
+ 2. The tour enters a **pending** state, waiting for that step's `TourZone` to mount.
359
+ 3. When the user navigates to the correct screen and the `TourZone` mounts, the tour resumes automatically.
360
+
361
+ ### Flat Array (Also Works Cross-Screen)
362
+
363
+ You can also use a flat array for multi-screen tours. The behavior is the same: if the next step isn't mounted, the tour waits for it:
364
+
365
+ ```tsx
366
+ stepsOrder={['bio', 'prompt', 'poll', 'filters', 'swipeableCards']}
367
+ ```
368
+
369
+ ### Example: Multi-Screen Tour
370
+
371
+ ```tsx
372
+ // App.tsx
373
+ <TourProvider
374
+ stepsOrder={{
375
+ ProfileSelf: ['bio', 'prompt', 'poll'],
376
+ HomeSwipe: ['filters'],
377
+ SwipeableCards: ['swipeableCards'],
378
+ }}
379
+ config={{ springConfig: SnappySpringConfig }}
380
+ >
381
+ <BottomTabNavigator />
382
+ </TourProvider>
383
+
384
+ // ProfileSelf.tsx
385
+ <TourZone stepKey="bio" order={1} description="Edit your bio.">
386
+ <Bio />
387
+ </TourZone>
388
+
389
+ <TourZone stepKey="prompt" order={2} description="Add prompts.">
390
+ <PromptCard />
391
+ </TourZone>
392
+
393
+ <TourZone stepKey="poll" order={3} description="Create polls.">
394
+ <PollCard />
395
+ </TourZone>
396
+
397
+ // HomeSwipe.tsx
398
+ <TourZone stepKey="filters" order={1} description="Filter your matches.">
399
+ <FilterButton />
400
+ </TourZone>
401
+
402
+ // SwipeableCards.tsx
403
+ <TourZone stepKey="swipeableCards" order={1} description="Swipe to match!">
404
+ <CardStack />
405
+ </TourZone>
406
+ ```
407
+
408
+ When the tour finishes the ProfileSelf steps and calls `next()` on the last ProfileSelf step (`poll`), the overlay hides. Once the user navigates to HomeSwipe, the `filters` TourZone mounts and the tour automatically resumes.
409
+
410
+ ## Tour Control (`useTour` Hook)
411
+
412
+ The `useTour` hook provides full control over the tour lifecycle.
413
+
414
+ ```tsx
415
+ import { useTour } from 'react-native-lumen';
416
+
417
+ const {
418
+ start, // Start or resume the tour
419
+ stop, // Stop the tour (hides overlay, preserves progress)
420
+ next, // Advance to the next step
421
+ prev, // Go back to the previous step
422
+ currentStep, // Currently active step key (null if inactive)
423
+ steps, // Map of all registered steps
424
+ orderedStepKeys, // Full ordered list of step keys
425
+ clearProgress, // Clear saved progress from storage
426
+ hasSavedProgress, // Whether there's saved progress to resume
427
+ scrollViewRef, // Attach to your ScrollView for auto-scrolling
428
+ } = useTour();
429
+ ```
430
+
431
+ ### `start(stepKey?: string)`
432
+
433
+ Starts (or resumes) the tour.
434
+
435
+ - **No arguments**: Starts at the first step. If persistence is enabled with `autoResume: true`, resumes from the last saved step.
436
+ - **With `stepKey`**: Starts at the specified step.
437
+ - If the target step is not mounted yet (on a different screen), the tour enters a pending state and automatically resumes when the step's `TourZone` mounts.
438
+
439
+ ```tsx
440
+ // Start from the beginning (or resume if autoResume is enabled)
441
+ start();
442
+
443
+ // Start at a specific step
444
+ start('filters');
445
+ ```
446
+
447
+ ### `stop()`
448
+
449
+ Stops the tour and hides the overlay. Does **NOT** clear saved progress. The user can resume later by calling `start()` again.
450
+
451
+ ```tsx
452
+ stop();
453
+ ```
454
+
455
+ ### `next()`
456
+
457
+ Advances to the next step. If the current step has `completed={false}`, the call is ignored (the user must complete the step first).
458
+
459
+ If the next step is on an unmounted screen, the overlay hides and the tour waits for that step to mount.
460
+
461
+ On the last step, `next()` ends the tour and clears progress if `clearOnComplete: true`.
462
+
463
+ ### `prev()`
464
+
465
+ Goes back to the previous step. If the previous step is on an unmounted screen, the overlay hides and the tour waits for it to mount.
466
+
467
+ ### `clearProgress()`
468
+
469
+ Manually clears all saved progress from storage. Useful for a "Reset Tour" button.
470
+
471
+ ```tsx
472
+ const { clearProgress } = useTour();
473
+
474
+ const handleResetTour = async () => {
475
+ await clearProgress();
476
+ };
477
+ ```
478
+
479
+ ## Customization Guide
480
+
481
+ ### Zone Shapes
482
+
483
+ React Native Lumen supports three zone shapes:
484
+
485
+ ```tsx
486
+ // Rounded rectangle (default)
487
+ <TourZone stepKey="feature" shape="rounded-rect" borderRadius={12}>
488
+ <MyComponent />
489
+ </TourZone>
490
+
491
+ // Circle - great for FAB buttons
492
+ <TourZone stepKey="action" shape="circle">
493
+ <FloatingActionButton />
494
+ </TourZone>
495
+
496
+ // Pill - great for horizontal elements like tag rows
497
+ <TourZone stepKey="tags" shape="pill">
498
+ <TagList />
499
+ </TourZone>
500
+ ```
501
+
502
+ ### Glow Styles & Per-Step Zone Styling
503
+
504
+ React Native Lumen features an optional glow effect around the highlighted zone, which can bring a beautiful focus to your UI elements.
505
+
506
+ **1. Enable Glow Globally**
507
+ Set `enableGlow: true` in your `TourProvider` config. This allows the glow effect to render.
508
+
509
+ ```tsx
510
+ <TourProvider config={{ enableGlow: true }}>{/* App Content */}</TourProvider>
511
+ ```
512
+
513
+ **2. Customize Per-Step styles**
514
+ You can customize the standard padding, border, and glow effects per-step using individual `zone*` props or the `zoneStyle` object:
515
+
516
+ ```tsx
517
+ // Using individual props
518
+ <TourZone
519
+ stepKey="important"
520
+ zoneGlowColor="rgba(255, 107, 107, 0.6)"
521
+ zoneBorderColor="#FF6B6B"
522
+ zoneGlowSpread={5}
523
+ zoneGlowOffsetY={2}
524
+ zonePadding={16}
525
+ >
526
+ <ImportantFeature />
527
+ </TourZone>
528
+
529
+ // Using zoneStyle object
530
+ <TourZone
531
+ stepKey="premium"
532
+ zoneStyle={{
533
+ shape: 'pill',
534
+ glowColor: 'rgba(255, 215, 0, 0.5)',
535
+ borderColor: '#FFD700',
536
+ borderWidth: 3,
537
+ }}
538
+ >
539
+ <PremiumBadge />
540
+ </TourZone>
541
+ ```
542
+
543
+ ### Per-Step Custom Cards
544
+
545
+ Render custom tooltip cards for specific steps:
546
+
547
+ ```tsx
548
+ <TourZone
549
+ stepKey="special"
550
+ renderCustomCard={({ step, next, stop, currentStepIndex, totalSteps }) => (
551
+ <View style={styles.customCard}>
552
+ <Text>{step.name}</Text>
553
+ <Text>{step.description}</Text>
554
+ <Button title="Continue" onPress={next} />
555
+ </View>
556
+ )}
557
+ >
558
+ <SpecialFeature />
559
+ </TourZone>
560
+ ```
561
+
562
+ ### Animation Presets
563
+
564
+ React Native Lumen comes with built-in Reanimated spring configs for easy usage.
565
+
566
+ ```tsx
567
+ import { TourProvider, WigglySpringConfig } from 'react-native-lumen';
568
+
569
+ <TourProvider config={{ springConfig: WigglySpringConfig }}>...</TourProvider>;
570
+ ```
571
+
572
+ ### Auto Scroll Support
573
+
574
+ React Native Lumen supports auto-scrolling to steps that are off-screen. It perfectly handles long scrollable lists by detecting exactly when the scroll animation finishes before snapping the highlight, ensuring the UI remains smooth.
575
+
576
+ To enable this, use the `useTourScrollView` hook and spread its props onto your scroll container:
577
+
578
+ ```tsx
579
+ import { useTourScrollView } from 'react-native-lumen';
580
+ import Animated from 'react-native-reanimated';
581
+
582
+ const MyScrollableScreen = () => {
583
+ const { scrollViewProps } = useTourScrollView({
584
+ // Optional: disable user scrolling while the tour is active
585
+ disableScrollDuringTour: true,
586
+ });
587
+
588
+ return (
589
+ <Animated.ScrollView {...scrollViewProps}>
590
+ {/* ... content with TourZones ... */}
591
+ </Animated.ScrollView>
592
+ );
593
+ };
594
+ ```
595
+
596
+ > **Note:** The scroll view must be compatible with Reanimated refs (e.g. `Animated.ScrollView`). Spreading `scrollViewProps` automatically wires up the `ref`, `scrollEnabled`, and the `onMomentumScrollEnd` event needed for perfect scroll-end detection and smooth transitions.
597
+
598
+ Available presets:
599
+
600
+ - `Reanimated3DefaultSpringConfig`
601
+ - `WigglySpringConfig` (Bouncy)
602
+ - `GentleSpringConfig` (Smooth)
603
+ - `SnappySpringConfig` (Fast & Responsive)
604
+ - `and more!`
605
+
606
+ ### Custom Tooltip Card
607
+
608
+ You can fully replace the default tooltip with your own beautiful UI using the `renderCard` prop in `config`.
609
+
610
+ ```tsx
611
+ import { TourProvider, CardProps } from 'react-native-lumen';
612
+
613
+ const CustomCard = ({
614
+ step,
615
+ next,
616
+ prev,
617
+ stop,
618
+ isLast,
619
+ currentStepIndex,
620
+ totalSteps,
621
+ required,
622
+ completed,
623
+ }: CardProps) => (
624
+ <View style={{ padding: 20, backgroundColor: 'white', borderRadius: 20 }}>
625
+ <Text style={{ fontWeight: 'bold', fontSize: 20 }}>{step.name}</Text>
626
+ <Text>{step.description}</Text>
627
+ <Text style={{ color: 'gray' }}>
628
+ Step {currentStepIndex + 1} of {totalSteps}
629
+ </Text>
630
+
631
+ <View style={{ flexDirection: 'row', marginTop: 10 }}>
632
+ {!required && <Button onPress={stop} title="Close" />}
633
+ <View style={{ flex: 1 }} />
634
+ {!isLast ? (
635
+ <Button onPress={next} title="Next" disabled={completed === false} />
636
+ ) : (
637
+ <Button onPress={next} title="Finish" disabled={completed === false} />
638
+ )}
639
+ </View>
640
+ </View>
641
+ );
642
+
643
+ export default function App() {
644
+ return (
645
+ <TourProvider config={{ renderCard: (props) => <CustomCard {...props} /> }}>
646
+ <AppContent />
647
+ </TourProvider>
648
+ );
649
+ }
650
+ ```
651
+
652
+ ### Persistence (Resume Tours)
653
+
654
+ React Native Lumen supports saving tour progress so users can resume where they left off. The library auto-detects available storage (MMKV v4 or AsyncStorage).
655
+
656
+ ```tsx
657
+ import { TourProvider } from 'react-native-lumen';
658
+
659
+ export default function App() {
660
+ return (
661
+ <TourProvider
662
+ config={{
663
+ persistence: {
664
+ enabled: true,
665
+ tourId: 'onboarding-v1', // Unique ID for this tour
666
+ autoResume: true, // Auto-resume from saved step (default: true)
667
+ clearOnComplete: true, // Clear progress when tour finishes (default: true)
668
+ maxAge: 7 * 24 * 60 * 60 * 1000, // Optional: expire after 7 days
669
+ },
670
+ }}
671
+ >
672
+ <AppContent />
673
+ </TourProvider>
674
+ );
675
+ }
676
+ ```
677
+
678
+ #### Storage Support
679
+
680
+ The library automatically detects and uses:
681
+
682
+ - **MMKV v4** (`react-native-mmkv` ^4.0.0) - Fastest, recommended
683
+ - **AsyncStorage** (`@react-native-async-storage/async-storage`) - Fallback
684
+
685
+ No additional setup required if either package is installed.
686
+
687
+ #### Custom Storage
688
+
689
+ You can provide a custom storage adapter:
690
+
691
+ ```tsx
692
+ import { TourProvider, type StorageAdapter } from 'react-native-lumen';
693
+
694
+ const customStorage: StorageAdapter = {
695
+ getItem: (key) => myStorage.get(key),
696
+ setItem: (key, value) => myStorage.set(key, value),
697
+ removeItem: (key) => myStorage.remove(key),
698
+ };
699
+
700
+ <TourProvider
701
+ config={{
702
+ persistence: {
703
+ enabled: true,
704
+ tourId: 'my-tour',
705
+ storage: customStorage,
706
+ },
707
+ }}
708
+ >
709
+ ...
710
+ </TourProvider>;
711
+ ```
712
+
713
+ #### Persistence API
714
+
715
+ ```tsx
716
+ const { start, clearProgress, hasSavedProgress } = useTour();
717
+
718
+ // Check if there's saved progress
719
+ if (hasSavedProgress) {
720
+ // Show "Resume Tour" button
721
+ }
722
+
723
+ // Start tour (auto-resumes if enabled)
724
+ start();
725
+
726
+ // Clear saved progress manually
727
+ await clearProgress();
728
+ ```
729
+
730
+ #### Manually Clearing Storage
731
+
732
+ If you need to clear tour data directly from storage outside the tour context (e.g., during logout or a full app reset):
733
+
734
+ **MMKV v4:**
735
+
736
+ ```tsx
737
+ import { createMMKV } from 'react-native-mmkv';
738
+
739
+ // The library uses a dedicated MMKV instance with this ID
740
+ const storage = createMMKV({ id: 'react-native-lumen-tour' });
741
+
742
+ // Clear a specific tour
743
+ storage.remove('@lumen_tour_onboarding-v1');
744
+
745
+ // Or clear all tour data - delete all keys starting with @lumen_tour_
746
+ const allKeys = storage.getAllKeys();
747
+ allKeys
748
+ .filter((key) => key.startsWith('@lumen_tour_'))
749
+ .forEach((key) => storage.remove(key));
750
+ ```
751
+
752
+ **AsyncStorage:**
753
+
754
+ ```tsx
755
+ import AsyncStorage from '@react-native-async-storage/async-storage';
756
+
757
+ // Clear a specific tour
758
+ await AsyncStorage.removeItem('@lumen_tour_onboarding-v1');
759
+
760
+ // Or clear all tour data
761
+ const allKeys = await AsyncStorage.getAllKeys();
762
+ const tourKeys = allKeys.filter((key) => key.startsWith('@lumen_tour_'));
763
+ await AsyncStorage.multiRemove(tourKeys);
764
+ ```
765
+
766
+ The storage key format is `@lumen_tour_{tourId}` where `tourId` is the value you passed in `persistence.tourId`.
767
+
768
+ ## License
769
+
770
+ MIT