@umituz/react-native-onboarding 3.6.16 → 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.16",
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';