@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.
- package/.github/ISSUE_TEMPLATE/bug_report.md +51 -0
- package/.github/ISSUE_TEMPLATE/documentation.md +52 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +63 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +84 -0
- package/AI_AGENT_GUIDELINES.md +367 -0
- package/ARCHITECTURE.md +246 -0
- package/CHANGELOG.md +67 -0
- package/CODE_OF_CONDUCT.md +75 -0
- package/CONTRIBUTING.md +107 -0
- package/DOCUMENTATION_MIGRATION.md +319 -0
- package/DOCUMENTATION_TEMPLATE.md +155 -0
- package/LICENSE +21 -0
- package/README.md +321 -498
- package/SECURITY.md +98 -0
- package/SETTINGS_SCREEN_GUIDE.md +185 -0
- package/TESTING.md +358 -0
- package/package.json +13 -2
- package/src/application/README.md +85 -271
- package/src/domains/about/README.md +85 -440
- package/src/domains/about/presentation/hooks/README.md +93 -348
- package/src/domains/appearance/README.md +95 -584
- package/src/domains/appearance/hooks/README.md +95 -303
- package/src/domains/appearance/infrastructure/services/README.md +83 -397
- package/src/domains/appearance/presentation/components/README.md +95 -489
- package/src/domains/cloud-sync/README.md +73 -439
- package/src/domains/cloud-sync/presentation/components/README.md +95 -493
- package/src/domains/dev/README.md +71 -457
- package/src/domains/disclaimer/README.md +77 -411
- package/src/domains/disclaimer/presentation/components/README.md +95 -392
- package/src/domains/faqs/README.md +86 -574
- package/src/domains/feedback/README.md +79 -553
- package/src/domains/feedback/presentation/hooks/README.md +93 -426
- package/src/domains/legal/README.md +88 -537
- package/src/domains/rating/README.md +73 -440
- package/src/domains/rating/presentation/components/README.md +95 -475
- package/src/domains/video-tutorials/README.md +77 -470
- package/src/domains/video-tutorials/presentation/components/README.md +95 -431
- package/src/infrastructure/README.md +78 -425
- package/src/infrastructure/repositories/README.md +88 -420
- package/src/infrastructure/services/README.md +74 -460
- package/src/presentation/components/README.md +97 -480
- package/src/presentation/components/SettingsErrorBoundary/README.md +48 -436
- package/src/presentation/components/SettingsFooter/README.md +48 -427
- package/src/presentation/components/SettingsItemCard/README.md +152 -391
- package/src/presentation/components/SettingsItemCard/STRATEGY.md +164 -0
- package/src/presentation/components/SettingsSection/README.md +47 -401
- package/src/presentation/hooks/README.md +95 -389
- package/src/presentation/hooks/mutations/README.md +99 -376
- package/src/presentation/hooks/queries/README.md +111 -353
- package/src/presentation/navigation/README.md +70 -502
- package/src/presentation/navigation/components/README.md +70 -295
- package/src/presentation/navigation/hooks/README.md +75 -367
- package/src/presentation/navigation/utils/README.md +100 -380
- package/src/presentation/screens/README.md +53 -504
- package/src/presentation/screens/components/SettingsContent/README.md +53 -382
- package/src/presentation/screens/components/SettingsHeader/README.md +48 -303
- package/src/presentation/screens/components/sections/CustomSettingsList/README.md +47 -359
- package/src/presentation/screens/components/sections/FeatureSettingsSection/README.md +81 -176
- package/src/presentation/screens/components/sections/IdentitySettingsSection/README.md +40 -297
- package/src/presentation/screens/components/sections/ProfileSectionLoader/README.md +47 -451
- package/src/presentation/screens/components/sections/SupportSettingsSection/README.md +45 -361
- package/src/presentation/screens/hooks/README.md +64 -354
- package/src/presentation/screens/types/README.md +79 -409
- package/src/presentation/screens/utils/README.md +65 -255
|
@@ -1,442 +1,162 @@
|
|
|
1
1
|
# Navigation Utilities
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
-
function getDefaultRoute(feature: keyof DefaultRoutes): string;
|
|
25
|
-
```
|
|
7
|
+
## File Paths
|
|
26
8
|
|
|
27
|
-
|
|
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
|
-
|
|
30
|
-
|---------|-------|
|
|
31
|
-
| `appearance` | `'Appearance'` |
|
|
32
|
-
| `language` | `'LanguageSelection'` |
|
|
33
|
-
| `notifications` | `'Notifications'` |
|
|
34
|
-
| `about` | `'About'` |
|
|
35
|
-
| `legal` | `'Legal'` |
|
|
36
|
-
| `disclaimer` | `'Disclaimer'` |
|
|
12
|
+
## Strategy
|
|
37
13
|
|
|
38
|
-
|
|
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
|
-
|
|
20
|
+
## Restrictions (Forbidden)
|
|
41
21
|
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
37
|
+
## Rules (Mandatory)
|
|
168
38
|
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
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
|
-
|
|
182
|
-
function validateParams(screen: string, params: any): boolean;
|
|
183
|
-
```
|
|
55
|
+
## AI Agent Guidelines
|
|
184
56
|
|
|
185
|
-
|
|
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
|
-
|
|
63
|
+
## Utility Reference
|
|
188
64
|
|
|
189
|
-
|
|
190
|
-
import { sanitizeParams } from '@umituz/react-native-settings';
|
|
65
|
+
### getDefaultRoute
|
|
191
66
|
|
|
192
|
-
|
|
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
|
-
|
|
69
|
+
**Parameters**:
|
|
70
|
+
- `feature`: Feature name (keyof DefaultRoutes)
|
|
200
71
|
|
|
201
|
-
|
|
202
|
-
function sanitizeParams(screen: string, params: any): any;
|
|
203
|
-
```
|
|
72
|
+
**Returns**: Default route name string
|
|
204
73
|
|
|
205
|
-
|
|
74
|
+
**Example**: `getDefaultRoute('appearance')` returns `'Appearance'`
|
|
206
75
|
|
|
207
|
-
|
|
76
|
+
**Usage**: Use when you need default route for a feature
|
|
208
77
|
|
|
209
|
-
|
|
78
|
+
### hasNavigationScreen
|
|
210
79
|
|
|
211
|
-
|
|
212
|
-
import { getActiveRouteName } from '@umituz/react-native-settings';
|
|
80
|
+
**Purpose**: Checks if screen exists in navigation state
|
|
213
81
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
```
|
|
82
|
+
**Parameters**:
|
|
83
|
+
- `navigation`: React Navigation object
|
|
84
|
+
- `screenName`: Screen name to check
|
|
218
85
|
|
|
219
|
-
|
|
86
|
+
**Returns**: Boolean indicating screen availability
|
|
220
87
|
|
|
221
|
-
|
|
222
|
-
function getActiveRouteName(navigation: any): string;
|
|
223
|
-
```
|
|
88
|
+
**Example**: `hasNavigationScreen(navigation, 'Appearance')`
|
|
224
89
|
|
|
225
|
-
|
|
90
|
+
**Usage**: Always check before navigating to dynamic screens
|
|
226
91
|
|
|
227
|
-
|
|
228
|
-
function SettingsScreen() {
|
|
229
|
-
const navigation = useNavigation();
|
|
230
|
-
const currentRoute = getActiveRouteName(navigation);
|
|
92
|
+
### safeNavigate
|
|
231
93
|
|
|
232
|
-
|
|
233
|
-
useCallback(() => {
|
|
234
|
-
Analytics.trackScreen(currentRoute);
|
|
235
|
-
}, [currentRoute])
|
|
236
|
-
);
|
|
94
|
+
**Purpose**: Safely navigates with error handling
|
|
237
95
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
96
|
+
**Parameters**:
|
|
97
|
+
- `navigation`: React Navigation object
|
|
98
|
+
- `routeName`: Target route name
|
|
99
|
+
- `params?`: Navigation parameters
|
|
241
100
|
|
|
242
|
-
|
|
101
|
+
**Returns**: Boolean success indicator
|
|
243
102
|
|
|
244
|
-
|
|
103
|
+
**Example**: `safeNavigate(navigation, 'Appearance', config)`
|
|
245
104
|
|
|
246
|
-
|
|
247
|
-
import { getNavigationDepth } from '@umituz/react-native-settings';
|
|
105
|
+
**Usage**: Use for all navigation that might fail
|
|
248
106
|
|
|
249
|
-
|
|
250
|
-
// Returns: 3 (three screens in stack)
|
|
251
|
-
```
|
|
107
|
+
### navigateWithFallback
|
|
252
108
|
|
|
253
|
-
|
|
109
|
+
**Purpose**: Navigates with fallback route if primary doesn't exist
|
|
254
110
|
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
117
|
+
**Returns**: void
|
|
260
118
|
|
|
261
|
-
|
|
119
|
+
**Example**: `navigateWithFallback(navigation, 'CustomAppearance', 'Appearance', config)`
|
|
262
120
|
|
|
263
|
-
|
|
264
|
-
import { canGoBack } from '@umituz/react-native-settings';
|
|
121
|
+
**Usage**: Use when supporting custom routes with defaults
|
|
265
122
|
|
|
266
|
-
|
|
267
|
-
navigation.goBack();
|
|
268
|
-
}
|
|
269
|
-
```
|
|
123
|
+
### getActiveRouteName
|
|
270
124
|
|
|
271
|
-
|
|
125
|
+
**Purpose**: Gets currently active route name
|
|
272
126
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
```
|
|
127
|
+
**Parameters**:
|
|
128
|
+
- `navigation`: React Navigation object
|
|
276
129
|
|
|
277
|
-
|
|
130
|
+
**Returns**: Current route name string
|
|
278
131
|
|
|
279
|
-
|
|
132
|
+
**Usage**: Use for analytics or tracking
|
|
280
133
|
|
|
281
|
-
|
|
134
|
+
### validateParams
|
|
282
135
|
|
|
283
|
-
|
|
284
|
-
import { safeNavigate } from '@umituz/react-native-settings';
|
|
136
|
+
**Purpose**: Validates navigation params for a screen
|
|
285
137
|
|
|
286
|
-
|
|
287
|
-
|
|
138
|
+
**Parameters**:
|
|
139
|
+
- `screen`: Screen name
|
|
140
|
+
- `params`: Params object to validate
|
|
288
141
|
|
|
289
|
-
|
|
142
|
+
**Returns**: Boolean validity indicator
|
|
290
143
|
|
|
291
|
-
|
|
292
|
-
function safeNavigate(
|
|
293
|
-
navigation: any,
|
|
294
|
-
routeName: string,
|
|
295
|
-
params?: any
|
|
296
|
-
): boolean;
|
|
297
|
-
```
|
|
144
|
+
**Usage**: Always validate before navigation
|
|
298
145
|
|
|
299
|
-
|
|
146
|
+
### sanitizeParams
|
|
300
147
|
|
|
301
|
-
|
|
302
|
-
function NavigateButton() {
|
|
303
|
-
const navigation = useNavigation();
|
|
148
|
+
**Purpose**: Removes invalid params from navigation params
|
|
304
149
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
313
|
-
}
|
|
314
|
-
```
|
|
154
|
+
**Returns**: Sanitized params object
|
|
315
155
|
|
|
316
|
-
|
|
156
|
+
**Usage**: Use to clean params before navigation
|
|
317
157
|
|
|
318
|
-
|
|
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
|