@umituz/react-native-settings 4.11.0 → 4.14.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,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Settings Repository Interface
|
|
2
|
+
* Settings Repository Interface and Types
|
|
3
3
|
*
|
|
4
|
-
* Defines
|
|
5
|
-
*
|
|
4
|
+
* Defines the contract for settings storage operations
|
|
5
|
+
* and the core types used throughout the settings domain.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* User settings data structure
|
|
10
|
+
*/
|
|
8
11
|
export interface UserSettings {
|
|
9
12
|
userId: string;
|
|
10
13
|
theme: 'light' | 'dark' | 'auto';
|
|
@@ -18,41 +21,28 @@ export interface UserSettings {
|
|
|
18
21
|
updatedAt: Date;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Settings operation result
|
|
26
|
+
*/
|
|
27
|
+
export interface SettingsResult<T> {
|
|
28
|
+
success: boolean;
|
|
29
|
+
data?: T;
|
|
30
|
+
error?: SettingsError;
|
|
23
31
|
}
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
33
|
+
/**
|
|
34
|
+
* Settings error types
|
|
35
|
+
*/
|
|
36
|
+
export interface SettingsError {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
}
|
|
32
40
|
|
|
33
41
|
/**
|
|
34
|
-
* Settings
|
|
35
|
-
* Repository pattern for settings management
|
|
42
|
+
* Settings repository interface
|
|
36
43
|
*/
|
|
37
44
|
export interface ISettingsRepository {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
loadSettings(userId: string): Promise<SettingsResult<UserSettings>>;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Save user settings to persistent storage
|
|
45
|
-
*/
|
|
46
|
-
saveSettings(settings: Partial<UserSettings>): Promise<SettingsResult<UserSettings>>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Reset settings to default values
|
|
50
|
-
*/
|
|
51
|
-
resetSettings(userId: string): Promise<SettingsResult<UserSettings>>;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Get default settings for a user
|
|
55
|
-
*/
|
|
56
|
-
getDefaultSettings(userId: string): UserSettings;
|
|
45
|
+
getSettings(userId: string): Promise<SettingsResult<UserSettings>>;
|
|
46
|
+
saveSettings(settings: UserSettings): Promise<SettingsResult<void>>;
|
|
47
|
+
deleteSettings(userId: string): Promise<SettingsResult<void>>;
|
|
57
48
|
}
|
|
58
|
-
|
|
@@ -73,8 +73,13 @@ export const DevSettingsSection: React.FC<DevSettingsProps> = ({
|
|
|
73
73
|
style: "destructive",
|
|
74
74
|
onPress: async () => {
|
|
75
75
|
try {
|
|
76
|
-
// Clear all storage
|
|
77
|
-
await storageRepository.clearAll();
|
|
76
|
+
// Clear all storage and check result
|
|
77
|
+
const result = await storageRepository.clearAll();
|
|
78
|
+
|
|
79
|
+
if (!result.success) {
|
|
80
|
+
Alert.alert(t.errorTitle, t.errorMessage);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
78
83
|
|
|
79
84
|
// If callback provided, call it (e.g., reload app)
|
|
80
85
|
if (onAfterClear) {
|
|
@@ -111,6 +111,15 @@ export const UserProfileHeader: React.FC<UserProfileHeaderProps> = ({
|
|
|
111
111
|
>
|
|
112
112
|
{finalDisplayName}
|
|
113
113
|
</AtomicText>
|
|
114
|
+
{userId && (
|
|
115
|
+
<AtomicText
|
|
116
|
+
type="bodySmall"
|
|
117
|
+
style={[styles.id, { color: colors.textSecondary }]}
|
|
118
|
+
numberOfLines={1}
|
|
119
|
+
>
|
|
120
|
+
{userId}
|
|
121
|
+
</AtomicText>
|
|
122
|
+
)}
|
|
114
123
|
</View>
|
|
115
124
|
</View>
|
|
116
125
|
{shouldShowChevron && (
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Ümit UZ
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|