@umituz/react-native-onboarding 3.3.8 → 3.3.9

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": "3.3.8",
3
+ "version": "3.3.9",
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",
@@ -7,27 +7,18 @@ interface BackgroundVideoProps {
7
7
  overlayOpacity?: number;
8
8
  }
9
9
 
10
- export const BackgroundVideo: React.FC<BackgroundVideoProps> = ({ source, overlayOpacity = 0.5 }) => {
11
- const player = useVideoPlayer(source, player => {
12
- player.loop = true;
13
- player.play();
14
- player.muted = true;
10
+ export const BackgroundVideo = ({ source, overlayOpacity = 0.5 }: BackgroundVideoProps) => {
11
+ const player = useVideoPlayer(source, (p) => {
12
+ p.loop = true;
13
+ p.play();
14
+ p.muted = true;
15
15
  });
16
16
 
17
17
  return (
18
18
  <View style={StyleSheet.absoluteFill}>
19
- <VideoView
20
- player={player}
21
- style={StyleSheet.absoluteFill}
22
- contentFit="cover"
23
- nativeControls={false}
24
- />
25
- <View
26
- style={[
27
- StyleSheet.absoluteFill,
28
- { backgroundColor: `rgba(0,0,0,${overlayOpacity})` }
29
- ]}
30
- />
19
+ <VideoView player={player} style={StyleSheet.absoluteFill} contentFit="cover" nativeControls={false} />
20
+ <View style={[StyleSheet.absoluteFill, { backgroundColor: `rgba(0,0,0,${overlayOpacity})` }]} />
31
21
  </View>
32
22
  );
33
23
  };
24
+
@@ -1,14 +1,8 @@
1
- /**
2
- * Onboarding Footer Component
3
- *
4
- * Displays progress bar, dots, and next/get started button
5
- */
6
-
7
1
  import React, { useMemo } from "react";
8
- import { View, TouchableOpacity, Text, StyleSheet } from "react-native";
2
+ import { View, StyleSheet } from "react-native";
9
3
  import { useSafeAreaInsets } from "react-native-safe-area-context";
10
4
  import { useLocalization } from "@umituz/react-native-localization";
11
- import { useAppDesignTokens } from "@umituz/react-native-design-system";
5
+ import { useAppDesignTokens, AtomicButton, AtomicText } from "@umituz/react-native-design-system";
12
6
 
13
7
  export interface OnboardingFooterProps {
14
8
  currentIndex: number;
@@ -24,7 +18,7 @@ export interface OnboardingFooterProps {
24
18
  useGradient?: boolean;
25
19
  }
26
20
 
27
- export const OnboardingFooter: React.FC<OnboardingFooterProps> = ({
21
+ export const OnboardingFooter = ({
28
22
  currentIndex,
29
23
  totalSlides,
30
24
  isLastSlide,
@@ -36,27 +30,23 @@ export const OnboardingFooter: React.FC<OnboardingFooterProps> = ({
36
30
  getStartedButtonText,
37
31
  disabled = false,
38
32
  useGradient = false,
39
- }) => {
33
+ }: OnboardingFooterProps) => {
40
34
  const insets = useSafeAreaInsets();
41
35
  const { t } = useLocalization();
42
36
  const tokens = useAppDesignTokens();
43
- const styles = useMemo(() => getStyles(insets, tokens, useGradient), [insets, tokens, useGradient]);
44
37
 
45
38
  const buttonText = isLastSlide
46
- ? getStartedButtonText || t("onboarding.getStarted")
47
- : nextButtonText || t("general.continue");
39
+ ? getStartedButtonText || t("onboarding.getStarted") || "Get Started"
40
+ : nextButtonText || t("general.continue") || "Continue";
41
+
42
+ const progressPercent = ((currentIndex + 1) / totalSlides) * 100;
48
43
 
49
44
  return (
50
- <View style={styles.footer}>
45
+ <View style={[styles.footer, { paddingBottom: insets.bottom + 24 }]}>
51
46
  {showProgressBar && (
52
47
  <View style={styles.progressContainer}>
53
- <View style={styles.progressBar}>
54
- <View
55
- style={[
56
- styles.progressFill,
57
- { width: `${((currentIndex + 1) / totalSlides) * 100}%` },
58
- ]}
59
- />
48
+ <View style={[styles.progressBar, { backgroundColor: useGradient ? "rgba(255, 255, 255, 0.2)" : tokens.colors.borderLight }]}>
49
+ <View style={[styles.progressFill, { width: `${progressPercent}%`, backgroundColor: useGradient ? '#FFFFFF' : tokens.colors.primary }]} />
60
50
  </View>
61
51
  </View>
62
52
  )}
@@ -66,106 +56,74 @@ export const OnboardingFooter: React.FC<OnboardingFooterProps> = ({
66
56
  {Array.from({ length: totalSlides }).map((_, index) => (
67
57
  <View
68
58
  key={index}
69
- style={[styles.dot, index === currentIndex && styles.dotActive]}
59
+ style={[
60
+ styles.dot,
61
+ { backgroundColor: useGradient ? "rgba(255, 255, 255, 0.4)" : tokens.colors.borderLight },
62
+ index === currentIndex && {
63
+ width: 12,
64
+ backgroundColor: useGradient ? '#FFFFFF' : tokens.colors.primary
65
+ }
66
+ ]}
70
67
  />
71
68
  ))}
72
69
  </View>
73
70
  )}
74
71
 
75
- <TouchableOpacity
76
- style={[styles.button, disabled && styles.buttonDisabled]}
72
+ <AtomicButton
77
73
  onPress={onNext}
78
74
  disabled={disabled}
79
- activeOpacity={disabled ? 1 : 0.7}
75
+ fullWidth
76
+ variant={useGradient ? "secondary" : "primary"}
77
+ style={useGradient && { backgroundColor: '#FFFFFF' }}
78
+ textStyle={useGradient && { color: tokens.colors.primary }}
80
79
  >
81
- <Text style={[styles.buttonText, disabled && styles.buttonTextDisabled]}>
82
- {buttonText}
83
- </Text>
84
- </TouchableOpacity>
80
+ {buttonText}
81
+ </AtomicButton>
85
82
 
86
83
  {showProgressText && (
87
- <Text style={styles.progressText}>
88
- {currentIndex + 1} {t("general.of")} {totalSlides}
89
- </Text>
84
+ <AtomicText
85
+ type="labelSmall"
86
+ style={[styles.progressText, { color: useGradient ? "rgba(255, 255, 255, 0.8)" : tokens.colors.textSecondary }]}
87
+ >
88
+ {currentIndex + 1} {t("general.of") || "of"} {totalSlides}
89
+ </AtomicText>
90
90
  )}
91
91
  </View>
92
92
  );
93
93
  };
94
94
 
95
- const getStyles = (
96
- insets: { bottom: number },
97
- tokens: ReturnType<typeof useAppDesignTokens>,
98
- useGradient: boolean,
99
- ) =>
100
- StyleSheet.create({
101
- footer: {
102
- paddingHorizontal: 30,
103
- paddingTop: 30,
104
- paddingBottom: insets.bottom + 20,
105
- },
106
- progressContainer: {
107
- marginBottom: 20,
108
- },
109
- progressBar: {
110
- height: 4,
111
- backgroundColor: useGradient
112
- ? "rgba(255, 255, 255, 0.2)"
113
- : tokens.colors.borderLight,
114
- borderRadius: 2,
115
- overflow: "hidden",
116
- },
117
- progressFill: {
118
- height: "100%",
119
- backgroundColor: useGradient ? tokens.colors.surface : tokens.colors.primary,
120
- borderRadius: 2,
121
- },
122
- dots: {
123
- flexDirection: "row",
124
- justifyContent: "center",
125
- marginBottom: 30,
126
- gap: 8,
127
- },
128
- dot: {
129
- width: 6,
130
- height: 6,
131
- borderRadius: 3,
132
- backgroundColor: useGradient
133
- ? "rgba(255, 255, 255, 0.4)"
134
- : tokens.colors.borderLight,
135
- },
136
- dotActive: {
137
- width: 8,
138
- backgroundColor: useGradient ? tokens.colors.surface : tokens.colors.primary,
139
- },
140
- button: {
141
- backgroundColor: useGradient ? tokens.colors.surface : tokens.colors.primary,
142
- paddingVertical: 16,
143
- borderRadius: 28,
144
- alignItems: "center",
145
- marginBottom: 12,
146
- },
147
- buttonDisabled: {
148
- backgroundColor: useGradient
149
- ? "rgba(255, 255, 255, 0.4)"
150
- : tokens.colors.borderLight,
151
- opacity: 0.5,
152
- },
153
- buttonText: {
154
- color: useGradient ? tokens.colors.primary : tokens.colors.surface,
155
- fontSize: 16,
156
- fontWeight: "bold",
157
- },
158
- buttonTextDisabled: {
159
- color: useGradient
160
- ? "rgba(255, 255, 255, 0.6)"
161
- : tokens.colors.textSecondary,
162
- },
163
- progressText: {
164
- color: useGradient
165
- ? "rgba(255, 255, 255, 0.75)"
166
- : tokens.colors.textSecondary,
167
- fontSize: 12,
168
- textAlign: "center",
169
- },
170
- });
95
+ const styles = StyleSheet.create({
96
+ footer: {
97
+ paddingHorizontal: 24,
98
+ paddingTop: 24,
99
+ },
100
+ progressContainer: {
101
+ marginBottom: 20,
102
+ },
103
+ progressBar: {
104
+ height: 4,
105
+ borderRadius: 2,
106
+ overflow: "hidden",
107
+ },
108
+ progressFill: {
109
+ height: "100%",
110
+ borderRadius: 2,
111
+ },
112
+ dots: {
113
+ flexDirection: "row",
114
+ justifyContent: "center",
115
+ marginBottom: 24,
116
+ gap: 8,
117
+ },
118
+ dot: {
119
+ width: 6,
120
+ height: 6,
121
+ borderRadius: 3,
122
+ },
123
+ progressText: {
124
+ marginTop: 12,
125
+ textAlign: "center",
126
+ },
127
+ });
128
+
171
129
 
@@ -1,14 +1,7 @@
1
- /**
2
- * Onboarding Header Component
3
- *
4
- * Displays back and skip buttons
5
- */
6
-
7
- import React, { useMemo } from "react";
8
- import { View, TouchableOpacity, Text, StyleSheet } from "react-native";
9
- import { AtomicIcon } from "@umituz/react-native-design-system";
1
+ import React from "react";
2
+ import { View, TouchableOpacity, StyleSheet } from "react-native";
3
+ import { AtomicIcon, AtomicText, useAppDesignTokens } from "@umituz/react-native-design-system";
10
4
  import { useLocalization } from "@umituz/react-native-localization";
11
- import { useAppDesignTokens } from "@umituz/react-native-design-system";
12
5
 
13
6
  export interface OnboardingHeaderProps {
14
7
  isFirstSlide: boolean;
@@ -20,7 +13,7 @@ export interface OnboardingHeaderProps {
20
13
  useGradient?: boolean;
21
14
  }
22
15
 
23
- export const OnboardingHeader: React.FC<OnboardingHeaderProps> = ({
16
+ export const OnboardingHeader = ({
24
17
  isFirstSlide,
25
18
  onBack,
26
19
  onSkip,
@@ -28,88 +21,72 @@ export const OnboardingHeader: React.FC<OnboardingHeaderProps> = ({
28
21
  showSkipButton = true,
29
22
  skipButtonText,
30
23
  useGradient = false,
31
- }) => {
24
+ }: OnboardingHeaderProps) => {
32
25
  const { t } = useLocalization();
33
26
  const tokens = useAppDesignTokens();
34
- const styles = useMemo(() => getStyles(tokens, useGradient), [tokens, useGradient]);
35
-
36
- const skipText = skipButtonText || t("onboarding.skip");
37
27
 
38
- const handleBackPress = () => {
39
- /* eslint-disable-next-line no-console */
40
- if (__DEV__) {
41
- console.log("[OnboardingHeader] Back pressed, isFirstSlide:", isFirstSlide);
42
- }
43
- if (!isFirstSlide && onBack) {
44
- onBack();
45
- }
46
- };
28
+ const skipText = skipButtonText || t("onboarding.skip") || "Skip";
29
+ const iconColor = useGradient ? "#FFFFFF" : tokens.colors.textPrimary;
47
30
 
48
31
  return (
49
32
  <View style={styles.header}>
50
33
  {showBackButton ? (
51
34
  <TouchableOpacity
52
- onPress={handleBackPress}
35
+ onPress={() => !isFirstSlide && onBack?.()}
53
36
  disabled={isFirstSlide}
54
37
  style={[
55
38
  styles.headerButton,
39
+ {
40
+ backgroundColor: useGradient ? "rgba(255, 255, 255, 0.2)" : tokens.colors.surface,
41
+ borderColor: useGradient ? "rgba(255, 255, 255, 0.3)" : tokens.colors.borderLight,
42
+ },
56
43
  isFirstSlide && styles.headerButtonDisabled,
57
44
  ]}
58
45
  activeOpacity={0.7}
59
46
  hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
60
47
  >
61
- <AtomicIcon
62
- name="chevron-back"
63
- customSize={20}
64
- customColor={useGradient ? tokens.colors.surface : tokens.colors.textPrimary}
65
- />
48
+ <AtomicIcon name="chevron-back" customSize={20} customColor={iconColor} />
66
49
  </TouchableOpacity>
67
50
  ) : (
68
51
  <View style={styles.headerButton} />
69
52
  )}
70
- {showSkipButton && (
53
+ {showSkipButton ? (
71
54
  <TouchableOpacity onPress={onSkip} activeOpacity={0.7}>
72
- <Text style={styles.skipText}>{skipText}</Text>
55
+ <AtomicText
56
+ type="labelLarge"
57
+ style={[styles.skipText, { color: iconColor }]}
58
+ >
59
+ {skipText}
60
+ </AtomicText>
73
61
  </TouchableOpacity>
74
- )}
62
+ ) : <View />}
75
63
  </View>
76
64
  );
77
65
  };
78
66
 
79
- const getStyles = (
80
- tokens: ReturnType<typeof useAppDesignTokens>,
81
- useGradient: boolean,
82
- ) =>
83
- StyleSheet.create({
84
- header: {
85
- flexDirection: "row",
86
- justifyContent: "space-between",
87
- alignItems: "center",
88
- paddingHorizontal: 20,
89
- paddingTop: 10,
90
- paddingBottom: 20,
91
- },
92
- headerButton: {
93
- width: 40,
94
- height: 40,
95
- borderRadius: 20,
96
- backgroundColor: useGradient
97
- ? "rgba(255, 255, 255, 0.2)"
98
- : tokens.colors.surface,
99
- alignItems: "center",
100
- justifyContent: "center",
101
- borderWidth: 1,
102
- borderColor: useGradient
103
- ? "rgba(255, 255, 255, 0.3)"
104
- : tokens.colors.borderLight,
105
- },
106
- headerButtonDisabled: {
107
- opacity: 0.3,
108
- },
109
- skipText: {
110
- color: useGradient ? tokens.colors.surface : tokens.colors.textPrimary,
111
- fontSize: 16,
112
- fontWeight: "600",
113
- },
114
- });
67
+ const styles = StyleSheet.create({
68
+ header: {
69
+ flexDirection: "row",
70
+ justifyContent: "space-between",
71
+ alignItems: "center",
72
+ paddingHorizontal: 20,
73
+ paddingTop: 10,
74
+ paddingBottom: 20,
75
+ },
76
+ headerButton: {
77
+ width: 40,
78
+ height: 40,
79
+ borderRadius: 20,
80
+ alignItems: "center",
81
+ justifyContent: "center",
82
+ borderWidth: 1,
83
+ },
84
+ headerButtonDisabled: {
85
+ opacity: 0,
86
+ },
87
+ skipText: {
88
+ fontWeight: "700",
89
+ },
90
+ });
91
+
115
92
 
@@ -1,34 +1,19 @@
1
- /**
2
- * Onboarding Reset Setting Component
3
- * Single Responsibility: Provide onboarding reset functionality for settings screens
4
- * Generic component for hundreds of apps
5
- */
6
-
7
1
  import React, { useCallback } from "react";
8
- import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
9
- import { AtomicIcon } from "@umituz/react-native-design-system";
10
- import { useAppDesignTokens } from "@umituz/react-native-design-system";
2
+ import { View, TouchableOpacity, StyleSheet } from "react-native";
3
+ import { AtomicIcon, AtomicText, useAppDesignTokens } from "@umituz/react-native-design-system";
11
4
 
12
5
  export interface OnboardingResetSettingProps {
13
- /** Callback when reset is triggered */
14
6
  onReset: () => void | Promise<void>;
15
- /** Title text to display */
16
7
  title?: string;
17
- /** Description text to display */
18
8
  description?: string;
19
- /** Custom icon name */
20
9
  iconName?: string;
21
- /** Custom icon color */
22
10
  iconColor?: string;
23
- /** Custom title color */
24
11
  titleColor?: string;
25
- /** Whether to show this setting (default: only in __DEV__) */
26
12
  visible?: boolean;
27
- /** Is last item in list */
28
13
  isLast?: boolean;
29
14
  }
30
15
 
31
- export const OnboardingResetSetting: React.FC<OnboardingResetSettingProps> = ({
16
+ export const OnboardingResetSetting = ({
32
17
  onReset,
33
18
  title = "Reset Onboarding",
34
19
  description = "Show onboarding flow again",
@@ -37,43 +22,31 @@ export const OnboardingResetSetting: React.FC<OnboardingResetSettingProps> = ({
37
22
  titleColor,
38
23
  visible = __DEV__,
39
24
  isLast = false,
40
- }) => {
25
+ }: OnboardingResetSettingProps) => {
41
26
  const tokens = useAppDesignTokens();
42
27
 
43
28
  const handlePress = useCallback(async () => {
44
29
  await onReset();
45
30
  }, [onReset]);
46
31
 
47
- if (!visible) {
48
- return null;
49
- }
32
+ if (!visible) return null;
50
33
 
51
- const defaultIconColor = iconColor || tokens.colors.warning;
52
- const defaultTitleColor = titleColor || tokens.colors.warning;
34
+ const defaultIconColor = iconColor || tokens.colors.error;
35
+ const defaultTitleColor = titleColor || tokens.colors.error;
53
36
 
54
37
  return (
55
38
  <TouchableOpacity onPress={handlePress} activeOpacity={0.7}>
56
39
  <View style={[styles.container, !isLast && { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: tokens.colors.border }]}>
57
40
  <View style={styles.iconContainer}>
58
- <AtomicIcon
59
- name={iconName}
60
- size="md"
61
- customColor={defaultIconColor}
62
- />
41
+ <AtomicIcon name={iconName} size="md" customColor={defaultIconColor} />
63
42
  </View>
64
43
  <View style={styles.content}>
65
- <Text
66
- style={[styles.title, { color: defaultTitleColor }]}
67
- numberOfLines={1}
68
- >
44
+ <AtomicText type="bodyLarge" style={{ color: defaultTitleColor, fontWeight: '600' }} numberOfLines={1}>
69
45
  {title}
70
- </Text>
71
- <Text
72
- style={[styles.description, { color: tokens.colors.textSecondary }]}
73
- numberOfLines={1}
74
- >
46
+ </AtomicText>
47
+ <AtomicText type="bodyMedium" style={{ color: tokens.colors.textSecondary }} numberOfLines={1}>
75
48
  {description}
76
- </Text>
49
+ </AtomicText>
77
50
  </View>
78
51
  </View>
79
52
  </TouchableOpacity>
@@ -84,21 +57,14 @@ const styles = StyleSheet.create({
84
57
  container: {
85
58
  flexDirection: "row",
86
59
  alignItems: "center",
87
- paddingVertical: 12,
88
- paddingHorizontal: 16,
60
+ paddingVertical: 16,
61
+ paddingHorizontal: 20,
89
62
  },
90
63
  iconContainer: {
91
- marginRight: 12,
64
+ marginRight: 16,
92
65
  },
93
66
  content: {
94
67
  flex: 1,
95
- },
96
- title: {
97
- fontSize: 16,
98
- fontWeight: "500",
99
- },
100
- description: {
101
- fontSize: 14,
102
- marginTop: 2,
103
- },
68
+ }
104
69
  });
70
+
@@ -56,7 +56,7 @@ export interface OnboardingScreenContentProps {
56
56
  variant?: "default" | "card" | "minimal" | "fullscreen";
57
57
  }
58
58
 
59
- export const OnboardingScreenContent: React.FC<OnboardingScreenContentProps> = ({
59
+ export const OnboardingScreenContent = ({
60
60
  containerStyle,
61
61
  useGradient,
62
62
  currentSlide,
@@ -84,7 +84,7 @@ export const OnboardingScreenContent: React.FC<OnboardingScreenContentProps> = (
84
84
  onUpgrade,
85
85
  showPaywallOnComplete,
86
86
  variant = "default",
87
- }) => {
87
+ }: OnboardingScreenContentProps) => {
88
88
  const { themeMode } = useTheme();
89
89
 
90
90
  const hasMedia = !!currentSlide?.backgroundImage || !!currentSlide?.backgroundVideo;