@umituz/react-native-settings 4.20.57 → 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/__tests__/setup.ts +1 -4
- 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 +99 -0
- 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 -442
- package/src/presentation/components/SettingsFooter/README.md +48 -427
- package/src/presentation/components/SettingsItemCard/README.md +153 -392
- 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,482 +1,99 @@
|
|
|
1
1
|
# Core Settings Components
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
**With Custom Icons:**
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
<SettingsItemCard
|
|
104
|
-
icon="shield-checkmark-outline"
|
|
105
|
-
title="Privacy"
|
|
106
|
-
description="Manage your privacy"
|
|
107
|
-
iconColor="#10B981"
|
|
108
|
-
iconBgColor="rgba(16, 185, 129, 0.1)"
|
|
109
|
-
onPress={() => navigation.navigate('Privacy')}
|
|
110
|
-
/>
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
**With Right Icon:**
|
|
114
|
-
|
|
115
|
-
```tsx
|
|
116
|
-
<SettingsItemCard
|
|
117
|
-
icon="globe-outline"
|
|
118
|
-
title="Language"
|
|
119
|
-
description="English"
|
|
120
|
-
rightIcon="chevron-down"
|
|
121
|
-
onPress={() => setShowLanguagePicker(true)}
|
|
122
|
-
/>
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### SettingsSection
|
|
126
|
-
|
|
127
|
-
Section container for grouping related settings items with a title.
|
|
128
|
-
|
|
129
|
-
```tsx
|
|
130
|
-
import { SettingsSection } from '@umituz/react-native-settings';
|
|
131
|
-
|
|
132
|
-
<SettingsSection title="PREFERENCES">
|
|
133
|
-
<SettingsItemCard icon="moon-outline" title="Dark Mode" showSwitch={true} />
|
|
134
|
-
<SettingsItemCard icon="globe-outline" title="Language" description="English" />
|
|
135
|
-
</SettingsSection>
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
#### Props
|
|
139
|
-
|
|
140
|
-
| Prop | Type | Default | Description |
|
|
141
|
-
|------|------|---------|-------------|
|
|
142
|
-
| `title` | `string` | **Required** | Section title |
|
|
143
|
-
| `children` | `ReactNode` | **Required** | Section content |
|
|
144
|
-
|
|
145
|
-
#### Example
|
|
146
|
-
|
|
147
|
-
```tsx
|
|
148
|
-
<View>
|
|
149
|
-
<SettingsSection title="GENERAL">
|
|
150
|
-
<SettingsItemCard
|
|
151
|
-
icon="person-outline"
|
|
152
|
-
title="Account"
|
|
153
|
-
onPress={handleAccount}
|
|
154
|
-
/>
|
|
155
|
-
<SettingsItemCard
|
|
156
|
-
icon="notifications-outline"
|
|
157
|
-
title="Notifications"
|
|
158
|
-
onPress={handleNotifications}
|
|
159
|
-
/>
|
|
160
|
-
</SettingsSection>
|
|
161
|
-
|
|
162
|
-
<SettingsSection title="APPEARANCE">
|
|
163
|
-
<SettingsItemCard
|
|
164
|
-
icon="moon-outline"
|
|
165
|
-
title="Dark Mode"
|
|
166
|
-
showSwitch={true}
|
|
167
|
-
switchValue={isDarkMode}
|
|
168
|
-
onSwitchChange={setDarkMode}
|
|
169
|
-
/>
|
|
170
|
-
<SettingsItemCard
|
|
171
|
-
icon="color-palette-outline"
|
|
172
|
-
title="Theme Color"
|
|
173
|
-
description="Blue"
|
|
174
|
-
onPress={handleThemeColor}
|
|
175
|
-
/>
|
|
176
|
-
</SettingsSection>
|
|
177
|
-
</View>
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### SettingsFooter
|
|
181
|
-
|
|
182
|
-
Footer component displaying app version information.
|
|
183
|
-
|
|
184
|
-
```tsx
|
|
185
|
-
import { SettingsFooter } from '@umituz/react-native-settings';
|
|
186
|
-
|
|
187
|
-
<SettingsFooter versionText="Version 1.0.0" />
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
#### Props
|
|
191
|
-
|
|
192
|
-
| Prop | Type | Default | Description |
|
|
193
|
-
|------|------|---------|-------------|
|
|
194
|
-
| `versionText` | `string` | `undefined` | Custom version text |
|
|
195
|
-
|
|
196
|
-
#### Example
|
|
197
|
-
|
|
198
|
-
```tsx
|
|
199
|
-
import { SettingsFooter } from '@umituz/react-native-settings';
|
|
200
|
-
import { Constants } from 'expo-constants';
|
|
201
|
-
|
|
202
|
-
function MySettingsScreen() {
|
|
203
|
-
const version = Constants.expoConfig?.version || '1.0.0';
|
|
204
|
-
|
|
205
|
-
return (
|
|
206
|
-
<View>
|
|
207
|
-
{/* Settings content */}
|
|
208
|
-
|
|
209
|
-
<SettingsFooter versionText={`Version ${version}`} />
|
|
210
|
-
</View>
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### SettingsErrorBoundary
|
|
216
|
-
|
|
217
|
-
Error boundary component for catching and displaying errors in settings screens.
|
|
218
|
-
|
|
219
|
-
```tsx
|
|
220
|
-
import { SettingsErrorBoundary } from '@umituz/react-native-settings';
|
|
221
|
-
|
|
222
|
-
<SettingsErrorBoundary
|
|
223
|
-
fallbackTitle="custom.error.title"
|
|
224
|
-
fallbackMessage="custom.error.message"
|
|
225
|
-
>
|
|
226
|
-
<YourSettingsComponents />
|
|
227
|
-
</SettingsErrorBoundary>
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
#### Props
|
|
231
|
-
|
|
232
|
-
| Prop | Type | Default | Description |
|
|
233
|
-
|------|------|---------|-------------|
|
|
234
|
-
| `children` | `ReactNode` | **Required** | Child components |
|
|
235
|
-
| `fallback` | `ReactNode` | `undefined` | Custom fallback component |
|
|
236
|
-
| `fallbackTitle` | `string` | `undefined` | Error title translation key |
|
|
237
|
-
| `fallbackMessage` | `string` | `undefined` | Error message translation key |
|
|
238
|
-
|
|
239
|
-
#### Example
|
|
240
|
-
|
|
241
|
-
```tsx
|
|
242
|
-
<SettingsErrorBoundary
|
|
243
|
-
fallbackTitle="settings_error"
|
|
244
|
-
fallbackMessage="settings_error_message"
|
|
245
|
-
>
|
|
246
|
-
<SettingsScreen />
|
|
247
|
-
</SettingsErrorBoundary>
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
**Custom Fallback:**
|
|
251
|
-
|
|
252
|
-
```tsx
|
|
253
|
-
const customFallback = (
|
|
254
|
-
<View style={{ padding: 20, alignItems: 'center' }}>
|
|
255
|
-
<Icon name="warning" size={64} color="#F59E0B" />
|
|
256
|
-
<Text style={{ fontSize: 18, fontWeight: 'bold', marginTop: 16 }}>
|
|
257
|
-
Settings Error
|
|
258
|
-
</Text>
|
|
259
|
-
<Button title="Retry" onPress={() => window.location.reload()} />
|
|
260
|
-
</View>
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
<SettingsErrorBoundary fallback={customFallback}>
|
|
264
|
-
<SettingsContent />
|
|
265
|
-
</SettingsErrorBoundary>
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## Complete Examples
|
|
269
|
-
|
|
270
|
-
### Basic Settings Screen
|
|
271
|
-
|
|
272
|
-
```tsx
|
|
273
|
-
import React from 'react';
|
|
274
|
-
import { View, ScrollView } from 'react-native';
|
|
275
|
-
import { SettingsSection, SettingsItemCard, SettingsFooter } from '@umituz/react-native-settings';
|
|
276
|
-
|
|
277
|
-
function BasicSettingsScreen() {
|
|
278
|
-
return (
|
|
279
|
-
<ScrollView style={{ flex: 1 }}>
|
|
280
|
-
<SettingsSection title="PREFERENCES">
|
|
281
|
-
<SettingsItemCard
|
|
282
|
-
icon="moon-outline"
|
|
283
|
-
title="Dark Mode"
|
|
284
|
-
showSwitch={true}
|
|
285
|
-
switchValue={isDarkMode}
|
|
286
|
-
onSwitchChange={setDarkMode}
|
|
287
|
-
/>
|
|
288
|
-
<SettingsItemCard
|
|
289
|
-
icon="globe-outline"
|
|
290
|
-
title="Language"
|
|
291
|
-
description="English"
|
|
292
|
-
onPress={() => {}}
|
|
293
|
-
/>
|
|
294
|
-
</SettingsSection>
|
|
295
|
-
|
|
296
|
-
<SettingsSection title="SUPPORT">
|
|
297
|
-
<SettingsItemCard
|
|
298
|
-
icon="help-circle-outline"
|
|
299
|
-
title="Help Center"
|
|
300
|
-
onPress={() => navigation.navigate('Help')}
|
|
301
|
-
/>
|
|
302
|
-
<SettingsItemCard
|
|
303
|
-
icon="chatbubble-outline"
|
|
304
|
-
title="Contact Us"
|
|
305
|
-
onPress={() => navigation.navigate('Contact')}
|
|
306
|
-
/>
|
|
307
|
-
</SettingsSection>
|
|
308
|
-
|
|
309
|
-
<SettingsFooter versionText="Version 1.0.0" />
|
|
310
|
-
</ScrollView>
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
### Advanced Settings Screen
|
|
316
|
-
|
|
317
|
-
```tsx
|
|
318
|
-
function AdvancedSettingsScreen() {
|
|
319
|
-
const [settings, setSettings] = useState({
|
|
320
|
-
notifications: true,
|
|
321
|
-
darkMode: false,
|
|
322
|
-
soundEnabled: true,
|
|
323
|
-
autoSync: false,
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
return (
|
|
327
|
-
<ScreenLayout>
|
|
328
|
-
<SettingsSection title="NOTIFICATIONS">
|
|
329
|
-
<SettingsItemCard
|
|
330
|
-
icon="notifications-outline"
|
|
331
|
-
title="Push Notifications"
|
|
332
|
-
description="Receive push notifications"
|
|
333
|
-
showSwitch={true}
|
|
334
|
-
switchValue={settings.notifications}
|
|
335
|
-
onSwitchChange={(value) => setSettings({ ...settings, notifications: value })}
|
|
336
|
-
/>
|
|
337
|
-
<SettingsItemCard
|
|
338
|
-
icon="mail-outline"
|
|
339
|
-
title="Email Notifications"
|
|
340
|
-
description="Receive email updates"
|
|
341
|
-
showSwitch={true}
|
|
342
|
-
switchValue={settings.emailNotifications}
|
|
343
|
-
onSwitchChange={(value) => setSettings({ ...settings, emailNotifications: value })}
|
|
344
|
-
/>
|
|
345
|
-
</SettingsSection>
|
|
346
|
-
|
|
347
|
-
<SettingsSection title="APPEARANCE">
|
|
348
|
-
<SettingsItemCard
|
|
349
|
-
icon="moon-outline"
|
|
350
|
-
title="Dark Mode"
|
|
351
|
-
description="Use dark theme"
|
|
352
|
-
showSwitch={true}
|
|
353
|
-
switchValue={settings.darkMode}
|
|
354
|
-
onSwitchChange={(value) => setSettings({ ...settings, darkMode: value })}
|
|
355
|
-
/>
|
|
356
|
-
<SettingsItemCard
|
|
357
|
-
icon="color-palette-outline"
|
|
358
|
-
title="Theme Color"
|
|
359
|
-
description="Blue"
|
|
360
|
-
onPress={() => navigation.navigate('ThemeColor')}
|
|
361
|
-
/>
|
|
362
|
-
</SettingsSection>
|
|
363
|
-
|
|
364
|
-
<SettingsSection title="SYNC">
|
|
365
|
-
<SettingsItemCard
|
|
366
|
-
icon="cloud-outline"
|
|
367
|
-
title="Auto Sync"
|
|
368
|
-
description="Sync data automatically"
|
|
369
|
-
showSwitch={true}
|
|
370
|
-
switchValue={settings.autoSync}
|
|
371
|
-
onSwitchChange={(value) => setSettings({ ...settings, autoSync: value })}
|
|
372
|
-
/>
|
|
373
|
-
<SettingsItemCard
|
|
374
|
-
icon="refresh-outline"
|
|
375
|
-
title="Sync Now"
|
|
376
|
-
description="Last synced: 5 minutes ago"
|
|
377
|
-
onPress={handleManualSync}
|
|
378
|
-
/>
|
|
379
|
-
</SettingsSection>
|
|
380
|
-
|
|
381
|
-
<SettingsFooter versionText={`Version ${Constants.expoConfig.version}`} />
|
|
382
|
-
</ScreenLayout>
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
### With Error Boundary
|
|
388
|
-
|
|
389
|
-
```tsx
|
|
390
|
-
function SettingsScreenWithErrorBoundary() {
|
|
391
|
-
return (
|
|
392
|
-
<SettingsErrorBoundary
|
|
393
|
-
fallbackTitle="settings.error.title"
|
|
394
|
-
fallbackMessage="settings.error.message"
|
|
395
|
-
>
|
|
396
|
-
<SettingsContent />
|
|
397
|
-
</SettingsErrorBoundary>
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
## Styling
|
|
403
|
-
|
|
404
|
-
All components use the design system tokens for consistent styling:
|
|
405
|
-
|
|
406
|
-
- **Colors**: Automatically adapts to light/dark theme
|
|
407
|
-
- **Spacing**: Consistent spacing using design tokens
|
|
408
|
-
- **Typography**: Design system typography scale
|
|
409
|
-
- **Icons**: AtomicIcon component from design system
|
|
410
|
-
- **Border Radius**: Consistent corner radius
|
|
411
|
-
|
|
412
|
-
## Best Practices
|
|
413
|
-
|
|
414
|
-
1. **Group Related Items**: Use `SettingsSection` to group related settings
|
|
415
|
-
2. **Clear Descriptions**: Provide helpful descriptions for settings
|
|
416
|
-
3. **Consistent Icons**: Use consistent icon styles across items
|
|
417
|
-
4. **Switch Usage**: Use switches for binary settings (on/off)
|
|
418
|
-
5. **Navigation**: Use chevron for navigation actions, switches for settings
|
|
419
|
-
6. **Accessibility**: Provide clear labels and descriptions
|
|
420
|
-
7. **Error Handling**: Always wrap screens in `SettingsErrorBoundary`
|
|
421
|
-
8. **Version Info**: Include footer with app version
|
|
422
|
-
|
|
423
|
-
## Testing
|
|
424
|
-
|
|
425
|
-
```tsx
|
|
426
|
-
import { render, fireEvent } from '@testing-library/react-native';
|
|
427
|
-
import { SettingsItemCard, SettingsSection } from '@umituz/react-native-settings';
|
|
428
|
-
|
|
429
|
-
describe('SettingsItemCard', () => {
|
|
430
|
-
it('renders title and icon', () => {
|
|
431
|
-
const { getByText } = render(
|
|
432
|
-
<SettingsItemCard
|
|
433
|
-
icon="settings-outline"
|
|
434
|
-
title="Settings"
|
|
435
|
-
/>
|
|
436
|
-
);
|
|
437
|
-
|
|
438
|
-
expect(getByText('Settings')).toBeTruthy();
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
it('handles press events', () => {
|
|
442
|
-
const mockPress = jest.fn();
|
|
443
|
-
const { getByTestId } = render(
|
|
444
|
-
<SettingsItemCard
|
|
445
|
-
icon="settings-outline"
|
|
446
|
-
title="Settings"
|
|
447
|
-
onPress={mockPress}
|
|
448
|
-
/>
|
|
449
|
-
);
|
|
450
|
-
|
|
451
|
-
fireEvent.press(getByTestId('settings-item-card'));
|
|
452
|
-
expect(mockPress).toHaveBeenCalled();
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
it('handles switch changes', () => {
|
|
456
|
-
const mockChange = jest.fn();
|
|
457
|
-
const { getByTestId } = render(
|
|
458
|
-
<SettingsItemCard
|
|
459
|
-
icon="notifications-outline"
|
|
460
|
-
title="Notifications"
|
|
461
|
-
showSwitch={true}
|
|
462
|
-
switchValue={false}
|
|
463
|
-
onSwitchChange={mockChange}
|
|
464
|
-
/>
|
|
465
|
-
);
|
|
466
|
-
|
|
467
|
-
const switch = getByTestId('switch');
|
|
468
|
-
fireEvent(switch, 'onValueChange', true);
|
|
469
|
-
expect(mockChange).toHaveBeenCalledWith(true);
|
|
470
|
-
});
|
|
471
|
-
});
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
## Related
|
|
475
|
-
|
|
476
|
-
- **SettingsScreen**: Main settings screen component
|
|
477
|
-
- **Settings Sections**: Feature-specific section components
|
|
478
|
-
- **Design System**: Styling and theming foundation
|
|
479
|
-
|
|
480
|
-
## License
|
|
481
|
-
|
|
482
|
-
MIT
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Reusable core components for building settings screens in React Native apps. These components provide a consistent, modern UI for settings interfaces with support for various interaction patterns including navigation, toggles, and display-only items.
|
|
6
|
+
|
|
7
|
+
## File Paths
|
|
8
|
+
|
|
9
|
+
- **SettingsItemCard**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/components/SettingsItemCard.tsx`
|
|
10
|
+
- **SettingsSection**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/components/SettingsSection.tsx`
|
|
11
|
+
- **SettingsFooter**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/components/SettingsFooter.tsx`
|
|
12
|
+
- **SettingsErrorBoundary**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/components/SettingsErrorBoundary.tsx`
|
|
13
|
+
|
|
14
|
+
## Strategy
|
|
15
|
+
|
|
16
|
+
1. **Design System Integration**: All components use design system tokens for consistent styling, automatic theme adaptation (light/dark), and cohesive visual language across the application.
|
|
17
|
+
|
|
18
|
+
2. **Flexible Component Architecture**: Components are designed to be composable and flexible, supporting various use cases from simple navigation items to complex toggle switches with custom styling.
|
|
19
|
+
|
|
20
|
+
3. **Accessibility First**: All components include proper accessibility labels, hints, and touch targets to ensure the settings interface is usable by all users, including those using assistive technologies.
|
|
21
|
+
|
|
22
|
+
4. **Error Resilience**: The SettingsErrorBoundary component wraps settings screens to gracefully handle errors, preventing crashes and providing users with clear error messages and recovery options.
|
|
23
|
+
|
|
24
|
+
5. **Type Safety**: Comprehensive TypeScript types and interfaces ensure type safety throughout the component hierarchy, reducing runtime errors and improving developer experience.
|
|
25
|
+
|
|
26
|
+
## Restrictions
|
|
27
|
+
|
|
28
|
+
### ❌ DO NOT
|
|
29
|
+
|
|
30
|
+
- Mix presentation logic with business logic in components
|
|
31
|
+
- Hardcode color values or spacing - always use design system tokens
|
|
32
|
+
- Bypass the SettingsErrorBoundary for any settings screen
|
|
33
|
+
- Override component styles without proper theme consideration
|
|
34
|
+
- Use inline styles that break theme consistency
|
|
35
|
+
|
|
36
|
+
### ❌ NEVER
|
|
37
|
+
|
|
38
|
+
- Import components directly from subdirectories - use the main package export
|
|
39
|
+
- Modify the internal state of SettingsItemCard from parent components
|
|
40
|
+
- Disable accessibility features or skip accessibility labels
|
|
41
|
+
- Use these components outside of a settings context without proper adaptation
|
|
42
|
+
- Create circular dependencies between settings components
|
|
43
|
+
|
|
44
|
+
### ❌ AVOID
|
|
45
|
+
|
|
46
|
+
- Excessive nesting of SettingsSection components
|
|
47
|
+
- Using SettingsItemCard for non-settings UI elements
|
|
48
|
+
- Overriding default behaviors without understanding implications
|
|
49
|
+
- Creating multiple instances of SettingsErrorBoundary for the same screen
|
|
50
|
+
- Mixing different icon systems or design patterns
|
|
51
|
+
|
|
52
|
+
## Rules
|
|
53
|
+
|
|
54
|
+
### ✅ ALWAYS
|
|
55
|
+
|
|
56
|
+
- Wrap all settings screens in SettingsErrorBoundary
|
|
57
|
+
- Use SettingsSection to group related settings items
|
|
58
|
+
- Provide clear, descriptive titles and descriptions for all settings
|
|
59
|
+
- Use the showSwitch prop for binary (on/off) settings
|
|
60
|
+
- Include proper accessibility labels for all interactive elements
|
|
61
|
+
- Respect the user's theme preference (light/dark/auto)
|
|
62
|
+
|
|
63
|
+
### ✅ MUST
|
|
64
|
+
|
|
65
|
+
- Import components from `@umituz/react-native-settings` package
|
|
66
|
+
- Provide required props (title, icon) for SettingsItemCard
|
|
67
|
+
- Handle onPress events for navigation items
|
|
68
|
+
- Display version information using SettingsFooter
|
|
69
|
+
- Ensure all interactive elements have proper hit areas (minimum 44x44)
|
|
70
|
+
- Test components in both light and dark themes
|
|
71
|
+
|
|
72
|
+
### ✅ SHOULD
|
|
73
|
+
|
|
74
|
+
- Group related settings using SettingsSection
|
|
75
|
+
- Use chevron icons for navigation actions
|
|
76
|
+
- Provide descriptions when settings need clarification
|
|
77
|
+
- Implement proper loading and error states
|
|
78
|
+
- Use custom icon colors sparingly and consistently
|
|
79
|
+
- Consider internationalization for all user-facing text
|
|
80
|
+
- Test components with various content lengths and edge cases
|
|
81
|
+
|
|
82
|
+
## AI Agent Guidelines
|
|
83
|
+
|
|
84
|
+
1. **Component Selection**: Use SettingsItemCard for all individual settings items. Choose between navigation mode (onPress), toggle mode (showSwitch), or display-only based on the setting's purpose.
|
|
85
|
+
|
|
86
|
+
2. **Grouping Strategy**: Organize related settings into logical sections using SettingsSection. Common section categories include: General, Appearance, Notifications, Privacy, and Support.
|
|
87
|
+
|
|
88
|
+
3. **Error Handling**: Always wrap settings screens in SettingsErrorBoundary with appropriate fallback UI. Provide translation keys for error messages to support internationalization.
|
|
89
|
+
|
|
90
|
+
4. **Styling Consistency**: Never override default styling unless absolutely necessary. When custom styling is required, use design system tokens to maintain theme consistency and automatic theme switching.
|
|
91
|
+
|
|
92
|
+
5. **Footer Implementation**: Include SettingsFooter at the bottom of all main settings screens. Use version information from Constants.expoConfig or app config to display accurate version numbers.
|
|
93
|
+
|
|
94
|
+
## Reference
|
|
95
|
+
|
|
96
|
+
- **Components Directory**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/components/`
|
|
97
|
+
- **Design System**: Refer to design system tokens for styling
|
|
98
|
+
- **Main Settings Screen**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/screens/SettingsScreen.tsx`
|
|
99
|
+
- **Domain Components**: See individual domain directories for feature-specific components
|