@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,337 +1,337 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import { View, StyleSheet, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
-
import Animated, { useAnimatedStyle, withSpring, useDerivedValue } from 'react-native-reanimated';
|
|
4
|
-
import { LinearGradient } from 'expo-linear-gradient';
|
|
5
|
-
import { PaginationProps, NavigationStyle } from '../types';
|
|
6
|
-
|
|
7
|
-
// DOTS PAGINATION
|
|
8
|
-
const DotsPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
9
|
-
const animatedIndex = useDerivedValue(() => withSpring(currentIndex, { damping: 15, stiffness: 150 }));
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<View style={[styles.dotsContainer, style]}>
|
|
13
|
-
{Array.from({ length: totalSlides }).map((_, index) => {
|
|
14
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
15
|
-
width: index === animatedIndex.value ? 24 : 8,
|
|
16
|
-
opacity: withSpring(index === animatedIndex.value ? 1 : 0.4, { damping: 15, stiffness: 150 }),
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Animated.View
|
|
21
|
-
key={index}
|
|
22
|
-
style={[
|
|
23
|
-
styles.dot,
|
|
24
|
-
{
|
|
25
|
-
backgroundColor: theme.colors.primary,
|
|
26
|
-
},
|
|
27
|
-
animatedStyle,
|
|
28
|
-
]}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
})}
|
|
32
|
-
</View>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// PROGRESS BAR PAGINATION
|
|
37
|
-
const ProgressBarPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
38
|
-
const progress = useMemo(() => (currentIndex + 1) / totalSlides, [currentIndex, totalSlides]);
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<View style={[styles.progressContainer, style]}>
|
|
42
|
-
<View style={[styles.progressBackground, { backgroundColor: theme.colors.border }]}>
|
|
43
|
-
<Animated.View
|
|
44
|
-
style={[
|
|
45
|
-
styles.progressFill,
|
|
46
|
-
{
|
|
47
|
-
width: `${progress * 100}%`,
|
|
48
|
-
backgroundColor: theme.colors.primary,
|
|
49
|
-
},
|
|
50
|
-
]}
|
|
51
|
-
/>
|
|
52
|
-
</View>
|
|
53
|
-
<Animated.Text style={[styles.progressText, { color: theme.colors.text.secondary }]}>
|
|
54
|
-
{currentIndex + 1} / {totalSlides}
|
|
55
|
-
</Animated.Text>
|
|
56
|
-
</View>
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// STEPS PAGINATION
|
|
61
|
-
const StepsPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
62
|
-
return (
|
|
63
|
-
<View style={[styles.stepsContainer, style]}>
|
|
64
|
-
{Array.from({ length: totalSlides }).map((_, index) => {
|
|
65
|
-
const isCompleted = index < currentIndex;
|
|
66
|
-
const isCurrent = index === currentIndex;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<View key={index} style={styles.stepItem}>
|
|
70
|
-
<View
|
|
71
|
-
style={[
|
|
72
|
-
styles.stepCircle,
|
|
73
|
-
{
|
|
74
|
-
backgroundColor: isCompleted ? theme.colors.primary : isCurrent ? theme.colors.primary : theme.colors.border,
|
|
75
|
-
borderColor: theme.colors.border,
|
|
76
|
-
},
|
|
77
|
-
]}
|
|
78
|
-
>
|
|
79
|
-
{isCompleted ? (
|
|
80
|
-
<View style={styles.stepCheckmark} />
|
|
81
|
-
) : (
|
|
82
|
-
<Animated.Text
|
|
83
|
-
style={[
|
|
84
|
-
styles.stepNumber,
|
|
85
|
-
{ color: isCurrent ? theme.colors.text.inverse : theme.colors.text.secondary },
|
|
86
|
-
]}
|
|
87
|
-
>
|
|
88
|
-
{index + 1}
|
|
89
|
-
</Animated.Text>
|
|
90
|
-
)}
|
|
91
|
-
</View>
|
|
92
|
-
{index < totalSlides - 1 && (
|
|
93
|
-
<View
|
|
94
|
-
style={[
|
|
95
|
-
styles.stepLine,
|
|
96
|
-
{ backgroundColor: isCompleted ? theme.colors.primary : theme.colors.border },
|
|
97
|
-
]}
|
|
98
|
-
/>
|
|
99
|
-
)}
|
|
100
|
-
</View>
|
|
101
|
-
);
|
|
102
|
-
})}
|
|
103
|
-
</View>
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// NUMBERS PAGINATION
|
|
108
|
-
const NumbersPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
109
|
-
return (
|
|
110
|
-
<View style={[styles.numbersContainer, style]}>
|
|
111
|
-
{Array.from({ length: totalSlides }).map((_, index) => {
|
|
112
|
-
const isCurrent = index === currentIndex;
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<Animated.View
|
|
116
|
-
key={index}
|
|
117
|
-
style={[
|
|
118
|
-
styles.numberCircle,
|
|
119
|
-
{
|
|
120
|
-
backgroundColor: isCurrent ? theme.colors.primary : 'transparent',
|
|
121
|
-
borderColor: theme.colors.border,
|
|
122
|
-
},
|
|
123
|
-
]}
|
|
124
|
-
>
|
|
125
|
-
<Animated.Text
|
|
126
|
-
style={[
|
|
127
|
-
styles.numberText,
|
|
128
|
-
{ color: isCurrent ? theme.colors.text.inverse : theme.colors.text.secondary },
|
|
129
|
-
]}
|
|
130
|
-
>
|
|
131
|
-
{index + 1}
|
|
132
|
-
</Animated.Text>
|
|
133
|
-
</Animated.View>
|
|
134
|
-
);
|
|
135
|
-
})}
|
|
136
|
-
</View>
|
|
137
|
-
);
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// FLOATING DOTS PAGINATION
|
|
141
|
-
const FloatingDotsPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
142
|
-
return (
|
|
143
|
-
<View style={[styles.floatingContainer, style]}>
|
|
144
|
-
<LinearGradient
|
|
145
|
-
colors={[theme.colors.surface + 'CC', theme.colors.surface + 'CC']}
|
|
146
|
-
style={styles.floatingBackground}
|
|
147
|
-
>
|
|
148
|
-
<View style={styles.floatingDots}>
|
|
149
|
-
{Array.from({ length: totalSlides }).map((_, index) => (
|
|
150
|
-
<Animated.View
|
|
151
|
-
key={index}
|
|
152
|
-
style={[
|
|
153
|
-
styles.floatingDot,
|
|
154
|
-
{
|
|
155
|
-
width: index === currentIndex ? 28 : 10,
|
|
156
|
-
backgroundColor: index === currentIndex ? theme.colors.primary : theme.colors.border,
|
|
157
|
-
},
|
|
158
|
-
]}
|
|
159
|
-
/>
|
|
160
|
-
))}
|
|
161
|
-
</View>
|
|
162
|
-
</LinearGradient>
|
|
163
|
-
</View>
|
|
164
|
-
);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// MAIN PAGINATION COMPONENT
|
|
168
|
-
export const Pagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, config, style }) => {
|
|
169
|
-
const { style: navStyle, position } = config || { style: 'dots' as const, position: 'bottom' as const };
|
|
170
|
-
|
|
171
|
-
const containerStyle: ViewStyle = useMemo(() => {
|
|
172
|
-
const base: ViewStyle = {};
|
|
173
|
-
|
|
174
|
-
if (position === 'top') {
|
|
175
|
-
base.position = 'absolute';
|
|
176
|
-
base.top = 0;
|
|
177
|
-
base.left = 0;
|
|
178
|
-
base.right = 0;
|
|
179
|
-
base.paddingTop = 20;
|
|
180
|
-
} else if (position === 'bottom') {
|
|
181
|
-
base.position = 'absolute';
|
|
182
|
-
base.bottom = 0;
|
|
183
|
-
base.left = 0;
|
|
184
|
-
base.right = 0;
|
|
185
|
-
base.paddingBottom = 20;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return base;
|
|
189
|
-
}, [position]);
|
|
190
|
-
|
|
191
|
-
const renderPagination = () => {
|
|
192
|
-
switch (navStyle) {
|
|
193
|
-
case 'dots':
|
|
194
|
-
return <DotsPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
195
|
-
case 'progress-bar':
|
|
196
|
-
return <ProgressBarPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
197
|
-
case 'steps':
|
|
198
|
-
return <StepsPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
199
|
-
case 'numbers':
|
|
200
|
-
return <NumbersPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
201
|
-
case 'none':
|
|
202
|
-
return null;
|
|
203
|
-
default:
|
|
204
|
-
return <DotsPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
if (navStyle === 'none') return null;
|
|
209
|
-
|
|
210
|
-
return <View style={containerStyle}>{renderPagination()}</View>;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const styles = StyleSheet.create({
|
|
214
|
-
// Dots
|
|
215
|
-
dotsContainer: {
|
|
216
|
-
flexDirection: 'row',
|
|
217
|
-
alignItems: 'center',
|
|
218
|
-
justifyContent: 'center',
|
|
219
|
-
gap: 8,
|
|
220
|
-
paddingVertical: 16,
|
|
221
|
-
},
|
|
222
|
-
dot: {
|
|
223
|
-
height: 8,
|
|
224
|
-
borderRadius: 4,
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
// Progress Bar
|
|
228
|
-
progressContainer: {
|
|
229
|
-
paddingHorizontal: 24,
|
|
230
|
-
paddingVertical: 16,
|
|
231
|
-
alignItems: 'center',
|
|
232
|
-
},
|
|
233
|
-
progressBackground: {
|
|
234
|
-
width: '100%',
|
|
235
|
-
height: 4,
|
|
236
|
-
borderRadius: 2,
|
|
237
|
-
overflow: 'hidden',
|
|
238
|
-
marginBottom: 8,
|
|
239
|
-
},
|
|
240
|
-
progressFill: {
|
|
241
|
-
height: '100%',
|
|
242
|
-
borderRadius: 2,
|
|
243
|
-
},
|
|
244
|
-
progressText: {
|
|
245
|
-
fontSize: 13,
|
|
246
|
-
fontWeight: '500',
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
// Steps
|
|
250
|
-
stepsContainer: {
|
|
251
|
-
flexDirection: 'row',
|
|
252
|
-
alignItems: 'center',
|
|
253
|
-
paddingHorizontal: 24,
|
|
254
|
-
paddingVertical: 16,
|
|
255
|
-
},
|
|
256
|
-
stepItem: {
|
|
257
|
-
flexDirection: 'row',
|
|
258
|
-
alignItems: 'center',
|
|
259
|
-
flex: 1,
|
|
260
|
-
},
|
|
261
|
-
stepCircle: {
|
|
262
|
-
width: 32,
|
|
263
|
-
height: 32,
|
|
264
|
-
borderRadius: 16,
|
|
265
|
-
borderWidth: 2,
|
|
266
|
-
alignItems: 'center',
|
|
267
|
-
justifyContent: 'center',
|
|
268
|
-
},
|
|
269
|
-
stepNumber: {
|
|
270
|
-
fontSize: 14,
|
|
271
|
-
fontWeight: '600',
|
|
272
|
-
},
|
|
273
|
-
stepCheckmark: {
|
|
274
|
-
width: 12,
|
|
275
|
-
height: 6,
|
|
276
|
-
borderBottomWidth: 2,
|
|
277
|
-
borderLeftWidth: 2,
|
|
278
|
-
borderColor: '#FFFFFF',
|
|
279
|
-
transform: [{ rotate: '-45deg' }, { translateY: -2 }],
|
|
280
|
-
},
|
|
281
|
-
stepLine: {
|
|
282
|
-
flex: 1,
|
|
283
|
-
height: 2,
|
|
284
|
-
minWidth: 8,
|
|
285
|
-
},
|
|
286
|
-
|
|
287
|
-
// Numbers
|
|
288
|
-
numbersContainer: {
|
|
289
|
-
flexDirection: 'row',
|
|
290
|
-
alignItems: 'center',
|
|
291
|
-
justifyContent: 'center',
|
|
292
|
-
gap: 16,
|
|
293
|
-
paddingVertical: 16,
|
|
294
|
-
},
|
|
295
|
-
numberCircle: {
|
|
296
|
-
width: 36,
|
|
297
|
-
height: 36,
|
|
298
|
-
borderRadius: 18,
|
|
299
|
-
borderWidth: 2,
|
|
300
|
-
alignItems: 'center',
|
|
301
|
-
justifyContent: 'center',
|
|
302
|
-
},
|
|
303
|
-
numberText: {
|
|
304
|
-
fontSize: 14,
|
|
305
|
-
fontWeight: '600',
|
|
306
|
-
},
|
|
307
|
-
|
|
308
|
-
// Floating
|
|
309
|
-
floatingContainer: {
|
|
310
|
-
position: 'absolute',
|
|
311
|
-
bottom: 32,
|
|
312
|
-
left: 0,
|
|
313
|
-
right: 0,
|
|
314
|
-
alignItems: 'center',
|
|
315
|
-
},
|
|
316
|
-
floatingBackground: {
|
|
317
|
-
paddingHorizontal: 20,
|
|
318
|
-
paddingVertical: 12,
|
|
319
|
-
borderRadius: 24,
|
|
320
|
-
shadowColor: '#000',
|
|
321
|
-
shadowOffset: { width: 0, height: 4 },
|
|
322
|
-
shadowOpacity: 0.15,
|
|
323
|
-
shadowRadius: 12,
|
|
324
|
-
elevation: 8,
|
|
325
|
-
},
|
|
326
|
-
floatingDots: {
|
|
327
|
-
flexDirection: 'row',
|
|
328
|
-
alignItems: 'center',
|
|
329
|
-
gap: 8,
|
|
330
|
-
},
|
|
331
|
-
floatingDot: {
|
|
332
|
-
height: 10,
|
|
333
|
-
borderRadius: 5,
|
|
334
|
-
},
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
export default Pagination;
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { View, StyleSheet, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
import Animated, { useAnimatedStyle, withSpring, useDerivedValue } from 'react-native-reanimated';
|
|
4
|
+
import { LinearGradient } from 'expo-linear-gradient';
|
|
5
|
+
import { PaginationProps, NavigationStyle } from '../types';
|
|
6
|
+
|
|
7
|
+
// DOTS PAGINATION
|
|
8
|
+
const DotsPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
9
|
+
const animatedIndex = useDerivedValue(() => withSpring(currentIndex, { damping: 15, stiffness: 150 }));
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<View style={[styles.dotsContainer, style]}>
|
|
13
|
+
{Array.from({ length: totalSlides }).map((_, index) => {
|
|
14
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
15
|
+
width: index === animatedIndex.value ? 24 : 8,
|
|
16
|
+
opacity: withSpring(index === animatedIndex.value ? 1 : 0.4, { damping: 15, stiffness: 150 }),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Animated.View
|
|
21
|
+
key={index}
|
|
22
|
+
style={[
|
|
23
|
+
styles.dot,
|
|
24
|
+
{
|
|
25
|
+
backgroundColor: theme.colors.primary,
|
|
26
|
+
},
|
|
27
|
+
animatedStyle,
|
|
28
|
+
]}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
})}
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// PROGRESS BAR PAGINATION
|
|
37
|
+
const ProgressBarPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
38
|
+
const progress = useMemo(() => (currentIndex + 1) / totalSlides, [currentIndex, totalSlides]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<View style={[styles.progressContainer, style]}>
|
|
42
|
+
<View style={[styles.progressBackground, { backgroundColor: theme.colors.border }]}>
|
|
43
|
+
<Animated.View
|
|
44
|
+
style={[
|
|
45
|
+
styles.progressFill,
|
|
46
|
+
{
|
|
47
|
+
width: `${progress * 100}%`,
|
|
48
|
+
backgroundColor: theme.colors.primary,
|
|
49
|
+
},
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
</View>
|
|
53
|
+
<Animated.Text style={[styles.progressText, { color: theme.colors.text.secondary }]}>
|
|
54
|
+
{currentIndex + 1} / {totalSlides}
|
|
55
|
+
</Animated.Text>
|
|
56
|
+
</View>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// STEPS PAGINATION
|
|
61
|
+
const StepsPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
62
|
+
return (
|
|
63
|
+
<View style={[styles.stepsContainer, style]}>
|
|
64
|
+
{Array.from({ length: totalSlides }).map((_, index) => {
|
|
65
|
+
const isCompleted = index < currentIndex;
|
|
66
|
+
const isCurrent = index === currentIndex;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<View key={index} style={styles.stepItem}>
|
|
70
|
+
<View
|
|
71
|
+
style={[
|
|
72
|
+
styles.stepCircle,
|
|
73
|
+
{
|
|
74
|
+
backgroundColor: isCompleted ? theme.colors.primary : isCurrent ? theme.colors.primary : theme.colors.border,
|
|
75
|
+
borderColor: theme.colors.border,
|
|
76
|
+
},
|
|
77
|
+
]}
|
|
78
|
+
>
|
|
79
|
+
{isCompleted ? (
|
|
80
|
+
<View style={styles.stepCheckmark} />
|
|
81
|
+
) : (
|
|
82
|
+
<Animated.Text
|
|
83
|
+
style={[
|
|
84
|
+
styles.stepNumber,
|
|
85
|
+
{ color: isCurrent ? theme.colors.text.inverse : theme.colors.text.secondary },
|
|
86
|
+
]}
|
|
87
|
+
>
|
|
88
|
+
{index + 1}
|
|
89
|
+
</Animated.Text>
|
|
90
|
+
)}
|
|
91
|
+
</View>
|
|
92
|
+
{index < totalSlides - 1 && (
|
|
93
|
+
<View
|
|
94
|
+
style={[
|
|
95
|
+
styles.stepLine,
|
|
96
|
+
{ backgroundColor: isCompleted ? theme.colors.primary : theme.colors.border },
|
|
97
|
+
]}
|
|
98
|
+
/>
|
|
99
|
+
)}
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
})}
|
|
103
|
+
</View>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// NUMBERS PAGINATION
|
|
108
|
+
const NumbersPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
109
|
+
return (
|
|
110
|
+
<View style={[styles.numbersContainer, style]}>
|
|
111
|
+
{Array.from({ length: totalSlides }).map((_, index) => {
|
|
112
|
+
const isCurrent = index === currentIndex;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Animated.View
|
|
116
|
+
key={index}
|
|
117
|
+
style={[
|
|
118
|
+
styles.numberCircle,
|
|
119
|
+
{
|
|
120
|
+
backgroundColor: isCurrent ? theme.colors.primary : 'transparent',
|
|
121
|
+
borderColor: theme.colors.border,
|
|
122
|
+
},
|
|
123
|
+
]}
|
|
124
|
+
>
|
|
125
|
+
<Animated.Text
|
|
126
|
+
style={[
|
|
127
|
+
styles.numberText,
|
|
128
|
+
{ color: isCurrent ? theme.colors.text.inverse : theme.colors.text.secondary },
|
|
129
|
+
]}
|
|
130
|
+
>
|
|
131
|
+
{index + 1}
|
|
132
|
+
</Animated.Text>
|
|
133
|
+
</Animated.View>
|
|
134
|
+
);
|
|
135
|
+
})}
|
|
136
|
+
</View>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// FLOATING DOTS PAGINATION
|
|
141
|
+
const FloatingDotsPagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, style }) => {
|
|
142
|
+
return (
|
|
143
|
+
<View style={[styles.floatingContainer, style]}>
|
|
144
|
+
<LinearGradient
|
|
145
|
+
colors={[theme.colors.surface + 'CC', theme.colors.surface + 'CC']}
|
|
146
|
+
style={styles.floatingBackground}
|
|
147
|
+
>
|
|
148
|
+
<View style={styles.floatingDots}>
|
|
149
|
+
{Array.from({ length: totalSlides }).map((_, index) => (
|
|
150
|
+
<Animated.View
|
|
151
|
+
key={index}
|
|
152
|
+
style={[
|
|
153
|
+
styles.floatingDot,
|
|
154
|
+
{
|
|
155
|
+
width: index === currentIndex ? 28 : 10,
|
|
156
|
+
backgroundColor: index === currentIndex ? theme.colors.primary : theme.colors.border,
|
|
157
|
+
},
|
|
158
|
+
]}
|
|
159
|
+
/>
|
|
160
|
+
))}
|
|
161
|
+
</View>
|
|
162
|
+
</LinearGradient>
|
|
163
|
+
</View>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// MAIN PAGINATION COMPONENT
|
|
168
|
+
export const Pagination: React.FC<PaginationProps> = ({ currentIndex, totalSlides, theme, config, style }) => {
|
|
169
|
+
const { style: navStyle, position } = config || { style: 'dots' as const, position: 'bottom' as const };
|
|
170
|
+
|
|
171
|
+
const containerStyle: ViewStyle = useMemo(() => {
|
|
172
|
+
const base: ViewStyle = {};
|
|
173
|
+
|
|
174
|
+
if (position === 'top') {
|
|
175
|
+
base.position = 'absolute';
|
|
176
|
+
base.top = 0;
|
|
177
|
+
base.left = 0;
|
|
178
|
+
base.right = 0;
|
|
179
|
+
base.paddingTop = 20;
|
|
180
|
+
} else if (position === 'bottom') {
|
|
181
|
+
base.position = 'absolute';
|
|
182
|
+
base.bottom = 0;
|
|
183
|
+
base.left = 0;
|
|
184
|
+
base.right = 0;
|
|
185
|
+
base.paddingBottom = 20;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return base;
|
|
189
|
+
}, [position]);
|
|
190
|
+
|
|
191
|
+
const renderPagination = () => {
|
|
192
|
+
switch (navStyle) {
|
|
193
|
+
case 'dots':
|
|
194
|
+
return <DotsPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
195
|
+
case 'progress-bar':
|
|
196
|
+
return <ProgressBarPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
197
|
+
case 'steps':
|
|
198
|
+
return <StepsPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
199
|
+
case 'numbers':
|
|
200
|
+
return <NumbersPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
201
|
+
case 'none':
|
|
202
|
+
return null;
|
|
203
|
+
default:
|
|
204
|
+
return <DotsPagination currentIndex={currentIndex} totalSlides={totalSlides} theme={theme} style={style} />;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
if (navStyle === 'none') return null;
|
|
209
|
+
|
|
210
|
+
return <View style={containerStyle}>{renderPagination()}</View>;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const styles = StyleSheet.create({
|
|
214
|
+
// Dots
|
|
215
|
+
dotsContainer: {
|
|
216
|
+
flexDirection: 'row',
|
|
217
|
+
alignItems: 'center',
|
|
218
|
+
justifyContent: 'center',
|
|
219
|
+
gap: 8,
|
|
220
|
+
paddingVertical: 16,
|
|
221
|
+
},
|
|
222
|
+
dot: {
|
|
223
|
+
height: 8,
|
|
224
|
+
borderRadius: 4,
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
// Progress Bar
|
|
228
|
+
progressContainer: {
|
|
229
|
+
paddingHorizontal: 24,
|
|
230
|
+
paddingVertical: 16,
|
|
231
|
+
alignItems: 'center',
|
|
232
|
+
},
|
|
233
|
+
progressBackground: {
|
|
234
|
+
width: '100%',
|
|
235
|
+
height: 4,
|
|
236
|
+
borderRadius: 2,
|
|
237
|
+
overflow: 'hidden',
|
|
238
|
+
marginBottom: 8,
|
|
239
|
+
},
|
|
240
|
+
progressFill: {
|
|
241
|
+
height: '100%',
|
|
242
|
+
borderRadius: 2,
|
|
243
|
+
},
|
|
244
|
+
progressText: {
|
|
245
|
+
fontSize: 13,
|
|
246
|
+
fontWeight: '500',
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
// Steps
|
|
250
|
+
stepsContainer: {
|
|
251
|
+
flexDirection: 'row',
|
|
252
|
+
alignItems: 'center',
|
|
253
|
+
paddingHorizontal: 24,
|
|
254
|
+
paddingVertical: 16,
|
|
255
|
+
},
|
|
256
|
+
stepItem: {
|
|
257
|
+
flexDirection: 'row',
|
|
258
|
+
alignItems: 'center',
|
|
259
|
+
flex: 1,
|
|
260
|
+
},
|
|
261
|
+
stepCircle: {
|
|
262
|
+
width: 32,
|
|
263
|
+
height: 32,
|
|
264
|
+
borderRadius: 16,
|
|
265
|
+
borderWidth: 2,
|
|
266
|
+
alignItems: 'center',
|
|
267
|
+
justifyContent: 'center',
|
|
268
|
+
},
|
|
269
|
+
stepNumber: {
|
|
270
|
+
fontSize: 14,
|
|
271
|
+
fontWeight: '600',
|
|
272
|
+
},
|
|
273
|
+
stepCheckmark: {
|
|
274
|
+
width: 12,
|
|
275
|
+
height: 6,
|
|
276
|
+
borderBottomWidth: 2,
|
|
277
|
+
borderLeftWidth: 2,
|
|
278
|
+
borderColor: '#FFFFFF',
|
|
279
|
+
transform: [{ rotate: '-45deg' }, { translateY: -2 }],
|
|
280
|
+
},
|
|
281
|
+
stepLine: {
|
|
282
|
+
flex: 1,
|
|
283
|
+
height: 2,
|
|
284
|
+
minWidth: 8,
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
// Numbers
|
|
288
|
+
numbersContainer: {
|
|
289
|
+
flexDirection: 'row',
|
|
290
|
+
alignItems: 'center',
|
|
291
|
+
justifyContent: 'center',
|
|
292
|
+
gap: 16,
|
|
293
|
+
paddingVertical: 16,
|
|
294
|
+
},
|
|
295
|
+
numberCircle: {
|
|
296
|
+
width: 36,
|
|
297
|
+
height: 36,
|
|
298
|
+
borderRadius: 18,
|
|
299
|
+
borderWidth: 2,
|
|
300
|
+
alignItems: 'center',
|
|
301
|
+
justifyContent: 'center',
|
|
302
|
+
},
|
|
303
|
+
numberText: {
|
|
304
|
+
fontSize: 14,
|
|
305
|
+
fontWeight: '600',
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
// Floating
|
|
309
|
+
floatingContainer: {
|
|
310
|
+
position: 'absolute',
|
|
311
|
+
bottom: 32,
|
|
312
|
+
left: 0,
|
|
313
|
+
right: 0,
|
|
314
|
+
alignItems: 'center',
|
|
315
|
+
},
|
|
316
|
+
floatingBackground: {
|
|
317
|
+
paddingHorizontal: 20,
|
|
318
|
+
paddingVertical: 12,
|
|
319
|
+
borderRadius: 24,
|
|
320
|
+
shadowColor: '#000',
|
|
321
|
+
shadowOffset: { width: 0, height: 4 },
|
|
322
|
+
shadowOpacity: 0.15,
|
|
323
|
+
shadowRadius: 12,
|
|
324
|
+
elevation: 8,
|
|
325
|
+
},
|
|
326
|
+
floatingDots: {
|
|
327
|
+
flexDirection: 'row',
|
|
328
|
+
alignItems: 'center',
|
|
329
|
+
gap: 8,
|
|
330
|
+
},
|
|
331
|
+
floatingDot: {
|
|
332
|
+
height: 10,
|
|
333
|
+
borderRadius: 5,
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
export default Pagination;
|