import type { VersionInfo } from '@/services/version'; import { Ionicons } from '@expo/vector-icons'; import { LinearGradient } from 'expo-linear-gradient'; import React, { useMemo } from 'react'; import { Modal, Pressable, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; type VersionUpdateModalProps = { visible: boolean; info: VersionInfo | null; currentVersion: string; onClose: () => void; onUpdate: () => void; strings: { title: string; tag: string; currentVersionLabel: string; latestVersionLabel: string; updatesTitle: string; fallbackNote: string; remindLater: string; updateCta: string; }; }; export function VersionUpdateModal({ visible, info, currentVersion, onClose, onUpdate, strings, }: VersionUpdateModalProps) { const notes = useMemo(() => { if (!info) return []; if (info.releaseNotes && info.releaseNotes.trim().length > 0) { return info.releaseNotes .split(/\r?\n+/) .map((line) => line.trim()) .filter(Boolean); } if (info.updateMessage && info.updateMessage.trim().length > 0) { return [info.updateMessage.trim()]; } return []; }, [info]); if (!info) return null; return ( {strings.tag} {strings.title} {info.latestVersion ? `v${info.latestVersion}` : ''} {strings.currentVersionLabel} v{currentVersion} {strings.latestVersionLabel} v{info.latestVersion} {strings.updatesTitle} {notes.length > 0 ? ( notes.map((line, idx) => ( {line} )) ) : ( {strings.fallbackNote} )} {strings.remindLater} {strings.updateCta} ); } const styles = StyleSheet.create({ overlay: { flex: 1, backgroundColor: 'rgba(7, 11, 34, 0.65)', alignItems: 'center', justifyContent: 'center', padding: 20, }, cardShadow: { width: '100%', maxWidth: 420, shadowColor: '#0B1236', shadowOpacity: 0.35, shadowOffset: { width: 0, height: 16 }, shadowRadius: 30, elevation: 8, }, card: { borderRadius: 24, padding: 20, overflow: 'hidden', borderWidth: 1, borderColor: 'rgba(255,255,255,0.08)', }, glowOrb: { position: 'absolute', width: 220, height: 220, borderRadius: 110, right: -60, top: -80, opacity: 0.8, }, ribbon: { position: 'absolute', left: -120, bottom: -120, width: 260, height: 260, transform: [{ rotate: '-8deg' }], opacity: 0.6, }, headerRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, tag: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 10, paddingVertical: 6, borderRadius: 14, backgroundColor: '#A5B4FC', }, tagText: { color: '#0F1B61', fontWeight: '700', marginLeft: 6, fontSize: 12, letterSpacing: 0.3, }, closeButton: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: 'rgba(255,255,255,0.06)', }, titleBlock: { marginTop: 14, marginBottom: 8, }, title: { fontSize: 24, fontWeight: '800', color: '#F9FAFB', letterSpacing: 0.2, }, subtitle: { color: '#C7D2FE', marginTop: 6, fontSize: 15, }, metaRow: { flexDirection: 'row', marginTop: 10, gap: 8, flexWrap: 'wrap', }, metaChip: { flexDirection: 'row', alignItems: 'center', backgroundColor: 'rgba(255,255,255,0.08)', borderRadius: 12, paddingHorizontal: 10, paddingVertical: 8, }, metaText: { color: '#E5E7EB', marginLeft: 6, fontSize: 12, }, noteCard: { marginTop: 16, borderRadius: 16, padding: 14, backgroundColor: 'rgba(255,255,255,0.06)', borderWidth: 1, borderColor: 'rgba(255,255,255,0.04)', }, noteTitle: { color: '#F9FAFB', fontWeight: '700', fontSize: 15, marginBottom: 8, }, noteItem: { flexDirection: 'row', alignItems: 'flex-start', marginTop: 8, }, bullet: { width: 18, alignItems: 'center', marginTop: 6, }, noteText: { flex: 1, color: '#E5E7EB', fontSize: 14, lineHeight: 20, }, actions: { marginTop: 18, flexDirection: 'row', gap: 10, }, secondaryButton: { flex: 1, height: 48, borderRadius: 14, borderWidth: 1, borderColor: 'rgba(255,255,255,0.16)', alignItems: 'center', justifyContent: 'center', backgroundColor: 'rgba(255,255,255,0.08)', }, secondaryText: { color: '#E5E7EB', fontWeight: '600', fontSize: 14, }, primaryButtonShadow: { flex: 1, height: 48, borderRadius: 14, overflow: 'hidden', shadowColor: '#1E40AF', shadowOpacity: 0.4, shadowOffset: { width: 0, height: 12 }, shadowRadius: 14, elevation: 6, }, primaryButton: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, }, primaryText: { color: '#0B1236', fontWeight: '800', fontSize: 15, }, }); export default VersionUpdateModal;