@umituz/react-native-settings 4.7.1 → 4.8.0
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-settings",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "Settings management for React Native apps - user preferences, theme, language, notifications",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
52
52
|
"@expo/vector-icons": "^14.0.0",
|
|
53
53
|
"@react-native/babel-preset": "^0.83.0",
|
|
54
|
+
"@react-navigation/native": "^6.1.17",
|
|
54
55
|
"@react-navigation/stack": "^7.6.12",
|
|
55
56
|
"@testing-library/jest-native": "^5.4.3",
|
|
56
57
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -35,7 +35,7 @@ const getDefaultSettings = (userId: string): UserSettings => {
|
|
|
35
35
|
if (DEFAULT_SETTINGS_CACHE.has(userId)) {
|
|
36
36
|
return DEFAULT_SETTINGS_CACHE.get(userId)!;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
const settings = {
|
|
40
40
|
userId,
|
|
41
41
|
theme: 'auto' as const,
|
|
@@ -48,7 +48,7 @@ const getDefaultSettings = (userId: string): UserSettings => {
|
|
|
48
48
|
privacyMode: false,
|
|
49
49
|
updatedAt: new Date(),
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
DEFAULT_SETTINGS_CACHE.set(userId, settings);
|
|
53
53
|
return settings;
|
|
54
54
|
};
|
|
@@ -62,12 +62,12 @@ export const useSettingsStore = create<SettingsStore>((set, get) => ({
|
|
|
62
62
|
if (__DEV__) {
|
|
63
63
|
console.log('SettingsStore: Loading settings for user:', userId);
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
set({ loading: true, error: null });
|
|
67
67
|
|
|
68
68
|
try {
|
|
69
69
|
const defaultSettings = getDefaultSettings(userId);
|
|
70
|
-
const storageKey = createUserKey(StorageKey.
|
|
70
|
+
const storageKey = createUserKey(StorageKey.USER_PREFERENCES, userId);
|
|
71
71
|
|
|
72
72
|
// ✅ DRY: Storage domain handles JSON parse, error handling
|
|
73
73
|
const result = await storageRepository.getItem<UserSettings>(storageKey, defaultSettings);
|
|
@@ -127,7 +127,7 @@ export const useSettingsStore = create<SettingsStore>((set, get) => ({
|
|
|
127
127
|
updatedAt: new Date(),
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
const storageKey = createUserKey(StorageKey.
|
|
130
|
+
const storageKey = createUserKey(StorageKey.USER_PREFERENCES, currentSettings.userId);
|
|
131
131
|
|
|
132
132
|
// ✅ DRY: Storage domain replaces JSON.stringify + AsyncStorage + try/catch
|
|
133
133
|
const result = await storageRepository.setItem(storageKey, updatedSettings);
|
|
@@ -153,7 +153,7 @@ export const useSettingsStore = create<SettingsStore>((set, get) => ({
|
|
|
153
153
|
set({ loading: true, error: null });
|
|
154
154
|
|
|
155
155
|
const defaultSettings = getDefaultSettings(userId);
|
|
156
|
-
const storageKey = createUserKey(StorageKey.
|
|
156
|
+
const storageKey = createUserKey(StorageKey.USER_PREFERENCES, userId);
|
|
157
157
|
|
|
158
158
|
// ✅ DRY: Storage domain replaces JSON.stringify + AsyncStorage + try/catch
|
|
159
159
|
const result = await storageRepository.setItem(storageKey, defaultSettings);
|
|
@@ -122,23 +122,71 @@ export const SettingsContent: React.FC<SettingsContentProps> = ({
|
|
|
122
122
|
)}
|
|
123
123
|
|
|
124
124
|
{features.appearance && (
|
|
125
|
-
<AppearanceSection
|
|
125
|
+
<AppearanceSection
|
|
126
|
+
config={{
|
|
127
|
+
...normalizedConfig.appearance.config,
|
|
128
|
+
title:
|
|
129
|
+
normalizedConfig.appearance.config?.title ||
|
|
130
|
+
t("settings.appearance.title"),
|
|
131
|
+
description:
|
|
132
|
+
normalizedConfig.appearance.config?.description ||
|
|
133
|
+
t("settings.appearance.description"),
|
|
134
|
+
}}
|
|
135
|
+
/>
|
|
126
136
|
)}
|
|
127
137
|
|
|
128
138
|
{features.language && (
|
|
129
|
-
<LanguageSection
|
|
139
|
+
<LanguageSection
|
|
140
|
+
config={{
|
|
141
|
+
...normalizedConfig.language.config,
|
|
142
|
+
title: t("settings.languageSelection.title"),
|
|
143
|
+
description:
|
|
144
|
+
normalizedConfig.language.config?.description ||
|
|
145
|
+
t("settings.languageSelection.description"),
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
130
148
|
)}
|
|
131
149
|
|
|
132
150
|
{features.notifications && (
|
|
133
|
-
<NotificationsSection
|
|
151
|
+
<NotificationsSection
|
|
152
|
+
config={{
|
|
153
|
+
...normalizedConfig.notifications.config,
|
|
154
|
+
title:
|
|
155
|
+
normalizedConfig.notifications.config?.title ||
|
|
156
|
+
t("settings.notifications.title"),
|
|
157
|
+
description:
|
|
158
|
+
normalizedConfig.notifications.config?.description ||
|
|
159
|
+
t("settings.notifications.description"),
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
134
162
|
)}
|
|
135
163
|
|
|
136
164
|
{features.about && (
|
|
137
|
-
<AboutSection
|
|
165
|
+
<AboutSection
|
|
166
|
+
config={{
|
|
167
|
+
...normalizedConfig.about.config,
|
|
168
|
+
title:
|
|
169
|
+
normalizedConfig.about.config?.title ||
|
|
170
|
+
t("settings.about.title"),
|
|
171
|
+
description:
|
|
172
|
+
normalizedConfig.about.config?.description ||
|
|
173
|
+
t("settings.about.description"),
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
138
176
|
)}
|
|
139
177
|
|
|
140
178
|
{features.legal && (
|
|
141
|
-
<LegalSection
|
|
179
|
+
<LegalSection
|
|
180
|
+
config={{
|
|
181
|
+
...normalizedConfig.legal.config,
|
|
182
|
+
title:
|
|
183
|
+
normalizedConfig.legal.config?.title ||
|
|
184
|
+
t("settings.legal.title"),
|
|
185
|
+
description:
|
|
186
|
+
normalizedConfig.legal.config?.description ||
|
|
187
|
+
t("settings.legal.description"),
|
|
188
|
+
}}
|
|
189
|
+
/>
|
|
142
190
|
)}
|
|
143
191
|
|
|
144
192
|
{features.disclaimer && DisclaimerSetting && (
|