import React, { useState } from 'react'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Alert, } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { SafeAreaView } from 'react-native-safe-area-context'; import { router } from 'expo-router'; import { AppColors, BorderRadius, FontSizes, Spacing } from '@/constants/theme'; import { PageHeader } from '@/components/PageHeader'; interface LanguageOptionProps { code: string; name: string; nativeName: string; flag: string; isSelected: boolean; isAvailable: boolean; onSelect: () => void; } function LanguageOption({ code, name, nativeName, flag, isSelected, isAvailable, onSelect, }: LanguageOptionProps) { return ( {flag} {name} {nativeName} {!isAvailable ? ( Coming Soon ) : isSelected ? ( ) : null} ); } export default function LanguageScreen() { const [selectedLanguage, setSelectedLanguage] = useState('en'); const languages = [ { code: 'en', name: 'English', nativeName: 'English', flag: '🇺🇸', available: true }, { code: 'es', name: 'Spanish', nativeName: 'Español', flag: '🇪🇸', available: false }, { code: 'fr', name: 'French', nativeName: 'Français', flag: '🇫🇷', available: false }, { code: 'de', name: 'German', nativeName: 'Deutsch', flag: '🇩🇪', available: false }, { code: 'it', name: 'Italian', nativeName: 'Italiano', flag: '🇮🇹', available: false }, { code: 'pt', name: 'Portuguese', nativeName: 'Português', flag: '🇵🇹', available: false }, { code: 'nl', name: 'Dutch', nativeName: 'Nederlands', flag: '🇳🇱', available: false }, { code: 'pl', name: 'Polish', nativeName: 'Polski', flag: '🇵🇱', available: false }, { code: 'ru', name: 'Russian', nativeName: 'Русский', flag: '🇷🇺', available: false }, { code: 'ja', name: 'Japanese', nativeName: '日本語', flag: '🇯🇵', available: false }, { code: 'zh', name: 'Chinese', nativeName: '中文', flag: '🇨🇳', available: false }, { code: 'ko', name: 'Korean', nativeName: '한국어', flag: '🇰🇷', available: false }, ]; const handleSelectLanguage = (code: string, name: string, available: boolean) => { if (!available) { Alert.alert( 'Coming Soon', `${name} translation is not available yet. We're working on adding more languages!`, [{ text: 'OK' }] ); return; } if (code === selectedLanguage) { return; } Alert.alert( 'Change Language', `Are you sure you want to change the app language to ${name}?`, [ { text: 'Cancel', style: 'cancel' }, { text: 'Change', onPress: () => { setSelectedLanguage(code); Alert.alert( 'Language Changed', `The app language has been changed to ${name}. Some changes may require restarting the app.`, [{ text: 'OK', onPress: () => router.back() }] ); }, }, ] ); }; const availableLanguages = languages.filter(l => l.available); const comingSoonLanguages = languages.filter(l => !l.available); return ( {/* Current Language */} Current Language {languages.find(l => l.code === selectedLanguage)?.name || 'English'} {/* Available Languages */} Available Languages {availableLanguages.map((lang, index) => ( handleSelectLanguage(lang.code, lang.name, lang.available)} /> {index < availableLanguages.length - 1 && } ))} {/* Coming Soon Languages */} Coming Soon {comingSoonLanguages.map((lang, index) => ( handleSelectLanguage(lang.code, lang.name, lang.available)} /> {index < comingSoonLanguages.length - 1 && } ))} {/* Help Translate */} Alert.alert( 'Help Us Translate', 'We\'d love your help translating WellNuo into more languages!\n\n' + 'If you\'re fluent in another language and would like to contribute, ' + 'please contact us at translations@wellnuo.com', [{ text: 'OK' }] )} > Help Us Translate Want to see WellNuo in your language? Help us by contributing translations. {/* Note */} Changing the language will translate the app interface. Beneficiary data and system notifications may remain in the original language. ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: AppColors.surface, }, section: { marginTop: Spacing.md, }, sectionTitle: { fontSize: FontSizes.sm, fontWeight: '600', color: AppColors.textSecondary, paddingHorizontal: Spacing.lg, paddingVertical: Spacing.sm, textTransform: 'uppercase', }, currentLanguageCard: { flexDirection: 'row', alignItems: 'center', backgroundColor: AppColors.background, marginHorizontal: Spacing.lg, padding: Spacing.md, borderRadius: BorderRadius.lg, }, currentLanguageInfo: { marginLeft: Spacing.md, }, currentLanguageLabel: { fontSize: FontSizes.xs, color: AppColors.textMuted, }, currentLanguageName: { fontSize: FontSizes.lg, fontWeight: '600', color: AppColors.textPrimary, marginTop: 2, }, languagesCard: { backgroundColor: AppColors.background, }, languageOption: { flexDirection: 'row', alignItems: 'center', paddingVertical: Spacing.md, paddingHorizontal: Spacing.lg, }, languageOptionSelected: { backgroundColor: '#DBEAFE', }, flag: { fontSize: 28, }, languageInfo: { flex: 1, marginLeft: Spacing.md, }, languageName: { fontSize: FontSizes.base, fontWeight: '500', color: AppColors.textPrimary, }, languageNameDisabled: { color: AppColors.textMuted, }, languageNative: { fontSize: FontSizes.xs, color: AppColors.textSecondary, marginTop: 2, }, comingSoonBadge: { backgroundColor: AppColors.surface, paddingHorizontal: Spacing.sm, paddingVertical: 4, borderRadius: BorderRadius.sm, }, comingSoonText: { fontSize: FontSizes.xs, color: AppColors.textMuted, }, divider: { height: 1, backgroundColor: AppColors.border, marginLeft: Spacing.lg + 28 + Spacing.md, }, helpTranslateCard: { flexDirection: 'row', alignItems: 'center', backgroundColor: AppColors.background, marginHorizontal: Spacing.lg, padding: Spacing.md, borderRadius: BorderRadius.lg, }, helpTranslateIcon: { width: 48, height: 48, borderRadius: BorderRadius.md, backgroundColor: '#DBEAFE', justifyContent: 'center', alignItems: 'center', }, helpTranslateContent: { flex: 1, marginLeft: Spacing.md, }, helpTranslateTitle: { fontSize: FontSizes.base, fontWeight: '500', color: AppColors.textPrimary, }, helpTranslateDescription: { fontSize: FontSizes.xs, color: AppColors.textMuted, marginTop: 2, }, noteContainer: { flexDirection: 'row', alignItems: 'flex-start', marginHorizontal: Spacing.lg, marginVertical: Spacing.lg, }, noteText: { flex: 1, fontSize: FontSizes.xs, color: AppColors.textMuted, marginLeft: Spacing.sm, lineHeight: 18, }, });