@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,442 +1,162 @@
1
1
  # Navigation Utilities
2
2
 
3
- Utility functions and helpers for managing navigation in the settings system, including screen options, params handling, and navigation helpers.
4
-
5
- ## Utilities
6
-
7
- ### getDefaultRoute
8
-
9
- Gets the default route name for a given feature.
10
-
11
- ```typescript
12
- import { getDefaultRoute } from '@umituz/react-native-settings';
3
+ ## Purpose
13
4
 
14
- const route = getDefaultRoute('appearance');
15
- // Returns: 'Appearance'
16
-
17
- const route = getDefaultRoute('language');
18
- // Returns: 'LanguageSelection'
19
- ```
20
-
21
- #### Signature
5
+ Utility functions and helpers for managing navigation in the settings system, including screen options, params handling, and navigation helpers.
22
6
 
23
- ```typescript
24
- function getDefaultRoute(feature: keyof DefaultRoutes): string;
25
- ```
7
+ ## File Paths
26
8
 
27
- #### Default Routes
9
+ - **Navigation Utils**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/navigation/utils/navigationHelpers.ts`
10
+ - **Screen Options**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/navigation/utils/screenOptions.ts`
28
11
 
29
- | Feature | Route |
30
- |---------|-------|
31
- | `appearance` | `'Appearance'` |
32
- | `language` | `'LanguageSelection'` |
33
- | `notifications` | `'Notifications'` |
34
- | `about` | `'About'` |
35
- | `legal` | `'Legal'` |
36
- | `disclaimer` | `'Disclaimer'` |
12
+ ## Strategy
37
13
 
38
- ### hasNavigationScreen
14
+ 1. **Screen Detection**: Checks if screens exist in navigation state
15
+ 2. **Route Mapping**: Maps features to default route names
16
+ 3. **Safe Navigation**: Provides safe navigation with error handling
17
+ 4. **Param Validation**: Validates and sanitizes navigation params
18
+ 5. **State Helpers**: Utilities for navigation state inspection
39
19
 
40
- Checks if a screen exists in the current navigation state.
20
+ ## Restrictions (Forbidden)
41
21
 
42
- ```typescript
43
- import { hasNavigationScreen } from '@umituz/react-native-settings';
22
+ ### DO NOT
23
+ - DO NOT use hardcoded route names (use getDefaultRoute)
24
+ - ❌ DO NOT bypass screen availability checks
25
+ - ❌ DO NOT navigate without validating params
44
26
 
45
- const navigation = useNavigation();
46
- const hasAppearance = hasNavigationScreen(navigation, 'Appearance');
47
- // Returns: true if 'Appearance' screen exists in navigation
48
- ```
49
-
50
- #### Signature
51
-
52
- ```typescript
53
- function hasNavigationScreen(navigation: any, screenName: string): boolean;
54
- ```
55
-
56
- #### Example
57
-
58
- ```tsx
59
- function SettingsButton() {
60
- const navigation = useNavigation();
61
-
62
- const handlePress = useCallback(() => {
63
- if (hasNavigationScreen(navigation, 'Appearance')) {
64
- navigation.navigate('Appearance');
65
- } else {
66
- console.warn('Appearance screen not found');
67
- }
68
- }, [navigation]);
69
-
70
- return <Button onPress={handlePress} title="Appearance" />;
71
- }
72
- ```
73
-
74
- ### createSettingsScreenOptions
75
-
76
- Creates screen options configuration for settings screens.
77
-
78
- ```typescript
79
- import { createSettingsScreenOptions } from '@umituz/react-native-settings';
80
-
81
- const options = createSettingsScreenOptions({
82
- title: 'Appearance',
83
- showHeader: true,
84
- headerStyle: { backgroundColor: '#fff' },
85
- });
86
- ```
87
-
88
- #### Signature
89
-
90
- ```typescript
91
- function createSettingsScreenOptions(config: {
92
- title?: string;
93
- showHeader?: boolean;
94
- headerStyle?: any;
95
- headerTintColor?: string;
96
- headerTitleStyle?: any;
97
- }): any;
98
- ```
99
-
100
- ### getLegalDocumentType
101
-
102
- Extracts document type from route params or returns default.
103
-
104
- ```typescript
105
- import { getLegalDocumentType } from '@umituz/react-native-settings';
106
-
107
- const documentType = getLegalDocumentType(route.params);
108
- // Returns: 'privacy-policy' | 'terms-of-service' | 'eula'
109
- ```
110
-
111
- #### Signature
112
-
113
- ```typescript
114
- function getLegalDocumentType(params: any): LegalDocumentType;
115
- ```
116
-
117
- ## Screen Options Helpers
118
-
119
- ### Default Screen Options
120
-
121
- ```typescript
122
- const defaultScreenOptions = {
123
- headerStyle: {
124
- backgroundColor: tokens.colors.surface,
125
- },
126
- headerTintColor: tokens.colors.textPrimary,
127
- headerTitleStyle: {
128
- fontWeight: '600',
129
- fontSize: 17,
130
- },
131
- cardStyle: {
132
- backgroundColor: tokens.colors.background,
133
- },
134
- };
135
- ```
136
-
137
- ### Modal Screen Options
138
-
139
- ```typescript
140
- const modalScreenOptions = {
141
- presentation: 'modal',
142
- headerShown: false,
143
- cardStyle: {
144
- backgroundColor: 'transparent',
145
- },
146
- cardOverlayEnabled: true,
147
- cardStyleInterpolator: CardStyleInterpolators.forVerticalIOS,
148
- };
149
- ```
150
-
151
- ### Settings Screen Options
152
-
153
- ```typescript
154
- const settingsScreenOptions = {
155
- headerShown: false,
156
- gestureEnabled: true,
157
- cardStyle: {
158
- backgroundColor: tokens.colors.background,
159
- },
160
- };
161
- ```
162
-
163
- ## Navigation Param Helpers
27
+ ### NEVER
28
+ - NEVER use navigation.navigate() without checking screen availability
29
+ - NEVER pass invalid or unsafe params to navigation
30
+ - ❌ NEVER assume navigation state is valid
164
31
 
165
- ### validateParams
32
+ ### AVOID
33
+ - ❌ AVOID complex navigation state parsing (use provided helpers)
34
+ - ❌ AVOID navigation without error handling
35
+ - ❌ AVOID manual route name construction
166
36
 
167
- Validates navigation params for a given screen.
37
+ ## Rules (Mandatory)
168
38
 
169
- ```typescript
170
- import { validateParams } from '@umituz/react-native-settings';
39
+ ### ALWAYS
40
+ - ALWAYS use safeNavigate for error-prone navigation
41
+ - ✅ ALWAYS check screen availability before navigation
42
+ - ✅ MUST validate params before navigation
43
+ - ✅ MUST handle navigation errors gracefully
171
44
 
172
- const isValid = validateParams('Appearance', {
173
- showThemeSection: true,
174
- showColorsSection: false,
175
- });
176
- // Returns: true
177
- ```
45
+ ### MUST
46
+ - ✅ MUST use getDefaultRoute for default route names
47
+ - ✅ MUST use hasNavigationScreen for availability checks
48
+ - ✅ MUST provide fallback routes for custom navigation
178
49
 
179
- #### Signature
50
+ ### SHOULD
51
+ - ✅ SHOULD use navigateWithFallback for custom routes
52
+ - ✅ SHOULD track navigation events for analytics
53
+ - ✅ SHOULD validate all navigation params
180
54
 
181
- ```typescript
182
- function validateParams(screen: string, params: any): boolean;
183
- ```
55
+ ## AI Agent Guidelines
184
56
 
185
- ### sanitizeParams
57
+ 1. **File Reference**: When modifying navigation utilities, refer to `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/navigation/utils/`
58
+ 2. **Screen Detection**: Always use hasNavigationScreen before navigating to dynamic screens
59
+ 3. **Route Mapping**: Use getDefaultRoute for default route names, don't hardcode
60
+ 4. **Safe Navigation**: Use safeNavigate for all navigation with error handling
61
+ 5. **Param Validation**: Always validate params before navigation
186
62
 
187
- Sanitizes and removes invalid params for navigation.
63
+ ## Utility Reference
188
64
 
189
- ```typescript
190
- import { sanitizeParams } from '@umituz/react-native-settings';
65
+ ### getDefaultRoute
191
66
 
192
- const cleanParams = sanitizeParams('Appearance', {
193
- showThemeSection: true,
194
- invalidParam: 'should be removed',
195
- });
196
- // Returns: { showThemeSection: true }
197
- ```
67
+ **Purpose**: Gets default route name for a feature
198
68
 
199
- #### Signature
69
+ **Parameters**:
70
+ - `feature`: Feature name (keyof DefaultRoutes)
200
71
 
201
- ```typescript
202
- function sanitizeParams(screen: string, params: any): any;
203
- ```
72
+ **Returns**: Default route name string
204
73
 
205
- ## Navigation State Helpers
74
+ **Example**: `getDefaultRoute('appearance')` returns `'Appearance'`
206
75
 
207
- ### getActiveRouteName
76
+ **Usage**: Use when you need default route for a feature
208
77
 
209
- Gets the name of the currently active route.
78
+ ### hasNavigationScreen
210
79
 
211
- ```typescript
212
- import { getActiveRouteName } from '@umituz/react-native-settings';
80
+ **Purpose**: Checks if screen exists in navigation state
213
81
 
214
- const navigation = useNavigation();
215
- const currentRoute = getActiveRouteName(navigation);
216
- // Returns: 'Appearance'
217
- ```
82
+ **Parameters**:
83
+ - `navigation`: React Navigation object
84
+ - `screenName`: Screen name to check
218
85
 
219
- #### Signature
86
+ **Returns**: Boolean indicating screen availability
220
87
 
221
- ```typescript
222
- function getActiveRouteName(navigation: any): string;
223
- ```
88
+ **Example**: `hasNavigationScreen(navigation, 'Appearance')`
224
89
 
225
- #### Example
90
+ **Usage**: Always check before navigating to dynamic screens
226
91
 
227
- ```tsx
228
- function SettingsScreen() {
229
- const navigation = useNavigation();
230
- const currentRoute = getActiveRouteName(navigation);
92
+ ### safeNavigate
231
93
 
232
- useFocusEffect(
233
- useCallback(() => {
234
- Analytics.trackScreen(currentRoute);
235
- }, [currentRoute])
236
- );
94
+ **Purpose**: Safely navigates with error handling
237
95
 
238
- return <SettingsContent />;
239
- }
240
- ```
96
+ **Parameters**:
97
+ - `navigation`: React Navigation object
98
+ - `routeName`: Target route name
99
+ - `params?`: Navigation parameters
241
100
 
242
- ### getNavigationDepth
101
+ **Returns**: Boolean success indicator
243
102
 
244
- Gets the depth of the current navigation stack.
103
+ **Example**: `safeNavigate(navigation, 'Appearance', config)`
245
104
 
246
- ```typescript
247
- import { getNavigationDepth } from '@umituz/react-native-settings';
105
+ **Usage**: Use for all navigation that might fail
248
106
 
249
- const depth = getNavigationDepth(navigation);
250
- // Returns: 3 (three screens in stack)
251
- ```
107
+ ### navigateWithFallback
252
108
 
253
- #### Signature
109
+ **Purpose**: Navigates with fallback route if primary doesn't exist
254
110
 
255
- ```typescript
256
- function getNavigationDepth(navigation: any): number;
257
- ```
111
+ **Parameters**:
112
+ - `navigation`: React Navigation object
113
+ - `primaryRoute`: Try this route first
114
+ - `fallbackRoute`: Use this if primary doesn't exist
115
+ - `params?`: Navigation parameters
258
116
 
259
- ### canGoBack
117
+ **Returns**: void
260
118
 
261
- Checks if navigation can go back.
119
+ **Example**: `navigateWithFallback(navigation, 'CustomAppearance', 'Appearance', config)`
262
120
 
263
- ```typescript
264
- import { canGoBack } from '@umituz/react-native-settings';
121
+ **Usage**: Use when supporting custom routes with defaults
265
122
 
266
- if (canGoBack(navigation)) {
267
- navigation.goBack();
268
- }
269
- ```
123
+ ### getActiveRouteName
270
124
 
271
- #### Signature
125
+ **Purpose**: Gets currently active route name
272
126
 
273
- ```typescript
274
- function canGoBack(navigation: any): boolean;
275
- ```
127
+ **Parameters**:
128
+ - `navigation`: React Navigation object
276
129
 
277
- ## Navigation Action Helpers
130
+ **Returns**: Current route name string
278
131
 
279
- ### safeNavigate
132
+ **Usage**: Use for analytics or tracking
280
133
 
281
- Safely navigates to a screen with error handling.
134
+ ### validateParams
282
135
 
283
- ```typescript
284
- import { safeNavigate } from '@umituz/react-native-settings';
136
+ **Purpose**: Validates navigation params for a screen
285
137
 
286
- safeNavigate(navigation, 'Appearance', { showThemeSection: true });
287
- ```
138
+ **Parameters**:
139
+ - `screen`: Screen name
140
+ - `params`: Params object to validate
288
141
 
289
- #### Signature
142
+ **Returns**: Boolean validity indicator
290
143
 
291
- ```typescript
292
- function safeNavigate(
293
- navigation: any,
294
- routeName: string,
295
- params?: any
296
- ): boolean;
297
- ```
144
+ **Usage**: Always validate before navigation
298
145
 
299
- #### Example
146
+ ### sanitizeParams
300
147
 
301
- ```tsx
302
- function NavigateButton() {
303
- const navigation = useNavigation();
148
+ **Purpose**: Removes invalid params from navigation params
304
149
 
305
- const handlePress = () => {
306
- const success = safeNavigate(navigation, 'Appearance');
307
- if (!success) {
308
- Alert.alert('Error', 'Could not navigate to Appearance');
309
- }
310
- };
150
+ **Parameters**:
151
+ - `screen`: Screen name
152
+ - `params`: Params object to sanitize
311
153
 
312
- return <Button onPress={handlePress} title="Go to Appearance" />;
313
- }
314
- ```
154
+ **Returns**: Sanitized params object
315
155
 
316
- ### navigateWithFallback
156
+ **Usage**: Use to clean params before navigation
317
157
 
318
- Navigates to a screen with a fallback route if the primary doesn't exist.
319
-
320
- ```typescript
321
- import { navigateWithFallback } from '@umituz/react-native-settings';
322
-
323
- navigateWithFallback(
324
- navigation,
325
- 'CustomAppearance', // Try this first
326
- 'Appearance' // Fallback to this
327
- );
328
- ```
329
-
330
- #### Signature
331
-
332
- ```typescript
333
- function navigateWithFallback(
334
- navigation: any,
335
- primaryRoute: string,
336
- fallbackRoute: string,
337
- params?: any
338
- ): void;
339
- ```
340
-
341
- ## Usage Examples
342
-
343
- ### Feature Detection Navigation
344
-
345
- ```tsx
346
- function AutoNavigateButton() {
347
- const navigation = useNavigation();
348
-
349
- const handlePress = useCallback(() => {
350
- // Try custom route first, fallback to default
351
- const customRoute = config?.appearance?.route || 'Appearance';
352
- navigateWithFallback(navigation, customRoute, 'Appearance', config);
353
- }, [navigation, config]);
354
-
355
- return <Button onPress={handlePress} title="Appearance" />;
356
- }
357
- ```
358
-
359
- ### Conditional Navigation
360
-
361
- ```tsx
362
- function ConditionalNavigation() {
363
- const navigation = useNavigation();
364
-
365
- const navigateToScreen = useCallback((screenName: string) => {
366
- if (hasNavigationScreen(navigation, screenName)) {
367
- safeNavigate(navigation, screenName);
368
- } else {
369
- console.warn(`Screen ${screenName} not available`);
370
- }
371
- }, [navigation]);
372
-
373
- return (
374
- <View>
375
- <Button onPress={() => navigateToScreen('Appearance')} title="Appearance" />
376
- <Button onPress={() => navigateToScreen('Language')} title="Language" />
377
- </View>
378
- );
379
- }
380
- ```
381
-
382
- ### Navigation Analytics
383
-
384
- ```tsx
385
- function useNavigationTracking() {
386
- const navigation = useNavigation();
387
- const currentRoute = getActiveRouteName(navigation);
388
-
389
- useEffect(() => {
390
- const unsubscribe = navigation.addListener('state', () => {
391
- const route = getActiveRouteName(navigation);
392
- Analytics.trackScreen(route);
393
- });
394
-
395
- return unsubscribe;
396
- }, [navigation]);
397
-
398
- return currentRoute;
399
- }
400
- ```
401
-
402
- ### Param Validation
403
-
404
- ```tsx
405
- function ValidatedNavigation() {
406
- const navigation = useNavigation();
407
-
408
- const handleNavigate = useCallback(() => {
409
- const params = {
410
- showThemeSection: true,
411
- showColorsSection: true,
412
- };
413
-
414
- if (validateParams('Appearance', params)) {
415
- navigation.navigate('Appearance', params);
416
- } else {
417
- Alert.alert('Error', 'Invalid parameters');
418
- }
419
- }, [navigation]);
420
-
421
- return <Button onPress={handleNavigate} title="Appearance" />;
422
- }
423
- ```
424
-
425
- ## Best Practices
426
-
427
- 1. **Validation**: Always validate params before navigation
428
- 2. **Fallbacks**: Provide fallback routes for custom navigation
429
- 3. **Error Handling**: Use safeNavigate for error-prone navigation
430
- 4. **Screen Detection**: Check for screen existence before navigation
431
- 5. **Analytics**: Track navigation events for insights
432
- 6. **Type Safety**: Use TypeScript for all navigation utilities
433
-
434
- ## Related
158
+ ## Related Components
435
159
 
436
160
  - **Navigation Hooks**: Custom navigation hooks
437
161
  - **Navigation Components**: Screen wrappers
438
162
  - **React Navigation**: Official navigation library
439
-
440
- ## License
441
-
442
- MIT