@umituz/react-native-onboarding 3.6.15 → 3.6.17
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.6.
|
|
3
|
+
"version": "3.6.17",
|
|
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",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onboarding Flow Hook
|
|
3
|
+
* Manages onboarding completion state with persistence
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
7
|
+
import { DeviceEventEmitter } from 'react-native';
|
|
8
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
9
|
+
|
|
10
|
+
const ONBOARDING_KEY = 'onboarding_complete';
|
|
11
|
+
|
|
12
|
+
export interface UseOnboardingFlowResult {
|
|
13
|
+
isOnboardingComplete: boolean;
|
|
14
|
+
completeOnboarding: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const useOnboardingFlow = (): UseOnboardingFlowResult => {
|
|
18
|
+
const [isOnboardingComplete, setIsOnboardingComplete] = useState(false);
|
|
19
|
+
|
|
20
|
+
// Load persisted state
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const loadPersistedState = async () => {
|
|
23
|
+
const value = await AsyncStorage.getItem(ONBOARDING_KEY);
|
|
24
|
+
setIsOnboardingComplete(value === 'true');
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
loadPersistedState();
|
|
28
|
+
|
|
29
|
+
const subscription = DeviceEventEmitter.addListener(
|
|
30
|
+
'onboarding-complete',
|
|
31
|
+
() => {
|
|
32
|
+
setIsOnboardingComplete(true);
|
|
33
|
+
AsyncStorage.setItem(ONBOARDING_KEY, 'true');
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return () => subscription.remove();
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
const completeOnboarding = useCallback(async () => {
|
|
41
|
+
await AsyncStorage.setItem(ONBOARDING_KEY, 'true');
|
|
42
|
+
setIsOnboardingComplete(true);
|
|
43
|
+
DeviceEventEmitter.emit('onboarding-complete');
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
isOnboardingComplete,
|
|
48
|
+
completeOnboarding,
|
|
49
|
+
};
|
|
50
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -105,3 +105,4 @@ export { OnboardingResetSetting } from "./presentation/components/OnboardingRese
|
|
|
105
105
|
export type { OnboardingResetSettingProps } from "./presentation/components/OnboardingResetSetting";
|
|
106
106
|
|
|
107
107
|
|
|
108
|
+
export { useOnboardingFlow, type UseOnboardingFlowResult } from './hooks/useOnboardingFlow';
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* This component only handles UI coordination - no business logic
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import React from "react";
|
|
10
|
+
import React, { useMemo } from "react";
|
|
11
11
|
import { StyleSheet } from "react-native";
|
|
12
|
+
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
12
13
|
import type { OnboardingOptions } from "../../domain/entities/OnboardingOptions";
|
|
13
14
|
import { useOnboardingScreenState } from "../hooks/useOnboardingScreenState";
|
|
14
15
|
import { OnboardingScreenContent } from "../components/OnboardingScreenContent";
|
|
@@ -55,9 +56,9 @@ export interface OnboardingScreenProps extends OnboardingOptions {
|
|
|
55
56
|
showPaywallOnComplete?: boolean;
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
|
-
* Theme colors for the onboarding (
|
|
59
|
+
* Theme colors for the onboarding (Optional - will use design tokens if not provided)
|
|
59
60
|
*/
|
|
60
|
-
themeColors
|
|
61
|
+
themeColors?: OnboardingColors;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
export const OnboardingScreen = ({
|
|
@@ -81,12 +82,37 @@ export const OnboardingScreen = ({
|
|
|
81
82
|
showPaywallOnComplete = false,
|
|
82
83
|
useGradient: globalUseGradient = false,
|
|
83
84
|
themeVariant = "default",
|
|
84
|
-
themeColors,
|
|
85
|
+
themeColors: providedThemeColors,
|
|
85
86
|
}: OnboardingScreenProps) => {
|
|
86
87
|
if (__DEV__) {
|
|
87
88
|
console.log("[OnboardingScreen] Rendering with slides:", slides?.length);
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
const tokens = useAppDesignTokens();
|
|
92
|
+
|
|
93
|
+
const themeColors = useMemo(
|
|
94
|
+
() =>
|
|
95
|
+
providedThemeColors ?? {
|
|
96
|
+
iconColor: tokens.colors.primary,
|
|
97
|
+
textColor: tokens.colors.textPrimary,
|
|
98
|
+
subTextColor: tokens.colors.textSecondary,
|
|
99
|
+
buttonBg: tokens.colors.primary,
|
|
100
|
+
buttonTextColor: tokens.colors.onPrimary,
|
|
101
|
+
progressBarBg: tokens.colors.surfaceSecondary,
|
|
102
|
+
progressFillColor: tokens.colors.primary,
|
|
103
|
+
dotColor: tokens.colors.surfaceSecondary,
|
|
104
|
+
activeDotColor: tokens.colors.primary,
|
|
105
|
+
progressTextColor: tokens.colors.textSecondary,
|
|
106
|
+
headerButtonBg: tokens.colors.surface,
|
|
107
|
+
headerButtonBorder: tokens.colors.borderLight,
|
|
108
|
+
iconBg: tokens.colors.surfaceSecondary,
|
|
109
|
+
iconBorder: tokens.colors.borderLight,
|
|
110
|
+
errorColor: tokens.colors.error,
|
|
111
|
+
featureItemBg: tokens.colors.surfaceSecondary,
|
|
112
|
+
},
|
|
113
|
+
[providedThemeColors, tokens]
|
|
114
|
+
);
|
|
115
|
+
|
|
90
116
|
const {
|
|
91
117
|
filteredSlides,
|
|
92
118
|
currentSlide,
|