@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.
- 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/SettingsStackNavigator.tsx +2 -0
- package/src/presentation/navigation/components/README.md +70 -295
- package/src/presentation/navigation/components/wrappers/SettingsScreenWrapper.tsx +3 -0
- package/src/presentation/navigation/hooks/README.md +75 -367
- package/src/presentation/navigation/types.ts +1 -0
- package/src/presentation/navigation/utils/README.md +100 -380
- package/src/presentation/screens/README.md +53 -504
- package/src/presentation/screens/SettingsScreen.tsx +4 -2
- 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,288 +1,98 @@
|
|
|
1
1
|
# Settings Screen Utilities
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Purpose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Utility functions for normalizing settings configuration, detecting features, and managing screen state.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Normalizes the settings configuration object to a consistent format.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { normalizeSettingsConfig } from '@umituz/react-native-settings';
|
|
13
|
-
|
|
14
|
-
const config = {
|
|
15
|
-
appearance: true,
|
|
16
|
-
notifications: 'auto',
|
|
17
|
-
about: false,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const normalized = normalizeSettingsConfig(config);
|
|
21
|
-
// Returns: NormalizedConfig with enabled flags and config objects
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
#### Parameters
|
|
25
|
-
|
|
26
|
-
| Parameter | Type | Description |
|
|
27
|
-
|-----------|------|-------------|
|
|
28
|
-
| `config` | `SettingsConfig \| undefined` | Raw configuration object |
|
|
29
|
-
|
|
30
|
-
#### Returns
|
|
31
|
-
|
|
32
|
-
`NormalizedConfig` - Normalized configuration with consistent structure
|
|
33
|
-
|
|
34
|
-
#### Examples
|
|
35
|
-
|
|
36
|
-
**Basic Config:**
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
const config = {
|
|
40
|
-
appearance: true,
|
|
41
|
-
language: true,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const normalized = normalizeSettingsConfig(config);
|
|
45
|
-
// {
|
|
46
|
-
// appearance: { enabled: true },
|
|
47
|
-
// language: { enabled: true },
|
|
48
|
-
// notifications: { enabled: false },
|
|
49
|
-
// // ... others default to { enabled: false }
|
|
50
|
-
// }
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Auto Detection:**
|
|
7
|
+
## File Paths
|
|
54
8
|
|
|
55
|
-
|
|
56
|
-
const config = {
|
|
57
|
-
appearance: 'auto', // Enable if screen exists
|
|
58
|
-
language: 'auto',
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const normalized = normalizeSettingsConfig(config);
|
|
62
|
-
// Will check navigation for screen availability
|
|
63
|
-
```
|
|
9
|
+
- **Config Normalization**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/screens/utils/normalizeConfig.ts`
|
|
64
10
|
|
|
65
|
-
|
|
11
|
+
## Strategy
|
|
66
12
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
showThemeSection: true,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
13
|
+
1. **Config Normalization**: Converts various config formats to consistent structure
|
|
14
|
+
2. **Feature Visibility**: Handles boolean, 'auto', and object config types
|
|
15
|
+
3. **Default Values**: Provides sensible defaults for all features
|
|
16
|
+
4. **Type Safety**: Ensures type safety through TypeScript
|
|
17
|
+
5. **Flexibility**: Supports simple and advanced configuration patterns
|
|
75
18
|
|
|
76
|
-
|
|
77
|
-
// {
|
|
78
|
-
// appearance: { enabled: true, config: { route: '...', showThemeSection: true } }
|
|
79
|
-
// }
|
|
80
|
-
```
|
|
19
|
+
## Restrictions (Forbidden)
|
|
81
20
|
|
|
82
|
-
###
|
|
21
|
+
### DO NOT
|
|
22
|
+
- ❌ DO NOT use raw config values without normalizing
|
|
23
|
+
- ❌ DO NOT modify normalized config objects after creation
|
|
24
|
+
- ❌ DO NOT assume config structure (always normalize first)
|
|
83
25
|
|
|
84
|
-
|
|
26
|
+
### NEVER
|
|
27
|
+
- ❌ NEVER rely on implicit undefined behavior in config
|
|
28
|
+
- ❌ NEVER bypass normalization for "simple" configs
|
|
29
|
+
- ❌ NEVER use hardcoded default values in components
|
|
85
30
|
|
|
86
|
-
|
|
87
|
-
|
|
31
|
+
### AVOID
|
|
32
|
+
- ❌ AVOID creating multiple normalization functions for same purpose
|
|
33
|
+
- ❌ AVOID mixing normalized and non-normalized config
|
|
34
|
+
- ❌ AVOID changing normalization logic frequently
|
|
88
35
|
|
|
89
|
-
|
|
90
|
-
normalizeConfigValue(true, false)
|
|
91
|
-
// { enabled: true }
|
|
36
|
+
## Rules (Mandatory)
|
|
92
37
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
38
|
+
### ALWAYS
|
|
39
|
+
- ✅ ALWAYS normalize config before passing to components
|
|
40
|
+
- ✅ ALWAYS use normalized config for feature detection
|
|
41
|
+
- ✅ MUST treat normalized config as immutable
|
|
42
|
+
- ✅ MUST provide defaults for all features
|
|
96
43
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
44
|
+
### MUST
|
|
45
|
+
- ✅ MUST handle boolean, 'auto', and object config types
|
|
46
|
+
- ✅ MUST preserve advanced config options in normalization
|
|
47
|
+
- ✅ MUST use TypeScript types for type safety
|
|
100
48
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
49
|
+
### SHOULD
|
|
50
|
+
- ✅ SHOULD normalize once and pass to multiple consumers
|
|
51
|
+
- ✅ SHOULD use 'auto' for conditionally shown features
|
|
52
|
+
- ✅ SHOULD keep normalization logic centralized
|
|
105
53
|
|
|
106
|
-
|
|
54
|
+
## AI Agent Guidelines
|
|
107
55
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
56
|
+
1. **File Reference**: When modifying normalization logic, refer to `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/screens/utils/normalizeConfig.ts`
|
|
57
|
+
2. **Config Types**: Understand three input types: boolean (true/false), 'auto' (detect), or object (advanced config)
|
|
58
|
+
3. **Default Strategy**: Most features default to 'auto', some to false (userProfile, subscription, etc.)
|
|
59
|
+
4. **Immutable Pattern**: Never mutate normalized config, create new objects if needed
|
|
60
|
+
5. **Type Safety**: Leverage TypeScript for compile-time checking
|
|
113
61
|
|
|
114
|
-
##
|
|
62
|
+
## Utility Reference
|
|
115
63
|
|
|
116
|
-
|
|
117
|
-
interface NormalizedConfig {
|
|
118
|
-
appearance: {
|
|
119
|
-
enabled: boolean;
|
|
120
|
-
config?: AppearanceConfig;
|
|
121
|
-
};
|
|
122
|
-
language: {
|
|
123
|
-
enabled: boolean;
|
|
124
|
-
config?: LanguageConfig;
|
|
125
|
-
};
|
|
126
|
-
notifications: {
|
|
127
|
-
enabled: boolean;
|
|
128
|
-
config?: NotificationsConfig;
|
|
129
|
-
};
|
|
130
|
-
about: {
|
|
131
|
-
enabled: boolean;
|
|
132
|
-
config?: AboutConfig;
|
|
133
|
-
};
|
|
134
|
-
legal: {
|
|
135
|
-
enabled: boolean;
|
|
136
|
-
config?: LegalConfig;
|
|
137
|
-
};
|
|
138
|
-
disclaimer: {
|
|
139
|
-
enabled: boolean;
|
|
140
|
-
config?: DisclaimerConfig;
|
|
141
|
-
};
|
|
142
|
-
userProfile: {
|
|
143
|
-
enabled: boolean;
|
|
144
|
-
config?: UserProfileConfig;
|
|
145
|
-
};
|
|
146
|
-
feedback: {
|
|
147
|
-
enabled: boolean;
|
|
148
|
-
config?: FeedbackConfig;
|
|
149
|
-
};
|
|
150
|
-
rating: {
|
|
151
|
-
enabled: boolean;
|
|
152
|
-
config?: RatingConfig;
|
|
153
|
-
};
|
|
154
|
-
faqs: {
|
|
155
|
-
enabled: boolean;
|
|
156
|
-
config?: FAQConfig;
|
|
157
|
-
};
|
|
158
|
-
subscription: {
|
|
159
|
-
enabled: boolean;
|
|
160
|
-
config?: SubscriptionConfig;
|
|
161
|
-
};
|
|
162
|
-
wallet: {
|
|
163
|
-
enabled: boolean;
|
|
164
|
-
config?: WalletConfig;
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## FeatureVisibility
|
|
170
|
-
|
|
171
|
-
Type alias for feature enablement:
|
|
172
|
-
|
|
173
|
-
```typescript
|
|
174
|
-
type FeatureVisibility = boolean | 'auto';
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
- `true`: Feature is enabled
|
|
178
|
-
- `false`: Feature is disabled
|
|
179
|
-
- `'auto'`: Feature is automatically detected (checks navigation)
|
|
180
|
-
|
|
181
|
-
## Default Values
|
|
182
|
-
|
|
183
|
-
Default values for each feature:
|
|
184
|
-
|
|
185
|
-
| Feature | Default | Description |
|
|
186
|
-
|---------|---------|-------------|
|
|
187
|
-
| `appearance` | `'auto'` | Auto-detect |
|
|
188
|
-
| `language` | `'auto'` | Auto-detect |
|
|
189
|
-
| `notifications` | `'auto'` | Auto-detect |
|
|
190
|
-
| `about` | `'auto'` | Auto-detect |
|
|
191
|
-
| `legal` | `'auto'` | Auto-detect |
|
|
192
|
-
| `disclaimer` | `false` | Disabled |
|
|
193
|
-
| `userProfile` | `false` | Disabled |
|
|
194
|
-
| `feedback` | `false` | Disabled |
|
|
195
|
-
| `rating` | `false` | Disabled |
|
|
196
|
-
| `faqs` | `false` | Disabled |
|
|
197
|
-
| `subscription` | `false` | Disabled |
|
|
198
|
-
| `wallet` | `false` | Disabled |
|
|
199
|
-
|
|
200
|
-
## Usage Examples
|
|
201
|
-
|
|
202
|
-
### Complete Normalization
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
import { normalizeSettingsConfig } from '@umituz/react-native-settings';
|
|
206
|
-
|
|
207
|
-
function SettingsScreenWrapper() {
|
|
208
|
-
const rawConfig = {
|
|
209
|
-
appearance: true,
|
|
210
|
-
language: {
|
|
211
|
-
enabled: true,
|
|
212
|
-
route: 'LanguageSelection',
|
|
213
|
-
showFlags: true,
|
|
214
|
-
},
|
|
215
|
-
notifications: 'auto',
|
|
216
|
-
};
|
|
64
|
+
### normalizeSettingsConfig
|
|
217
65
|
|
|
218
|
-
|
|
66
|
+
**Purpose**: Converts raw config to normalized format
|
|
219
67
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
normalizedConfig={normalized}
|
|
223
|
-
features={normalized}
|
|
224
|
-
/>
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
```
|
|
68
|
+
**Parameters**:
|
|
69
|
+
- `config`: Raw SettingsConfig (boolean | 'auto' | object values)
|
|
228
70
|
|
|
229
|
-
|
|
71
|
+
**Returns**: NormalizedConfig with enabled flags and config objects
|
|
230
72
|
|
|
73
|
+
**Output Structure**:
|
|
231
74
|
```typescript
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const config = {
|
|
237
|
-
appearance: 'auto',
|
|
238
|
-
language: 'auto',
|
|
239
|
-
notifications: 'auto',
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const normalized = normalizeSettingsConfig(config);
|
|
243
|
-
const features = useFeatureDetection(normalized, navigation, {
|
|
244
|
-
notificationServiceAvailable: true,
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
return (
|
|
248
|
-
<SettingsContent
|
|
249
|
-
normalizedConfig={normalized}
|
|
250
|
-
features={features}
|
|
251
|
-
/>
|
|
252
|
-
);
|
|
75
|
+
{
|
|
76
|
+
appearance: { enabled: boolean, config?: AppearanceConfig },
|
|
77
|
+
language: { enabled: boolean, config?: LanguageConfig },
|
|
78
|
+
// ... other features
|
|
253
79
|
}
|
|
254
80
|
```
|
|
255
81
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
When using `'auto'`, features are detected based on:
|
|
259
|
-
|
|
260
|
-
1. **Navigation State**: Checks if screen exists in navigation stack
|
|
261
|
-
2. **Config Override**: Respects `enabled: true/false` in config object
|
|
262
|
-
3. **Service Availability**: Checks if required services are available
|
|
263
|
-
|
|
264
|
-
```typescript
|
|
265
|
-
// Auto detection flow
|
|
266
|
-
appearance.config?.enabled === true // Explicitly enabled
|
|
267
|
-
|| (appearance.config?.enabled !== false // Not explicitly disabled
|
|
268
|
-
&& hasNavigationScreen(navigation, 'Appearance')) // Screen exists
|
|
269
|
-
```
|
|
82
|
+
### normalizeConfigValue
|
|
270
83
|
|
|
271
|
-
|
|
84
|
+
**Purpose**: Normalizes a single config value
|
|
272
85
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
4. **Advanced Config**: Use config objects for detailed customization
|
|
277
|
-
5. **Feature Detection**: Always use with `useFeatureDetection` hook
|
|
278
|
-
6. **Type Safety**: Leverage TypeScript for config type checking
|
|
86
|
+
**Parameters**:
|
|
87
|
+
- `value`: FeatureVisibility | ConfigObject | undefined
|
|
88
|
+
- `defaultValue`: Default enabled state
|
|
279
89
|
|
|
280
|
-
|
|
90
|
+
**Returns**: { enabled: boolean, config?: ConfigObject }
|
|
281
91
|
|
|
282
|
-
|
|
283
|
-
- **SettingsConfig**: Configuration types
|
|
284
|
-
- **SettingsContent**: Content component
|
|
92
|
+
**Usage**: Use for normalizing individual feature configs
|
|
285
93
|
|
|
286
|
-
##
|
|
94
|
+
## Related Components
|
|
287
95
|
|
|
288
|
-
|
|
96
|
+
- **useFeatureDetection**: Hook that uses normalized config
|
|
97
|
+
- **SettingsScreen**: Screen that uses normalized config
|
|
98
|
+
- **SettingsContent**: Content component that requires normalized config
|