@umituz/react-native-onboarding 2.7.2 → 2.7.3
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 +1 -1
- package/src/domain/entities/OnboardingQuestion.ts +0 -6
- package/src/domain/entities/OnboardingSlide.ts +0 -6
- package/src/presentation/components/OnboardingHeader.tsx +6 -1
- package/src/presentation/components/questions/SingleChoiceQuestion.tsx +1 -1
- package/src/presentation/components/questions/SliderQuestion.tsx +48 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-onboarding",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
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",
|
|
@@ -27,15 +27,9 @@ export interface QuestionOption {
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Display label for the option
|
|
30
|
-
* Can be either a string or an i18n key
|
|
31
30
|
*/
|
|
32
31
|
label: string;
|
|
33
32
|
|
|
34
|
-
/**
|
|
35
|
-
* i18n key for label (optional, if provided, label will be used as fallback)
|
|
36
|
-
*/
|
|
37
|
-
labelKey?: string;
|
|
38
|
-
|
|
39
33
|
/**
|
|
40
34
|
* Optional icon (emoji or Lucide icon name)
|
|
41
35
|
*/
|
|
@@ -62,15 +62,9 @@ export interface OnboardingSlide {
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Optional features list to display
|
|
65
|
-
* Can be either strings or i18n keys
|
|
66
65
|
*/
|
|
67
66
|
features?: string[];
|
|
68
67
|
|
|
69
|
-
/**
|
|
70
|
-
* Optional i18n keys for features (optional, if provided, features will be used as fallback)
|
|
71
|
-
*/
|
|
72
|
-
featuresKeys?: string[];
|
|
73
|
-
|
|
74
68
|
/**
|
|
75
69
|
* Optional question for personalization
|
|
76
70
|
* Only used when type is "question"
|
|
@@ -36,7 +36,11 @@ export const OnboardingHeader: React.FC<OnboardingHeaderProps> = ({
|
|
|
36
36
|
const skipText = skipButtonText || t("onboarding.skip", "Skip");
|
|
37
37
|
|
|
38
38
|
const handleBackPress = () => {
|
|
39
|
-
|
|
39
|
+
/* eslint-disable-next-line no-console */
|
|
40
|
+
if (__DEV__) {
|
|
41
|
+
console.log("[OnboardingHeader] Back pressed, isFirstSlide:", isFirstSlide);
|
|
42
|
+
}
|
|
43
|
+
if (!isFirstSlide && onBack) {
|
|
40
44
|
onBack();
|
|
41
45
|
}
|
|
42
46
|
};
|
|
@@ -52,6 +56,7 @@ export const OnboardingHeader: React.FC<OnboardingHeaderProps> = ({
|
|
|
52
56
|
isFirstSlide && styles.headerButtonDisabled,
|
|
53
57
|
]}
|
|
54
58
|
activeOpacity={0.7}
|
|
59
|
+
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
55
60
|
>
|
|
56
61
|
<ArrowLeft
|
|
57
62
|
size={20}
|
|
@@ -39,61 +39,62 @@ export const SliderQuestion: React.FC<SliderQuestionProps> = ({
|
|
|
39
39
|
}) => {
|
|
40
40
|
const { min, max } = useMemo(() => getSliderConfig(question), [question]);
|
|
41
41
|
const currentValue = value ?? question.defaultValue ?? min;
|
|
42
|
+
const [sliderError, setSliderError] = React.useState<string | null>(null);
|
|
42
43
|
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<View style={styles.
|
|
48
|
-
<Text style={styles.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
<SliderComponent
|
|
52
|
-
style={styles.slider}
|
|
53
|
-
minimumValue={min}
|
|
54
|
-
maximumValue={max}
|
|
55
|
-
value={currentValue}
|
|
56
|
-
onValueChange={onChange}
|
|
57
|
-
minimumTrackTintColor="#FFFFFF"
|
|
58
|
-
maximumTrackTintColor="rgba(255, 255, 255, 0.3)"
|
|
59
|
-
thumbTintColor="#FFFFFF"
|
|
60
|
-
step={1}
|
|
61
|
-
/>
|
|
62
|
-
) : (
|
|
63
|
-
<View style={styles.errorContainer}>
|
|
64
|
-
<Text style={styles.errorText}>
|
|
65
|
-
Slider component is not available. Please provide SliderComponent prop.
|
|
66
|
-
</Text>
|
|
67
|
-
</View>
|
|
68
|
-
)}
|
|
69
|
-
<View style={styles.labels}>
|
|
70
|
-
<Text style={styles.label}>{min}</Text>
|
|
71
|
-
<Text style={styles.label}>{max}</Text>
|
|
44
|
+
// Render slider with error boundary
|
|
45
|
+
const renderSlider = () => {
|
|
46
|
+
if (!SliderComponent) {
|
|
47
|
+
return (
|
|
48
|
+
<View style={styles.errorContainer}>
|
|
49
|
+
<Text style={styles.errorText}>
|
|
50
|
+
Slider component is not available. Please provide SliderComponent prop.
|
|
51
|
+
</Text>
|
|
72
52
|
</View>
|
|
73
|
-
|
|
74
|
-
);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
/* eslint-disable-next-line no-console */
|
|
77
|
-
if (__DEV__) {
|
|
78
|
-
console.error("SliderQuestion render error:", error);
|
|
53
|
+
);
|
|
79
54
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
return (
|
|
58
|
+
<SliderComponent
|
|
59
|
+
style={styles.slider}
|
|
60
|
+
minimumValue={min}
|
|
61
|
+
maximumValue={max}
|
|
62
|
+
value={currentValue}
|
|
63
|
+
onValueChange={onChange}
|
|
64
|
+
minimumTrackTintColor="#FFFFFF"
|
|
65
|
+
maximumTrackTintColor="rgba(255, 255, 255, 0.3)"
|
|
66
|
+
thumbTintColor="#FFFFFF"
|
|
67
|
+
step={1}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
/* eslint-disable-next-line no-console */
|
|
72
|
+
if (__DEV__) {
|
|
73
|
+
console.error("[SliderQuestion] Error rendering slider:", error);
|
|
74
|
+
}
|
|
75
|
+
setSliderError("Unable to render slider. Native module may not be linked.");
|
|
76
|
+
return (
|
|
85
77
|
<View style={styles.errorContainer}>
|
|
86
78
|
<Text style={styles.errorText}>
|
|
87
|
-
Unable to render slider. Please
|
|
79
|
+
Unable to render slider. Please ensure @react-native-community/slider is properly installed and linked.
|
|
88
80
|
</Text>
|
|
89
81
|
</View>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View style={styles.container}>
|
|
88
|
+
<View style={styles.valueContainer}>
|
|
89
|
+
<Text style={styles.valueText}>{currentValue}</Text>
|
|
90
|
+
</View>
|
|
91
|
+
{renderSlider()}
|
|
92
|
+
<View style={styles.labels}>
|
|
93
|
+
<Text style={styles.label}>{min}</Text>
|
|
94
|
+
<Text style={styles.label}>{max}</Text>
|
|
94
95
|
</View>
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
</View>
|
|
97
|
+
);
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
const styles = StyleSheet.create({
|