@umituz/react-native-settings 4.20.56 → 4.20.58

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 (49) hide show
  1. package/README.md +146 -4
  2. package/package.json +1 -2
  3. package/src/__tests__/setup.ts +1 -4
  4. package/src/application/README.md +322 -0
  5. package/src/domains/about/README.md +452 -0
  6. package/src/domains/about/presentation/hooks/README.md +350 -0
  7. package/src/domains/appearance/README.md +596 -0
  8. package/src/domains/appearance/hooks/README.md +366 -0
  9. package/src/domains/appearance/infrastructure/services/README.md +455 -0
  10. package/src/domains/appearance/presentation/components/README.md +493 -0
  11. package/src/domains/cloud-sync/README.md +451 -0
  12. package/src/domains/cloud-sync/presentation/components/README.md +493 -0
  13. package/src/domains/dev/README.md +477 -0
  14. package/src/domains/disclaimer/README.md +421 -0
  15. package/src/domains/disclaimer/presentation/components/README.md +394 -0
  16. package/src/domains/faqs/README.md +586 -0
  17. package/src/domains/feedback/README.md +565 -0
  18. package/src/domains/feedback/presentation/hooks/README.md +428 -0
  19. package/src/domains/legal/README.md +549 -0
  20. package/src/domains/rating/README.md +452 -0
  21. package/src/domains/rating/presentation/components/README.md +475 -0
  22. package/src/domains/video-tutorials/README.md +482 -0
  23. package/src/domains/video-tutorials/presentation/components/README.md +433 -0
  24. package/src/infrastructure/README.md +509 -0
  25. package/src/infrastructure/repositories/README.md +475 -0
  26. package/src/infrastructure/services/README.md +510 -0
  27. package/src/presentation/components/README.md +482 -0
  28. package/src/presentation/components/SettingsErrorBoundary/README.md +455 -0
  29. package/src/presentation/components/SettingsFooter/README.md +446 -0
  30. package/src/presentation/components/SettingsItemCard/README.md +457 -0
  31. package/src/presentation/components/SettingsSection/README.md +421 -0
  32. package/src/presentation/hooks/README.md +413 -0
  33. package/src/presentation/hooks/mutations/README.md +430 -0
  34. package/src/presentation/hooks/queries/README.md +441 -0
  35. package/src/presentation/navigation/README.md +532 -0
  36. package/src/presentation/navigation/components/README.md +330 -0
  37. package/src/presentation/navigation/hooks/README.md +399 -0
  38. package/src/presentation/navigation/utils/README.md +442 -0
  39. package/src/presentation/screens/README.md +525 -0
  40. package/src/presentation/screens/components/SettingsContent/README.md +404 -0
  41. package/src/presentation/screens/components/SettingsHeader/README.md +322 -0
  42. package/src/presentation/screens/components/sections/CustomSettingsList/README.md +388 -0
  43. package/src/presentation/screens/components/sections/FeatureSettingsSection/README.md +232 -0
  44. package/src/presentation/screens/components/sections/IdentitySettingsSection/README.md +325 -0
  45. package/src/presentation/screens/components/sections/ProfileSectionLoader/README.md +480 -0
  46. package/src/presentation/screens/components/sections/SupportSettingsSection/README.md +391 -0
  47. package/src/presentation/screens/hooks/README.md +383 -0
  48. package/src/presentation/screens/types/README.md +439 -0
  49. package/src/presentation/screens/utils/README.md +288 -0
@@ -0,0 +1,525 @@
1
+ # Settings Screen
2
+
3
+ Main settings screen component with modular architecture for displaying app settings in an organized, user-friendly interface.
4
+
5
+ ## Features
6
+
7
+ - **Modular Architecture**: Composable sections for different feature groups
8
+ - **User Profile Header**: Optional user profile display
9
+ - **Feature Detection**: Automatically detect available features
10
+ - **Custom Sections**: Support for custom settings sections
11
+ - **Error Boundaries**: Built-in error handling
12
+ - **Responsive Design**: Adapts to different screen sizes
13
+ - **Theme Support**: Automatic light/dark theme support
14
+
15
+ ## Installation
16
+
17
+ This component is part of `@umituz/react-native-settings`:
18
+
19
+ ```bash
20
+ npm install @umituz/react-native-settings
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Basic Usage
26
+
27
+ ```tsx
28
+ import { SettingsScreen } from '@umituz/react-native-settings';
29
+
30
+ function MySettingsScreen() {
31
+ return (
32
+ <SettingsScreen />
33
+ );
34
+ }
35
+ ```
36
+
37
+ ### With Configuration
38
+
39
+ ```tsx
40
+ import { SettingsScreen } from '@umituz/react-native-settings';
41
+
42
+ function ConfiguredSettingsScreen() {
43
+ const config = {
44
+ appearance: true,
45
+ language: false,
46
+ notifications: true,
47
+ privacy: true,
48
+ support: true,
49
+ about: true,
50
+ legal: true,
51
+ feedback: true,
52
+ faqs: true,
53
+ };
54
+
55
+ return (
56
+ <SettingsScreen
57
+ config={config}
58
+ showUserProfile={true}
59
+ userProfile={{
60
+ displayName: 'John Doe',
61
+ userId: 'user123',
62
+ avatarUrl: 'https://example.com/avatar.jpg',
63
+ }}
64
+ showFooter={true}
65
+ appVersion="1.0.0"
66
+ />
67
+ );
68
+ }
69
+ ```
70
+
71
+ ## Props
72
+
73
+ ### SettingsScreenProps
74
+
75
+ | Prop | Type | Default | Description |
76
+ |------|------|---------|-------------|
77
+ | `config` | `SettingsConfig` | `{}` | Configuration for which features to show |
78
+ | `showUserProfile` | `boolean` | `undefined` | Show user profile header |
79
+ | `userProfile` | `UserProfileProps` | `undefined` | User profile data |
80
+ | `showFooter` | `boolean` | `true` | Show footer with version |
81
+ | `footerText` | `string` | `undefined` | Custom footer text |
82
+ | `appVersion` | `string` | `undefined` | App version number |
83
+ | `customSections` | `CustomSettingsSection[]` | `[]` | Custom sections to render |
84
+ | `showCloseButton` | `boolean` | `false` | Show close button in header |
85
+ | `onClose` | `() => void` | `undefined` | Close button handler |
86
+ | `featureOptions` | `FeatureOptions` | `undefined` | Feature detection options |
87
+ | `devSettings` | `DevSettingsProps` | `undefined` | Dev settings (DEV mode only) |
88
+
89
+ ### SettingsConfig
90
+
91
+ ```typescript
92
+ interface SettingsConfig {
93
+ appearance?: boolean; // Show appearance settings
94
+ language?: boolean; // Show language selection
95
+ notifications?: boolean; // Show notification settings
96
+ privacy?: boolean; // Show privacy settings
97
+ support?: boolean; // Show support section
98
+ about?: boolean; // Show about section
99
+ legal?: boolean; // Show legal section
100
+ feedback?: boolean; // Show feedback section
101
+ faqs?: boolean; // Show FAQ section
102
+ cloudSync?: boolean; // Show cloud sync settings
103
+ // ... more feature flags
104
+ }
105
+ ```
106
+
107
+ ### UserProfileProps
108
+
109
+ ```typescript
110
+ interface UserProfileProps {
111
+ displayName?: string; // User display name
112
+ userId?: string; // User ID
113
+ isAnonymous?: boolean; // Anonymous user flag
114
+ avatarUrl?: string; // Avatar image URL
115
+ accountSettingsRoute?: string; // Navigation route
116
+ onPress?: () => void; // Custom press handler
117
+ anonymousDisplayName?: string; // Anonymous display name
118
+ avatarServiceUrl?: string; // Avatar service base URL
119
+ }
120
+ ```
121
+
122
+ ## Examples
123
+
124
+ ### Minimal Settings
125
+
126
+ ```tsx
127
+ import { SettingsScreen } from '@umituz/react-native-settings';
128
+
129
+ export default function MinimalSettings() {
130
+ return <SettingsScreen />;
131
+ }
132
+ ```
133
+
134
+ ### Custom Configuration
135
+
136
+ ```tsx
137
+ function CustomSettings() {
138
+ return (
139
+ <SettingsScreen
140
+ config={{
141
+ appearance: true,
142
+ notifications: true,
143
+ privacy: true,
144
+ support: true,
145
+ about: true,
146
+ }}
147
+ />
148
+ );
149
+ }
150
+ ```
151
+
152
+ ### With User Profile
153
+
154
+ ```tsx
155
+ function SettingsWithProfile() {
156
+ return (
157
+ <SettingsScreen
158
+ showUserProfile={true}
159
+ userProfile={{
160
+ displayName: 'Jane Doe',
161
+ userId: 'user456',
162
+ avatarUrl: 'https://api.example.com/avatars/user456.jpg',
163
+ onPress: () => navigation.navigate('AccountSettings'),
164
+ }}
165
+ />
166
+ );
167
+ }
168
+ ```
169
+
170
+ ### Anonymous User
171
+
172
+ ```tsx
173
+ function SettingsForAnonymous() {
174
+ return (
175
+ <SettingsScreen
176
+ showUserProfile={true}
177
+ userProfile={{
178
+ isAnonymous: true,
179
+ anonymousDisplayName: 'Guest User',
180
+ onPress: () => navigation.navigate('SignUp'),
181
+ }}
182
+ />
183
+ );
184
+ }
185
+ ```
186
+
187
+ ### With Custom Sections
188
+
189
+ ```tsx
190
+ function SettingsWithCustomSections() {
191
+ const customSections = [
192
+ {
193
+ title: 'INTEGRATIONS',
194
+ items: [
195
+ {
196
+ icon: 'logo-google',
197
+ title: 'Google',
198
+ description: 'Connected',
199
+ showSwitch: true,
200
+ switchValue: googleEnabled,
201
+ onSwitchChange: setGoogleEnabled,
202
+ },
203
+ {
204
+ icon: 'logo-apple',
205
+ title: 'Apple',
206
+ description: 'Not connected',
207
+ onPress: () => connectApple(),
208
+ },
209
+ ],
210
+ },
211
+ ];
212
+
213
+ return (
214
+ <SettingsScreen
215
+ customSections={customSections}
216
+ />
217
+ );
218
+ }
219
+ ```
220
+
221
+ ### With Close Button
222
+
223
+ ```tsx
224
+ function ModalSettingsScreen() {
225
+ return (
226
+ <SettingsScreen
227
+ showCloseButton={true}
228
+ onClose={() => navigation.goBack()}
229
+ />
230
+ );
231
+ }
232
+ ```
233
+
234
+ ### With Dev Settings
235
+
236
+ ```tsx
237
+ import { DevSettingsSection } from '@umituz/react-native-settings';
238
+
239
+ function SettingsWithDevTools() {
240
+ return (
241
+ <SettingsScreen
242
+ devSettings={{
243
+ enabled: true,
244
+ onAfterClear: async () => {
245
+ await resetApp();
246
+ Updates.reloadAsync();
247
+ },
248
+ }}
249
+ />
250
+ );
251
+ }
252
+ ```
253
+
254
+ ### Complete Example
255
+
256
+ ```tsx
257
+ import React from 'react';
258
+ import { SettingsScreen } from '@umituz/react-native-settings';
259
+ import { useAuth } from './auth';
260
+
261
+ export default function CompleteSettingsScreen() {
262
+ const { user } = useAuth();
263
+
264
+ const config = {
265
+ appearance: true,
266
+ notifications: true,
267
+ privacy: true,
268
+ support: true,
269
+ about: true,
270
+ legal: true,
271
+ };
272
+
273
+ const customSections = [
274
+ {
275
+ title: 'PRO FEATURES',
276
+ items: [
277
+ {
278
+ icon: 'star-outline',
279
+ title: 'Upgrade to Pro',
280
+ description: 'Unlock all features',
281
+ onPress: () => navigation.navigate('Upgrade'),
282
+ },
283
+ ],
284
+ },
285
+ ];
286
+
287
+ return (
288
+ <SettingsScreen
289
+ config={config}
290
+ showUserProfile={true}
291
+ userProfile={{
292
+ displayName: user?.displayName,
293
+ userId: user?.uid,
294
+ avatarUrl: user?.photoURL,
295
+ onPress: () => navigation.navigate('Account'),
296
+ }}
297
+ showFooter={true}
298
+ footerText={`Version ${Constants.expoConfig.version}`}
299
+ customSections={customSections}
300
+ showCloseButton={true}
301
+ onClose={() => navigation.goBack()}
302
+ devSettings={{
303
+ onAfterClear: async () => {
304
+ await signOut();
305
+ navigation.reset('Welcome');
306
+ },
307
+ }}
308
+ />
309
+ );
310
+ }
311
+ ```
312
+
313
+ ## Component Structure
314
+
315
+ The SettingsScreen is composed of several sub-components:
316
+
317
+ ```
318
+ SettingsScreen
319
+ ├── SettingsHeader # Header with title and close button
320
+ └── SettingsContent # Main content area
321
+ ├── UserProfileHeader # User profile display (optional)
322
+ ├── Feature Sections # Dynamic sections based on config
323
+ │ ├── AppearanceSection
324
+ │ ├── IdentitySection
325
+ │ ├── NotificationSection
326
+ │ ├── PrivacySection
327
+ │ ├── SupportSection
328
+ │ ├── AboutSection
329
+ │ └── LegalSection
330
+ ├── Custom Sections # User-defined sections
331
+ ├── Dev Settings # Development tools (DEV only)
332
+ └── SettingsFooter # App version footer
333
+ ```
334
+
335
+ ## Custom Sections
336
+
337
+ You can add custom settings sections using the `customSections` prop:
338
+
339
+ ```tsx
340
+ const customSections: CustomSettingsSection[] = [
341
+ {
342
+ title: 'SECTION TITLE',
343
+ items: [
344
+ {
345
+ icon: 'icon-name',
346
+ title: 'Item Title',
347
+ description: 'Optional description',
348
+ onPress: () => {},
349
+ // OR
350
+ showSwitch: true,
351
+ switchValue: true,
352
+ onSwitchChange: (value) => {},
353
+ },
354
+ ],
355
+ },
356
+ ];
357
+ ```
358
+
359
+ ### Custom Section Types
360
+
361
+ **Navigation Items:**
362
+
363
+ ```tsx
364
+ {
365
+ icon: 'chevron-forward-outline',
366
+ title: 'Advanced Settings',
367
+ onPress: () => navigation.navigate('Advanced'),
368
+ }
369
+ ```
370
+
371
+ **Toggle Items:**
372
+
373
+ ```tsx
374
+ {
375
+ icon: 'notifications-outline',
376
+ title: 'Enable Feature',
377
+ showSwitch: true,
378
+ switchValue: enabled,
379
+ onSwitchChange: setEnabled,
380
+ }
381
+ ```
382
+
383
+ **Info Items:**
384
+
385
+ ```tsx
386
+ {
387
+ icon: 'information-circle-outline',
388
+ title: 'App Version',
389
+ description: '1.0.0 (123)',
390
+ }
391
+ ```
392
+
393
+ ## Feature Detection
394
+
395
+ The screen uses feature detection to show/hide sections:
396
+
397
+ ```tsx
398
+ const featureOptions = {
399
+ notificationServiceAvailable: true, // Enable notification features
400
+ };
401
+
402
+ <SettingsScreen
403
+ featureOptions={featureOptions}
404
+ />
405
+ ```
406
+
407
+ ## Styling
408
+
409
+ All styling uses the design system tokens:
410
+
411
+ ```tsx
412
+ // Theme integration handled automatically
413
+ // Supports light/dark mode switching
414
+ // Responsive design for all screen sizes
415
+ ```
416
+
417
+ ## Error Handling
418
+
419
+ The screen includes built-in error boundaries:
420
+
421
+ ```tsx
422
+ <SettingsErrorBoundary>
423
+ <SettingsScreen />
424
+ </SettingsErrorBoundary>
425
+ ```
426
+
427
+ Custom error messages:
428
+
429
+ ```tsx
430
+ <SettingsScreen
431
+ // Screen will use these translation keys for errors
432
+ // "settings.error.title"
433
+ // "settings.error.message"
434
+ />
435
+ ```
436
+
437
+ ## Best Practices
438
+
439
+ 1. **Configuration**: Use `config` prop to control which sections appear
440
+ 2. **User Profile**: Show user profile for signed-in users
441
+ 3. **Custom Sections**: Add app-specific settings via `customSections`
442
+ 4. **Version Info**: Always show app version in footer
443
+ 5. **Error Boundaries**: Don't wrap in additional error boundaries
444
+ 6. **Navigation**: Provide proper navigation handlers
445
+ 7. **Dev Settings**: Include dev tools for development builds
446
+ 8. **Feature Flags**: Use feature flags for experimental features
447
+
448
+ ## Testing
449
+
450
+ ```tsx
451
+ import { render, fireEvent } from '@testing-library/react-native';
452
+ import { SettingsScreen } from '@umituz/react-native-settings';
453
+
454
+ describe('SettingsScreen', () => {
455
+ it('renders with default config', () => {
456
+ const { getByText } = render(<SettingsScreen />);
457
+ expect(getByText(/settings/i)).toBeTruthy();
458
+ });
459
+
460
+ it('shows user profile when configured', () => {
461
+ const { getByText } = render(
462
+ <SettingsScreen
463
+ showUserProfile={true}
464
+ userProfile={{ displayName: 'John Doe' }}
465
+ />
466
+ );
467
+ expect(getByText('John Doe')).toBeTruthy();
468
+ });
469
+
470
+ it('renders custom sections', () => {
471
+ const customSections = [
472
+ {
473
+ title: 'CUSTOM',
474
+ items: [
475
+ {
476
+ icon: 'star',
477
+ title: 'Custom Item',
478
+ onPress: () => {},
479
+ },
480
+ ],
481
+ },
482
+ ];
483
+
484
+ const { getByText } = render(
485
+ <SettingsScreen customSections={customSections} />
486
+ );
487
+ expect(getByText('Custom Item')).toBeTruthy();
488
+ });
489
+ });
490
+ ```
491
+
492
+ ## Architecture
493
+
494
+ The SettingsScreen follows a clean architecture:
495
+
496
+ ```
497
+ presentation/screens/
498
+ ├── SettingsScreen.tsx # Main screen component
499
+ ├── components/
500
+ │ ├── SettingsHeader.tsx # Header component
501
+ │ ├── SettingsContent.tsx # Content composer
502
+ │ └── sections/ # Section components
503
+ │ ├── AppearanceSection.tsx
504
+ │ ├── IdentitySection.tsx
505
+ │ ├── NotificationSection.tsx
506
+ │ ├── PrivacySection.tsx
507
+ │ ├── SupportSection.tsx
508
+ │ ├── AboutSection.tsx
509
+ │ └── LegalSection.tsx
510
+ ├── hooks/
511
+ │ └── useFeatureDetection.ts # Feature detection logic
512
+ ├── utils/
513
+ │ └── normalizeConfig.ts # Config normalization
514
+ └── types/ # TypeScript definitions
515
+ ```
516
+
517
+ ## Related
518
+
519
+ - **Core Components**: SettingsItemCard, SettingsSection
520
+ - **Domains**: Feature-specific domain documentation
521
+ - **Design System**: UI components and theming
522
+
523
+ ## License
524
+
525
+ MIT