@umituz/react-native-settings 4.20.58 → 4.20.59

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.
Files changed (64) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +51 -0
  2. package/.github/ISSUE_TEMPLATE/documentation.md +52 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +63 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +84 -0
  5. package/AI_AGENT_GUIDELINES.md +367 -0
  6. package/ARCHITECTURE.md +246 -0
  7. package/CHANGELOG.md +67 -0
  8. package/CODE_OF_CONDUCT.md +75 -0
  9. package/CONTRIBUTING.md +107 -0
  10. package/DOCUMENTATION_MIGRATION.md +319 -0
  11. package/DOCUMENTATION_TEMPLATE.md +155 -0
  12. package/LICENSE +21 -0
  13. package/README.md +321 -498
  14. package/SECURITY.md +98 -0
  15. package/SETTINGS_SCREEN_GUIDE.md +185 -0
  16. package/TESTING.md +358 -0
  17. package/package.json +13 -2
  18. package/src/application/README.md +85 -271
  19. package/src/domains/about/README.md +85 -440
  20. package/src/domains/about/presentation/hooks/README.md +93 -348
  21. package/src/domains/appearance/README.md +95 -584
  22. package/src/domains/appearance/hooks/README.md +95 -303
  23. package/src/domains/appearance/infrastructure/services/README.md +83 -397
  24. package/src/domains/appearance/presentation/components/README.md +95 -489
  25. package/src/domains/cloud-sync/README.md +73 -439
  26. package/src/domains/cloud-sync/presentation/components/README.md +95 -493
  27. package/src/domains/dev/README.md +71 -457
  28. package/src/domains/disclaimer/README.md +77 -411
  29. package/src/domains/disclaimer/presentation/components/README.md +95 -392
  30. package/src/domains/faqs/README.md +86 -574
  31. package/src/domains/feedback/README.md +79 -553
  32. package/src/domains/feedback/presentation/hooks/README.md +93 -426
  33. package/src/domains/legal/README.md +88 -537
  34. package/src/domains/rating/README.md +73 -440
  35. package/src/domains/rating/presentation/components/README.md +95 -475
  36. package/src/domains/video-tutorials/README.md +77 -470
  37. package/src/domains/video-tutorials/presentation/components/README.md +95 -431
  38. package/src/infrastructure/README.md +78 -425
  39. package/src/infrastructure/repositories/README.md +88 -420
  40. package/src/infrastructure/services/README.md +74 -460
  41. package/src/presentation/components/README.md +97 -480
  42. package/src/presentation/components/SettingsErrorBoundary/README.md +48 -436
  43. package/src/presentation/components/SettingsFooter/README.md +48 -427
  44. package/src/presentation/components/SettingsItemCard/README.md +152 -391
  45. package/src/presentation/components/SettingsItemCard/STRATEGY.md +164 -0
  46. package/src/presentation/components/SettingsSection/README.md +47 -401
  47. package/src/presentation/hooks/README.md +95 -389
  48. package/src/presentation/hooks/mutations/README.md +99 -376
  49. package/src/presentation/hooks/queries/README.md +111 -353
  50. package/src/presentation/navigation/README.md +70 -502
  51. package/src/presentation/navigation/components/README.md +70 -295
  52. package/src/presentation/navigation/hooks/README.md +75 -367
  53. package/src/presentation/navigation/utils/README.md +100 -380
  54. package/src/presentation/screens/README.md +53 -504
  55. package/src/presentation/screens/components/SettingsContent/README.md +53 -382
  56. package/src/presentation/screens/components/SettingsHeader/README.md +48 -303
  57. package/src/presentation/screens/components/sections/CustomSettingsList/README.md +47 -359
  58. package/src/presentation/screens/components/sections/FeatureSettingsSection/README.md +81 -176
  59. package/src/presentation/screens/components/sections/IdentitySettingsSection/README.md +40 -297
  60. package/src/presentation/screens/components/sections/ProfileSectionLoader/README.md +47 -451
  61. package/src/presentation/screens/components/sections/SupportSettingsSection/README.md +45 -361
  62. package/src/presentation/screens/hooks/README.md +64 -354
  63. package/src/presentation/screens/types/README.md +79 -409
  64. package/src/presentation/screens/utils/README.md +65 -255
@@ -1,214 +1,124 @@
1
1
  # Application Layer
2
2
 
3
- The application layer defines the core business logic, interfaces, and types for the settings domain following Domain-Driven Design (DDD) principles.
3
+ Defines the core business logic, interfaces, and types for the settings domain following Domain-Driven Design (DDD) principles.
4
4
 
5
- ## Architecture
5
+ ## Purpose
6
6
 
7
- The application layer serves as the bridge between the presentation and infrastructure layers, defining the contracts that both layers must follow.
7
+ The application layer serves as the bridge between the presentation and infrastructure layers, defining the contracts that both layers must follow. It contains pure business logic without any dependencies on external frameworks or storage mechanisms.
8
+
9
+ ## File Paths
8
10
 
9
11
  ```
10
- application/
12
+ src/application/
11
13
  └── ports/
12
14
  └── ISettingsRepository.ts # Repository interface and types
13
15
  ```
14
16
 
15
- ## Core Types
17
+ ## Strategy
16
18
 
17
- ### UserSettings
19
+ 1. **Interface Segregation**: Define clear, focused interfaces that separate concerns between layers
20
+ 2. **Type Safety**: Use TypeScript interfaces to ensure compile-time type checking across the entire application
21
+ 3. **Result Pattern**: Wrap all operations in a Result type for consistent error handling
22
+ 4. **Dependency Inversion**: High-level modules should not depend on low-level modules; both should depend on abstractions
23
+ 5. **Domain Independence**: Keep business logic independent of frameworks, databases, and external services
18
24
 
19
- The main data structure for user settings.
20
-
21
- ```typescript
22
- interface UserSettings {
23
- userId: string; // Unique user identifier
24
- theme: 'light' | 'dark' | 'auto'; // Theme preference
25
- language: string; // Language code (e.g., 'en-US')
26
- notificationsEnabled: boolean; // Master notification switch
27
- emailNotifications: boolean; // Email notification preference
28
- pushNotifications: boolean; // Push notification preference
29
- soundEnabled: boolean; // Sound effects toggle
30
- vibrationEnabled: boolean; // Haptic feedback toggle
31
- privacyMode: boolean; // Privacy/screen shield mode
32
- disclaimerAccepted: boolean; // Legal disclaimer acceptance
33
- updatedAt: Date; // Last update timestamp
34
- }
35
- ```
25
+ ## Restrictions
36
26
 
37
- ### SettingsResult
27
+ ### DO NOT
38
28
 
39
- Result wrapper for settings operations.
29
+ - DO NOT include any implementation details in interfaces
30
+ - ❌ DO NOT import or use React Native components
31
+ - ❌ DO NOT include storage or persistence logic
32
+ - ❌ DO NOT add framework-specific dependencies
33
+ - ❌ DO NOT expose raw exceptions; use Result types
40
34
 
41
- ```typescript
42
- interface SettingsResult<T> {
43
- success: boolean; // Operation success flag
44
- data?: T; // Result data (if successful)
45
- error?: SettingsError; // Error details (if failed)
46
- }
47
- ```
35
+ ### NEVER
48
36
 
49
- ### SettingsError
37
+ - ❌ NEVER couple interfaces to specific storage implementations
38
+ - ❌ NEVER change interface signatures without considering backward compatibility
39
+ - ❌ NEVER include UI-related types in domain interfaces
40
+ - ❌ NEVER use any concrete implementations in type definitions
50
41
 
51
- Error structure for settings operations.
42
+ ### AVOID
52
43
 
53
- ```typescript
54
- interface SettingsError {
55
- code: string; // Error code for identification
56
- message: string; // Human-readable error message
57
- }
58
- ```
44
+ - ❌ AVOID making interfaces too broad or unfocused
45
+ - AVOID circular dependencies between types
46
+ - AVOID optional properties in core data structures
47
+ - AVOID using primitive types where domain-specific types would be clearer
59
48
 
60
- ## Repository Interface
49
+ ## Rules
61
50
 
62
- ### ISettingsRepository
51
+ ### ALWAYS
63
52
 
64
- The contract that all settings repository implementations must follow.
65
-
66
- ```typescript
67
- interface ISettingsRepository {
68
- /**
69
- * Retrieve settings for a user
70
- * @param userId - Unique user identifier
71
- * @returns Promise resolving to settings result
72
- */
73
- getSettings(userId: string): Promise<SettingsResult<UserSettings>>;
74
-
75
- /**
76
- * Save settings for a user
77
- * @param settings - Complete settings object to save
78
- * @returns Promise resolving to operation result
79
- */
80
- saveSettings(settings: UserSettings): Promise<SettingsResult<void>>;
81
-
82
- /**
83
- * Delete settings for a user
84
- * @param userId - Unique user identifier
85
- * @returns Promise resolving to operation result
86
- */
87
- deleteSettings(userId: string): Promise<SettingsResult<void>>;
88
- }
89
- ```
53
+ - ALWAYS define interfaces before implementations
54
+ - ✅ ALWAYS use Result types for operations that can fail
55
+ - ✅ ALWAYS include comprehensive TypeScript documentation comments
56
+ - ALWAYS define error codes as string literals for type safety
57
+ - ✅ ALWAYS update timestamps when data changes
90
58
 
91
- ## Usage Examples
92
-
93
- ### Defining a Custom Repository
94
-
95
- ```typescript
96
- import type { ISettingsRepository, UserSettings, SettingsResult } from '@umituz/react-native-settings';
97
-
98
- class CustomSettingsRepository implements ISettingsRepository {
99
- async getSettings(userId: string): Promise<SettingsResult<UserSettings>> {
100
- try {
101
- // Your custom implementation
102
- const settings = await fetchFromAPI(userId);
103
- return { success: true, data: settings };
104
- } catch (error) {
105
- return {
106
- success: false,
107
- error: {
108
- code: 'FETCH_FAILED',
109
- message: error.message,
110
- },
111
- };
112
- }
113
- }
114
-
115
- async saveSettings(settings: UserSettings): Promise<SettingsResult<void>> {
116
- // Your implementation
117
- }
118
-
119
- async deleteSettings(userId: string): Promise<SettingsResult<void>> {
120
- // Your implementation
121
- }
122
- }
123
- ```
59
+ ### MUST
124
60
 
125
- ### Using Repository Interface
61
+ - MUST export all public types from index files
62
+ - ✅ MUST keep interfaces framework-agnostic
63
+ - ✅ MUST validate all inputs at the application boundary
64
+ - ✅ MUST provide default values for all optional fields
126
65
 
127
- ```typescript
128
- import type { ISettingsRepository } from '@umituz/react-native-settings';
66
+ ### SHOULD
129
67
 
130
- class SettingsService {
131
- constructor(private repository: ISettingsRepository) {}
68
+ - SHOULD favor composition over inheritance
69
+ - SHOULD keep interfaces focused and single-purpose
70
+ - ✅ SHOULD use readonly properties where immutability is important
71
+ - ✅ SHOULD provide factory functions for complex object creation
132
72
 
133
- async getUserSettings(userId: string) {
134
- const result = await this.repository.getSettings(userId);
73
+ ## AI Agent Guidelines
135
74
 
136
- if (!result.success) {
137
- throw new Error(result.error?.message);
138
- }
75
+ 1. **When adding new properties**: Update the UserSettings interface, add validation rules, and provide migration path
76
+ 2. **When modifying interfaces**: Consider backward compatibility and provide deprecation warnings if needed
77
+ 3. **When defining error codes**: Use descriptive, action-oriented codes (e.g., 'VALIDATION_ERROR' not 'ERR_001')
78
+ 4. **When creating Result types**: Always include both success and error states with relevant data
79
+ 5. **When documenting types**: Include examples of valid usage and common pitfalls
139
80
 
140
- return result.data;
141
- }
81
+ ## Core Types Reference
142
82
 
143
- async updateUserPreferences(userId: string, preferences: Partial<UserSettings>) {
144
- const current = await this.getUserSettings(userId);
145
- const updated = { ...current, ...preferences, updatedAt: new Date() };
83
+ ### UserSettings
146
84
 
147
- return this.repository.saveSettings(updated);
148
- }
149
- }
150
- ```
85
+ Main data structure for user settings containing theme, language, notifications, and other preferences.
151
86
 
152
- ### Testing with Mock Repository
153
-
154
- ```typescript
155
- class MockSettingsRepository implements ISettingsRepository {
156
- private settings: Map<string, UserSettings> = new Map();
157
-
158
- async getSettings(userId: string): Promise<SettingsResult<UserSettings>> {
159
- const settings = this.settings.get(userId);
160
- if (!settings) {
161
- return {
162
- success: false,
163
- error: { code: 'NOT_FOUND', message: 'Settings not found' },
164
- };
165
- }
166
- return { success: true, data: settings };
167
- }
168
-
169
- async saveSettings(settings: UserSettings): Promise<SettingsResult<void>> {
170
- this.settings.set(settings.userId, settings);
171
- return { success: true };
172
- }
173
-
174
- async deleteSettings(userId: string): Promise<SettingsResult<void>> {
175
- this.settings.delete(userId);
176
- return { success: true };
177
- }
178
- }
179
-
180
- // Usage in tests
181
- const mockRepo = new MockSettingsRepository();
182
- const service = new SettingsService(mockRepo);
183
-
184
- await service.updateUserPreferences('user123', { theme: 'dark' });
185
- ```
87
+ **Location**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/application/ports/ISettingsRepository.ts`
186
88
 
187
- ## Default Settings
188
-
189
- When no settings exist, the following defaults are used:
190
-
191
- ```typescript
192
- const defaultSettings: UserSettings = {
193
- userId: '',
194
- theme: 'auto', // Follow system theme
195
- language: 'en-US', // English (US)
196
- notificationsEnabled: true, // Notifications on
197
- emailNotifications: true, // Email notifications on
198
- pushNotifications: true, // Push notifications on
199
- soundEnabled: true, // Sound on
200
- vibrationEnabled: true, // Vibration on
201
- privacyMode: false, // Privacy mode off
202
- disclaimerAccepted: false, // Disclaimer not accepted
203
- updatedAt: new Date(),
204
- };
205
- ```
89
+ ### SettingsResult<T>
90
+
91
+ Result wrapper for settings operations with success flag and optional data/error.
92
+
93
+ **Location**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/application/ports/ISettingsRepository.ts`
94
+
95
+ ### SettingsError
96
+
97
+ Error structure with code and message for structured error handling.
98
+
99
+ **Location**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/application/ports/ISettingsRepository.ts`
100
+
101
+ ## Repository Interface
102
+
103
+ ### ISettingsRepository
104
+
105
+ Contract that all settings repository implementations must follow.
106
+
107
+ **Location**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/application/ports/ISettingsRepository.ts`
108
+
109
+ **Methods**:
110
+ - `getSettings(userId: string): Promise<SettingsResult<UserSettings>>`
111
+ - `saveSettings(settings: UserSettings): Promise<SettingsResult<void>>`
112
+ - `deleteSettings(userId: string): Promise<SettingsResult<void>>`
206
113
 
207
114
  ## Error Handling
208
115
 
209
- ### Error Codes
116
+ All operations return `SettingsResult<T>` type with the following structure:
117
+
118
+ **Success**: `{ success: true, data: T }`
119
+ **Error**: `{ success: false, error: { code: string, message: string } }`
210
120
 
211
- Common error codes used throughout the application:
121
+ ## Common Error Codes
212
122
 
213
123
  | Code | Description |
214
124
  |------|-------------|
@@ -221,102 +131,6 @@ Common error codes used throughout the application:
221
131
  | `STORAGE_ERROR` | Underlying storage error |
222
132
  | `NETWORK_ERROR` | Network communication error |
223
133
 
224
- ### Error Handling Pattern
225
-
226
- ```typescript
227
- async function handleSettingsOperation<T>(
228
- operation: () => Promise<SettingsResult<T>>
229
- ): Promise<T> {
230
- const result = await operation();
231
-
232
- if (!result.success) {
233
- throw new SettingsError(
234
- result.error?.code || 'UNKNOWN_ERROR',
235
- result.error?.message || 'An unknown error occurred'
236
- );
237
- }
238
-
239
- return result.data!;
240
- }
241
-
242
- // Usage
243
- try {
244
- const settings = await handleSettingsOperation(() =>
245
- repository.getSettings(userId)
246
- );
247
- } catch (error) {
248
- if (error instanceof SettingsError) {
249
- console.error(`[${error.code}] ${error.message}`);
250
- }
251
- }
252
- ```
253
-
254
- ## Best Practices
255
-
256
- 1. **Type Safety**: Always use the defined interfaces
257
- 2. **Error Handling**: Check `success` flag before accessing data
258
- 3. **Immutability**: Return new objects, don't mutate existing ones
259
- 4. **Validation**: Validate settings before saving
260
- 5. **Default Values**: Always provide sensible defaults
261
- 6. **Timestamp Updates**: Update `updatedAt` on every change
262
- 7. **Partial Updates**: Support partial updates when possible
263
- 8. **Repository Pattern**: Always program to the interface, not implementation
264
-
265
- ## Testing Utilities
266
-
267
- ```typescript
268
- // Test factory for creating test settings
269
- function createTestSettings(overrides?: Partial<UserSettings>): UserSettings {
270
- return {
271
- userId: 'test-user',
272
- theme: 'light',
273
- language: 'en-US',
274
- notificationsEnabled: true,
275
- emailNotifications: true,
276
- pushNotifications: true,
277
- soundEnabled: true,
278
- vibrationEnabled: true,
279
- privacyMode: false,
280
- disclaimerAccepted: true,
281
- updatedAt: new Date(),
282
- ...overrides,
283
- };
284
- }
285
-
286
- // Test factory for creating error results
287
- function createErrorResult<T>(
288
- code: string,
289
- message: string
290
- ): SettingsResult<T> {
291
- return {
292
- success: false,
293
- error: { code, message },
294
- };
295
- }
296
-
297
- // Test factory for creating success results
298
- function createSuccessResult<T>(data?: T): SettingsResult<T> {
299
- return {
300
- success: true,
301
- data,
302
- };
303
- }
304
- ```
305
-
306
- ## Integration Points
307
-
308
- The application layer integrates with:
309
-
310
- - **Presentation Layer**: Provides interfaces for UI components
311
- - **Infrastructure Layer**: Defines contracts for storage implementation
312
- - **Domain Layer**: Contains business logic and entities
313
-
314
- ## Related
315
-
316
- - **Infrastructure**: Repository implementations
317
- - **Presentation Hooks**: React hooks for UI
318
- - **Type Definitions**: Complete type definitions
319
-
320
134
  ## License
321
135
 
322
136
  MIT