@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
|
@@ -2,437 +2,129 @@
|
|
|
2
2
|
|
|
3
3
|
Service layer for appearance domain including system theme detection, validation, and appearance management.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Purpose
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Main service for managing appearance settings including theme mode, custom colors, and system theme detection.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { AppearanceService } from '@umituz/react-native-settings';
|
|
13
|
-
|
|
14
|
-
const appearanceService = new AppearanceService();
|
|
15
|
-
|
|
16
|
-
// Get current theme mode
|
|
17
|
-
const themeMode = await appearanceService.getThemeMode();
|
|
18
|
-
|
|
19
|
-
// Set theme mode
|
|
20
|
-
await appearanceService.setThemeMode('dark');
|
|
21
|
-
|
|
22
|
-
// Get custom colors
|
|
23
|
-
const colors = await appearanceService.getCustomColors();
|
|
7
|
+
Provides business logic services for managing appearance settings including theme mode, custom colors, and system theme detection. Services encapsulate complex operations and provide a clean API for the domain.
|
|
24
8
|
|
|
25
|
-
|
|
26
|
-
await appearanceService.setCustomColors({ primary: '#FF5722' });
|
|
9
|
+
## File Paths
|
|
27
10
|
|
|
28
|
-
// Reset to defaults
|
|
29
|
-
await appearanceService.resetColors();
|
|
30
11
|
```
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Gets the current theme mode setting.
|
|
37
|
-
|
|
38
|
-
```typescript
|
|
39
|
-
const themeMode = await appearanceService.getThemeMode();
|
|
40
|
-
console.log(themeMode); // 'light' | 'dark' | 'auto'
|
|
12
|
+
src/domains/appearance/infrastructure/services/
|
|
13
|
+
├── AppearanceService.ts # Main appearance management
|
|
14
|
+
├── SystemThemeDetectionService.ts # System theme detection
|
|
15
|
+
└── ValidationService.ts # Color/theme validation
|
|
41
16
|
```
|
|
42
17
|
|
|
43
|
-
|
|
18
|
+
## Strategy
|
|
44
19
|
|
|
45
|
-
|
|
20
|
+
1. **Service Encapsulation**: Encapsulate complex appearance logic in service classes
|
|
21
|
+
2. **System Integration**: Detect and respond to system theme changes
|
|
22
|
+
3. **Validation First**: Validate all appearance changes before applying
|
|
23
|
+
4. **Event-Driven**: Use event listeners for system theme changes
|
|
24
|
+
5. **Type Safety**: Provide strongly typed service interfaces
|
|
46
25
|
|
|
47
|
-
|
|
48
|
-
await appearanceService.setThemeMode('dark');
|
|
49
|
-
```
|
|
26
|
+
## Restrictions
|
|
50
27
|
|
|
51
|
-
|
|
28
|
+
### DO NOT
|
|
52
29
|
|
|
53
|
-
|
|
30
|
+
- ❌ DO NOT include UI components or React hooks in services
|
|
31
|
+
- ❌ DO NOT directly access storage; use repositories
|
|
32
|
+
- ❌ DO NOT mix validation logic with business logic
|
|
33
|
+
- ❌ DO NOT create circular dependencies between services
|
|
34
|
+
- ❌ DO NOT swallow validation errors
|
|
54
35
|
|
|
55
|
-
|
|
56
|
-
const colors = await appearanceService.getCustomColors();
|
|
57
|
-
if (colors) {
|
|
58
|
-
console.log(colors.primary);
|
|
59
|
-
}
|
|
60
|
-
```
|
|
36
|
+
### NEVER
|
|
61
37
|
|
|
62
|
-
|
|
38
|
+
- ❌ NEVER apply invalid color values
|
|
39
|
+
- ❌ NEVER assume system theme is available
|
|
40
|
+
- ❌ EVER bypass validation for any reason
|
|
41
|
+
- ❌ EVER store raw hex values without validation
|
|
63
42
|
|
|
64
|
-
|
|
43
|
+
### AVOID
|
|
65
44
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
accent: '#FFC107',
|
|
71
|
-
background: '#FFFFFF',
|
|
72
|
-
surface: '#F5F5F5',
|
|
73
|
-
});
|
|
74
|
-
```
|
|
45
|
+
- ❌ AVOID creating god services that do too much
|
|
46
|
+
- ❌ AVOID tight coupling between services
|
|
47
|
+
- ❌ AVOID synchronous operations for appearance changes
|
|
48
|
+
- ❌ AVOID ignoring system theme change events
|
|
75
49
|
|
|
76
|
-
|
|
50
|
+
## Rules
|
|
77
51
|
|
|
78
|
-
|
|
52
|
+
### ALWAYS
|
|
79
53
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
54
|
+
- ✅ ALWAYS validate theme modes before applying
|
|
55
|
+
- ✅ ALWAYS validate hex color format before applying
|
|
56
|
+
- ✅ ALWAYS handle system theme unsubscription
|
|
57
|
+
- ✅ ALWAYS return typed results from service methods
|
|
58
|
+
- ✅ ALWAYS handle service errors gracefully
|
|
83
59
|
|
|
84
|
-
###
|
|
60
|
+
### MUST
|
|
85
61
|
|
|
86
|
-
|
|
62
|
+
- ✅ MUST validate all inputs before processing
|
|
63
|
+
- ✅ MUST provide clear error messages for validation failures
|
|
64
|
+
- ✅ MUST clean up event listeners on cleanup
|
|
65
|
+
- ✅ MUST respect user preferences over system defaults
|
|
87
66
|
|
|
88
|
-
|
|
89
|
-
import { SystemThemeDetectionService } from '@umituz/react-native-settings';
|
|
67
|
+
### SHOULD
|
|
90
68
|
|
|
91
|
-
|
|
69
|
+
- ✅ SHOULD provide reactive interfaces for theme changes
|
|
70
|
+
- ✅ SHOULD cache theme detection results
|
|
71
|
+
- ✅ SHOULD offer batch operations for multiple changes
|
|
72
|
+
- ✅ SHOULD log important service operations
|
|
92
73
|
|
|
93
|
-
|
|
94
|
-
const systemTheme = detectionService.getSystemTheme();
|
|
95
|
-
console.log(systemTheme); // 'light' | 'dark' | null
|
|
74
|
+
## AI Agent Guidelines
|
|
96
75
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
76
|
+
1. **When creating services**: Keep them focused and single-purpose
|
|
77
|
+
2. **When adding validation**: Provide clear, actionable error messages
|
|
78
|
+
3. **When detecting system theme**: Use native APIs with fallbacks
|
|
79
|
+
4. **When managing colors**: Validate hex format (#RRGGBB) before applying
|
|
80
|
+
5. **When handling errors**: Transform technical errors into user-friendly messages
|
|
101
81
|
|
|
102
|
-
|
|
103
|
-
unsubscribe();
|
|
104
|
-
```
|
|
82
|
+
## Services Reference
|
|
105
83
|
|
|
106
|
-
|
|
84
|
+
### AppearanceService
|
|
107
85
|
|
|
108
|
-
|
|
86
|
+
Main service for managing appearance settings including theme mode, custom colors, and system theme detection.
|
|
109
87
|
|
|
110
|
-
|
|
88
|
+
**Location**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/infrastructure/services/AppearanceService.ts`
|
|
111
89
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
90
|
+
**Methods**:
|
|
91
|
+
- `getThemeMode(): Promise<'light' | 'dark' | 'auto'>` - Get current theme mode
|
|
92
|
+
- `setThemeMode(mode: 'light' | 'dark' | 'auto'): Promise<void>` - Set theme mode
|
|
93
|
+
- `getCustomColors(): Promise<ColorPalette | undefined>` - Get custom colors
|
|
94
|
+
- `setCustomColors(colors: ColorPalette): Promise<void>` - Set custom colors
|
|
95
|
+
- `resetColors(): Promise<void>` - Reset to default colors
|
|
118
96
|
|
|
119
|
-
|
|
97
|
+
### SystemThemeDetectionService
|
|
120
98
|
|
|
121
|
-
|
|
99
|
+
Service for detecting and monitoring system theme changes.
|
|
122
100
|
|
|
123
|
-
|
|
124
|
-
const unsubscribe = detectionService.listen((theme) => {
|
|
125
|
-
console.log('Theme changed to:', theme);
|
|
126
|
-
// Update app theme accordingly
|
|
127
|
-
});
|
|
101
|
+
**Location**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/infrastructure/services/SystemThemeDetectionService.ts`
|
|
128
102
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}, []);
|
|
133
|
-
```
|
|
103
|
+
**Methods**:
|
|
104
|
+
- `getSystemTheme(): 'light' | 'dark' | null` - Get current system theme
|
|
105
|
+
- `listen(callback: (theme: 'light' | 'dark') => void): () => void` - Listen for changes
|
|
134
106
|
|
|
135
107
|
### ValidationService
|
|
136
108
|
|
|
137
109
|
Service for validating appearance settings.
|
|
138
110
|
|
|
139
|
-
|
|
140
|
-
import { ValidationService } from '@umituz/react-native-settings';
|
|
141
|
-
|
|
142
|
-
const validationService = new ValidationService();
|
|
143
|
-
|
|
144
|
-
// Validate theme mode
|
|
145
|
-
const themeValid = validationService.validateThemeMode('dark');
|
|
146
|
-
console.log(themeValid); // true
|
|
147
|
-
|
|
148
|
-
const themeInvalid = validationService.validateThemeMode('invalid');
|
|
149
|
-
console.log(themeInvalid); // false
|
|
111
|
+
**Location**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/infrastructure/services/ValidationService.ts`
|
|
150
112
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const colorInvalid = validationService.validateColor('invalid');
|
|
156
|
-
console.log(colorInvalid); // false
|
|
157
|
-
|
|
158
|
-
// Validate color palette
|
|
159
|
-
const paletteValid = validationService.validateColorPalette({
|
|
160
|
-
primary: '#FF5722',
|
|
161
|
-
secondary: '#2196F3',
|
|
162
|
-
});
|
|
163
|
-
console.log(paletteValid); // true
|
|
164
|
-
```
|
|
113
|
+
**Methods**:
|
|
114
|
+
- `validateThemeMode(mode: string): boolean` - Validate theme mode
|
|
115
|
+
- `validateColor(color: string): boolean` - Validate hex color
|
|
116
|
+
- `validateColorPalette(palette: ColorPalette): boolean` - Validate complete palette
|
|
165
117
|
|
|
166
|
-
|
|
118
|
+
## Color Palette Structure
|
|
167
119
|
|
|
168
|
-
**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
console.error('Invalid theme mode');
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
**validateColor(color: string): boolean**
|
|
181
|
-
|
|
182
|
-
Validates if the provided string is a valid hex color.
|
|
183
|
-
|
|
184
|
-
```typescript
|
|
185
|
-
if (validationService.validateColor('#FF5722')) {
|
|
186
|
-
// Color is valid
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
**validateColorPalette(palette: ColorPalette): boolean**
|
|
191
|
-
|
|
192
|
-
Validates a complete color palette.
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
const palette = {
|
|
196
|
-
primary: '#FF5722',
|
|
197
|
-
secondary: '#2196F3',
|
|
198
|
-
accent: '#FFC107',
|
|
199
|
-
background: '#FFFFFF',
|
|
200
|
-
surface: '#F5F5F5',
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
if (validationService.validateColorPalette(palette)) {
|
|
204
|
-
await appearanceService.setCustomColors(palette);
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
## Usage Examples
|
|
209
|
-
|
|
210
|
-
### Auto Theme with System Detection
|
|
211
|
-
|
|
212
|
-
```tsx
|
|
213
|
-
function useAutoTheme() {
|
|
214
|
-
const [theme, setTheme] = useState<'light' | 'dark'>('light');
|
|
215
|
-
const { themeMode } = useAppearance();
|
|
216
|
-
|
|
217
|
-
useEffect(() => {
|
|
218
|
-
if (themeMode === 'auto') {
|
|
219
|
-
// Use system theme
|
|
220
|
-
const systemTheme = SystemThemeDetectionService.getSystemTheme();
|
|
221
|
-
if (systemTheme) {
|
|
222
|
-
setTheme(systemTheme);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// Listen for changes
|
|
226
|
-
const unsubscribe = SystemThemeDetectionService.listen((newTheme) => {
|
|
227
|
-
setTheme(newTheme);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
return unsubscribe;
|
|
231
|
-
} else {
|
|
232
|
-
// Use explicit theme
|
|
233
|
-
setTheme(themeMode === 'dark' ? 'dark' : 'light');
|
|
234
|
-
}
|
|
235
|
-
}, [themeMode]);
|
|
236
|
-
|
|
237
|
-
return theme;
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Theme Persistence
|
|
242
|
-
|
|
243
|
-
```tsx
|
|
244
|
-
class ThemePersistence {
|
|
245
|
-
private service: AppearanceService;
|
|
246
|
-
|
|
247
|
-
constructor() {
|
|
248
|
-
this.service = new AppearanceService();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async loadTheme(): Promise<'light' | 'dark' | 'auto'> {
|
|
252
|
-
const mode = await this.service.getThemeMode();
|
|
253
|
-
return mode;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
async saveTheme(mode: 'light' | 'dark' | 'auto'): Promise<void> {
|
|
257
|
-
await this.service.setThemeMode(mode);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
async loadColors(): Promise<ColorPalette | undefined> {
|
|
261
|
-
return await this.service.getCustomColors();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async saveColors(colors: ColorPalette): Promise<void> {
|
|
265
|
-
if (ValidationService.validateColorPalette(colors)) {
|
|
266
|
-
await this.service.setCustomColors(colors);
|
|
267
|
-
} else {
|
|
268
|
-
throw new Error('Invalid color palette');
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
### Color Validation
|
|
275
|
-
|
|
276
|
-
```tsx
|
|
277
|
-
function ColorInput({ value, onChange }) {
|
|
278
|
-
const validationService = new ValidationService();
|
|
279
|
-
const [error, setError] = useState<string | null>(null);
|
|
280
|
-
|
|
281
|
-
const handleChange = (color: string) => {
|
|
282
|
-
if (validationService.validateColor(color)) {
|
|
283
|
-
setError(null);
|
|
284
|
-
onChange(color);
|
|
285
|
-
} else {
|
|
286
|
-
setError('Invalid color format. Use hex format: #RRGGBB');
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
return (
|
|
291
|
-
<View>
|
|
292
|
-
<TextInput
|
|
293
|
-
value={value}
|
|
294
|
-
onChangeText={handleChange}
|
|
295
|
-
placeholder="#FF5722"
|
|
296
|
-
/>
|
|
297
|
-
{error && <Text style={styles.error}>{error}</Text>}
|
|
298
|
-
</View>
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### Theme Switcher with Validation
|
|
304
|
-
|
|
305
|
-
```tsx
|
|
306
|
-
function ThemeSwitcher() {
|
|
307
|
-
const { themeMode, setThemeMode } = useAppearance();
|
|
308
|
-
const validationService = new ValidationService();
|
|
309
|
-
|
|
310
|
-
const handleThemeChange = async (mode: string) => {
|
|
311
|
-
if (validationService.validateThemeMode(mode)) {
|
|
312
|
-
await setThemeMode(mode as 'light' | 'dark' | 'auto');
|
|
313
|
-
} else {
|
|
314
|
-
Alert.alert('Error', 'Invalid theme mode');
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
return (
|
|
319
|
-
<View>
|
|
320
|
-
<Button
|
|
321
|
-
onPress={() => handleThemeChange('light')}
|
|
322
|
-
title="Light Mode"
|
|
323
|
-
/>
|
|
324
|
-
<Button
|
|
325
|
-
onPress={() => handleThemeChange('dark')}
|
|
326
|
-
title="Dark Mode"
|
|
327
|
-
/>
|
|
328
|
-
<Button
|
|
329
|
-
onPress={() => handleThemeChange('auto')}
|
|
330
|
-
title="Auto Mode"
|
|
331
|
-
/>
|
|
332
|
-
</View>
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
### Complete Appearance Manager
|
|
338
|
-
|
|
339
|
-
```tsx
|
|
340
|
-
class AppearanceManager {
|
|
341
|
-
private appearanceService: AppearanceService;
|
|
342
|
-
private detectionService: SystemThemeDetectionService;
|
|
343
|
-
private validationService: ValidationService;
|
|
344
|
-
|
|
345
|
-
constructor() {
|
|
346
|
-
this.appearanceService = new AppearanceService();
|
|
347
|
-
this.detectionService = new SystemThemeDetectionService();
|
|
348
|
-
this.validationService = new ValidationService();
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
async initialize(): Promise<void> {
|
|
352
|
-
const mode = await this.appearanceService.getThemeMode();
|
|
353
|
-
return mode;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
async setTheme(mode: 'light' | 'dark' | 'auto'): Promise<void> {
|
|
357
|
-
if (!this.validationService.validateThemeMode(mode)) {
|
|
358
|
-
throw new Error('Invalid theme mode');
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
await this.appearanceService.setThemeMode(mode);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
getEffectiveTheme(): 'light' | 'dark' {
|
|
365
|
-
const mode = this.appearanceService.getThemeMode();
|
|
366
|
-
if (mode === 'auto') {
|
|
367
|
-
return this.detectionService.getSystemTheme() || 'light';
|
|
368
|
-
}
|
|
369
|
-
return mode;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
listenToThemeChanges(callback: (theme: 'light' | 'dark') => void): () => void {
|
|
373
|
-
return this.detectionService.listen(callback);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
async setCustomColors(colors: ColorPalette): Promise<void> {
|
|
377
|
-
if (!this.validationService.validateColorPalette(colors)) {
|
|
378
|
-
throw new Error('Invalid color palette');
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
await this.appearanceService.setCustomColors(colors);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
async reset(): Promise<void> {
|
|
385
|
-
await this.appearanceService.resetColors();
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
## Color Palette
|
|
391
|
-
|
|
392
|
-
```typescript
|
|
393
|
-
interface ColorPalette {
|
|
394
|
-
primary: string; // #FF5722
|
|
395
|
-
secondary: string; // #2196F3
|
|
396
|
-
accent: string; // #FFC107
|
|
397
|
-
background: string; // #FFFFFF
|
|
398
|
-
surface: string; // #F5F5F5
|
|
399
|
-
error: string; // #F44336
|
|
400
|
-
success: string; // #4CAF50
|
|
401
|
-
warning: string; // #FF9800
|
|
402
|
-
}
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
## Default Palettes
|
|
406
|
-
|
|
407
|
-
### Light Theme
|
|
408
|
-
|
|
409
|
-
```typescript
|
|
410
|
-
const lightColors: ColorPalette = {
|
|
411
|
-
primary: '#FF5722',
|
|
412
|
-
secondary: '#2196F3',
|
|
413
|
-
accent: '#FFC107',
|
|
414
|
-
background: '#FFFFFF',
|
|
415
|
-
surface: '#F5F5F5',
|
|
416
|
-
error: '#F44336',
|
|
417
|
-
success: '#4CAF50',
|
|
418
|
-
warning: '#FF9800',
|
|
419
|
-
};
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
### Dark Theme
|
|
423
|
-
|
|
424
|
-
```typescript
|
|
425
|
-
const darkColors: ColorPalette = {
|
|
426
|
-
primary: '#FF5722',
|
|
427
|
-
secondary: '#2196F3',
|
|
428
|
-
accent: '#FFC107',
|
|
429
|
-
background: '#121212',
|
|
430
|
-
surface: '#1E1E1E',
|
|
431
|
-
error: '#EF5350',
|
|
432
|
-
success: '#66BB6A',
|
|
433
|
-
warning: '#FFA726',
|
|
434
|
-
};
|
|
435
|
-
```
|
|
120
|
+
**Primary**: Main brand color (#FF5722)
|
|
121
|
+
**Secondary**: Secondary brand color (#2196F3)
|
|
122
|
+
**Accent**: Highlight color (#FFC107)
|
|
123
|
+
**Background**: Background color (#FFFFFF)
|
|
124
|
+
**Surface**: Surface/card color (#F5F5F5)
|
|
125
|
+
**Error**: Error state color (#F44336)
|
|
126
|
+
**Success**: Success state color (#4CAF50)
|
|
127
|
+
**Warning**: Warning state color (#FF9800)
|
|
436
128
|
|
|
437
129
|
## Best Practices
|
|
438
130
|
|
|
@@ -444,12 +136,6 @@ const darkColors: ColorPalette = {
|
|
|
444
136
|
6. **Persistence**: Save theme changes immediately
|
|
445
137
|
7. **Performance**: Cache theme detection results
|
|
446
138
|
|
|
447
|
-
## Related
|
|
448
|
-
|
|
449
|
-
- **Appearance Hooks**: React hooks for appearance
|
|
450
|
-
- **Appearance Components**: UI components for appearance
|
|
451
|
-
- **Appearance Repository**: Data persistence layer
|
|
452
|
-
|
|
453
139
|
## License
|
|
454
140
|
|
|
455
141
|
MIT
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Appearance Components
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Components for theme management and appearance customization including theme selection, color picking, and live preview. Enables users to personalize their app experience with comprehensive theming options.
|
|
6
|
+
|
|
7
|
+
## File Paths
|
|
8
|
+
|
|
9
|
+
- **AppearanceScreen**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/presentation/screens/AppearanceScreen.tsx`
|
|
10
|
+
- **ThemeModeSection**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/presentation/components/ThemeModeSection.tsx`
|
|
11
|
+
- **CustomColorsSection**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/presentation/components/CustomColorsSection.tsx`
|
|
12
|
+
- **AppearancePreview**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/presentation/components/AppearancePreview.tsx`
|
|
13
|
+
- **ThemeOption**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/presentation/components/ThemeOption.tsx`
|
|
14
|
+
- **ColorPicker**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/presentation/components/ColorPicker.tsx`
|
|
15
|
+
|
|
16
|
+
## Strategy
|
|
17
|
+
|
|
18
|
+
1. **Live Preview Implementation**: Shows real-time preview of theme changes as users make selections, providing immediate feedback and building confidence before applying changes globally.
|
|
19
|
+
|
|
20
|
+
2. **System Theme Respect**: Implements "auto" mode that automatically switches between light and dark themes based on system preferences, providing a seamless native experience.
|
|
21
|
+
|
|
22
|
+
3. **Progressive Customization**: Offers simple theme mode selection (light/dark/auto) for casual users and advanced color palette customization for power users, accommodating different user needs.
|
|
23
|
+
|
|
24
|
+
4. **Design System Integration**: Works seamlessly with design system tokens, allowing theme changes to propagate consistently across all components without manual style updates.
|
|
25
|
+
|
|
26
|
+
5. **Reset Capability**: Provides easy reset to defaults option, allowing users to quickly revert customizations if they're unsatisfied with their changes.
|
|
27
|
+
|
|
28
|
+
## Restrictions
|
|
29
|
+
|
|
30
|
+
### ❌ DO NOT
|
|
31
|
+
|
|
32
|
+
- Hardcode color values anywhere in the app
|
|
33
|
+
- Ignore system theme preference in auto mode
|
|
34
|
+
- Make theme changes without user action
|
|
35
|
+
- Break design system token dependencies
|
|
36
|
+
- Allow invalid color hex codes
|
|
37
|
+
|
|
38
|
+
### ❌ NEVER
|
|
39
|
+
|
|
40
|
+
- Remove the reset to defaults option
|
|
41
|
+
- Force a theme that violates accessibility standards
|
|
42
|
+
- Make color changes without proper validation
|
|
43
|
+
- Bypass theme persistence
|
|
44
|
+
- Use different theme scales across the app
|
|
45
|
+
|
|
46
|
+
### ❌ AVOID
|
|
47
|
+
|
|
48
|
+
- Too many preset themes (keep under 10)
|
|
49
|
+
- Clashing color combinations
|
|
50
|
+
- Overly complex color customization UI
|
|
51
|
+
- Delayed theme application
|
|
52
|
+
- Inconsistent theme transition animations
|
|
53
|
+
|
|
54
|
+
## Rules
|
|
55
|
+
|
|
56
|
+
### ✅ ALWAYS
|
|
57
|
+
|
|
58
|
+
- Show theme preview before applying changes
|
|
59
|
+
- Save theme changes immediately
|
|
60
|
+
- Respect system theme in auto mode
|
|
61
|
+
- Validate color hex codes before applying
|
|
62
|
+
- Ensure sufficient color contrast for accessibility
|
|
63
|
+
|
|
64
|
+
### ✅ MUST
|
|
65
|
+
|
|
66
|
+
- Provide light, dark, and auto theme options
|
|
67
|
+
- Support design system token integration
|
|
68
|
+
- Include reset to defaults button
|
|
69
|
+
- Test themes in different lighting conditions
|
|
70
|
+
- Maintain consistent theme across app lifecycle
|
|
71
|
+
|
|
72
|
+
### ✅ SHOULD
|
|
73
|
+
|
|
74
|
+
- Offer preset color palettes for quick selection
|
|
75
|
+
- Use smooth transitions for theme changes
|
|
76
|
+
- Show color names or hex codes for clarity
|
|
77
|
+
- Provide theme customization in dedicated screen
|
|
78
|
+
- Consider accessibility when selecting default colors
|
|
79
|
+
- Test with various color blindness types
|
|
80
|
+
|
|
81
|
+
## AI Agent Guidelines
|
|
82
|
+
|
|
83
|
+
1. **Theme Mode Implementation**: Always offer three options: Light, Dark, and Auto. In Auto mode, use useColorScheme or Appearance API to detect system preference and switch automatically. Show the active theme in preview so users understand what Auto means.
|
|
84
|
+
|
|
85
|
+
2. **Color Customization Strategy**: Provide preset color palettes (Ocean, Sunset, Forest, etc.) for users who want quick customization. For advanced users, offer individual color pickers for primary, secondary, and accent colors. Always validate hex codes and show color preview.
|
|
86
|
+
|
|
87
|
+
3. **Preview UX**: Position preview at the top of the appearance screen so users see changes immediately. Update preview in real-time as users select options. Show various UI elements in preview (cards, buttons, text) to demonstrate theme comprehensively.
|
|
88
|
+
|
|
89
|
+
4. **Persistence and Reset**: Save theme preferences to AsyncStorage immediately on change. Use keys like "theme-mode" and "custom-colors". The reset button should clear custom colors and revert to default theme mode (usually Auto or Light).
|
|
90
|
+
|
|
91
|
+
5. **Accessibility Testing**: Always test custom color themes for contrast ratios. Use tools to ensure text meets WCAG AA standards (4.5:1 for normal text, 3:1 for large text). Warn users if their custom colors don't meet accessibility standards, or prevent applying them.
|
|
92
|
+
|
|
93
|
+
## Reference
|
|
94
|
+
|
|
95
|
+
- **Main Screen**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/presentation/screens/AppearanceScreen.tsx`
|
|
96
|
+
- **Theme Components**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/presentation/components/`
|
|
97
|
+
- **Appearance Hooks**: Check for useAppearance and related hooks for state management
|
|
98
|
+
- **Appearance Services**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/domains/appearance/services/`
|
|
99
|
+
- **Design System Tokens**: Refer to design system for color definitions and theming infrastructure
|