@umituz/react-native-onboarding 2.5.0 → 2.5.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-onboarding",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "Advanced onboarding flow for React Native apps with personalization questions, theme-aware colors, animations, and customizable slides. SOLID, DRY, KISS principles applied.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -19,9 +19,13 @@ export class OnboardingSlideService {
|
|
|
19
19
|
* @returns Filtered slides that should be shown
|
|
20
20
|
*/
|
|
21
21
|
static filterSlides(
|
|
22
|
-
slides: OnboardingSlide[],
|
|
22
|
+
slides: OnboardingSlide[] | undefined,
|
|
23
23
|
userData: OnboardingUserData,
|
|
24
24
|
): OnboardingSlide[] {
|
|
25
|
+
// Safety check: return empty array if slides is undefined or not an array
|
|
26
|
+
if (!slides || !Array.isArray(slides)) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
25
29
|
return slides.filter((slide) => {
|
|
26
30
|
if (slide.skipIf) {
|
|
27
31
|
return !slide.skipIf(userData.answers);
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Radio button style question for single selection
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import React from "react";
|
|
7
|
+
import React, { useMemo } from "react";
|
|
8
8
|
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
|
|
9
9
|
import { AtomicIcon } from "@umituz/react-native-design-system-atoms";
|
|
10
|
+
import { useAppDesignTokens, withAlpha } from "@umituz/react-native-design-system-theme";
|
|
10
11
|
import type { OnboardingQuestion, QuestionOption } from "../../../domain/entities/OnboardingQuestion";
|
|
11
12
|
|
|
12
13
|
export interface SingleChoiceQuestionProps {
|
|
@@ -20,6 +21,9 @@ export const SingleChoiceQuestion: React.FC<SingleChoiceQuestionProps> = ({
|
|
|
20
21
|
value,
|
|
21
22
|
onChange,
|
|
22
23
|
}) => {
|
|
24
|
+
const tokens = useAppDesignTokens();
|
|
25
|
+
const styles = useMemo(() => getStyles(tokens), [tokens]);
|
|
26
|
+
|
|
23
27
|
const isEmoji = (icon: string) =>
|
|
24
28
|
/[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]/u.test(icon);
|
|
25
29
|
|
|
@@ -41,7 +45,7 @@ export const SingleChoiceQuestion: React.FC<SingleChoiceQuestionProps> = ({
|
|
|
41
45
|
<AtomicIcon
|
|
42
46
|
name={option.icon as any}
|
|
43
47
|
customSize={24}
|
|
44
|
-
customColor={isSelected ?
|
|
48
|
+
customColor={isSelected ? tokens.colors.primary : tokens.colors.textSecondary}
|
|
45
49
|
/>
|
|
46
50
|
)}
|
|
47
51
|
</View>
|
|
@@ -63,57 +67,58 @@ export const SingleChoiceQuestion: React.FC<SingleChoiceQuestionProps> = ({
|
|
|
63
67
|
);
|
|
64
68
|
};
|
|
65
69
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
70
|
+
const getStyles = (tokens: ReturnType<typeof useAppDesignTokens>) =>
|
|
71
|
+
StyleSheet.create({
|
|
72
|
+
container: {
|
|
73
|
+
width: "100%",
|
|
74
|
+
gap: 12,
|
|
75
|
+
},
|
|
76
|
+
option: {
|
|
77
|
+
flexDirection: "row",
|
|
78
|
+
alignItems: "center",
|
|
79
|
+
backgroundColor: withAlpha(tokens.colors.primary, 0.05),
|
|
80
|
+
borderRadius: 12,
|
|
81
|
+
padding: 16,
|
|
82
|
+
borderWidth: 2,
|
|
83
|
+
borderColor: tokens.colors.borderLight,
|
|
84
|
+
},
|
|
85
|
+
optionSelected: {
|
|
86
|
+
backgroundColor: withAlpha(tokens.colors.primary, 0.1),
|
|
87
|
+
borderColor: tokens.colors.primary,
|
|
88
|
+
},
|
|
89
|
+
optionIcon: {
|
|
90
|
+
marginRight: 12,
|
|
91
|
+
},
|
|
92
|
+
emoji: {
|
|
93
|
+
fontSize: 24,
|
|
94
|
+
},
|
|
95
|
+
optionLabel: {
|
|
96
|
+
flex: 1,
|
|
97
|
+
fontSize: 16,
|
|
98
|
+
color: tokens.colors.textPrimary,
|
|
99
|
+
fontWeight: "500",
|
|
100
|
+
},
|
|
101
|
+
optionLabelSelected: {
|
|
102
|
+
color: tokens.colors.primary,
|
|
103
|
+
fontWeight: "600",
|
|
104
|
+
},
|
|
105
|
+
radio: {
|
|
106
|
+
width: 24,
|
|
107
|
+
height: 24,
|
|
108
|
+
borderRadius: 12,
|
|
109
|
+
borderWidth: 2,
|
|
110
|
+
borderColor: tokens.colors.border,
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
justifyContent: "center",
|
|
113
|
+
},
|
|
114
|
+
radioSelected: {
|
|
115
|
+
borderColor: tokens.colors.primary,
|
|
116
|
+
},
|
|
117
|
+
radioInner: {
|
|
118
|
+
width: 12,
|
|
119
|
+
height: 12,
|
|
120
|
+
borderRadius: 6,
|
|
121
|
+
backgroundColor: tokens.colors.primary,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
119
124
|
|
|
@@ -96,6 +96,10 @@ export const OnboardingScreen: React.FC<OnboardingScreenProps> = ({
|
|
|
96
96
|
|
|
97
97
|
// Filter slides using service
|
|
98
98
|
const filteredSlides = useMemo(() => {
|
|
99
|
+
// Safety check: if slides is undefined or empty, return empty array
|
|
100
|
+
if (!slides || !Array.isArray(slides) || slides.length === 0) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
99
103
|
const userData = onboardingStore.getUserData();
|
|
100
104
|
return OnboardingSlideService.filterSlides(slides, userData);
|
|
101
105
|
}, [slides, onboardingStore]);
|