Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | import React from 'react';
import {
View,
Text,
StyleSheet,
TouchableOpacity,
Modal,
Animated,
Dimensions,
Switch,
ScrollView,
} from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { router } from 'expo-router';
import {
AppColors,
BorderRadius,
FontSizes,
Spacing,
FontWeights,
} from '@/constants/theme';
const { width: SCREEN_WIDTH } = Dimensions.get('window');
const DRAWER_WIDTH = SCREEN_WIDTH * 0.85;
interface DrawerItemProps {
icon: keyof typeof Ionicons.glyphMap;
label: string;
onPress?: () => void;
rightElement?: React.ReactNode;
danger?: boolean;
badge?: string;
}
function DrawerItem({ icon, label, onPress, rightElement, danger, badge }: DrawerItemProps) {
return (
<TouchableOpacity
style={styles.drawerItem}
onPress={onPress}
disabled={!onPress && !rightElement}
activeOpacity={0.6}
>
<View style={[styles.iconContainer, danger && styles.iconContainerDanger]}>
<Ionicons
name={icon}
size={22}
color={danger ? AppColors.error : AppColors.textSecondary}
/>
</View>
<Text style={[styles.drawerItemLabel, danger && styles.dangerText]}>
{label}
</Text>
{badge && (
<Text style={styles.badgeText}>{badge}</Text>
)}
{rightElement || (onPress && (
<Ionicons name="chevron-forward" size={18} color={AppColors.textMuted} />
))}
</TouchableOpacity>
);
}
interface ProfileDrawerProps {
visible: boolean;
onClose: () => void;
onLogout: () => void;
settings: {
pushNotifications: boolean;
emailNotifications: boolean;
biometricLogin: boolean;
};
onSettingChange: (key: string, value: boolean) => void;
}
export function ProfileDrawer({
visible,
onClose,
onLogout,
settings,
onSettingChange,
}: ProfileDrawerProps) {
const insets = useSafeAreaInsets();
const slideAnim = React.useRef(new Animated.Value(-DRAWER_WIDTH)).current;
const fadeAnim = React.useRef(new Animated.Value(0)).current;
React.useEffect(() => {
Animated.parallel([
Animated.timing(slideAnim, {
toValue: visible ? 0 : -DRAWER_WIDTH,
duration: 250,
useNativeDriver: true,
}),
Animated.timing(fadeAnim, {
toValue: visible ? 1 : 0,
duration: 250,
useNativeDriver: true,
}),
]).start();
}, [visible]);
const handleNavigate = (route: string) => {
onClose();
router.push(route as any);
};
return (
<Modal
visible={visible}
transparent
animationType="none"
onRequestClose={onClose}
>
<View style={styles.overlay}>
<Animated.View
style={[styles.backdrop, { opacity: fadeAnim }]}
>
<TouchableOpacity
style={StyleSheet.absoluteFill}
activeOpacity={1}
onPress={onClose}
/>
</Animated.View>
<Animated.View
style={[
styles.drawer,
{ transform: [{ translateX: slideAnim }] },
]}
>
<SafeAreaView style={styles.drawerContent} edges={['left']}>
{/* Header */}
<View style={[styles.drawerHeader, { paddingTop: insets.top + Spacing.md }]}>
<Text style={styles.drawerTitle}>Settings</Text>
<TouchableOpacity style={styles.closeButton} onPress={onClose}>
<Ionicons name="close" size={24} color={AppColors.textSecondary} />
</TouchableOpacity>
</View>
<ScrollView style={styles.drawerScroll} showsVerticalScrollIndicator={false}>
{/* Preferences */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>Preferences</Text>
<DrawerItem
icon="notifications-outline"
label="Push Notifications"
rightElement={
<Switch
value={settings.pushNotifications}
onValueChange={(v) => onSettingChange('pushNotifications', v)}
trackColor={{ false: AppColors.border, true: AppColors.primary }}
thumbColor={AppColors.white}
ios_backgroundColor={AppColors.border}
/>
}
/>
<DrawerItem
icon="mail-outline"
label="Email Notifications"
rightElement={
<Switch
value={settings.emailNotifications}
onValueChange={(v) => onSettingChange('emailNotifications', v)}
trackColor={{ false: AppColors.border, true: AppColors.primary }}
thumbColor={AppColors.white}
ios_backgroundColor={AppColors.border}
/>
}
/>
</View>
{/* Account */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>Account</Text>
<DrawerItem
icon="language-outline"
label="Language"
badge="EN"
onPress={() => handleNavigate('/(tabs)/profile/language')}
/>
</View>
{/* Support */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>Support</Text>
<DrawerItem
icon="help-circle-outline"
label="Help Center"
onPress={() => handleNavigate('/(tabs)/profile/help')}
/>
<DrawerItem
icon="chatbubble-outline"
label="Contact Support"
onPress={() => handleNavigate('/(tabs)/profile/support')}
/>
<DrawerItem
icon="document-text-outline"
label="Terms & Privacy"
onPress={() => handleNavigate('/(tabs)/profile/terms')}
/>
</View>
{/* About */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>About</Text>
<DrawerItem
icon="information-circle-outline"
label="About WellNuo"
onPress={() => handleNavigate('/(tabs)/profile/about')}
/>
</View>
</ScrollView>
{/* Version */}
<View style={styles.versionContainer}>
<Text style={styles.versionText}>WellNuo v1.0.0</Text>
</View>
</SafeAreaView>
</Animated.View>
</View>
</Modal>
);
}
const styles = StyleSheet.create({
overlay: {
flex: 1,
flexDirection: 'row',
},
backdrop: {
...StyleSheet.absoluteFillObject,
backgroundColor: 'rgba(0,0,0,0.4)',
},
drawer: {
position: 'absolute',
left: 0,
top: 0,
bottom: 0,
width: DRAWER_WIDTH,
backgroundColor: '#FFFFFF',
shadowColor: '#000',
shadowOffset: { width: 2, height: 0 },
shadowOpacity: 0.15,
shadowRadius: 12,
elevation: 8,
},
drawerContent: {
flex: 1,
},
drawerHeader: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: Spacing.lg,
paddingBottom: Spacing.lg,
borderBottomWidth: 1,
borderBottomColor: AppColors.border,
},
drawerTitle: {
fontSize: FontSizes.xl,
fontWeight: FontWeights.bold,
color: AppColors.textPrimary,
},
closeButton: {
width: 40,
height: 40,
borderRadius: BorderRadius.md,
backgroundColor: AppColors.surfaceSecondary,
justifyContent: 'center',
alignItems: 'center',
},
drawerScroll: {
flex: 1,
},
section: {
paddingTop: Spacing.lg,
},
sectionTitle: {
fontSize: FontSizes.xs,
fontWeight: FontWeights.semibold,
color: AppColors.textMuted,
textTransform: 'uppercase',
letterSpacing: 0.5,
marginBottom: Spacing.sm,
marginLeft: Spacing.lg,
},
drawerItem: {
flexDirection: 'row',
alignItems: 'center',
paddingVertical: Spacing.md,
paddingHorizontal: Spacing.lg,
borderBottomWidth: 1,
borderBottomColor: AppColors.border,
},
iconContainer: {
width: 40,
height: 40,
borderRadius: BorderRadius.md,
backgroundColor: AppColors.surfaceSecondary,
justifyContent: 'center',
alignItems: 'center',
marginRight: Spacing.md,
},
iconContainerDanger: {
backgroundColor: AppColors.errorLight,
},
drawerItemLabel: {
flex: 1,
fontSize: FontSizes.base,
fontWeight: FontWeights.medium,
color: AppColors.textPrimary,
},
dangerText: {
color: AppColors.error,
},
badgeText: {
fontSize: FontSizes.sm,
fontWeight: FontWeights.medium,
color: AppColors.textMuted,
marginRight: Spacing.sm,
},
versionContainer: {
paddingVertical: Spacing.lg,
alignItems: 'center',
borderTopWidth: 1,
borderTopColor: AppColors.border,
},
versionText: {
fontSize: FontSizes.sm,
color: AppColors.textMuted,
},
});
|