@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.
Files changed (59) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +383 -383
  3. package/dist/components/NavigationButtons.d.ts +23 -0
  4. package/dist/components/NavigationButtons.d.ts.map +1 -0
  5. package/dist/components/NavigationButtons.js +106 -0
  6. package/dist/components/Onboarding.d.ts +11 -0
  7. package/dist/components/Onboarding.d.ts.map +1 -0
  8. package/dist/components/Onboarding.js +219 -0
  9. package/dist/components/Pagination.d.ts +5 -0
  10. package/dist/components/Pagination.d.ts.map +1 -0
  11. package/dist/components/Pagination.js +269 -0
  12. package/dist/components/SimpleOnboardingScreen.d.ts +54 -0
  13. package/dist/components/SimpleOnboardingScreen.d.ts.map +1 -0
  14. package/dist/components/SimpleOnboardingScreen.js +184 -0
  15. package/dist/components/index.d.ts +7 -0
  16. package/dist/components/index.d.ts.map +1 -0
  17. package/dist/components/index.js +5 -0
  18. package/dist/index.d.ts +9 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +12 -0
  21. package/dist/presets/index.d.ts +27 -0
  22. package/dist/presets/index.d.ts.map +1 -0
  23. package/dist/presets/index.js +370 -0
  24. package/dist/slides/FormSlide.d.ts +12 -0
  25. package/dist/slides/FormSlide.d.ts.map +1 -0
  26. package/dist/slides/FormSlide.js +227 -0
  27. package/dist/slides/IconSlide.d.ts +10 -0
  28. package/dist/slides/IconSlide.d.ts.map +1 -0
  29. package/dist/slides/IconSlide.js +133 -0
  30. package/dist/slides/ImageSlide.d.ts +10 -0
  31. package/dist/slides/ImageSlide.d.ts.map +1 -0
  32. package/dist/slides/ImageSlide.js +99 -0
  33. package/dist/slides/VideoSlide.d.ts +10 -0
  34. package/dist/slides/VideoSlide.d.ts.map +1 -0
  35. package/dist/slides/VideoSlide.js +101 -0
  36. package/dist/slides/index.d.ts +14 -0
  37. package/dist/slides/index.d.ts.map +1 -0
  38. package/dist/slides/index.js +25 -0
  39. package/dist/themes/index.d.ts +35 -0
  40. package/dist/themes/index.d.ts.map +1 -0
  41. package/dist/themes/index.js +547 -0
  42. package/dist/types/index.d.ts +191 -0
  43. package/dist/types/index.d.ts.map +1 -0
  44. package/dist/types/index.js +1 -0
  45. package/package.json +73 -60
  46. package/src/components/NavigationButtons.tsx +198 -198
  47. package/src/components/Onboarding.tsx +337 -340
  48. package/src/components/Pagination.tsx +337 -337
  49. package/src/components/SimpleOnboardingScreen.tsx +266 -0
  50. package/src/components/index.ts +7 -5
  51. package/src/index.ts +69 -65
  52. package/src/presets/index.ts +391 -394
  53. package/src/slides/FormSlide.tsx +314 -314
  54. package/src/slides/IconSlide.tsx +166 -166
  55. package/src/slides/ImageSlide.tsx +132 -132
  56. package/src/slides/VideoSlide.tsx +146 -146
  57. package/src/slides/{index.ts → index.tsx} +37 -44
  58. package/src/themes/index.ts +576 -574
  59. package/src/types/index.ts +247 -247
@@ -1,198 +1,198 @@
1
- import React, { useMemo } from 'react';
2
- import { View, Text, TouchableOpacity, StyleSheet, ActivityIndicator, ViewStyle, TextStyle, Platform } from 'react-native';
3
- import { BlurView } from 'expo-blur';
4
- import { LinearGradient } from 'expo-linear-gradient';
5
- import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
6
- import { Ionicons } from '@expo/vector-icons';
7
- import { NavigationButtonProps } from '../types';
8
-
9
- const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
10
-
11
- export const NavigationButton: React.FC<NavigationButtonProps> = ({
12
- label,
13
- onPress,
14
- theme,
15
- variant = 'primary',
16
- disabled = false,
17
- loading = false,
18
- style,
19
- textStyle,
20
- }) => {
21
- const buttonStyle = useMemo(() => {
22
- const base: ViewStyle = {
23
- ...styles.button,
24
- minHeight: 48,
25
- paddingHorizontal: 24,
26
- borderRadius: theme.borderRadius.full,
27
- alignItems: 'center',
28
- justifyContent: 'center',
29
- flexDirection: 'row',
30
- };
31
-
32
- switch (variant) {
33
- case 'primary':
34
- base.backgroundColor = theme.colors.primary;
35
- break;
36
- case 'secondary':
37
- base.backgroundColor = theme.colors.secondary;
38
- break;
39
- case 'ghost':
40
- base.backgroundColor = 'transparent';
41
- base.borderWidth = 1.5;
42
- base.borderColor = theme.colors.border;
43
- break;
44
- }
45
-
46
- return base;
47
- }, [theme, variant]);
48
-
49
- const buttonText = useMemo(() => {
50
- const base: TextStyle = {
51
- ...styles.buttonText,
52
- color: variant === 'ghost' ? theme.colors.text.primary : theme.colors.text.inverse,
53
- };
54
-
55
- return base;
56
- }, [theme, variant]);
57
-
58
- return (
59
- <AnimatedTouchableOpacity
60
- style={[buttonStyle, style]}
61
- onPress={onPress}
62
- disabled={disabled || loading}
63
- activeOpacity={0.8}
64
- entering={FadeIn}
65
- exiting={FadeOut}
66
- >
67
- {loading ? (
68
- <ActivityIndicator color={variant === 'ghost' ? theme.colors.text.primary : theme.colors.text.inverse} />
69
- ) : (
70
- <Text style={[buttonText, textStyle]}>{label}</Text>
71
- )}
72
- </AnimatedTouchableOpacity>
73
- );
74
- };
75
-
76
- interface NavigationButtonsProps {
77
- currentIndex: number;
78
- totalSlides: number;
79
- theme: any;
80
- config: any;
81
- onNext: () => void;
82
- onBack: () => void;
83
- onSkip: () => void;
84
- canGoNext?: boolean;
85
- isLastSlide?: boolean;
86
- isLoading?: boolean;
87
- darkMode?: boolean;
88
- }
89
-
90
- export const NavigationButtons: React.FC<NavigationButtonsProps> = ({
91
- currentIndex,
92
- totalSlides,
93
- theme,
94
- config,
95
- onNext,
96
- onBack,
97
- onSkip,
98
- canGoNext = true,
99
- isLastSlide = false,
100
- isLoading = false,
101
- darkMode = false,
102
- }) => {
103
- const { showSkip = true, showBack = true, skipLabel = 'Skip', backLabel = 'Back', nextLabel = 'Next', doneLabel = 'Get Started', position = 'bottom' } = config;
104
-
105
- const containerStyle: ViewStyle = useMemo(() => {
106
- const base: ViewStyle = {
107
- paddingHorizontal: theme.spacing.lg,
108
- paddingVertical: theme.spacing.md,
109
- gap: theme.spacing.sm,
110
- };
111
-
112
- if (position === 'floating') {
113
- base.position = 'absolute';
114
- base.bottom = theme.spacing.xl;
115
- base.left = theme.spacing.lg;
116
- base.right = theme.spacing.lg;
117
- }
118
-
119
- return base;
120
- }, [theme, position]);
121
-
122
- const isAtStart = currentIndex === 0;
123
-
124
- const buttons = (
125
- <>
126
- {/* Back Button */}
127
- {showBack && !isAtStart && (
128
- <NavigationButton
129
- label={backLabel}
130
- onPress={onBack}
131
- theme={theme}
132
- variant="ghost"
133
- />
134
- )}
135
-
136
- {/* Skip Button */}
137
- {showSkip && !isLastSlide && !isLoading && (
138
- <TouchableOpacity
139
- style={styles.skipButton}
140
- onPress={onSkip}
141
- activeOpacity={0.7}
142
- >
143
- <Text style={[styles.skipButtonText, { color: theme.colors.text.secondary }]}>
144
- {skipLabel}
145
- </Text>
146
- </TouchableOpacity>
147
- )}
148
-
149
- {/* Next/Done Button */}
150
- <NavigationButton
151
- label={isLastSlide ? doneLabel : nextLabel}
152
- onPress={onNext}
153
- theme={theme}
154
- variant="primary"
155
- disabled={!canGoNext}
156
- loading={isLoading}
157
- />
158
- </>
159
- );
160
-
161
- if (position === 'floating') {
162
- return (
163
- <BlurView intensity={80} tint={darkMode ? 'dark' : 'light'} style={containerStyle}>
164
- <View style={styles.buttonRow}>{buttons}</View>
165
- </BlurView>
166
- );
167
- }
168
-
169
- return <View style={containerStyle}>{buttons}</View>;
170
- };
171
-
172
- const styles = StyleSheet.create({
173
- button: {
174
- minWidth: 120,
175
- },
176
- buttonText: {
177
- fontSize: 16,
178
- fontWeight: '600',
179
- letterSpacing: 0.5,
180
- },
181
- buttonRow: {
182
- flexDirection: 'row',
183
- justifyContent: 'space-between',
184
- alignItems: 'center',
185
- },
186
- skipButton: {
187
- alignSelf: 'flex-end',
188
- paddingVertical: 8,
189
- paddingHorizontal: 4,
190
- marginRight: 8,
191
- },
192
- skipButtonText: {
193
- fontSize: 15,
194
- fontWeight: '500',
195
- },
196
- });
197
-
198
- export default { NavigationButton, NavigationButtons };
1
+ import React, { useMemo } from 'react';
2
+ import { View, Text, TouchableOpacity, StyleSheet, ActivityIndicator, ViewStyle, TextStyle, Platform } from 'react-native';
3
+ import { BlurView } from 'expo-blur';
4
+ import { LinearGradient } from 'expo-linear-gradient';
5
+ import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
6
+ import { Ionicons } from '@expo/vector-icons';
7
+ import { NavigationButtonProps } from '../types';
8
+
9
+ const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
10
+
11
+ export const NavigationButton: React.FC<NavigationButtonProps> = ({
12
+ label,
13
+ onPress,
14
+ theme,
15
+ variant = 'primary',
16
+ disabled = false,
17
+ loading = false,
18
+ style,
19
+ textStyle,
20
+ }) => {
21
+ const buttonStyle = useMemo(() => {
22
+ const base: ViewStyle = {
23
+ ...styles.button,
24
+ minHeight: 48,
25
+ paddingHorizontal: 24,
26
+ borderRadius: theme.borderRadius.full,
27
+ alignItems: 'center',
28
+ justifyContent: 'center',
29
+ flexDirection: 'row',
30
+ };
31
+
32
+ switch (variant) {
33
+ case 'primary':
34
+ base.backgroundColor = theme.colors.primary;
35
+ break;
36
+ case 'secondary':
37
+ base.backgroundColor = theme.colors.secondary;
38
+ break;
39
+ case 'ghost':
40
+ base.backgroundColor = 'transparent';
41
+ base.borderWidth = 1.5;
42
+ base.borderColor = theme.colors.border;
43
+ break;
44
+ }
45
+
46
+ return base;
47
+ }, [theme, variant]);
48
+
49
+ const buttonText = useMemo(() => {
50
+ const base: TextStyle = {
51
+ ...styles.buttonText,
52
+ color: variant === 'ghost' ? theme.colors.text.primary : theme.colors.text.inverse,
53
+ };
54
+
55
+ return base;
56
+ }, [theme, variant]);
57
+
58
+ return (
59
+ <AnimatedTouchableOpacity
60
+ style={[buttonStyle, style]}
61
+ onPress={onPress}
62
+ disabled={disabled || loading}
63
+ activeOpacity={0.8}
64
+ entering={FadeIn}
65
+ exiting={FadeOut}
66
+ >
67
+ {loading ? (
68
+ <ActivityIndicator color={variant === 'ghost' ? theme.colors.text.primary : theme.colors.text.inverse} />
69
+ ) : (
70
+ <Text style={[buttonText, textStyle]}>{label}</Text>
71
+ )}
72
+ </AnimatedTouchableOpacity>
73
+ );
74
+ };
75
+
76
+ interface NavigationButtonsProps {
77
+ currentIndex: number;
78
+ totalSlides: number;
79
+ theme: any;
80
+ config: any;
81
+ onNext: () => void;
82
+ onBack: () => void;
83
+ onSkip: () => void;
84
+ canGoNext?: boolean;
85
+ isLastSlide?: boolean;
86
+ isLoading?: boolean;
87
+ darkMode?: boolean;
88
+ }
89
+
90
+ export const NavigationButtons: React.FC<NavigationButtonsProps> = ({
91
+ currentIndex,
92
+ totalSlides,
93
+ theme,
94
+ config,
95
+ onNext,
96
+ onBack,
97
+ onSkip,
98
+ canGoNext = true,
99
+ isLastSlide = false,
100
+ isLoading = false,
101
+ darkMode = false,
102
+ }) => {
103
+ const { showSkip = true, showBack = true, skipLabel = 'Skip', backLabel = 'Back', nextLabel = 'Next', doneLabel = 'Get Started', position = 'bottom' } = config;
104
+
105
+ const containerStyle: ViewStyle = useMemo(() => {
106
+ const base: ViewStyle = {
107
+ paddingHorizontal: theme.spacing.lg,
108
+ paddingVertical: theme.spacing.md,
109
+ gap: theme.spacing.sm,
110
+ };
111
+
112
+ if (position === 'floating') {
113
+ base.position = 'absolute';
114
+ base.bottom = theme.spacing.xl;
115
+ base.left = theme.spacing.lg;
116
+ base.right = theme.spacing.lg;
117
+ }
118
+
119
+ return base;
120
+ }, [theme, position]);
121
+
122
+ const isAtStart = currentIndex === 0;
123
+
124
+ const buttons = (
125
+ <>
126
+ {/* Back Button */}
127
+ {showBack && !isAtStart && (
128
+ <NavigationButton
129
+ label={backLabel}
130
+ onPress={onBack}
131
+ theme={theme}
132
+ variant="ghost"
133
+ />
134
+ )}
135
+
136
+ {/* Skip Button */}
137
+ {showSkip && !isLastSlide && !isLoading && (
138
+ <TouchableOpacity
139
+ style={styles.skipButton}
140
+ onPress={onSkip}
141
+ activeOpacity={0.7}
142
+ >
143
+ <Text style={[styles.skipButtonText, { color: theme.colors.text.secondary }]}>
144
+ {skipLabel}
145
+ </Text>
146
+ </TouchableOpacity>
147
+ )}
148
+
149
+ {/* Next/Done Button */}
150
+ <NavigationButton
151
+ label={isLastSlide ? doneLabel : nextLabel}
152
+ onPress={onNext}
153
+ theme={theme}
154
+ variant="primary"
155
+ disabled={!canGoNext}
156
+ loading={isLoading}
157
+ />
158
+ </>
159
+ );
160
+
161
+ if (position === 'floating') {
162
+ return (
163
+ <BlurView intensity={80} tint={darkMode ? 'dark' : 'light'} style={containerStyle}>
164
+ <View style={styles.buttonRow}>{buttons}</View>
165
+ </BlurView>
166
+ );
167
+ }
168
+
169
+ return <View style={containerStyle}>{buttons}</View>;
170
+ };
171
+
172
+ const styles = StyleSheet.create({
173
+ button: {
174
+ minWidth: 120,
175
+ },
176
+ buttonText: {
177
+ fontSize: 16,
178
+ fontWeight: '600',
179
+ letterSpacing: 0.5,
180
+ },
181
+ buttonRow: {
182
+ flexDirection: 'row',
183
+ justifyContent: 'space-between',
184
+ alignItems: 'center',
185
+ },
186
+ skipButton: {
187
+ alignSelf: 'flex-end',
188
+ paddingVertical: 8,
189
+ paddingHorizontal: 4,
190
+ marginRight: 8,
191
+ },
192
+ skipButtonText: {
193
+ fontSize: 15,
194
+ fontWeight: '500',
195
+ },
196
+ });
197
+
198
+ export default { NavigationButton, NavigationButtons };