@rubixscript/react-native-onboarding 1.0.1 → 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.js +17 -17
- package/dist/components/Onboarding.js +16 -16
- package/dist/components/Pagination.js +30 -30
- 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 +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/presets/index.d.ts.map +1 -1
- package/dist/presets/index.js +24 -27
- package/dist/slides/FormSlide.js +37 -37
- package/dist/slides/IconSlide.js +24 -24
- package/dist/slides/ImageSlide.js +20 -20
- package/dist/slides/VideoSlide.js +20 -20
- package/dist/themes/index.d.ts.map +1 -1
- package/dist/themes/index.js +9 -7
- package/package.json +73 -66
- package/src/components/NavigationButtons.tsx +198 -198
- package/src/components/Onboarding.tsx +337 -337
- 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.tsx +37 -37
- package/src/themes/index.ts +576 -574
- 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 };
|