@umituz/react-native-settings 4.20.56 → 4.20.57
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/README.md +145 -3
- package/package.json +1 -2
- package/src/application/README.md +322 -0
- package/src/domains/about/README.md +452 -0
- package/src/domains/about/presentation/hooks/README.md +350 -0
- package/src/domains/appearance/README.md +596 -0
- package/src/domains/appearance/hooks/README.md +366 -0
- package/src/domains/appearance/infrastructure/services/README.md +455 -0
- package/src/domains/cloud-sync/README.md +451 -0
- package/src/domains/cloud-sync/presentation/components/README.md +493 -0
- package/src/domains/dev/README.md +477 -0
- package/src/domains/disclaimer/README.md +421 -0
- package/src/domains/disclaimer/presentation/components/README.md +394 -0
- package/src/domains/faqs/README.md +586 -0
- package/src/domains/feedback/README.md +565 -0
- package/src/domains/feedback/presentation/hooks/README.md +428 -0
- package/src/domains/legal/README.md +549 -0
- package/src/domains/rating/README.md +452 -0
- package/src/domains/rating/presentation/components/README.md +475 -0
- package/src/domains/video-tutorials/README.md +482 -0
- package/src/domains/video-tutorials/presentation/components/README.md +433 -0
- package/src/infrastructure/README.md +509 -0
- package/src/infrastructure/repositories/README.md +475 -0
- package/src/infrastructure/services/README.md +510 -0
- package/src/presentation/components/README.md +482 -0
- package/src/presentation/components/SettingsErrorBoundary/README.md +461 -0
- package/src/presentation/components/SettingsFooter/README.md +446 -0
- package/src/presentation/components/SettingsItemCard/README.md +457 -0
- package/src/presentation/components/SettingsSection/README.md +421 -0
- package/src/presentation/hooks/README.md +413 -0
- package/src/presentation/hooks/mutations/README.md +430 -0
- package/src/presentation/hooks/queries/README.md +441 -0
- package/src/presentation/navigation/README.md +532 -0
- package/src/presentation/navigation/components/README.md +330 -0
- package/src/presentation/navigation/hooks/README.md +399 -0
- package/src/presentation/navigation/utils/README.md +442 -0
- package/src/presentation/screens/README.md +525 -0
- package/src/presentation/screens/components/SettingsContent/README.md +404 -0
- package/src/presentation/screens/components/SettingsHeader/README.md +322 -0
- package/src/presentation/screens/components/sections/CustomSettingsList/README.md +388 -0
- package/src/presentation/screens/components/sections/FeatureSettingsSection/README.md +232 -0
- package/src/presentation/screens/components/sections/IdentitySettingsSection/README.md +325 -0
- package/src/presentation/screens/components/sections/ProfileSectionLoader/README.md +480 -0
- package/src/presentation/screens/components/sections/SupportSettingsSection/README.md +391 -0
- package/src/presentation/screens/hooks/README.md +383 -0
- package/src/presentation/screens/types/README.md +439 -0
- package/src/presentation/screens/utils/README.md +288 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# Navigation Utilities
|
|
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';
|
|
13
|
+
|
|
14
|
+
const route = getDefaultRoute('appearance');
|
|
15
|
+
// Returns: 'Appearance'
|
|
16
|
+
|
|
17
|
+
const route = getDefaultRoute('language');
|
|
18
|
+
// Returns: 'LanguageSelection'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### Signature
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
function getDefaultRoute(feature: keyof DefaultRoutes): string;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### Default Routes
|
|
28
|
+
|
|
29
|
+
| Feature | Route |
|
|
30
|
+
|---------|-------|
|
|
31
|
+
| `appearance` | `'Appearance'` |
|
|
32
|
+
| `language` | `'LanguageSelection'` |
|
|
33
|
+
| `notifications` | `'Notifications'` |
|
|
34
|
+
| `about` | `'About'` |
|
|
35
|
+
| `legal` | `'Legal'` |
|
|
36
|
+
| `disclaimer` | `'Disclaimer'` |
|
|
37
|
+
|
|
38
|
+
### hasNavigationScreen
|
|
39
|
+
|
|
40
|
+
Checks if a screen exists in the current navigation state.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { hasNavigationScreen } from '@umituz/react-native-settings';
|
|
44
|
+
|
|
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
|
|
164
|
+
|
|
165
|
+
### validateParams
|
|
166
|
+
|
|
167
|
+
Validates navigation params for a given screen.
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { validateParams } from '@umituz/react-native-settings';
|
|
171
|
+
|
|
172
|
+
const isValid = validateParams('Appearance', {
|
|
173
|
+
showThemeSection: true,
|
|
174
|
+
showColorsSection: false,
|
|
175
|
+
});
|
|
176
|
+
// Returns: true
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Signature
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
function validateParams(screen: string, params: any): boolean;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### sanitizeParams
|
|
186
|
+
|
|
187
|
+
Sanitizes and removes invalid params for navigation.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { sanitizeParams } from '@umituz/react-native-settings';
|
|
191
|
+
|
|
192
|
+
const cleanParams = sanitizeParams('Appearance', {
|
|
193
|
+
showThemeSection: true,
|
|
194
|
+
invalidParam: 'should be removed',
|
|
195
|
+
});
|
|
196
|
+
// Returns: { showThemeSection: true }
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Signature
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
function sanitizeParams(screen: string, params: any): any;
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Navigation State Helpers
|
|
206
|
+
|
|
207
|
+
### getActiveRouteName
|
|
208
|
+
|
|
209
|
+
Gets the name of the currently active route.
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
import { getActiveRouteName } from '@umituz/react-native-settings';
|
|
213
|
+
|
|
214
|
+
const navigation = useNavigation();
|
|
215
|
+
const currentRoute = getActiveRouteName(navigation);
|
|
216
|
+
// Returns: 'Appearance'
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### Signature
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
function getActiveRouteName(navigation: any): string;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### Example
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
function SettingsScreen() {
|
|
229
|
+
const navigation = useNavigation();
|
|
230
|
+
const currentRoute = getActiveRouteName(navigation);
|
|
231
|
+
|
|
232
|
+
useFocusEffect(
|
|
233
|
+
useCallback(() => {
|
|
234
|
+
Analytics.trackScreen(currentRoute);
|
|
235
|
+
}, [currentRoute])
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
return <SettingsContent />;
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### getNavigationDepth
|
|
243
|
+
|
|
244
|
+
Gets the depth of the current navigation stack.
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
import { getNavigationDepth } from '@umituz/react-native-settings';
|
|
248
|
+
|
|
249
|
+
const depth = getNavigationDepth(navigation);
|
|
250
|
+
// Returns: 3 (three screens in stack)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Signature
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
function getNavigationDepth(navigation: any): number;
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### canGoBack
|
|
260
|
+
|
|
261
|
+
Checks if navigation can go back.
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import { canGoBack } from '@umituz/react-native-settings';
|
|
265
|
+
|
|
266
|
+
if (canGoBack(navigation)) {
|
|
267
|
+
navigation.goBack();
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
#### Signature
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
function canGoBack(navigation: any): boolean;
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Navigation Action Helpers
|
|
278
|
+
|
|
279
|
+
### safeNavigate
|
|
280
|
+
|
|
281
|
+
Safely navigates to a screen with error handling.
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
import { safeNavigate } from '@umituz/react-native-settings';
|
|
285
|
+
|
|
286
|
+
safeNavigate(navigation, 'Appearance', { showThemeSection: true });
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### Signature
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
function safeNavigate(
|
|
293
|
+
navigation: any,
|
|
294
|
+
routeName: string,
|
|
295
|
+
params?: any
|
|
296
|
+
): boolean;
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
#### Example
|
|
300
|
+
|
|
301
|
+
```tsx
|
|
302
|
+
function NavigateButton() {
|
|
303
|
+
const navigation = useNavigation();
|
|
304
|
+
|
|
305
|
+
const handlePress = () => {
|
|
306
|
+
const success = safeNavigate(navigation, 'Appearance');
|
|
307
|
+
if (!success) {
|
|
308
|
+
Alert.alert('Error', 'Could not navigate to Appearance');
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
return <Button onPress={handlePress} title="Go to Appearance" />;
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### navigateWithFallback
|
|
317
|
+
|
|
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
|
|
435
|
+
|
|
436
|
+
- **Navigation Hooks**: Custom navigation hooks
|
|
437
|
+
- **Navigation Components**: Screen wrappers
|
|
438
|
+
- **React Navigation**: Official navigation library
|
|
439
|
+
|
|
440
|
+
## License
|
|
441
|
+
|
|
442
|
+
MIT
|