@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,110 +1,110 @@
|
|
|
1
1
|
# SettingsItemCard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Purpose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Premium, consistent card component for settings items with icons, text, optional controls, and smooth interactions. Provides a unified interface for all settings items throughout the application.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **Customizable**: Icon, title, subtitle, colors, and styles
|
|
9
|
-
- **Interactive**: Press feedback, switch controls, right icons
|
|
10
|
-
- **Accessible**: Full accessibility support with proper labels
|
|
11
|
-
- **Modern**: Sleek design, smooth animations
|
|
12
|
-
- **Design System**: Uses tokens for consistent styling
|
|
7
|
+
## File Paths
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
```
|
|
10
|
+
src/presentation/components/SettingsItemCard/
|
|
11
|
+
├── SettingsItemCard.tsx # Main component
|
|
12
|
+
├── STRATEGY.md # Detailed strategy guide
|
|
13
|
+
└── README.md # This file
|
|
14
|
+
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
**Component Location**: `/Users/umituz/Desktop/github/umituz/apps/artificial_intelligence/npm-packages/react-native-settings/src/presentation/components/SettingsItemCard/SettingsItemCard.tsx`
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Strategy
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
1. **Unified Interface**: All settings items use this component for consistency
|
|
21
|
+
2. **Flexibility**: Supports buttons, switches, links, and navigation items
|
|
22
|
+
3. **Design System Integration**: Uses tokens for consistent styling across the app
|
|
23
|
+
4. **Performance Optimized**: Memoized component with optimized re-rendering
|
|
24
|
+
5. **Accessibility First**: Full accessibility support with proper labels and hints
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
import { SettingsItemCard } from '@umituz/react-native-settings';
|
|
26
|
+
## Restrictions
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<SettingsItemCard
|
|
28
|
-
icon="settings-outline"
|
|
29
|
-
title="Settings"
|
|
30
|
-
description="Configure your preferences"
|
|
31
|
-
onPress={() => navigation.navigate('Settings')}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
```
|
|
28
|
+
### DO NOT
|
|
36
29
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<SettingsItemCard
|
|
45
|
-
icon="notifications-outline"
|
|
46
|
-
title="Notifications"
|
|
47
|
-
description="Enable push notifications"
|
|
48
|
-
showSwitch={true}
|
|
49
|
-
switchValue={enabled}
|
|
50
|
-
onSwitchChange={setEnabled}
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
```
|
|
30
|
+
- ❌ DO NOT create custom settings item components; use SettingsItemCard
|
|
31
|
+
- ❌ DO NOT bypass design system tokens for styling
|
|
32
|
+
- ❌ DO NOT use without proper icon and title props
|
|
33
|
+
- ❌ DO NOT mix interaction patterns (e.g., switch + press)
|
|
34
|
+
- ❌ DO NOT ignore disabled state styling
|
|
55
35
|
|
|
56
|
-
###
|
|
57
|
-
|
|
58
|
-
```tsx
|
|
59
|
-
function LanguageItem() {
|
|
60
|
-
return (
|
|
61
|
-
<SettingsItemCard
|
|
62
|
-
icon="globe-outline"
|
|
63
|
-
title="Language"
|
|
64
|
-
subtitle="English"
|
|
65
|
-
rightIcon="chevron-forward"
|
|
66
|
-
onPress={() => navigation.navigate('Language')}
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
```
|
|
36
|
+
### NEVER
|
|
71
37
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
38
|
+
- ❌ NEVER use icons that don't match the item's purpose
|
|
39
|
+
- ❌ NEVER omit accessibility labels for interactive items
|
|
40
|
+
- ❌ NEVER use without proper error boundaries
|
|
41
|
+
- ❌ EVER hardcode colors or spacing values
|
|
42
|
+
|
|
43
|
+
### AVOID
|
|
44
|
+
|
|
45
|
+
- ❌ AVOID creating multiple items with the same title
|
|
46
|
+
- ❌ AOVERWHELM users with overly long titles or descriptions
|
|
47
|
+
- ❌ AVOID using inconsistent icon styles
|
|
48
|
+
- ❌ AVOID unstable handler functions (use useCallback)
|
|
49
|
+
|
|
50
|
+
## Rules
|
|
51
|
+
|
|
52
|
+
### ALWAYS
|
|
53
|
+
|
|
54
|
+
- ✅ ALWAYS provide a valid icon from Ionicons
|
|
55
|
+
- ✅ ALWAYS provide a clear, concise title
|
|
56
|
+
- ✅ ALWAYS use design system tokens for custom styling
|
|
57
|
+
- ✅ ALWAYS provide proper accessibility labels
|
|
58
|
+
- ✅ ALWAYS use testID props for E2E testing
|
|
59
|
+
|
|
60
|
+
### MUST
|
|
61
|
+
|
|
62
|
+
- ✅ MUST provide onPress handler for interactive items
|
|
63
|
+
- ✅ MUST use switch controls for boolean settings
|
|
64
|
+
- ✅ MUST provide visual feedback for disabled items
|
|
65
|
+
- ✅ MUST respect design system spacing tokens
|
|
66
|
+
|
|
67
|
+
### SHOULD
|
|
68
|
+
|
|
69
|
+
- ✅ SHOULD use subtitles for additional context
|
|
70
|
+
- ✅ SHOULD show right icon for navigation items
|
|
71
|
+
- ✅ SHOULD use custom icon colors for emphasis
|
|
72
|
+
- ✅ SHOULD provide meaningful descriptions
|
|
73
|
+
|
|
74
|
+
## AI Agent Guidelines
|
|
87
75
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
76
|
+
1. **When creating settings items**: Always use SettingsItemCard component
|
|
77
|
+
2. **When selecting icons**: Choose icons that clearly represent the setting
|
|
78
|
+
3. **When adding interactions**: Use onPress for navigation, switch for toggles
|
|
79
|
+
4. **When customizing**: Use design system tokens, not hardcoded values
|
|
80
|
+
5. **When testing**: Always include testID props for E2E testing
|
|
81
|
+
|
|
82
|
+
## Props Reference
|
|
83
|
+
|
|
84
|
+
### Required Props
|
|
85
|
+
|
|
86
|
+
- `icon: IconName` - Icon name from Ionicons (required)
|
|
87
|
+
- `title: string` - Main title text (required)
|
|
88
|
+
|
|
89
|
+
### Optional Props
|
|
90
|
+
|
|
91
|
+
**Interaction:**
|
|
92
|
+
- `onPress?: () => void` - Press handler for navigation/actions
|
|
93
|
+
- `showSwitch?: boolean` - Show switch control (default: false)
|
|
94
|
+
- `switchValue?: boolean` - Switch value
|
|
95
|
+
- `onSwitchChange?: (value: boolean) => void` - Switch change handler
|
|
96
|
+
|
|
97
|
+
**Display:**
|
|
98
|
+
- `subtitle?: string` - Subtitle text
|
|
99
|
+
- `description?: string` - Description text (alias for subtitle)
|
|
100
|
+
- `rightIcon?: IconName` - Right arrow/icon
|
|
101
|
+
- `iconBgColor?: string` - Custom icon background color
|
|
102
|
+
- `iconColor?: string` - Custom icon color
|
|
103
|
+
|
|
104
|
+
**State:**
|
|
105
|
+
- `disabled?: boolean` - Disabled state (default: false)
|
|
106
|
+
- `style?: ViewStyle` - Custom container style
|
|
107
|
+
- `testID?: string` - Test identifier
|
|
108
108
|
|
|
109
109
|
## Component Structure
|
|
110
110
|
|
|
@@ -112,345 +112,106 @@ function CustomColoredItem() {
|
|
|
112
112
|
SettingsItemCard
|
|
113
113
|
├── Icon Container
|
|
114
114
|
│ ├── Icon Background
|
|
115
|
-
│ └── Icon
|
|
115
|
+
│ └── Icon (from Ionicons)
|
|
116
116
|
├── Content
|
|
117
|
-
│ ├── Title
|
|
118
|
-
│ └── Subtitle/Description
|
|
117
|
+
│ ├── Title (required)
|
|
118
|
+
│ └── Subtitle/Description (optional)
|
|
119
119
|
└── Right Element
|
|
120
120
|
├── Switch (if showSwitch)
|
|
121
121
|
├── Right Icon (if rightIcon)
|
|
122
122
|
└── Chevron (default if onPress)
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
##
|
|
125
|
+
## Usage Patterns
|
|
126
126
|
|
|
127
127
|
### Navigation Item
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
icon="person-outline"
|
|
132
|
-
title="Account"
|
|
133
|
-
subtitle="Manage your account"
|
|
134
|
-
rightIcon="chevron-forward"
|
|
135
|
-
onPress={() => navigation.navigate('Account')}
|
|
136
|
-
/>
|
|
137
|
-
```
|
|
128
|
+
- Use with `onPress` prop
|
|
129
|
+
- Show `rightIcon` for navigation indication
|
|
130
|
+
- Include `subtitle` for additional context
|
|
138
131
|
|
|
139
132
|
### Toggle Setting
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
<SettingsItemCard
|
|
145
|
-
icon="moon-outline"
|
|
146
|
-
title="Dark Mode"
|
|
147
|
-
description="Enable dark theme"
|
|
148
|
-
showSwitch={true}
|
|
149
|
-
switchValue={darkMode}
|
|
150
|
-
onSwitchChange={setDarkMode}
|
|
151
|
-
/>
|
|
152
|
-
```
|
|
133
|
+
- Use with `showSwitch={true}`
|
|
134
|
+
- Provide `switchValue` state
|
|
135
|
+
- Provide `onSwitchChange` handler
|
|
136
|
+
- Use `description` for explanation
|
|
153
137
|
|
|
154
138
|
### Link Item
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
icon="help-circle-outline"
|
|
159
|
-
title="Help & Support"
|
|
160
|
-
rightIcon="open-outline"
|
|
161
|
-
onPress={() => Linking.openURL('https://support.example.com')}
|
|
162
|
-
/>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### With Custom Icon Colors
|
|
166
|
-
|
|
167
|
-
```tsx
|
|
168
|
-
<SettingsItemCard
|
|
169
|
-
icon="shield-checkmark-outline"
|
|
170
|
-
title="Privacy"
|
|
171
|
-
iconBgColor="#4CAF50"
|
|
172
|
-
iconColor="white"
|
|
173
|
-
rightIcon="chevron-forward"
|
|
174
|
-
onPress={() => navigation.navigate('Privacy')}
|
|
175
|
-
/>
|
|
176
|
-
```
|
|
139
|
+
- Use with `onPress` that opens URL
|
|
140
|
+
- Show external link icon (`open-outline`)
|
|
141
|
+
- Handle URL errors gracefully
|
|
177
142
|
|
|
178
143
|
### Disabled Item
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
icon="cloud-upload-outline"
|
|
183
|
-
title="Cloud Sync"
|
|
184
|
-
description="Not available"
|
|
185
|
-
disabled={true}
|
|
186
|
-
/>
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### Multiple Items in Section
|
|
190
|
-
|
|
191
|
-
```tsx
|
|
192
|
-
function SettingsSection() {
|
|
193
|
-
return (
|
|
194
|
-
<SettingsSection title="GENERAL">
|
|
195
|
-
<SettingsItemCard
|
|
196
|
-
icon="person-outline"
|
|
197
|
-
title="Profile"
|
|
198
|
-
rightIcon="chevron-forward"
|
|
199
|
-
onPress={() => {}}
|
|
200
|
-
/>
|
|
201
|
-
|
|
202
|
-
<SettingsItemCard
|
|
203
|
-
icon="notifications-outline"
|
|
204
|
-
title="Notifications"
|
|
205
|
-
showSwitch={true}
|
|
206
|
-
switchValue={notifications}
|
|
207
|
-
onSwitchChange={setNotifications}
|
|
208
|
-
/>
|
|
209
|
-
|
|
210
|
-
<SettingsItemCard
|
|
211
|
-
icon="moon-outline"
|
|
212
|
-
title="Dark Mode"
|
|
213
|
-
showSwitch={true}
|
|
214
|
-
switchValue={darkMode}
|
|
215
|
-
onSwitchChange={setDarkMode}
|
|
216
|
-
/>
|
|
217
|
-
</SettingsSection>
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
```
|
|
144
|
+
- Set `disabled={true}`
|
|
145
|
+
- Provide explanation in `description`
|
|
146
|
+
- Use appropriate icon colors
|
|
221
147
|
|
|
222
148
|
## Styling
|
|
223
149
|
|
|
224
|
-
###
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
const styles = StyleSheet.create({
|
|
228
|
-
container: {
|
|
229
|
-
flexDirection: 'row',
|
|
230
|
-
alignItems: 'center',
|
|
231
|
-
backgroundColor: tokens.colors.surface,
|
|
232
|
-
paddingVertical: tokens.spacing.md,
|
|
233
|
-
paddingHorizontal: tokens.spacing.lg,
|
|
234
|
-
marginHorizontal: tokens.spacing.lg,
|
|
235
|
-
marginTop: tokens.spacing.sm,
|
|
236
|
-
borderRadius: tokens.borderRadius.lg,
|
|
237
|
-
...tokens.shadows.sm,
|
|
238
|
-
},
|
|
239
|
-
iconContainer: {
|
|
240
|
-
width: 40,
|
|
241
|
-
height: 40,
|
|
242
|
-
borderRadius: tokens.borderRadius.md,
|
|
243
|
-
justifyContent: 'center',
|
|
244
|
-
alignItems: 'center',
|
|
245
|
-
marginRight: tokens.spacing.md,
|
|
246
|
-
},
|
|
247
|
-
icon: {
|
|
248
|
-
size: 'lg' as const,
|
|
249
|
-
},
|
|
250
|
-
content: {
|
|
251
|
-
flex: 1,
|
|
252
|
-
},
|
|
253
|
-
title: {
|
|
254
|
-
fontSize: tokens.typography.fontSize.base,
|
|
255
|
-
fontWeight: '600',
|
|
256
|
-
color: tokens.colors.textPrimary,
|
|
257
|
-
},
|
|
258
|
-
subtitle: {
|
|
259
|
-
fontSize: tokens.typography.fontSize.sm,
|
|
260
|
-
color: tokens.colors.textSecondary,
|
|
261
|
-
marginTop: 2,
|
|
262
|
-
},
|
|
263
|
-
});
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### Custom Styles
|
|
267
|
-
|
|
268
|
-
```tsx
|
|
269
|
-
<SettingsItemCard
|
|
270
|
-
icon="settings"
|
|
271
|
-
title="Settings"
|
|
272
|
-
style={{
|
|
273
|
-
backgroundColor: '#f0f0f0',
|
|
274
|
-
borderWidth: 1,
|
|
275
|
-
borderColor: '#ddd',
|
|
276
|
-
}}
|
|
277
|
-
/>
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Pressable Styles
|
|
281
|
-
|
|
282
|
-
The component uses Pressable with pressed state feedback:
|
|
283
|
-
|
|
284
|
-
```typescript
|
|
285
|
-
<Pressable
|
|
286
|
-
style={({ pressed }) => [
|
|
287
|
-
styles.container,
|
|
288
|
-
{
|
|
289
|
-
backgroundColor: pressed
|
|
290
|
-
? tokens.colors.surfaceVariant
|
|
291
|
-
: tokens.colors.surface,
|
|
292
|
-
opacity: pressed ? 0.8 : 1,
|
|
293
|
-
},
|
|
294
|
-
]}
|
|
295
|
-
>
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## Icon Colors
|
|
150
|
+
### Design System Tokens
|
|
299
151
|
|
|
300
|
-
|
|
152
|
+
All styling uses design system tokens:
|
|
153
|
+
- **Colors**: `tokens.colors.surface`, `tokens.colors.textPrimary`
|
|
154
|
+
- **Spacing**: `tokens.spacing.md`, `tokens.spacing.lg`
|
|
155
|
+
- **Typography**: `tokens.typography.fontSize.base`
|
|
156
|
+
- **Shadows**: `tokens.shadows.sm`
|
|
157
|
+
- **Border Radius**: `tokens.borderRadius.lg`
|
|
301
158
|
|
|
302
|
-
|
|
159
|
+
### Custom Styling
|
|
303
160
|
|
|
161
|
+
Use the `style` prop for custom container styling, but prefer design system tokens:
|
|
304
162
|
```typescript
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
'notifications-outline': '#FF9800',
|
|
308
|
-
'person-outline': '#9C27B0',
|
|
309
|
-
'moon-outline': '#673AB7',
|
|
310
|
-
'globe-outline': '#00BCD4',
|
|
311
|
-
'shield-checkmark-outline': '#4CAF50',
|
|
312
|
-
'help-circle-outline': '#FF5722',
|
|
313
|
-
};
|
|
314
|
-
```
|
|
163
|
+
// Prefer this:
|
|
164
|
+
style={{ backgroundColor: tokens.colors.surfaceVariant }}
|
|
315
165
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
```tsx
|
|
319
|
-
// Custom background color
|
|
320
|
-
<SettingsItemCard
|
|
321
|
-
icon="heart"
|
|
322
|
-
iconBgColor="#E91E63"
|
|
323
|
-
iconColor="white"
|
|
324
|
-
title="Favorites"
|
|
325
|
-
/>
|
|
326
|
-
|
|
327
|
-
// Custom color
|
|
328
|
-
<SettingsItemCard
|
|
329
|
-
icon="star"
|
|
330
|
-
iconBgColor="#FFD700"
|
|
331
|
-
iconColor="#333"
|
|
332
|
-
title="Premium"
|
|
333
|
-
/>
|
|
166
|
+
// Over this:
|
|
167
|
+
style={{ backgroundColor: '#f0f0f0' }}
|
|
334
168
|
```
|
|
335
169
|
|
|
336
170
|
## Accessibility
|
|
337
171
|
|
|
338
|
-
### Accessibility
|
|
339
|
-
|
|
340
|
-
```tsx
|
|
341
|
-
<SettingsItemCard
|
|
342
|
-
icon="notifications-outline"
|
|
343
|
-
title="Notifications"
|
|
344
|
-
showSwitch={true}
|
|
345
|
-
switchValue={enabled}
|
|
346
|
-
onSwitchChange={setEnabled}
|
|
347
|
-
accessible={true}
|
|
348
|
-
accessibilityLabel="Notifications setting"
|
|
349
|
-
accessibilityHint="Toggle push notifications on or off"
|
|
350
|
-
/>
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
### Accessibility State
|
|
354
|
-
|
|
355
|
-
```tsx
|
|
356
|
-
<SettingsItemCard
|
|
357
|
-
icon="cloud-upload-outline"
|
|
358
|
-
title="Cloud Sync"
|
|
359
|
-
disabled={true}
|
|
360
|
-
accessibilityState={{ disabled: true }}
|
|
361
|
-
/>
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
## Variants
|
|
172
|
+
### Required Accessibility
|
|
365
173
|
|
|
366
|
-
|
|
174
|
+
- All interactive items need `accessibilityLabel`
|
|
175
|
+
- Switch items need `accessibilityHint`
|
|
176
|
+
- Disabled items need `accessibilityState`
|
|
367
177
|
|
|
368
|
-
|
|
369
|
-
<SettingsItemCard
|
|
370
|
-
icon="arrow-back"
|
|
371
|
-
title="Back"
|
|
372
|
-
onPress={() => navigation.goBack()}
|
|
373
|
-
/>
|
|
374
|
-
```
|
|
178
|
+
### Test IDs
|
|
375
179
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
<SettingsItemCard
|
|
380
|
-
icon="information-circle-outline"
|
|
381
|
-
title="About"
|
|
382
|
-
subtitle="Version 1.0.0"
|
|
383
|
-
description="Build 100"
|
|
384
|
-
rightIcon="chevron-forward"
|
|
385
|
-
onPress={() => navigation.navigate('About')}
|
|
386
|
-
/>
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
### Control Variant
|
|
390
|
-
|
|
391
|
-
```tsx
|
|
392
|
-
<SettingsItemCard
|
|
393
|
-
icon="volume-high-outline"
|
|
394
|
-
title="Sound Effects"
|
|
395
|
-
description="Play sounds for actions"
|
|
396
|
-
showSwitch={true}
|
|
397
|
-
switchValue={soundEnabled}
|
|
398
|
-
onSwitchChange={setSoundEnabled}
|
|
399
|
-
/>
|
|
400
|
-
```
|
|
180
|
+
Provide `testID` props for E2E testing:
|
|
181
|
+
- Pattern: `{feature}-setting-item`
|
|
182
|
+
- Example: `notifications-setting-item`
|
|
401
183
|
|
|
402
184
|
## Performance
|
|
403
185
|
|
|
404
|
-
### Memoization
|
|
405
|
-
|
|
406
|
-
The component is memoized for performance:
|
|
407
|
-
|
|
408
|
-
```tsx
|
|
409
|
-
export const SettingsItemCard = memo<Props>((props) => {
|
|
410
|
-
// Component implementation
|
|
411
|
-
}, (prevProps, nextProps) => {
|
|
412
|
-
return (
|
|
413
|
-
prevProps.title === nextProps.title &&
|
|
414
|
-
prevProps.subtitle === nextProps.subtitle &&
|
|
415
|
-
prevProps.switchValue === nextProps.switchValue &&
|
|
416
|
-
prevProps.disabled === nextProps.disabled
|
|
417
|
-
);
|
|
418
|
-
});
|
|
419
|
-
```
|
|
186
|
+
### Component Memoization
|
|
420
187
|
|
|
421
|
-
|
|
188
|
+
SettingsItemCard is memoized for performance. To ensure proper memoization:
|
|
189
|
+
1. Use stable handler functions (useCallback)
|
|
190
|
+
2. Avoid inline function definitions
|
|
191
|
+
3. Keep props stable across renders
|
|
422
192
|
|
|
423
|
-
|
|
424
|
-
2. **Memo Values**: Memoize subtitle and description values
|
|
425
|
-
3. **Avoid Inline Functions**: Don't define functions in render
|
|
426
|
-
|
|
427
|
-
```tsx
|
|
428
|
-
const handlePress = useCallback(() => {
|
|
429
|
-
navigation.navigate('Settings');
|
|
430
|
-
}, [navigation]);
|
|
193
|
+
### Optimization Tips
|
|
431
194
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
/>
|
|
437
|
-
```
|
|
195
|
+
1. Use `useCallback` for `onPress` handlers
|
|
196
|
+
2. Memoize subtitle and description values
|
|
197
|
+
3. Avoid passing anonymous functions
|
|
198
|
+
4. Keep `switchValue` stable
|
|
438
199
|
|
|
439
200
|
## Best Practices
|
|
440
201
|
|
|
441
|
-
1. **
|
|
442
|
-
2. **
|
|
443
|
-
3. **Descriptions**: Use
|
|
444
|
-
4. **Consistency**: Maintain consistent styling
|
|
445
|
-
5. **Feedback**:
|
|
446
|
-
6. **Accessibility**:
|
|
447
|
-
7. **Performance**: Use stable handlers
|
|
202
|
+
1. **Icon Selection**: Choose descriptive, recognizable icons
|
|
203
|
+
2. **Title Length**: Keep titles short and clear (under 30 chars)
|
|
204
|
+
3. **Descriptions**: Use for additional context when needed
|
|
205
|
+
4. **Consistency**: Maintain consistent styling across items
|
|
206
|
+
5. **Feedback**: All interactive items show press feedback
|
|
207
|
+
6. **Accessibility**: Always include proper labels
|
|
208
|
+
7. **Performance**: Use stable handlers and memoization
|
|
448
209
|
|
|
449
|
-
## Related
|
|
210
|
+
## Related Components
|
|
450
211
|
|
|
451
|
-
- **SettingsSection**:
|
|
452
|
-
- **SettingsContent**: Content composer
|
|
453
|
-
- **SettingsScreen**: Main screen
|
|
212
|
+
- **SettingsSection**: Container for grouping items
|
|
213
|
+
- **SettingsContent**: Content composer that uses items
|
|
214
|
+
- **SettingsScreen**: Main screen that displays items
|
|
454
215
|
|
|
455
216
|
## License
|
|
456
217
|
|