@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.
- package/README.md +146 -4
- package/package.json +1 -2
- package/src/__tests__/setup.ts +1 -4
- package/src/application/README.md +322 -0
- package/src/domains/about/README.md +452 -0
- package/src/domains/about/presentation/hooks/README.md +350 -0
- package/src/domains/appearance/README.md +596 -0
- package/src/domains/appearance/hooks/README.md +366 -0
- package/src/domains/appearance/infrastructure/services/README.md +455 -0
- package/src/domains/appearance/presentation/components/README.md +493 -0
- package/src/domains/cloud-sync/README.md +451 -0
- package/src/domains/cloud-sync/presentation/components/README.md +493 -0
- package/src/domains/dev/README.md +477 -0
- package/src/domains/disclaimer/README.md +421 -0
- package/src/domains/disclaimer/presentation/components/README.md +394 -0
- package/src/domains/faqs/README.md +586 -0
- package/src/domains/feedback/README.md +565 -0
- package/src/domains/feedback/presentation/hooks/README.md +428 -0
- package/src/domains/legal/README.md +549 -0
- package/src/domains/rating/README.md +452 -0
- package/src/domains/rating/presentation/components/README.md +475 -0
- package/src/domains/video-tutorials/README.md +482 -0
- package/src/domains/video-tutorials/presentation/components/README.md +433 -0
- package/src/infrastructure/README.md +509 -0
- package/src/infrastructure/repositories/README.md +475 -0
- package/src/infrastructure/services/README.md +510 -0
- package/src/presentation/components/README.md +482 -0
- package/src/presentation/components/SettingsErrorBoundary/README.md +455 -0
- package/src/presentation/components/SettingsFooter/README.md +446 -0
- package/src/presentation/components/SettingsItemCard/README.md +457 -0
- package/src/presentation/components/SettingsSection/README.md +421 -0
- package/src/presentation/hooks/README.md +413 -0
- package/src/presentation/hooks/mutations/README.md +430 -0
- package/src/presentation/hooks/queries/README.md +441 -0
- package/src/presentation/navigation/README.md +532 -0
- package/src/presentation/navigation/components/README.md +330 -0
- package/src/presentation/navigation/hooks/README.md +399 -0
- package/src/presentation/navigation/utils/README.md +442 -0
- package/src/presentation/screens/README.md +525 -0
- package/src/presentation/screens/components/SettingsContent/README.md +404 -0
- package/src/presentation/screens/components/SettingsHeader/README.md +322 -0
- package/src/presentation/screens/components/sections/CustomSettingsList/README.md +388 -0
- package/src/presentation/screens/components/sections/FeatureSettingsSection/README.md +232 -0
- package/src/presentation/screens/components/sections/IdentitySettingsSection/README.md +325 -0
- package/src/presentation/screens/components/sections/ProfileSectionLoader/README.md +480 -0
- package/src/presentation/screens/components/sections/SupportSettingsSection/README.md +391 -0
- package/src/presentation/screens/hooks/README.md +383 -0
- package/src/presentation/screens/types/README.md +439 -0
- package/src/presentation/screens/utils/README.md +288 -0
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
# Appearance Domain
|
|
2
|
+
|
|
3
|
+
The Appearance domain provides comprehensive theme management and customization capabilities for your React Native app, including light/dark mode switching and custom color schemes.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Theme Mode Switching**: Toggle between light and dark themes
|
|
8
|
+
- **Custom Color Schemes**: Define and apply custom color palettes
|
|
9
|
+
- **Live Preview**: See theme changes in real-time
|
|
10
|
+
- **Persistent Settings**: Theme preferences are saved automatically
|
|
11
|
+
- **System Theme Detection**: Respect device theme preferences
|
|
12
|
+
- **Type-Safe**: Full TypeScript support
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
This domain is part of `@umituz/react-native-settings`. Install the package to use it:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @umituz/react-native-settings
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Components
|
|
23
|
+
|
|
24
|
+
### AppearanceScreen
|
|
25
|
+
|
|
26
|
+
The main screen for managing appearance settings including theme mode and custom colors.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { AppearanceScreen } from '@umituz/react-native-settings';
|
|
30
|
+
|
|
31
|
+
function MyAppearanceScreen() {
|
|
32
|
+
return <AppearanceScreen />;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### Props
|
|
37
|
+
|
|
38
|
+
| Prop | Type | Default | Description |
|
|
39
|
+
|------|------|---------|-------------|
|
|
40
|
+
| `texts` | `AppearanceTexts` | `undefined` | Custom text labels |
|
|
41
|
+
| `headerComponent` | `ReactNode` | `undefined` | Custom header component |
|
|
42
|
+
| `showThemeSection` | `boolean` | `true` | Show theme mode section |
|
|
43
|
+
| `showColorsSection` | `boolean` | `true` | Show custom colors section |
|
|
44
|
+
| `showPreviewSection` | `boolean` | `true` | Show preview section |
|
|
45
|
+
|
|
46
|
+
#### Example with Custom Texts
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { AppearanceScreen } from '@umituz/react-native-settings';
|
|
50
|
+
|
|
51
|
+
function LocalizedAppearanceScreen() {
|
|
52
|
+
const texts = {
|
|
53
|
+
title: 'Appearance',
|
|
54
|
+
subtitle: 'Customize your app experience',
|
|
55
|
+
themeSectionTitle: 'Theme',
|
|
56
|
+
themeSectionDescription: 'Choose your preferred theme mode',
|
|
57
|
+
featuresSectionTitle: 'Features',
|
|
58
|
+
colorsSectionTitle: 'Custom Colors',
|
|
59
|
+
colorsSectionDescription: 'Personalize your color scheme',
|
|
60
|
+
previewSectionTitle: 'Preview',
|
|
61
|
+
previewSectionDescription: 'See how your changes look',
|
|
62
|
+
resetButtonText: 'Reset to Default',
|
|
63
|
+
lightMode: {
|
|
64
|
+
title: 'Light Mode',
|
|
65
|
+
subtitle: 'Bright and clean',
|
|
66
|
+
description: 'Perfect for daytime use',
|
|
67
|
+
features: ['Easy on the eyes', 'Better visibility', 'Classic look'],
|
|
68
|
+
},
|
|
69
|
+
darkMode: {
|
|
70
|
+
title: 'Dark Mode',
|
|
71
|
+
subtitle: 'Easy on the eyes',
|
|
72
|
+
description: 'Great for low-light environments',
|
|
73
|
+
features: ['Reduces eye strain', 'Saves battery', 'Modern look'],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return <AppearanceScreen texts={texts} />;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### ThemeModeSection
|
|
82
|
+
|
|
83
|
+
Section for selecting between light and dark theme modes.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { ThemeModeSection } from '@umituz/react-native-settings';
|
|
87
|
+
|
|
88
|
+
function ThemeSection() {
|
|
89
|
+
const themes = [
|
|
90
|
+
{
|
|
91
|
+
mode: 'light',
|
|
92
|
+
title: 'Light Mode',
|
|
93
|
+
subtitle: 'Bright and clean',
|
|
94
|
+
description: 'Perfect for daytime use',
|
|
95
|
+
features: ['Easy on the eyes', 'Better visibility'],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
mode: 'dark',
|
|
99
|
+
title: 'Dark Mode',
|
|
100
|
+
subtitle: 'Easy on the eyes',
|
|
101
|
+
description: 'Great for low-light environments',
|
|
102
|
+
features: ['Reduces eye strain', 'Saves battery'],
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<ThemeModeSection
|
|
108
|
+
themeMode="dark"
|
|
109
|
+
onThemeSelect={(mode) => console.log('Selected:', mode)}
|
|
110
|
+
title="Choose Theme"
|
|
111
|
+
description="Select your preferred theme"
|
|
112
|
+
themes={themes}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### Props
|
|
119
|
+
|
|
120
|
+
| Prop | Type | Default | Description |
|
|
121
|
+
|------|------|---------|-------------|
|
|
122
|
+
| `tokens` | `DesignTokens` | **Required** | Design tokens from design system |
|
|
123
|
+
| `themeMode` | `ThemeMode` | **Required** | Current theme mode |
|
|
124
|
+
| `onThemeSelect` | `(mode) => void` | **Required** | Theme change handler |
|
|
125
|
+
| `title` | `string` | `undefined` | Section title |
|
|
126
|
+
| `description` | `string` | `undefined` | Section description |
|
|
127
|
+
| `themes` | `ThemeOptionConfig[]` | **Required** | Available theme options |
|
|
128
|
+
|
|
129
|
+
### CustomColorsSection
|
|
130
|
+
|
|
131
|
+
Section for customizing app colors.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { CustomColorsSection } from '@umituz/react-native-settings';
|
|
135
|
+
|
|
136
|
+
function ColorsSection() {
|
|
137
|
+
const customColors = {
|
|
138
|
+
primary: '#007AFF',
|
|
139
|
+
secondary: '#5856D6',
|
|
140
|
+
accent: '#FF9500',
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<CustomColorsSection
|
|
145
|
+
localCustomColors={customColors}
|
|
146
|
+
onColorChange={(key, color) => console.log(`${key}: ${color}`)}
|
|
147
|
+
onResetColors={() => console.log('Reset colors')}
|
|
148
|
+
title="Custom Colors"
|
|
149
|
+
description="Personalize your color scheme"
|
|
150
|
+
resetButtonText="Reset"
|
|
151
|
+
/>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Props
|
|
157
|
+
|
|
158
|
+
| Prop | Type | Default | Description |
|
|
159
|
+
|------|------|---------|-------------|
|
|
160
|
+
| `tokens` | `DesignTokens` | **Required** | Design tokens from design system |
|
|
161
|
+
| `localCustomColors` | `CustomThemeColors` | **Required** | Current custom colors |
|
|
162
|
+
| `onColorChange` | `(key, color) => void` | **Required** | Color change handler |
|
|
163
|
+
| `onResetColors` | `() => void` | **Required** | Reset handler |
|
|
164
|
+
| `title` | `string` | `undefined` | Section title |
|
|
165
|
+
| `description` | `string` | `undefined` | Section description |
|
|
166
|
+
| `resetButtonText` | `string` | `undefined` | Reset button text |
|
|
167
|
+
|
|
168
|
+
### AppearancePreview
|
|
169
|
+
|
|
170
|
+
Live preview component showing how theme changes look.
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
import { AppearancePreview } from '@umituz/react-native-settings';
|
|
174
|
+
|
|
175
|
+
function PreviewSection() {
|
|
176
|
+
const customColors = {
|
|
177
|
+
primary: '#007AFF',
|
|
178
|
+
secondary: '#5856D6',
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<AppearancePreview
|
|
183
|
+
localCustomColors={customColors}
|
|
184
|
+
title="Preview"
|
|
185
|
+
description="See how your changes look in real-time"
|
|
186
|
+
/>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### Props
|
|
192
|
+
|
|
193
|
+
| Prop | Type | Default | Description |
|
|
194
|
+
|------|------|---------|-------------|
|
|
195
|
+
| `tokens` | `DesignTokens` | **Required** | Design tokens from design system |
|
|
196
|
+
| `localCustomColors` | `CustomThemeColors` | **Required** | Custom colors to preview |
|
|
197
|
+
| `title` | `string` | `undefined` | Section title |
|
|
198
|
+
| `description` | `string` | `undefined` | Section description |
|
|
199
|
+
|
|
200
|
+
### ColorPicker
|
|
201
|
+
|
|
202
|
+
Color picker component for selecting custom colors.
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
import { ColorPicker } from '@umituz/react-native-settings';
|
|
206
|
+
|
|
207
|
+
function MyColorPicker() {
|
|
208
|
+
return (
|
|
209
|
+
<ColorPicker
|
|
210
|
+
label="Primary Color"
|
|
211
|
+
value="#007AFF"
|
|
212
|
+
onChange={(color) => console.log('Color:', color)}
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### AppearanceHeader
|
|
219
|
+
|
|
220
|
+
Header component for the appearance screen.
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
import { AppearanceHeader } from '@umituz/react-native-settings';
|
|
224
|
+
|
|
225
|
+
function MyAppearanceHeader() {
|
|
226
|
+
const tokens = useAppDesignTokens();
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<AppearanceHeader
|
|
230
|
+
tokens={tokens}
|
|
231
|
+
title="Appearance"
|
|
232
|
+
subtitle="Customize your app"
|
|
233
|
+
/>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### Props
|
|
239
|
+
|
|
240
|
+
| Prop | Type | Default | Description |
|
|
241
|
+
|------|------|---------|-------------|
|
|
242
|
+
| `tokens` | `DesignTokens` | **Required** | Design tokens |
|
|
243
|
+
| `title` | `string` | `undefined` | Header title |
|
|
244
|
+
| `subtitle` | `string` | `undefined` | Header subtitle |
|
|
245
|
+
|
|
246
|
+
## Hooks
|
|
247
|
+
|
|
248
|
+
### useAppearance
|
|
249
|
+
|
|
250
|
+
Main hook for accessing and managing appearance settings.
|
|
251
|
+
|
|
252
|
+
```tsx
|
|
253
|
+
import { useAppearance } from '@umituz/react-native-settings';
|
|
254
|
+
|
|
255
|
+
function MyComponent() {
|
|
256
|
+
const {
|
|
257
|
+
themeMode,
|
|
258
|
+
customColors,
|
|
259
|
+
isLoading,
|
|
260
|
+
setThemeMode,
|
|
261
|
+
setCustomColors,
|
|
262
|
+
reset,
|
|
263
|
+
} = useAppearance();
|
|
264
|
+
|
|
265
|
+
return (
|
|
266
|
+
<View>
|
|
267
|
+
<Text>Current theme: {themeMode}</Text>
|
|
268
|
+
<Button title="Switch to Dark" onPress={() => setThemeMode('dark')} />
|
|
269
|
+
<Button title="Reset" onPress={reset} />
|
|
270
|
+
</View>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### Return Value
|
|
276
|
+
|
|
277
|
+
| Property | Type | Description |
|
|
278
|
+
|----------|------|-------------|
|
|
279
|
+
| `themeMode` | `ThemeMode` | Current theme mode (`'light'` or `'dark'`) |
|
|
280
|
+
| `customColors` | `CustomThemeColors \| undefined` | Custom color scheme |
|
|
281
|
+
| `isLoading` | `boolean` | Loading state |
|
|
282
|
+
| `setThemeMode` | `(mode) => void` | Function to set theme mode |
|
|
283
|
+
| `setCustomColors` | `(colors) => void` | Function to set custom colors |
|
|
284
|
+
| `reset` | `() => void` | Reset to default appearance |
|
|
285
|
+
|
|
286
|
+
### useAppearanceActions
|
|
287
|
+
|
|
288
|
+
Hook for appearance-related actions and handlers.
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
import { useAppearanceActions } from '@umituz/react-native-settings';
|
|
292
|
+
|
|
293
|
+
function AppearanceActions() {
|
|
294
|
+
const {
|
|
295
|
+
localCustomColors,
|
|
296
|
+
handleThemeSelect,
|
|
297
|
+
handleColorChange,
|
|
298
|
+
handleResetColors,
|
|
299
|
+
} = useAppearanceActions();
|
|
300
|
+
|
|
301
|
+
return (
|
|
302
|
+
<View>
|
|
303
|
+
<Button
|
|
304
|
+
title="Select Dark Theme"
|
|
305
|
+
onPress={() => handleThemeSelect('dark')}
|
|
306
|
+
/>
|
|
307
|
+
<Button
|
|
308
|
+
title="Change Primary Color"
|
|
309
|
+
onPress={() => handleColorChange('primary', '#FF0000')}
|
|
310
|
+
/>
|
|
311
|
+
<Button title="Reset Colors" onPress={handleResetColors} />
|
|
312
|
+
</View>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
#### Return Value
|
|
318
|
+
|
|
319
|
+
| Property | Type | Description |
|
|
320
|
+
|----------|------|-------------|
|
|
321
|
+
| `localCustomColors` | `CustomThemeColors` | Current custom colors |
|
|
322
|
+
| `handleThemeSelect` | `(mode) => void` | Handle theme selection |
|
|
323
|
+
| `handleColorChange` | `(key, color) => void` | Handle color change |
|
|
324
|
+
| `handleResetColors` | `() => void` | Handle color reset |
|
|
325
|
+
|
|
326
|
+
## Types
|
|
327
|
+
|
|
328
|
+
### ThemeMode
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
type ThemeMode = 'light' | 'dark';
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### CustomThemeColors
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
interface CustomThemeColors {
|
|
338
|
+
primary?: string;
|
|
339
|
+
secondary?: string;
|
|
340
|
+
accent?: string;
|
|
341
|
+
background?: string;
|
|
342
|
+
surface?: string;
|
|
343
|
+
// ... more color options
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### AppearanceSettings
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
interface AppearanceSettings {
|
|
351
|
+
themeMode: ThemeMode;
|
|
352
|
+
customColors?: CustomThemeColors;
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### AppearanceTexts
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
interface AppearanceTexts {
|
|
360
|
+
title?: string;
|
|
361
|
+
subtitle?: string;
|
|
362
|
+
themeSectionTitle?: string;
|
|
363
|
+
themeSectionDescription?: string;
|
|
364
|
+
featuresSectionTitle?: string;
|
|
365
|
+
colorsSectionTitle?: string;
|
|
366
|
+
colorsSectionDescription?: string;
|
|
367
|
+
previewSectionTitle?: string;
|
|
368
|
+
previewSectionDescription?: string;
|
|
369
|
+
resetButtonText?: string;
|
|
370
|
+
lightMode?: ThemeModeTextConfig;
|
|
371
|
+
darkMode?: ThemeModeTextConfig;
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### ThemeModeTextConfig
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
interface ThemeModeTextConfig {
|
|
379
|
+
title: string;
|
|
380
|
+
subtitle?: string;
|
|
381
|
+
description?: string;
|
|
382
|
+
features: string[];
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### ThemeOptionConfig
|
|
387
|
+
|
|
388
|
+
```typescript
|
|
389
|
+
interface ThemeOptionConfig {
|
|
390
|
+
mode: ThemeMode;
|
|
391
|
+
title: string;
|
|
392
|
+
subtitle?: string;
|
|
393
|
+
description?: string;
|
|
394
|
+
features?: string[];
|
|
395
|
+
featuresTitle?: string;
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
## Examples
|
|
400
|
+
|
|
401
|
+
### Basic Usage
|
|
402
|
+
|
|
403
|
+
```tsx
|
|
404
|
+
import React from 'react';
|
|
405
|
+
import { View } from 'react-native';
|
|
406
|
+
import { AppearanceScreen } from '@umituz/react-native-settings';
|
|
407
|
+
|
|
408
|
+
export default function App() {
|
|
409
|
+
return (
|
|
410
|
+
<View style={{ flex: 1 }}>
|
|
411
|
+
<AppearanceScreen />
|
|
412
|
+
</View>
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Custom Sections
|
|
418
|
+
|
|
419
|
+
```tsx
|
|
420
|
+
import { AppearanceScreen } from '@umituz/react-native-settings';
|
|
421
|
+
|
|
422
|
+
function CustomAppearanceScreen() {
|
|
423
|
+
return (
|
|
424
|
+
<AppearanceScreen
|
|
425
|
+
showThemeSection={true}
|
|
426
|
+
showColorsSection={false} // Hide color customization
|
|
427
|
+
showPreviewSection={true}
|
|
428
|
+
/>
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Using the Hook
|
|
434
|
+
|
|
435
|
+
```tsx
|
|
436
|
+
import { useAppearance } from '@umituz/react-native-settings';
|
|
437
|
+
|
|
438
|
+
function ThemeToggle() {
|
|
439
|
+
const { themeMode, setThemeMode } = useAppearance();
|
|
440
|
+
|
|
441
|
+
return (
|
|
442
|
+
<View>
|
|
443
|
+
<Text>Current: {themeMode}</Text>
|
|
444
|
+
<Button
|
|
445
|
+
title="Toggle Theme"
|
|
446
|
+
onPress={() => setThemeMode(themeMode === 'light' ? 'dark' : 'light')}
|
|
447
|
+
/>
|
|
448
|
+
</View>
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### Custom Colors
|
|
454
|
+
|
|
455
|
+
```tsx
|
|
456
|
+
import { useAppearance } from '@umituz/react-native-settings';
|
|
457
|
+
|
|
458
|
+
function ColorCustomizer() {
|
|
459
|
+
const { customColors, setCustomColors } = useAppearance();
|
|
460
|
+
|
|
461
|
+
const applyCustomTheme = () => {
|
|
462
|
+
setCustomColors({
|
|
463
|
+
primary: '#FF6B6B',
|
|
464
|
+
secondary: '#4ECDC4',
|
|
465
|
+
accent: '#FFE66D',
|
|
466
|
+
});
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
return (
|
|
470
|
+
<View>
|
|
471
|
+
<Text>Primary: {customColors?.primary}</Text>
|
|
472
|
+
<Button title="Apply Custom Theme" onPress={applyCustomTheme} />
|
|
473
|
+
</View>
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Complete Customization
|
|
479
|
+
|
|
480
|
+
```tsx
|
|
481
|
+
import { AppearanceScreen } from '@umituz/react-native-settings';
|
|
482
|
+
|
|
483
|
+
function FullyCustomizedScreen() {
|
|
484
|
+
const texts = {
|
|
485
|
+
title: 'Personalization',
|
|
486
|
+
subtitle: 'Make it yours',
|
|
487
|
+
themeSectionTitle: 'Theme Mode',
|
|
488
|
+
colorsSectionTitle: 'Color Palette',
|
|
489
|
+
resetButtonText: 'Reset Everything',
|
|
490
|
+
lightMode: {
|
|
491
|
+
title: 'Light',
|
|
492
|
+
features: ['Clean look', 'Better readability'],
|
|
493
|
+
},
|
|
494
|
+
darkMode: {
|
|
495
|
+
title: 'Dark',
|
|
496
|
+
features: ['Easy on eyes', 'Saves battery'],
|
|
497
|
+
},
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
const customHeader = (
|
|
501
|
+
<View style={{ padding: 20 }}>
|
|
502
|
+
<Text style={{ fontSize: 24, fontWeight: 'bold' }}>
|
|
503
|
+
App Settings
|
|
504
|
+
</Text>
|
|
505
|
+
</View>
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
return (
|
|
509
|
+
<AppearanceScreen
|
|
510
|
+
texts={texts}
|
|
511
|
+
headerComponent={customHeader}
|
|
512
|
+
showPreviewSection={false}
|
|
513
|
+
/>
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
## Architecture
|
|
519
|
+
|
|
520
|
+
The Appearance domain follows a clean architecture pattern:
|
|
521
|
+
|
|
522
|
+
```
|
|
523
|
+
src/domains/appearance/
|
|
524
|
+
├── application/ # Application logic
|
|
525
|
+
│ └── ports/ # Repository interfaces
|
|
526
|
+
├── infrastructure/ # Implementation
|
|
527
|
+
│ ├── repositories/ # Data persistence
|
|
528
|
+
│ └── services/ # System theme detection, validation
|
|
529
|
+
├── presentation/ # UI components
|
|
530
|
+
│ ├── screens/ # AppearanceScreen
|
|
531
|
+
│ ├── components/ # ThemeModeSection, CustomColorsSection, etc.
|
|
532
|
+
│ └── hooks/ # useAppearance, useAppearanceActions
|
|
533
|
+
├── data/ # Color palettes and constants
|
|
534
|
+
└── types/ # TypeScript definitions
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
## Best Practices
|
|
538
|
+
|
|
539
|
+
1. **Respect System Theme**: Detect and respect the user's device theme preference
|
|
540
|
+
2. **Provide Preview**: Always show users how changes look before applying
|
|
541
|
+
3. **Smooth Transitions**: Animate theme changes for a polished experience
|
|
542
|
+
4. **Persist Choices**: Save theme preferences automatically
|
|
543
|
+
5. **Accessibility First**: Ensure good contrast ratios in both themes
|
|
544
|
+
6. **Test Both Themes**: Verify your UI looks good in light and dark modes
|
|
545
|
+
|
|
546
|
+
## Testing
|
|
547
|
+
|
|
548
|
+
```tsx
|
|
549
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
550
|
+
import { AppearanceScreen } from '@umituz/react-native-settings';
|
|
551
|
+
|
|
552
|
+
describe('AppearanceScreen', () => {
|
|
553
|
+
it('displays theme options', () => {
|
|
554
|
+
const { getByText } = render(<AppearanceScreen />);
|
|
555
|
+
|
|
556
|
+
expect(getByText(/light/i)).toBeTruthy();
|
|
557
|
+
expect(getByText(/dark/i)).toBeTruthy();
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
it('handles theme selection', () => {
|
|
561
|
+
const { getByText } = render(<AppearanceScreen />);
|
|
562
|
+
|
|
563
|
+
const darkButton = getByText(/dark/i);
|
|
564
|
+
fireEvent.press(darkButton);
|
|
565
|
+
|
|
566
|
+
// Assert theme changed
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
## Integration with Design System
|
|
572
|
+
|
|
573
|
+
This domain integrates seamlessly with `@umituz/react-native-design-system`:
|
|
574
|
+
|
|
575
|
+
```tsx
|
|
576
|
+
import { useAppDesignTokens, ThemeProvider } from '@umituz/react-native-design-system';
|
|
577
|
+
import { AppearanceScreen } from '@umituz/react-native-settings';
|
|
578
|
+
|
|
579
|
+
function App() {
|
|
580
|
+
return (
|
|
581
|
+
<ThemeProvider>
|
|
582
|
+
<AppearanceScreen />
|
|
583
|
+
</ThemeProvider>
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
## Related
|
|
589
|
+
|
|
590
|
+
- **Settings**: Main settings management
|
|
591
|
+
- **Design System**: Theme and styling foundation
|
|
592
|
+
- **Storage**: Persistent theme storage
|
|
593
|
+
|
|
594
|
+
## License
|
|
595
|
+
|
|
596
|
+
MIT
|