feat(i18n-mobile): add bilingual support (Català / Castellano) for React Native app
Run Tests on Branches / Detect Changes (push) Successful in 13s
Run Tests on Branches / Backend Tests (push) Has been skipped
Run Tests on Branches / Frontend Tests (push) Successful in 1m40s
Run Tests on Branches / Frontend Mobile Tests (push) Successful in 1m37s
Run Tests on Branches / Parapharmacy API Tests (push) Has been skipped
Run Tests on Branches / PIP Platform Tests (push) Has been skipped

Add lightweight i18n system matching the web app architecture.
Language persisted in AsyncStorage('ff-lang').

New files:
- src/i18n/locales/ca.js (~190 translation keys)
- src/i18n/locales/es.js (~190 translation keys)
- src/i18n/LanguageContext.jsx (Provider + AsyncStorage)
- src/i18n/useTranslation.js (hook)
- src/i18n/index.js (barrel export)

Modified 16 files:
- app/_layout.tsx: wrap with LanguageProvider, translate stack titles
- app/(tabs)/_layout.tsx: translate tab bar labels
- app/(tabs)/index.tsx: translate home screen
- app/(tabs)/search.tsx: translate search screen
- app/(tabs)/alerts.tsx: translate alerts screen
- app/(tabs)/profile.tsx: translate profile + add language selector (CA/ES)
- app/(tabs)/scan.tsx: translate scanner screen
- app/auth/login.tsx: translate login/register
- app/medicine/[id].tsx: translate medicine detail
- app/pharmacy/[id].tsx: translate pharmacy detail
- app/product/[source]/[id].tsx: translate product detail
- 5 components: MedicineCard, StockBadge, SearchBar, LoadingSpinner, BarcodeScanner

Language selector in Profile screen (globe icon + CA/ES toggle).
No routes changed. No API calls affected.
This commit is contained in:
Antoni Nuñez Romeu
2026-07-17 10:22:14 +02:00
parent d12c575fcf
commit ee958d4525
21 changed files with 771 additions and 198 deletions
+81 -56
View File
@@ -6,6 +6,7 @@ import * as ImagePicker from 'expo-image-picker';
import { useAuth } from '../../hooks/useAuth';
import { useThemeContext } from '../../components/ThemeProvider';
import { useThemeStore, ThemeMode } from '../../store/themeStore';
import { useTranslation } from '../../src/i18n';
import { spacing, borderRadius, shadows } from '../../constants/theme';
import api from '../../services/api';
@@ -62,10 +63,10 @@ interface Address {
created_at: string;
}
const THEME_OPTIONS: { mode: ThemeMode; label: string; icon: string }[] = [
{ mode: 'system', label: 'Sistema', icon: 'phone-portrait-outline' },
{ mode: 'light', label: 'Claro', icon: 'sunny-outline' },
{ mode: 'dark', label: 'Oscuro', icon: 'moon-outline' },
const THEME_OPTIONS: { mode: ThemeMode; labelKey: string; icon: string }[] = [
{ mode: 'system', labelKey: 'profile.themeSystem', icon: 'phone-portrait-outline' },
{ mode: 'light', labelKey: 'profile.themeLight', icon: 'sunny-outline' },
{ mode: 'dark', labelKey: 'profile.themeDark', icon: 'moon-outline' },
];
export default function ProfileScreen() {
@@ -74,6 +75,7 @@ export default function ProfileScreen() {
const isTablet = width >= TABLET_MIN_WIDTH;
const { user, isAuthenticated, isLoading, logout, isAdmin } = useAuth();
const { colors, isDark } = useThemeContext();
const { t, lang, setLang } = useTranslation();
const themeMode = useThemeStore((s) => s.mode);
const setThemeMode = useThemeStore((s) => s.setMode);
@@ -146,10 +148,10 @@ export default function ProfileScreen() {
});
setFirstName(res.data.first_name || '');
setLastName(res.data.last_name || '');
setConfigFeedback({ type: 'ok', text: 'Perfil guardado.' });
setConfigFeedback({ type: 'ok', text: t('profile.profileSaved') });
setTimeout(() => setShowConfig(false), 1200);
} catch (err: any) {
setConfigFeedback({ type: 'err', text: err.message || 'Error al guardar' });
setConfigFeedback({ type: 'err', text: err.message || t('profile.saveError') });
} finally { setConfigSaving(false); }
}
@@ -164,7 +166,7 @@ export default function ProfileScreen() {
async function handleTakePhoto() {
const { status } = await ImagePicker.requestCameraPermissionsAsync();
if (status !== 'granted') { Alert.alert('Permiso requerido', 'Necesitamos permiso para acceder a la cámara.'); return; }
if (status !== 'granted') { Alert.alert(t('profile.cameraPermission'), t('profile.cameraPermissionDesc')); return; }
const result = await ImagePicker.launchCameraAsync({ allowsEditing: true, aspect: [1, 1], quality: 0.8, base64: true });
if (!result.canceled && result.assets[0]?.base64) {
const dataUri = `data:${result.assets[0].mimeType};base64,${result.assets[0].base64}`;
@@ -204,12 +206,12 @@ export default function ProfileScreen() {
async function handleAddressSave() {
const addr = formAddress.trim();
if (!addr) { setFormError('La dirección es obligatoria'); return; }
if (!addr) { setFormError(t('profile.addressRequired')); return; }
setFormSaving(true); setFormError('');
try {
const url = editingAddressId ? `/api/addresses/${editingAddressId}` : '/api/addresses';
const res = await fetch(url, { method: editingAddressId ? 'PUT' : 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', body: JSON.stringify({ address: addr, label: formLabel.trim(), is_default: formDefault }) });
if (!res.ok) { const err = await res.json().catch(() => ({})); throw new Error(err.error || 'Error al guardar'); }
if (!res.ok) { const err = await res.json().catch(() => ({})); throw new Error(err.error || t('profile.saveError')); }
setShowAddressForm(false); setEditingAddressId(null); loadAddresses();
} catch (err: any) { setFormError(err.message); } finally { setFormSaving(false); }
}
@@ -223,9 +225,9 @@ export default function ProfileScreen() {
}
const handleLogout = () => {
Alert.alert('Cerrar Sesión', '¿Estás seguro que deseas cerrar sesión?', [
{ text: 'Cancelar', style: 'cancel' },
{ text: 'Cerrar Sesión', style: 'destructive', onPress: async () => { await logout(); router.replace('/auth/login'); } },
Alert.alert(t('profile.logoutTitle'), t('profile.logoutConfirm'), [
{ text: t('profile.logoutCancel'), style: 'cancel' },
{ text: t('profile.logoutConfirmBtn'), style: 'destructive', onPress: async () => { await logout(); router.replace('/auth/login'); } },
]);
};
@@ -246,12 +248,12 @@ export default function ProfileScreen() {
<View style={[styles.authIconCircle, { backgroundColor: colors.primaryContainer }]}>
<Ionicons name="person-outline" size={isTablet ? 60 : 48} color={colors.primary} />
</View>
<Text style={[styles.authTitle, isTablet && styles.authTitleTablet, { color: colors.text }]}>Inicia Sesión</Text>
<Text style={[styles.authTitle, isTablet && styles.authTitleTablet, { color: colors.text }]}>{t('profile.loginTitle')}</Text>
<Text style={[styles.authSubtitle, isTablet && styles.authSubtitleTablet, { color: colors.textSecondary }]}>
Inicia sesión para acceder a tu perfil, notificaciones y más
{t('profile.loginDescription')}
</Text>
<TouchableOpacity style={[styles.authButton, { backgroundColor: colors.primary }]} onPress={() => router.push('/auth/login')}>
<Text style={[styles.authButtonText, { color: colors.onPrimaryContainer }]}>Iniciar Sesión</Text>
<Text style={[styles.authButtonText, { color: colors.onPrimaryContainer }]}>{t('profile.loginBtn')}</Text>
</TouchableOpacity>
</View>
</View>
@@ -287,15 +289,15 @@ export default function ProfileScreen() {
<View style={[styles.card, { backgroundColor: colors.card }, shadows.card]}>
<View style={styles.cardHeader}>
<Ionicons name="person-outline" size={18} color={colors.primary} />
<Text style={[styles.cardTitle, { color: colors.text }]}>Datos personales</Text>
<Text style={[styles.cardTitle, { color: colors.text }]}>{t('profile.personalData')}</Text>
</View>
<View style={styles.infoGrid}>
<View style={[styles.infoBox, { backgroundColor: colors.surfaceLow }]}>
<Text style={[styles.infoLabel, { color: colors.textSecondary }]}>Nombre</Text>
<Text style={[styles.infoLabel, { color: colors.textSecondary }]}>{t('profile.firstName')}</Text>
<Text style={[styles.infoValue, { color: colors.text }]}>{firstName || '—'}</Text>
</View>
<View style={[styles.infoBox, { backgroundColor: colors.surfaceLow }]}>
<Text style={[styles.infoLabel, { color: colors.textSecondary }]}>Apellidos</Text>
<Text style={[styles.infoLabel, { color: colors.textSecondary }]}>{t('profile.lastName')}</Text>
<Text style={[styles.infoValue, { color: colors.text }]}>{lastName || '—'}</Text>
</View>
</View>
@@ -306,7 +308,7 @@ export default function ProfileScreen() {
<View style={[styles.card, { backgroundColor: colors.card }, shadows.card]}>
<View style={styles.cardHeader}>
<Ionicons name={getThemeModeIcon()} size={18} color={colors.primary} />
<Text style={[styles.cardTitle, { color: colors.text }]}>Apariencia</Text>
<Text style={[styles.cardTitle, { color: colors.text }]}>{t('profile.appearance')}</Text>
</View>
<View style={[styles.themePills, { backgroundColor: colors.surfaceLow }]}>
{THEME_OPTIONS.map((opt) => (
@@ -316,7 +318,30 @@ export default function ProfileScreen() {
onPress={() => setThemeMode(opt.mode)}
>
<Ionicons name={opt.icon as any} size={16} color={themeMode === opt.mode ? colors.onPrimaryContainer : colors.textSecondary} />
<Text style={[styles.themePillText, { color: themeMode === opt.mode ? colors.onPrimaryContainer : colors.textSecondary }]}>{opt.label}</Text>
<Text style={[styles.themePillText, { color: themeMode === opt.mode ? colors.onPrimaryContainer : colors.textSecondary }]}>{t(opt.labelKey)}</Text>
</TouchableOpacity>
))}
</View>
</View>
{/* Language card */}
<View style={[styles.card, { backgroundColor: colors.card }, shadows.card]}>
<View style={styles.cardHeader}>
<Ionicons name="globe-outline" size={18} color={colors.primary} />
<Text style={[styles.cardTitle, { color: colors.text }]}>{t('profile.language')}</Text>
</View>
<View style={[styles.themePills, { backgroundColor: colors.surfaceLow }]}>
{[
{ value: 'ca' as const, labelKey: 'profile.languageCatalan', icon: 'language-outline' },
{ value: 'es' as const, labelKey: 'profile.languageSpanish', icon: 'language-outline' },
].map((opt) => (
<TouchableOpacity
key={opt.value}
style={[styles.themePill, lang === opt.value && { backgroundColor: colors.primary }]}
onPress={() => setLang(opt.value)}
>
<Ionicons name={opt.icon as any} size={16} color={lang === opt.value ? colors.onPrimaryContainer : colors.textSecondary} />
<Text style={[styles.themePillText, { color: lang === opt.value ? colors.onPrimaryContainer : colors.textSecondary }]}>{t(opt.labelKey)}</Text>
</TouchableOpacity>
))}
</View>
@@ -328,7 +353,7 @@ export default function ProfileScreen() {
<View style={[styles.menuIconCircle, { backgroundColor: colors.surfaceLow }]}>
<Ionicons name="settings-outline" size={20} color={colors.primary} />
</View>
<Text style={[styles.menuLabel, { color: colors.text }]}>Configuración</Text>
<Text style={[styles.menuLabel, { color: colors.text }]}>{t('profile.config')}</Text>
<Ionicons name="chevron-forward" size={18} color={colors.textSecondary} />
</TouchableOpacity>
@@ -338,7 +363,7 @@ export default function ProfileScreen() {
<View style={[styles.menuIconCircle, { backgroundColor: colors.surfaceLow }]}>
<Ionicons name="location-outline" size={20} color={colors.primary} />
</View>
<Text style={[styles.menuLabel, { color: colors.text }]}>Mis Direcciones</Text>
<Text style={[styles.menuLabel, { color: colors.text }]}>{t('profile.myAddresses')}</Text>
<Ionicons name="chevron-forward" size={18} color={colors.textSecondary} />
</TouchableOpacity>
@@ -349,7 +374,7 @@ export default function ProfileScreen() {
<View style={[styles.menuIconCircle, { backgroundColor: colors.surfaceLow }]}>
<Ionicons name="shield-outline" size={20} color={colors.primary} />
</View>
<Text style={[styles.menuLabel, { color: colors.text }]}>Panel Admin</Text>
<Text style={[styles.menuLabel, { color: colors.text }]}>{t('profile.admin')}</Text>
<Ionicons name="chevron-forward" size={18} color={colors.textSecondary} />
</TouchableOpacity>
</>
@@ -361,7 +386,7 @@ export default function ProfileScreen() {
<View style={[styles.card, { backgroundColor: colors.card }, shadows.card]}>
<View style={styles.cardHeader}>
<Ionicons name="time-outline" size={18} color={colors.primary} />
<Text style={[styles.cardTitle, { color: colors.text }]}>Búsquedas recientes</Text>
<Text style={[styles.cardTitle, { color: colors.text }]}>{t('profile.recentSearches')}</Text>
</View>
{searchHistory.map((item, i) => (
<React.Fragment key={item.id}>
@@ -381,7 +406,7 @@ export default function ProfileScreen() {
{/* Logout */}
<TouchableOpacity style={[styles.logoutCard, { backgroundColor: colors.card, borderColor: isDark ? '#5a2020' : '#fecaca' }]} onPress={handleLogout}>
<Ionicons name="log-out-outline" size={20} color={colors.danger} />
<Text style={[styles.logoutText, { color: colors.danger }]}>Cerrar Sesión</Text>
<Text style={[styles.logoutText, { color: colors.danger }]}>{t('profile.logout')}</Text>
</TouchableOpacity>
<View style={{ height: spacing.xl }} />
@@ -394,16 +419,16 @@ export default function ProfileScreen() {
<View style={[styles.modalSheet, { backgroundColor: colors.card }]}>
<View style={[styles.modalHandle, { backgroundColor: colors.border }]} />
<View style={[styles.modalHeader, { borderBottomColor: colors.surfaceLow }]}>
<Text style={[styles.modalTitle, { color: colors.text }]}>Cambiar Avatar</Text>
<Text style={[styles.modalTitle, { color: colors.text }]}>{t('profile.changeAvatar')}</Text>
<TouchableOpacity onPress={() => setShowAvatarModal(false)} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}>
<Ionicons name="close" size={24} color={colors.textSecondary} />
</TouchableOpacity>
</View>
<View style={[styles.avatarTabBar, { borderBottomColor: colors.surfaceLow }]}>
{(['presets', 'colors', 'upload'] as const).map((t) => (
<TouchableOpacity key={t} style={[styles.avatarTabBtn, avatarTab === t && { borderBottomColor: colors.primary }]} onPress={() => setAvatarTab(t)}>
<Ionicons name={t === 'presets' ? 'person-outline' : t === 'colors' ? 'color-palette-outline' : 'cloud-upload-outline'} size={18} color={avatarTab === t ? colors.primary : colors.textSecondary} />
<Text style={[styles.avatarTabLabel, { color: avatarTab === t ? colors.primary : colors.textSecondary }]}>{t === 'presets' ? 'Prediseñado' : t === 'colors' ? 'Colores' : 'Subir'}</Text>
{(['presets', 'colors', 'upload'] as const).map((tab) => (
<TouchableOpacity key={tab} style={[styles.avatarTabBtn, avatarTab === tab && { borderBottomColor: colors.primary }]} onPress={() => setAvatarTab(tab)}>
<Ionicons name={tab === 'presets' ? 'person-outline' : tab === 'colors' ? 'color-palette-outline' : 'cloud-upload-outline'} size={18} color={avatarTab === tab ? colors.primary : colors.textSecondary} />
<Text style={[styles.avatarTabLabel, { color: avatarTab === tab ? colors.primary : colors.textSecondary }]}>{tab === 'presets' ? t('profile.presetAvatar') : tab === 'colors' ? t('profile.colors') : t('profile.upload')}</Text>
</TouchableOpacity>
))}
</View>
@@ -433,8 +458,8 @@ export default function ProfileScreen() {
<Ionicons name="camera-outline" size={28} color={colors.primary} />
</View>
<View style={{ flex: 1 }}>
<Text style={[styles.uploadTitle, { color: colors.text }]}>Tomar foto</Text>
<Text style={[styles.uploadSub, { color: colors.textSecondary }]}>Usa la cámara de tu dispositivo</Text>
<Text style={[styles.uploadTitle, { color: colors.text }]}>{t('profile.takePhoto')}</Text>
<Text style={[styles.uploadSub, { color: colors.textSecondary }]}>{t('profile.takePhotoDesc')}</Text>
</View>
<Ionicons name="chevron-forward" size={18} color={colors.textSecondary} />
</TouchableOpacity>
@@ -443,8 +468,8 @@ export default function ProfileScreen() {
<Ionicons name="images-outline" size={28} color={colors.primary} />
</View>
<View style={{ flex: 1 }}>
<Text style={[styles.uploadTitle, { color: colors.text }]}>Elegir de galería</Text>
<Text style={[styles.uploadSub, { color: colors.textSecondary }]}>Selecciona una imagen existente</Text>
<Text style={[styles.uploadTitle, { color: colors.text }]}>{t('profile.chooseGallery')}</Text>
<Text style={[styles.uploadSub, { color: colors.textSecondary }]}>{t('profile.chooseGalleryDesc')}</Text>
</View>
<Ionicons name="chevron-forward" size={18} color={colors.textSecondary} />
</TouchableOpacity>
@@ -461,28 +486,28 @@ export default function ProfileScreen() {
<View style={[styles.modalSheet, { backgroundColor: colors.card }]}>
<View style={[styles.modalHandle, { backgroundColor: colors.border }]} />
<View style={[styles.modalHeader, { borderBottomColor: colors.surfaceLow }]}>
<Text style={[styles.modalTitle, { color: colors.text }]}>Configuración</Text>
<Text style={[styles.modalTitle, { color: colors.text }]}>{t('profile.configTitle')}</Text>
<TouchableOpacity onPress={() => setShowConfig(false)} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}>
<Ionicons name="close" size={24} color={colors.textSecondary} />
</TouchableOpacity>
</View>
<ScrollView style={styles.modalBody} contentContainerStyle={{ paddingBottom: spacing.xl }}>
{[
{ label: 'Nombre', value: configFirstName, onChange: setConfigFirstName, placeholder: 'Tu nombre', icon: 'person-outline' },
{ label: 'Apellidos', value: configLastName, onChange: setConfigLastName, placeholder: 'Tus apellidos', icon: 'person-outline' },
{ label: 'Correo electrónico', value: configEmail, onChange: setConfigEmail, placeholder: 'tu@email.com', icon: 'mail-outline', keyboard: 'email-address' as const },
{ label: 'Ciudad', value: configCity, onChange: setConfigCity, placeholder: 'Tu ciudad', icon: 'business-outline' },
{ label: 'Dirección', value: configAddress, onChange: setConfigAddress, placeholder: 'Calle Mayor 1, Madrid', icon: 'location-outline' },
{ labelKey: 'profile.firstNameLabel', placeholderKey: 'profile.firstNamePlaceholder', value: configFirstName, onChange: setConfigFirstName, icon: 'person-outline' },
{ labelKey: 'profile.lastNameLabel', placeholderKey: 'profile.lastNamePlaceholder', value: configLastName, onChange: setConfigLastName, icon: 'person-outline' },
{ labelKey: 'profile.email', placeholder: 'tu@email.com', value: configEmail, onChange: setConfigEmail, icon: 'mail-outline', keyboard: 'email-address' as const },
{ labelKey: 'profile.city', placeholderKey: 'profile.cityPlaceholder', value: configCity, onChange: setConfigCity, icon: 'business-outline' },
{ labelKey: 'profile.address', placeholderKey: 'profile.addressPlaceholder', value: configAddress, onChange: setConfigAddress, icon: 'location-outline' },
].map((field) => (
<View key={field.label} style={styles.modalField}>
<Text style={[styles.modalLabel, { color: colors.textSecondary }]}>{field.label}</Text>
<View key={field.labelKey} style={styles.modalField}>
<Text style={[styles.modalLabel, { color: colors.textSecondary }]}>{t(field.labelKey)}</Text>
<View style={[styles.modalInputRow, { backgroundColor: colors.surfaceLow, borderColor: colors.border }]}>
<Ionicons name={field.icon as any} size={18} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
<TextInput
style={[styles.modalInput, { color: colors.text }]}
value={field.value}
onChangeText={field.onChange}
placeholder={field.placeholder}
placeholder={field.placeholderKey ? t(field.placeholderKey) : field.placeholder}
placeholderTextColor={colors.textSecondary}
keyboardType={field.keyboard}
autoCapitalize="none"
@@ -501,10 +526,10 @@ export default function ProfileScreen() {
<View style={styles.modalActions}>
<TouchableOpacity style={[styles.modalCancelBtn, { borderColor: colors.border }]} onPress={() => setShowConfig(false)} disabled={configSaving}>
<Text style={[styles.modalCancelText, { color: colors.text }]}>Cancelar</Text>
<Text style={[styles.modalCancelText, { color: colors.text }]}>{t('profile.cancel')}</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.modalSaveBtn, { backgroundColor: colors.primary }, configSaving && { opacity: 0.6 }]} onPress={handleConfigSave} disabled={configSaving}>
{configSaving ? <ActivityIndicator color={colors.onPrimaryContainer} /> : <Text style={[styles.modalSaveText, { color: colors.onPrimaryContainer }]}>Guardar</Text>}
{configSaving ? <ActivityIndicator color={colors.onPrimaryContainer} /> : <Text style={[styles.modalSaveText, { color: colors.onPrimaryContainer }]}>{t('profile.save')}</Text>}
</TouchableOpacity>
</View>
</ScrollView>
@@ -518,7 +543,7 @@ export default function ProfileScreen() {
<View style={[styles.modalSheet, { backgroundColor: colors.card }]}>
<View style={[styles.modalHandle, { backgroundColor: colors.border }]} />
<View style={[styles.modalHeader, { borderBottomColor: colors.surfaceLow }]}>
<Text style={[styles.modalTitle, { color: colors.text }]}>Mis Direcciones</Text>
<Text style={[styles.modalTitle, { color: colors.text }]}>{t('profile.addressesTitle')}</Text>
<TouchableOpacity onPress={() => { setShowAddresses(false); setShowAddressForm(false); }} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}>
<Ionicons name="close" size={24} color={colors.textSecondary} />
</TouchableOpacity>
@@ -527,22 +552,22 @@ export default function ProfileScreen() {
{showAddressForm ? (
<View>
<View style={styles.modalField}>
<Text style={[styles.modalLabel, { color: colors.textSecondary }]}>Dirección</Text>
<Text style={[styles.modalLabel, { color: colors.textSecondary }]}>{t('profile.addressLabel')}</Text>
<View style={[styles.modalInputRow, { backgroundColor: colors.surfaceLow, borderColor: colors.border }]}>
<Ionicons name="location-outline" size={18} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
<TextInput style={[styles.modalInput, { color: colors.text }]} value={formAddress} onChangeText={setFormAddress} placeholder="Calle Mayor 1, Madrid" placeholderTextColor={colors.textSecondary} editable={!formSaving} />
<TextInput style={[styles.modalInput, { color: colors.text }]} value={formAddress} onChangeText={setFormAddress} placeholder={t('profile.addressPlaceholder')} placeholderTextColor={colors.textSecondary} editable={!formSaving} />
</View>
</View>
<View style={styles.modalField}>
<Text style={[styles.modalLabel, { color: colors.textSecondary }]}>Etiqueta (opcional)</Text>
<Text style={[styles.modalLabel, { color: colors.textSecondary }]}>{t('profile.addressOptional')}</Text>
<View style={[styles.modalInputRow, { backgroundColor: colors.surfaceLow, borderColor: colors.border }]}>
<Ionicons name="pricetag-outline" size={18} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
<TextInput style={[styles.modalInput, { color: colors.text }]} value={formLabel} onChangeText={setFormLabel} placeholder="Casa, Trabajo..." placeholderTextColor={colors.textSecondary} editable={!formSaving} />
<TextInput style={[styles.modalInput, { color: colors.text }]} value={formLabel} onChangeText={setFormLabel} placeholder={t('profile.addressLabelPlaceholder')} placeholderTextColor={colors.textSecondary} editable={!formSaving} />
</View>
</View>
<TouchableOpacity style={styles.checkboxRow} onPress={() => setFormDefault(!formDefault)} disabled={formSaving}>
<Ionicons name={formDefault ? 'checkbox' : 'square-outline'} size={22} color={formDefault ? colors.primary : colors.textSecondary} />
<Text style={[styles.checkboxLabel, { color: colors.text }]}>Dirección predeterminada</Text>
<Text style={[styles.checkboxLabel, { color: colors.text }]}>{t('profile.defaultAddress')}</Text>
</TouchableOpacity>
{formError ? (
<View style={[styles.modalFeedback, { backgroundColor: colors.dangerContainer, borderColor: isDark ? '#5a2020' : '#fecaca' }]}>
@@ -551,10 +576,10 @@ export default function ProfileScreen() {
) : null}
<View style={styles.modalActions}>
<TouchableOpacity style={[styles.modalCancelBtn, { borderColor: colors.border }]} onPress={() => { setShowAddressForm(false); setFormError(''); }} disabled={formSaving}>
<Text style={[styles.modalCancelText, { color: colors.text }]}>Cancelar</Text>
<Text style={[styles.modalCancelText, { color: colors.text }]}>{t('profile.cancel')}</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.modalSaveBtn, { backgroundColor: colors.primary }, formSaving && { opacity: 0.6 }]} onPress={handleAddressSave} disabled={formSaving}>
{formSaving ? <ActivityIndicator color={colors.onPrimaryContainer} /> : <Text style={[styles.modalSaveText, { color: colors.onPrimaryContainer }]}>{editingAddressId ? 'Actualizar' : 'Añadir'}</Text>}
{formSaving ? <ActivityIndicator color={colors.onPrimaryContainer} /> : <Text style={[styles.modalSaveText, { color: colors.onPrimaryContainer }]}>{editingAddressId ? t('profile.update') : t('profile.add')}</Text>}
</TouchableOpacity>
</View>
</View>
@@ -567,7 +592,7 @@ export default function ProfileScreen() {
{user?.address && (
<View style={[styles.addrCard, { borderColor: colors.primary, backgroundColor: isDark ? '#1a3a1c' : '#eaf7ec' }]}>
<View style={{ flex: 1 }}>
<Text style={[styles.addrBadge, { color: colors.primary }]}>Principal</Text>
<Text style={[styles.addrBadge, { color: colors.primary }]}>{t('profile.mainAddress')}</Text>
<Text style={[styles.addrText, { color: colors.text }]}>{user.address}</Text>
</View>
<Ionicons name="checkmark-circle" size={20} color={colors.primary} />
@@ -580,7 +605,7 @@ export default function ProfileScreen() {
<Text style={[styles.addrText, { color: colors.text }]}>{addr.address}</Text>
{!addr.is_default && (
<TouchableOpacity onPress={() => handleSetDefault(addr.id)}>
<Text style={[styles.addrDefaultLink, { color: colors.primary }]}>Marcar como predeterminada</Text>
<Text style={[styles.addrDefaultLink, { color: colors.primary }]}>{t('profile.setDefault')}</Text>
</TouchableOpacity>
)}
</View>
@@ -596,7 +621,7 @@ export default function ProfileScreen() {
))}
<TouchableOpacity style={[styles.addAddrBtn, { borderColor: colors.border }]} onPress={openAddAddressForm}>
<Ionicons name="add-circle-outline" size={20} color={colors.primary} />
<Text style={[styles.addAddrText, { color: colors.primary }]}>Añadir dirección</Text>
<Text style={[styles.addAddrText, { color: colors.primary }]}>{t('profile.addAddress')}</Text>
</TouchableOpacity>
</View>
)}