@umituz/react-native-onboarding 3.0.0 → 3.0.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": "3.0.
|
|
3
|
+
"version": "3.0.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",
|
|
@@ -3,16 +3,12 @@
|
|
|
3
3
|
* Single Responsibility: Async store actions
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
storageRepository,
|
|
8
|
-
StorageKey,
|
|
9
|
-
unwrap,
|
|
10
|
-
} from "@umituz/react-native-storage";
|
|
6
|
+
import { storageRepository, unwrap } from "@umituz/react-native-storage";
|
|
11
7
|
import type { OnboardingUserData } from "../../domain/entities/OnboardingUserData";
|
|
12
8
|
import type { OnboardingStoreState } from "./OnboardingStoreState";
|
|
13
9
|
|
|
14
|
-
const DEFAULT_STORAGE_KEY =
|
|
15
|
-
const USER_DATA_STORAGE_KEY = "@
|
|
10
|
+
const DEFAULT_STORAGE_KEY = "@onboarding:completed";
|
|
11
|
+
const USER_DATA_STORAGE_KEY = "@onboarding:user_data";
|
|
16
12
|
|
|
17
13
|
export interface OnboardingStoreActions {
|
|
18
14
|
initialize: (storageKey?: string) => Promise<void>;
|
|
@@ -35,7 +31,7 @@ export function createOnboardingStoreActions(
|
|
|
35
31
|
const completionResult = await storageRepository.getString(storageKey, "false");
|
|
36
32
|
const isComplete = unwrap(completionResult, "false") === "true";
|
|
37
33
|
|
|
38
|
-
const userDataResult = await storageRepository.
|
|
34
|
+
const userDataResult = await storageRepository.getItem<OnboardingUserData>(
|
|
39
35
|
USER_DATA_STORAGE_KEY,
|
|
40
36
|
{ answers: {} }
|
|
41
37
|
);
|
|
@@ -56,7 +52,7 @@ export function createOnboardingStoreActions(
|
|
|
56
52
|
loading: false,
|
|
57
53
|
error: error instanceof Error ? error.message : "Failed to initialize onboarding",
|
|
58
54
|
});
|
|
59
|
-
|
|
55
|
+
|
|
60
56
|
if (__DEV__) {
|
|
61
57
|
console.error('[OnboardingStore] Initialization error:', error);
|
|
62
58
|
}
|
|
@@ -72,7 +68,7 @@ export function createOnboardingStoreActions(
|
|
|
72
68
|
const userData = { ...get().userData };
|
|
73
69
|
userData.completedAt = new Date().toISOString();
|
|
74
70
|
|
|
75
|
-
await storageRepository.
|
|
71
|
+
await storageRepository.setItem(USER_DATA_STORAGE_KEY, userData);
|
|
76
72
|
|
|
77
73
|
set({
|
|
78
74
|
isOnboardingComplete: result.success,
|
|
@@ -89,7 +85,7 @@ export function createOnboardingStoreActions(
|
|
|
89
85
|
loading: false,
|
|
90
86
|
error: error instanceof Error ? error.message : "Failed to complete onboarding",
|
|
91
87
|
});
|
|
92
|
-
|
|
88
|
+
|
|
93
89
|
if (__DEV__) {
|
|
94
90
|
console.error('[OnboardingStore] Completion error:', error);
|
|
95
91
|
}
|
|
@@ -105,7 +101,7 @@ export function createOnboardingStoreActions(
|
|
|
105
101
|
const userData = { ...get().userData };
|
|
106
102
|
userData.skipped = true;
|
|
107
103
|
userData.completedAt = new Date().toISOString();
|
|
108
|
-
await storageRepository.
|
|
104
|
+
await storageRepository.setItem(USER_DATA_STORAGE_KEY, userData);
|
|
109
105
|
|
|
110
106
|
set({
|
|
111
107
|
isOnboardingComplete: result.success,
|
|
@@ -122,7 +118,7 @@ export function createOnboardingStoreActions(
|
|
|
122
118
|
loading: false,
|
|
123
119
|
error: error instanceof Error ? error.message : "Failed to skip onboarding",
|
|
124
120
|
});
|
|
125
|
-
|
|
121
|
+
|
|
126
122
|
if (__DEV__) {
|
|
127
123
|
console.error('[OnboardingStore] Skip error:', error);
|
|
128
124
|
}
|
|
@@ -152,7 +148,7 @@ export function createOnboardingStoreActions(
|
|
|
152
148
|
loading: false,
|
|
153
149
|
error: error instanceof Error ? error.message : "Failed to reset onboarding",
|
|
154
150
|
});
|
|
155
|
-
|
|
151
|
+
|
|
156
152
|
if (__DEV__) {
|
|
157
153
|
console.error('[OnboardingStore] Reset error:', error);
|
|
158
154
|
}
|
|
@@ -164,7 +160,7 @@ export function createOnboardingStoreActions(
|
|
|
164
160
|
const userData = { ...get().userData };
|
|
165
161
|
userData.answers[questionId] = answer;
|
|
166
162
|
|
|
167
|
-
await storageRepository.
|
|
163
|
+
await storageRepository.setItem(USER_DATA_STORAGE_KEY, userData);
|
|
168
164
|
set({ userData });
|
|
169
165
|
|
|
170
166
|
if (__DEV__) {
|
|
@@ -179,7 +175,7 @@ export function createOnboardingStoreActions(
|
|
|
179
175
|
|
|
180
176
|
setUserData: async (data: OnboardingUserData) => {
|
|
181
177
|
try {
|
|
182
|
-
await storageRepository.
|
|
178
|
+
await storageRepository.setItem(USER_DATA_STORAGE_KEY, data);
|
|
183
179
|
set({ userData: data });
|
|
184
180
|
|
|
185
181
|
if (__DEV__) {
|