import React, { useState, useCallback } from 'react' import { View, Text, FlatList, StyleSheet, RefreshControl, TouchableOpacity } from 'react-native' import Constants from 'expo-constants' import { useFocusEffect } from 'expo-router' import { COLORS } from '../../constants/Config' import { getReleaseNotes } from '../../services/api' export default function ReleaseNotesScreen() { const [notes, setNotes] = useState([]) const [loading, setLoading] = useState(false) const [expanded, setExpanded] = useState>(new Set()) const load = useCallback(async () => { setLoading(true) try { const r = await getReleaseNotes(); setNotes(r.data?.items ?? r.data ?? []) } catch { setNotes([]) } finally { setLoading(false) } }, []) useFocusEffect(useCallback(() => { load() }, [load])) const toggle = (v: string) => { const next = new Set(expanded) next.has(v) ? next.delete(v) : next.add(v) setExpanded(next) } const appVersion = Constants.expoConfig?.version ?? '1.0.0' return ( 릴리즈 노트 앱 버전: {appVersion} String(i)} refreshControl={} ListEmptyComponent={릴리즈 노트가 없습니다.} contentContainerStyle={{ padding: 12 }} renderItem={({ item, index }) => { const v = item.version ?? `v${index + 1}` const isOpen = expanded.has(v) return ( toggle(v)}> {index === 0 && NEW} {v} {item.released_at?.slice(0, 10) ?? '-'} {isOpen ? '▲' : '▼'} {isOpen && ( {(item.changes ?? item.items ?? [item.description ?? '']).map((c: string, i: number) => ( • {c} ))} )} ) }} /> ) } const s = StyleSheet.create({ container: { flex: 1, backgroundColor: COLORS.bg }, header: { backgroundColor: COLORS.primary, padding: 16, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }, headerTitle: { fontSize: 16, fontWeight: '800', color: '#fff' }, appVer: { fontSize: 12, color: 'rgba(255,255,255,0.7)' }, card: { backgroundColor: '#fff', borderRadius: 10, padding: 14, marginBottom: 8, elevation: 1 }, row: { flexDirection: 'row', alignItems: 'center', gap: 8 }, rowLeft: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 6 }, newBadge: { backgroundColor: COLORS.danger, borderRadius: 4, paddingHorizontal: 5, paddingVertical: 2 }, newBadgeText: { fontSize: 9, color: '#fff', fontWeight: '800' }, version: { fontSize: 15, fontWeight: '700', color: COLORS.text }, date: { fontSize: 12, color: COLORS.muted }, arrow: { fontSize: 12, color: COLORS.muted }, body: { marginTop: 10, paddingTop: 10, borderTopWidth: 1, borderTopColor: COLORS.border }, change: { fontSize: 13, color: COLORS.text, lineHeight: 22 }, empty: { textAlign: 'center', color: COLORS.muted, marginTop: 40 }, })