@umituz/react-native-settings 4.20.58 → 4.20.60

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 (68) 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/SettingsStackNavigator.tsx +2 -0
  52. package/src/presentation/navigation/components/README.md +70 -295
  53. package/src/presentation/navigation/components/wrappers/SettingsScreenWrapper.tsx +3 -0
  54. package/src/presentation/navigation/hooks/README.md +75 -367
  55. package/src/presentation/navigation/types.ts +1 -0
  56. package/src/presentation/navigation/utils/README.md +100 -380
  57. package/src/presentation/screens/README.md +53 -504
  58. package/src/presentation/screens/SettingsScreen.tsx +4 -2
  59. package/src/presentation/screens/components/SettingsContent/README.md +53 -382
  60. package/src/presentation/screens/components/SettingsHeader/README.md +48 -303
  61. package/src/presentation/screens/components/sections/CustomSettingsList/README.md +47 -359
  62. package/src/presentation/screens/components/sections/FeatureSettingsSection/README.md +81 -176
  63. package/src/presentation/screens/components/sections/IdentitySettingsSection/README.md +40 -297
  64. package/src/presentation/screens/components/sections/ProfileSectionLoader/README.md +47 -451
  65. package/src/presentation/screens/components/sections/SupportSettingsSection/README.md +45 -361
  66. package/src/presentation/screens/hooks/README.md +64 -354
  67. package/src/presentation/screens/types/README.md +79 -409
  68. package/src/presentation/screens/utils/README.md +65 -255
@@ -1,383 +1,93 @@
1
- # useFeatureDetection Hook
1
+ # Settings Screen Hooks
2
2
 
3
- Hook for automatically detecting which settings features should be shown based on configuration and navigation state.
3
+ ## Purpose
4
4
 
5
- ## Features
5
+ Custom React hooks for settings screen feature detection, configuration normalization, and navigation management.
6
6
 
7
- - **Auto Detection**: Automatically detects available screens
8
- - **Config Override**: Respects explicit enabled/disabled flags
9
- - **Service Check**: Checks for required services (e.g., notifications)
10
- - **Navigation Check**: Verifies screen exists in navigation stack
11
- - **Memoized**: Optimized with useMemo for performance
7
+ ## File Paths
12
8
 
13
- ## Installation
9
+ - **Feature Detection**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/screens/hooks/useFeatureDetection.ts`
10
+ - **Config Utils**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/screens/utils/normalizeConfig.ts`
14
11
 
15
- This hook is part of `@umituz/react-native-settings`.
12
+ ## Strategy
16
13
 
17
- ## Usage
14
+ 1. **Auto Detection**: Automatically detects available screens based on navigation state
15
+ 2. **Config Normalization**: Converts various config formats to consistent structure
16
+ 3. **Feature Flags**: Generates boolean flags for each feature based on config and availability
17
+ 4. **Performance Optimization**: Uses useMemo to prevent unnecessary recalculations
18
+ 5. **Service Integration**: Checks for required services (e.g., notifications)
18
19
 
19
- ### Basic Usage
20
+ ## Restrictions (Forbidden)
20
21
 
21
- ```tsx
22
- import { useFeatureDetection } from '@umituz/react-native-settings';
22
+ ### DO NOT
23
+ - DO NOT use raw config without normalizing first
24
+ - ❌ DO NOT bypass feature detection for dynamic features
25
+ - ❌ DO NOT mutate normalized config objects
23
26
 
24
- function MySettingsScreen() {
25
- const navigation = useNavigation();
26
- const normalizedConfig = normalizeSettingsConfig(config);
27
+ ### NEVER
28
+ - NEVER hardcode feature availability (use detection)
29
+ - NEVER use feature flags without first normalizing config
30
+ - ❌ NEVER rely on auto-detection for must-show features
27
31
 
28
- const features = useFeatureDetection(normalizedConfig, navigation);
32
+ ### AVOID
33
+ - ❌ AVOID changing config structure after normalization
34
+ - ❌ AVOID unnecessary hook re-renders by keeping dependencies stable
35
+ - ❌ AVOID mixing auto-detection with explicit booleans inconsistently
29
36
 
30
- return (
31
- <View>
32
- {features.appearance && <Text>Appearance is available</Text>}
33
- {features.language && <Text>Language is available</Text>}
34
- </View>
35
- );
36
- }
37
- ```
37
+ ## Rules (Mandatory)
38
38
 
39
- ## API
39
+ ### ALWAYS
40
+ - ✅ ALWAYS normalize config before passing to components or hooks
41
+ - ✅ ALWAYS use useFeatureDetection for dynamic features
42
+ - ✅ ALWAYS provide stable navigation reference to hooks
43
+ - ✅ MUST use memoization for performance optimization
40
44
 
41
- ### Parameters
45
+ ### MUST
46
+ - ✅ MUST check navigation state for screen availability
47
+ - ✅ MUST respect explicit enabled/disabled flags in config
48
+ - ✅ MUST provide service availability for features that require it
42
49
 
43
- | Parameter | Type | Description |
44
- |-----------|------|-------------|
45
- | `normalizedConfig` | `NormalizedConfig` | Normalized configuration object |
46
- | `navigation` | `NavigationProp` | React Navigation object |
47
- | `options` | `DetectionOptions` | Optional detection options |
50
+ ### SHOULD
51
+ - ✅ SHOULD use 'auto' for features that should be conditionally shown
52
+ - SHOULD use boolean for must-show/must-hide features
53
+ - SHOULD keep feature detection logic in hooks, not components
48
54
 
49
- ### DetectionOptions
55
+ ## AI Agent Guidelines
50
56
 
51
- ```typescript
52
- interface DetectionOptions {
53
- notificationServiceAvailable?: boolean;
54
- }
55
- ```
57
+ 1. **File Reference**: When modifying feature detection, refer to `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/screens/hooks/useFeatureDetection.ts`
58
+ 2. **Normalization**: Always call `normalizeSettingsConfig()` before using config
59
+ 3. **Feature Types**: Understand three config types: boolean (true/false), 'auto' (detect), or object (advanced)
60
+ 4. **Navigation Checks**: Auto-detection checks if screen exists in navigation stack
61
+ 5. **Service Checks**: Some features (notifications) require service availability checks
56
62
 
57
- ### Returns
63
+ ## Hook Reference
58
64
 
59
- ```typescript
60
- interface FeatureFlags {
61
- appearance: boolean; // Is appearance screen available?
62
- language: boolean; // Is language screen available?
63
- notifications: boolean; // Are notifications available?
64
- about: boolean; // Is about screen available?
65
- legal: boolean; // Is legal screen available?
66
- disclaimer: boolean; // Is disclaimer available?
67
- userProfile: boolean; // Should show user profile?
68
- feedback: boolean; // Is feedback available?
69
- rating: boolean; // Is rating available?
70
- faqs: boolean; // Are FAQs available?
71
- subscription: boolean; // Is subscription available?
72
- wallet: boolean; // Is wallet available?
73
- }
74
- ```
65
+ ### useFeatureDetection
75
66
 
76
- ## Detection Logic
67
+ **Purpose**: Detects which features should be shown based on config and navigation state
77
68
 
78
- ### Auto Detection Algorithm
69
+ **Parameters**:
70
+ - `normalizedConfig`: Normalized configuration object
71
+ - `navigation`: React Navigation object
72
+ - `options`: Detection options (e.g., notificationServiceAvailable)
79
73
 
80
- For each feature:
74
+ **Returns**: FeatureFlags object with boolean flags for each feature
81
75
 
82
- ```typescript
83
- function shouldShowFeature(
84
- normalizedConfig,
85
- navigation,
86
- options
87
- ): boolean {
88
- const { enabled, config } = normalizedConfig;
76
+ **Usage**: Use in SettingsScreen or SettingsContent to control section visibility
89
77
 
90
- // Check normalized enabled flag
91
- if (!enabled) return false;
78
+ ### normalizeSettingsConfig
92
79
 
93
- // Explicit override in config object
94
- if (config?.enabled === true) return true;
95
- if (config?.enabled === false) return false;
80
+ **Purpose**: Converts raw config to normalized format with enabled flags and config objects
96
81
 
97
- // Auto-detect based on navigation
98
- const defaultRoute = getDefaultRoute(feature);
99
- return hasNavigationScreen(navigation, defaultRoute);
100
- }
101
- ```
82
+ **Parameters**:
83
+ - `config`: Raw SettingsConfig object
102
84
 
103
- ### Navigation Screen Check
85
+ **Returns**: NormalizedConfig with consistent structure
104
86
 
105
- ```typescript
106
- function hasNavigationScreen(
107
- navigation: any,
108
- screenName: string
109
- ): boolean {
110
- try {
111
- const state = navigation.getState();
112
- if (!state) return false;
87
+ **Usage**: Always call before passing config to components or hooks
113
88
 
114
- const checkRoutes = (routes: any[]): boolean => {
115
- for (const route of routes) {
116
- if (route.name === screenName) return true;
117
- if (route.state?.routes && checkRoutes(route.state.routes)) {
118
- return true;
119
- }
120
- }
121
- return false;
122
- };
89
+ ## Related Components
123
90
 
124
- return checkRoutes(state.routes || []);
125
- } catch {
126
- return false;
127
- }
128
- }
129
- ```
130
-
131
- ## Examples
132
-
133
- ### With Auto Detection
134
-
135
- ```tsx
136
- function AutoDetectedSettings() {
137
- const navigation = useNavigation();
138
- const config = {
139
- appearance: 'auto', // Will detect Appearance screen
140
- language: 'auto', // Will detect Language screen
141
- notifications: 'auto', // Will detect Notifications screen
142
- };
143
-
144
- const normalized = normalizeSettingsConfig(config);
145
- const features = useFeatureDetection(normalized, navigation);
146
-
147
- return (
148
- <SettingsContent
149
- normalizedConfig={normalized}
150
- features={features}
151
- />
152
- );
153
- }
154
- ```
155
-
156
- ### With Service Check
157
-
158
- ```tsx
159
- function SettingsWithServiceCheck() {
160
- const navigation = useNavigation();
161
- const notificationServiceAvailable = true; // From app state
162
-
163
- const features = useFeatureDetection(normalizedConfig, navigation, {
164
- notificationServiceAvailable,
165
- });
166
-
167
- // notifications will only be true if:
168
- // 1. enabled in config
169
- // 2. notificationServiceAvailable is true
170
- // 3. Notifications screen exists
171
- }
172
- ```
173
-
174
- ### With Custom Routes
175
-
176
- ```tsx
177
- function SettingsWithCustomRoutes() {
178
- const config = {
179
- appearance: {
180
- enabled: true,
181
- route: 'CustomAppearance', // Custom screen name
182
- },
183
- language: {
184
- enabled: true,
185
- route: 'LanguagePicker', // Custom screen name
186
- },
187
- };
188
-
189
- const features = useFeatureDetection(
190
- normalizeSettingsConfig(config),
191
- navigation
192
- );
193
- }
194
- ```
195
-
196
- ### Explicit Enable/Disable
197
-
198
- ```tsx
199
- function ExplicitlyConfiguredSettings() {
200
- const config = {
201
- appearance: true, // Always show
202
- language: false, // Never show
203
- notifications: {
204
- enabled: true, // Explicitly enabled
205
- route: 'Notifications', // Will check this route
206
- },
207
- about: {
208
- enabled: false, // Explicitly disabled
209
- route: 'About', // Won't check even if exists
210
- },
211
- };
212
-
213
- const features = useFeatureDetection(
214
- normalizeSettingsConfig(config),
215
- navigation
216
- );
217
-
218
- // features.appearance === true
219
- // features.language === false
220
- // features.notifications === (has Notifications screen)
221
- // features.about === false
222
- }
223
- ```
224
-
225
- ### Combined Configuration
226
-
227
- ```tsx
228
- function MixedConfiguration() {
229
- const config = {
230
- // Simple boolean
231
- appearance: true,
232
-
233
- // Auto-detect
234
- language: 'auto',
235
-
236
- // Advanced with explicit enabled
237
- notifications: {
238
- enabled: true,
239
- route: 'Notifications',
240
- showQuietHours: true,
241
- },
242
-
243
- // Advanced with auto-detection
244
- about: {
245
- enabled: 'auto',
246
- route: 'About',
247
- },
248
-
249
- // Explicitly disabled
250
- legal: false,
251
- };
252
-
253
- const features = useFeatureDetection(
254
- normalizeSettingsConfig(config),
255
- navigation
256
- );
257
- }
258
- ```
259
-
260
- ## Default Routes
261
-
262
- Default screen routes checked for each feature:
263
-
264
- | Feature | Default Route |
265
- |---------|--------------|
266
- | `appearance` | `'Appearance'` |
267
- | `language` | `'LanguageSelection'` |
268
- | `notifications` | `'Notifications'` |
269
- | `about` | `'About'` |
270
- | `legal` | `'Legal'` |
271
- | `disclaimer` | `'Disclaimer'` |
272
-
273
- ## Feature-Specific Logic
274
-
275
- ### Notifications
276
-
277
- ```typescript
278
- notifications: notifications.enabled && (
279
- notifications.config?.enabled === true ||
280
- (notifications.config?.enabled !== false &&
281
- notificationServiceAvailable &&
282
- hasNavigationScreen(navigation, 'Notifications'))
283
- )
284
- ```
285
-
286
- Requires both:
287
- - Service availability check
288
- - Navigation screen check
289
-
290
- ### Profile, Feedback, Rating, FAQs
291
-
292
- These features don't check navigation:
293
-
294
- ```typescript
295
- userProfile: userProfile.enabled,
296
- feedback: feedback.enabled,
297
- rating: rating.enabled,
298
- faqs: faqs.enabled,
299
- ```
300
-
301
- ## Performance
302
-
303
- ### Memoization
304
-
305
- The hook uses `useMemo` to prevent unnecessary recalculations:
306
-
307
- ```typescript
308
- const features = useMemo(() => {
309
- // Detection logic
310
- }, [normalizedConfig, navigation, options]);
311
- ```
312
-
313
- ### Dependencies
314
-
315
- Recalculates when:
316
- - `normalizedConfig` changes
317
- - `navigation` changes (should be stable)
318
- - `options` changes
319
-
320
- ## Best Practices
321
-
322
- 1. **Normalize First**: Always normalize config before passing to hook
323
- 2. **Use Auto**: Prefer `'auto'` for automatic detection
324
- 3. **Service Checks**: Provide service availability in options
325
- 4. **Custom Routes**: Define custom routes in config objects
326
- 5. **Explicit Flags**: Use boolean for must-show/must-hide features
327
- 6. **Stable Navigation**: Pass stable navigation reference
328
- 7. **Memoization**: Hook is already memoized for performance
329
-
330
- ## Testing
331
-
332
- ```tsx
333
- import { renderHook } from '@testing-library/react-native';
334
- import { useFeatureDetection } from '@umituz/react-native-settings';
335
-
336
- describe('useFeatureDetection', () => {
337
- it('detects available screens', () => {
338
- const navigation = {
339
- getState: () => ({
340
- routes: [
341
- { name: 'Appearance' },
342
- { name: 'LanguageSelection' },
343
- ],
344
- }),
345
- };
346
-
347
- const config = {
348
- appearance: 'auto',
349
- language: 'auto',
350
- notifications: 'auto',
351
- };
352
-
353
- const { result } = renderHook(() =>
354
- useFeatureDetection(normalizeSettingsConfig(config), navigation)
355
- );
356
-
357
- expect(result.current.appearance).toBe(true);
358
- expect(result.current.language).toBe(true);
359
- });
360
-
361
- it('respects explicit disabled', () => {
362
- const config = {
363
- appearance: false, // Explicitly disabled
364
- };
365
-
366
- const { result } = renderHook(() =>
367
- useFeatureDetection(normalizeSettingsConfig(config), navigation)
368
- );
369
-
370
- expect(result.current.appearance).toBe(false);
371
- });
372
- });
373
- ```
374
-
375
- ## Related
376
-
377
- - **normalizeSettingsConfig**: Config normalization
378
- - **SettingsContent**: Content component
379
- - **Feature Detection**: Detection utility functions
380
-
381
- ## License
382
-
383
- MIT
91
+ - **SettingsScreen**: Main screen that uses these hooks
92
+ - **SettingsContent**: Content component that uses feature flags
93
+ - **Navigation Utils**: Helper functions for navigation checks