import React, { useState } from 'react'; import { View, Text, StyleSheet, ScrollView, TextInput, TouchableOpacity, Alert, KeyboardAvoidingView, Platform, } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { SafeAreaView } from 'react-native-safe-area-context'; import { router } from 'expo-router'; import { useAuth } from '@/contexts/AuthContext'; import { AppColors, BorderRadius, FontSizes, Spacing } from '@/constants/theme'; export default function EditProfileScreen() { const { user } = useAuth(); const [displayName, setDisplayName] = useState(user?.user_name || ''); const [email, setEmail] = useState(''); const [phone, setPhone] = useState(''); const [timezone, setTimezone] = useState('UTC'); const [isSaving, setIsSaving] = useState(false); const handleSave = async () => { if (!displayName.trim()) { Alert.alert('Error', 'Display name is required'); return; } setIsSaving(true); // Simulate API call await new Promise(resolve => setTimeout(resolve, 1000)); setIsSaving(false); Alert.alert( 'Profile Updated', 'Your profile has been updated successfully.', [{ text: 'OK', onPress: () => router.back() }] ); }; const handleChangePhoto = () => { Alert.alert( 'Change Photo', 'Choose an option', [ { text: 'Take Photo', onPress: () => Alert.alert('Camera', 'Camera functionality coming soon!') }, { text: 'Choose from Library', onPress: () => Alert.alert('Library', 'Photo library coming soon!') }, { text: 'Remove Photo', style: 'destructive', onPress: () => Alert.alert('Removed', 'Photo removed') }, { text: 'Cancel', style: 'cancel' }, ] ); }; return ( {/* Avatar Section */} {displayName?.charAt(0).toUpperCase() || 'U'} Tap to change photo {/* Form */} Display Name * Email Address Used for notifications and account recovery Phone Number For emergency contact and SMS alerts Timezone { Alert.alert( 'Select Timezone', 'Choose your timezone', [ { text: 'UTC', onPress: () => setTimezone('UTC') }, { text: 'America/New_York', onPress: () => setTimezone('America/New_York') }, { text: 'America/Los_Angeles', onPress: () => setTimezone('America/Los_Angeles') }, { text: 'Europe/London', onPress: () => setTimezone('Europe/London') }, { text: 'Cancel', style: 'cancel' }, ] ); }} > {timezone} {/* Account Info (read-only) */} Account Information User ID {user?.user_id || 'N/A'} Username {user?.user_name || 'N/A'} Role {user?.max_role === 2 ? 'Administrator' : 'Caregiver'} Assigned Beneficiaries {user?.privileges?.split(',').length || 0} {/* Save Button */} {isSaving ? 'Saving...' : 'Save Changes'} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: AppColors.surface, }, keyboardView: { flex: 1, }, avatarSection: { alignItems: 'center', paddingVertical: Spacing.xl, backgroundColor: AppColors.background, }, avatarContainer: { width: 100, height: 100, borderRadius: 50, backgroundColor: AppColors.primary, justifyContent: 'center', alignItems: 'center', }, avatarText: { fontSize: 40, fontWeight: '600', color: AppColors.white, }, changePhotoButton: { position: 'absolute', bottom: 50, right: '35%', width: 32, height: 32, borderRadius: 16, backgroundColor: AppColors.primaryLight, justifyContent: 'center', alignItems: 'center', borderWidth: 2, borderColor: AppColors.background, }, changePhotoText: { marginTop: Spacing.sm, fontSize: FontSizes.sm, color: AppColors.primary, }, form: { padding: Spacing.lg, }, inputGroup: { marginBottom: Spacing.lg, }, label: { fontSize: FontSizes.sm, fontWeight: '600', color: AppColors.textPrimary, marginBottom: Spacing.xs, }, input: { backgroundColor: AppColors.background, borderRadius: BorderRadius.md, paddingHorizontal: Spacing.md, paddingVertical: Spacing.md, fontSize: FontSizes.base, color: AppColors.textPrimary, borderWidth: 1, borderColor: AppColors.border, }, selectInput: { backgroundColor: AppColors.background, borderRadius: BorderRadius.md, paddingHorizontal: Spacing.md, paddingVertical: Spacing.md, borderWidth: 1, borderColor: AppColors.border, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, selectText: { fontSize: FontSizes.base, color: AppColors.textPrimary, }, hint: { fontSize: FontSizes.xs, color: AppColors.textMuted, marginTop: Spacing.xs, }, readOnlySection: { marginTop: Spacing.lg, backgroundColor: AppColors.background, borderRadius: BorderRadius.lg, padding: Spacing.md, }, readOnlyTitle: { fontSize: FontSizes.sm, fontWeight: '600', color: AppColors.textSecondary, marginBottom: Spacing.md, }, readOnlyItem: { flexDirection: 'row', justifyContent: 'space-between', paddingVertical: Spacing.sm, borderBottomWidth: 1, borderBottomColor: AppColors.border, }, readOnlyLabel: { fontSize: FontSizes.sm, color: AppColors.textSecondary, }, readOnlyValue: { fontSize: FontSizes.sm, fontWeight: '500', color: AppColors.textPrimary, }, footer: { padding: Spacing.lg, backgroundColor: AppColors.background, borderTopWidth: 1, borderTopColor: AppColors.border, }, saveButton: { backgroundColor: AppColors.primary, borderRadius: BorderRadius.lg, paddingVertical: Spacing.md, alignItems: 'center', }, saveButtonDisabled: { opacity: 0.6, }, saveButtonText: { fontSize: FontSizes.base, fontWeight: '600', color: AppColors.white, }, });