@umituz/react-native-settings 4.20.56 → 4.20.57
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 +145 -3
- package/package.json +1 -2
- 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/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 +461 -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,366 @@
|
|
|
1
|
+
# Appearance Hooks
|
|
2
|
+
|
|
3
|
+
Custom hooks for managing appearance settings including theme mode and custom colors.
|
|
4
|
+
|
|
5
|
+
## Hooks
|
|
6
|
+
|
|
7
|
+
### useAppearance
|
|
8
|
+
|
|
9
|
+
Hook for accessing current appearance settings and theme mode.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { useAppearance } from '@umituz/react-native-settings';
|
|
13
|
+
|
|
14
|
+
function AppearanceScreen() {
|
|
15
|
+
const { themeMode, customColors, isLoading } = useAppearance();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<View>
|
|
19
|
+
<Text>Current theme: {themeMode}</Text>
|
|
20
|
+
{customColors && <Text>Custom colors enabled</Text>}
|
|
21
|
+
</View>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Returns
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
interface UseAppearanceResult {
|
|
30
|
+
themeMode: 'light' | 'dark' | 'auto'; // Current theme mode
|
|
31
|
+
customColors?: ColorPalette; // Custom color palette
|
|
32
|
+
isLoading: boolean; // Loading state
|
|
33
|
+
error?: Error; // Error object
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### Examples
|
|
38
|
+
|
|
39
|
+
**Basic Usage:**
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
function ThemeDisplay() {
|
|
43
|
+
const { themeMode } = useAppearance();
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Text>Current theme: {themeMode}</Text>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**With Loading State:**
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
function ThemeSelector() {
|
|
55
|
+
const { themeMode, isLoading } = useAppearance();
|
|
56
|
+
|
|
57
|
+
if (isLoading) {
|
|
58
|
+
return <ActivityIndicator />;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Picker selectedValue={themeMode}>
|
|
63
|
+
<Picker.Item label="Light" value="light" />
|
|
64
|
+
<Picker.Item label="Dark" value="dark" />
|
|
65
|
+
<Picker.Item label="Auto" value="auto" />
|
|
66
|
+
</Picker>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**With Custom Colors:**
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
function ColorDisplay() {
|
|
75
|
+
const { customColors } = useAppearance();
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<View>
|
|
79
|
+
<View style={{ backgroundColor: customColors?.primary }} />
|
|
80
|
+
<View style={{ backgroundColor: customColors?.secondary }} />
|
|
81
|
+
<View style={{ backgroundColor: customColors?.accent }} />
|
|
82
|
+
</View>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### useAppearanceActions
|
|
88
|
+
|
|
89
|
+
Hook for accessing appearance action functions to update theme and colors.
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { useAppearanceActions } from '@umituz/react-native-settings';
|
|
93
|
+
|
|
94
|
+
function AppearanceControls() {
|
|
95
|
+
const { setThemeMode, setCustomColors, resetColors } = useAppearanceActions();
|
|
96
|
+
|
|
97
|
+
const handleThemeChange = (theme: 'light' | 'dark') => {
|
|
98
|
+
setThemeMode(theme);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleSetColors = (colors: ColorPalette) => {
|
|
102
|
+
setCustomColors(colors);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const handleReset = () => {
|
|
106
|
+
resetColors();
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<View>
|
|
111
|
+
<Button onPress={() => handleThemeChange('dark')} title="Dark Mode" />
|
|
112
|
+
<Button onPress={() => handleSetColors(newColors)} title="Set Colors" />
|
|
113
|
+
<Button onPress={handleReset} title="Reset Colors" />
|
|
114
|
+
</View>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Returns
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
interface UseAppearanceActionsResult {
|
|
123
|
+
setThemeMode: (themeMode: 'light' | 'dark' | 'auto') => void;
|
|
124
|
+
setCustomColors: (colors: ColorPalette) => void;
|
|
125
|
+
resetColors: () => void;
|
|
126
|
+
isUpdating: boolean;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### Actions
|
|
131
|
+
|
|
132
|
+
**setThemeMode:**
|
|
133
|
+
|
|
134
|
+
Sets the theme mode.
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
const { setThemeMode } = useAppearanceActions();
|
|
138
|
+
|
|
139
|
+
// Set to dark mode
|
|
140
|
+
setThemeMode('dark');
|
|
141
|
+
|
|
142
|
+
// Set to light mode
|
|
143
|
+
setThemeMode('light');
|
|
144
|
+
|
|
145
|
+
// Set to auto (system preference)
|
|
146
|
+
setThemeMode('auto');
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**setCustomColors:**
|
|
150
|
+
|
|
151
|
+
Sets custom color palette.
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
const { setCustomColors } = useAppearanceActions();
|
|
155
|
+
|
|
156
|
+
const colors = {
|
|
157
|
+
primary: '#FF5722',
|
|
158
|
+
secondary: '#2196F3',
|
|
159
|
+
accent: '#FFC107',
|
|
160
|
+
background: '#FFFFFF',
|
|
161
|
+
surface: '#F5F5F5',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
setCustomColors(colors);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**resetColors:**
|
|
168
|
+
|
|
169
|
+
Resets to default colors.
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
const { resetColors } = useAppearanceActions();
|
|
173
|
+
|
|
174
|
+
resetColors();
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Complete Example
|
|
178
|
+
|
|
179
|
+
### Theme Switcher
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
function ThemeSwitcher() {
|
|
183
|
+
const { themeMode } = useAppearance();
|
|
184
|
+
const { setThemeMode } = useAppearanceActions();
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<View>
|
|
188
|
+
<Text>Current Theme: {themeMode}</Text>
|
|
189
|
+
|
|
190
|
+
<TouchableOpacity onPress={() => setThemeMode('light')}>
|
|
191
|
+
<Text>Light Mode</Text>
|
|
192
|
+
</TouchableOpacity>
|
|
193
|
+
|
|
194
|
+
<TouchableOpacity onPress={() => setThemeMode('dark')}>
|
|
195
|
+
<Text>Dark Mode</Text>
|
|
196
|
+
</TouchableOpacity>
|
|
197
|
+
|
|
198
|
+
<TouchableOpacity onPress={() => setThemeMode('auto')}>
|
|
199
|
+
<Text>Auto (System)</Text>
|
|
200
|
+
</TouchableOpacity>
|
|
201
|
+
</View>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Color Customizer
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
function ColorCustomizer() {
|
|
210
|
+
const { customColors } = useAppearance();
|
|
211
|
+
const { setCustomColors, resetColors } = useAppearanceActions();
|
|
212
|
+
|
|
213
|
+
const [colors, setColors] = useState(customColors || defaultColors);
|
|
214
|
+
|
|
215
|
+
const handleSave = () => {
|
|
216
|
+
setCustomColors(colors);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const handleReset = () => {
|
|
220
|
+
resetColors();
|
|
221
|
+
setColors(defaultColors);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<View>
|
|
226
|
+
<ColorPicker
|
|
227
|
+
label="Primary Color"
|
|
228
|
+
value={colors.primary}
|
|
229
|
+
onChange={(color) => setColors({ ...colors, primary: color })}
|
|
230
|
+
/>
|
|
231
|
+
|
|
232
|
+
<ColorPicker
|
|
233
|
+
label="Secondary Color"
|
|
234
|
+
value={colors.secondary}
|
|
235
|
+
onChange={(color) => setColors({ ...colors, secondary: color })}
|
|
236
|
+
/>
|
|
237
|
+
|
|
238
|
+
<Button onPress={handleSave} title="Save Colors" />
|
|
239
|
+
<Button onPress={handleReset} title="Reset to Default" />
|
|
240
|
+
</View>
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Theme Toggle Button
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
function ThemeToggleButton() {
|
|
249
|
+
const { themeMode } = useAppearance();
|
|
250
|
+
const { setThemeMode } = useAppearanceActions();
|
|
251
|
+
const isDark = themeMode === 'dark';
|
|
252
|
+
|
|
253
|
+
const handleToggle = useCallback(() => {
|
|
254
|
+
setThemeMode(isDark ? 'light' : 'dark');
|
|
255
|
+
}, [isDark, setThemeMode]);
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<TouchableOpacity onPress={handleToggle}>
|
|
259
|
+
<Ionicons
|
|
260
|
+
name={isDark ? 'sunny-outline' : 'moon-outline'}
|
|
261
|
+
size={24}
|
|
262
|
+
color="black"
|
|
263
|
+
/>
|
|
264
|
+
</TouchableOpacity>
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Live Preview
|
|
270
|
+
|
|
271
|
+
```tsx
|
|
272
|
+
function AppearancePreview() {
|
|
273
|
+
const { themeMode, customColors } = useAppearance();
|
|
274
|
+
const { setThemeMode } = useAppearanceActions();
|
|
275
|
+
|
|
276
|
+
const effectiveTheme = useEffectiveTheme(themeMode);
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<View style={{ backgroundColor: effectiveTheme.background }}>
|
|
280
|
+
<Text style={{ color: effectiveTheme.text }}>
|
|
281
|
+
Theme Preview
|
|
282
|
+
</Text>
|
|
283
|
+
|
|
284
|
+
<View style={{ backgroundColor: customColors?.primary }}>
|
|
285
|
+
<Text>Primary Color</Text>
|
|
286
|
+
</View>
|
|
287
|
+
|
|
288
|
+
<TouchableOpacity onPress={() => setThemeMode('dark')}>
|
|
289
|
+
<Text>Switch to Dark</Text>
|
|
290
|
+
</TouchableOpacity>
|
|
291
|
+
</View>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function useEffectiveTheme(themeMode: 'light' | 'dark' | 'auto') {
|
|
296
|
+
const systemTheme = useColorScheme();
|
|
297
|
+
const effectiveMode = themeMode === 'auto' ? systemTheme : themeMode;
|
|
298
|
+
|
|
299
|
+
return effectiveMode === 'dark' ? darkTheme : lightTheme;
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## System Theme Detection
|
|
304
|
+
|
|
305
|
+
### Auto Theme
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
function AutoThemeDetector() {
|
|
309
|
+
const { themeMode } = useAppearance();
|
|
310
|
+
const systemTheme = useColorScheme();
|
|
311
|
+
|
|
312
|
+
const effectiveTheme = useMemo(() => {
|
|
313
|
+
if (themeMode === 'auto') {
|
|
314
|
+
return systemTheme;
|
|
315
|
+
}
|
|
316
|
+
return themeMode;
|
|
317
|
+
}, [themeMode, systemTheme]);
|
|
318
|
+
|
|
319
|
+
return (
|
|
320
|
+
<Text>
|
|
321
|
+
Theme Mode: {themeMode}
|
|
322
|
+
Effective Theme: {effectiveTheme}
|
|
323
|
+
</Text>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Theme Provider
|
|
329
|
+
|
|
330
|
+
```tsx
|
|
331
|
+
function AppearanceProvider({ children }) {
|
|
332
|
+
const { themeMode, customColors } = useAppearance();
|
|
333
|
+
|
|
334
|
+
const theme = useMemo(() => ({
|
|
335
|
+
mode: themeMode,
|
|
336
|
+
colors: customColors || defaultColors,
|
|
337
|
+
}), [themeMode, customColors]);
|
|
338
|
+
|
|
339
|
+
return (
|
|
340
|
+
<ThemeContext.Provider value={theme}>
|
|
341
|
+
{children}
|
|
342
|
+
</ThemeContext.Provider>
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Best Practices
|
|
348
|
+
|
|
349
|
+
1. **Persistence**: Theme changes are automatically persisted
|
|
350
|
+
2. **System Preference**: Respect system theme when mode is 'auto'
|
|
351
|
+
3. **Transition**: Use smooth transitions when changing themes
|
|
352
|
+
4. **Validation**: Validate color values before setting
|
|
353
|
+
5. **Reset**: Provide option to reset to defaults
|
|
354
|
+
6. **Preview**: Show live preview of changes
|
|
355
|
+
7. **Performance**: Use useMemo for expensive calculations
|
|
356
|
+
|
|
357
|
+
## Related
|
|
358
|
+
|
|
359
|
+
- **AppearanceScreen**: Appearance screen component
|
|
360
|
+
- **ThemeModeSection**: Theme mode section
|
|
361
|
+
- **CustomColorsSection**: Custom colors section
|
|
362
|
+
- **Appearance Store**: Zustand store for appearance state
|
|
363
|
+
|
|
364
|
+
## License
|
|
365
|
+
|
|
366
|
+
MIT
|