import React, { useState, useCallback, useRef } from 'react'; import { View, Text, StyleSheet, ScrollView, Image, TouchableOpacity, Animated, Dimensions, Alert, Share, FlatList, } from 'react-native'; import { useFocusEffect } from '@react-navigation/native'; import { LinearGradient } from 'expo-linear-gradient'; import { BlurView } from 'expo-blur'; import { Ionicons } from '@expo/vector-icons'; import { getConcertById, deleteConcert } from '../utils/storage'; import { getGenreTheme } from '../constants/genres'; const { width, height } = Dimensions.get('window'); export default function ConcertDetailScreen({ navigation, route }) { const { id } = route.params; const [concert, setConcert] = useState(null); const scrollY = useRef(new Animated.Value(0)).current; useFocusEffect( useCallback(() => { loadConcert(); }, [id]) ); const loadConcert = async () => { const data = await getConcertById(id); setConcert(data); }; if (!concert) return ; const theme = getGenreTheme(concert.genre); const c = theme.colors; const formattedDate = concert.date ? new Date(concert.date).toLocaleDateString('de-DE', { weekday: 'long', day: '2-digit', month: 'long', year: 'numeric', }) : null; const headerScale = scrollY.interpolate({ inputRange: [-100, 0], outputRange: [1.2, 1], extrapolateRight: 'clamp', }); const headerOpacity = scrollY.interpolate({ inputRange: [0, 200], outputRange: [1, 0], extrapolate: 'clamp', }); const navOpacity = scrollY.interpolate({ inputRange: [150, 250], outputRange: [0, 1], extrapolate: 'clamp', }); const handleDelete = () => { Alert.alert( 'Konzert löschen', 'Möchtest du diesen Eintrag wirklich löschen?', [ { text: 'Abbrechen', style: 'cancel' }, { text: 'Löschen', style: 'destructive', onPress: async () => { await deleteConcert(id); navigation.goBack(); }, }, ] ); }; const handleShare = async () => { try { await Share.share({ message: `🎵 ${concert.title || 'Konzert'}\n${concert.artist ? `👤 ${concert.artist}` : ''}\n${concert.venue ? `📍 ${concert.venue}` : ''}\n${formattedDate || ''}\n\nGeteilt via SETLIST App`, }); } catch (e) {} }; const renderStars = (rating) => [1, 2, 3, 4, 5].map((s) => ( )); const renderGalleryItem = ({ item }) => ( navigation.navigate('FullscreenImage', { uri: item, images: concert.gallery })} activeOpacity={0.9} > ); return ( {/* Floating Nav on scroll */} {concert.title} {/* Back / Actions */} navigation.goBack()} style={styles.navBtn} activeOpacity={0.7}> navigation.navigate('EditConcert', { id: concert.id })} style={styles.navBtn} activeOpacity={0.7} > {/* Hero Image */} {concert.ticketImage ? ( navigation.navigate('FullscreenImage', { uri: concert.ticketImage, images: [concert.ticketImage], }) } activeOpacity={0.95} > ) : ( {theme.icon} )} {/* Content */} {/* Genre + Date tag */} {theme.icon} {theme.label} {formattedDate && ( {formattedDate} )} {/* Title */} {concert.title || 'Unbenannt'} {/* Artist */} {concert.artist && ( {concert.artist} )} {/* Venue */} {concert.venue && ( {concert.venue} )} {/* Rating */} {concert.rating > 0 && ( {renderStars(concert.rating)} {['', 'Enttäuschend', 'Okay', 'Gut', 'Sehr gut', 'Unvergesslich'][concert.rating]} )} {/* Divider */} {/* Notes */} {concert.notes && concert.notes.trim() !== '' && ( Erinnerungen {concert.notes} )} {/* Setlist */} {concert.setlist && concert.setlist.length > 0 && ( Setlist {concert.setlist.map((song, i) => ( {String(i + 1).padStart(2, '0')} {song} ))} )} {/* Gallery */} {concert.gallery && concert.gallery.length > 0 && ( Galerie {concert.gallery.length} Fotos i.toString()} renderItem={renderGalleryItem} horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.galleryList} /> )} {/* Delete */} Eintrag löschen ); } const styles = StyleSheet.create({ container: { flex: 1 }, floatingNav: { position: 'absolute', top: 0, left: 0, right: 0, height: 90, zIndex: 20, alignItems: 'center', justifyContent: 'flex-end', paddingBottom: 12, overflow: 'hidden', }, floatingNavTitle: { fontSize: 16, fontWeight: '700', letterSpacing: 0.5 }, navBar: { position: 'absolute', top: 52, left: 0, right: 0, flexDirection: 'row', justifyContent: 'space-between', paddingHorizontal: 20, zIndex: 30, }, navBtn: { width: 40, height: 40, borderRadius: 20, overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: 'rgba(0,0,0,0.4)', }, navRight: { flexDirection: 'row', gap: 10 }, heroContainer: { height: 380, overflow: 'hidden' }, heroImage: { width: '100%', height: '100%' }, heroPlaceholder: { width: '100%', height: '100%', alignItems: 'center', justifyContent: 'center', }, heroEmoji: { fontSize: 100 }, heroOverlay: { position: 'absolute', bottom: 0, left: 0, right: 0, height: 120 }, content: { flex: 1, paddingHorizontal: 20, paddingTop: 16 }, tagsRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, marginBottom: 12 }, tag: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 10, paddingVertical: 5, borderRadius: 8, borderWidth: 1, gap: 4, }, tagText: { fontSize: 12, fontWeight: '600' }, title: { fontSize: 32, fontWeight: '900', letterSpacing: -0.5, marginBottom: 4, lineHeight: 38 }, artist: { fontSize: 18, fontWeight: '700', letterSpacing: 0.3, marginBottom: 8 }, venueRow: { flexDirection: 'row', alignItems: 'center', gap: 4, marginBottom: 16 }, venue: { fontSize: 14 }, ratingRow: { flexDirection: 'row', alignItems: 'center', gap: 8, marginBottom: 16 }, ratingLabel: { fontSize: 13, marginLeft: 4 }, divider: { height: 1, marginBottom: 24 }, section: { marginBottom: 28 }, sectionHeader: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }, sectionTitle: { fontSize: 11, fontWeight: '700', letterSpacing: 2, textTransform: 'uppercase', marginBottom: 12 }, sectionCount: { fontSize: 12, fontWeight: '600' }, notes: { fontSize: 16, lineHeight: 26, fontWeight: '400' }, setlistItem: { flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 10 }, setlistNum: { fontSize: 12, fontWeight: '800', width: 24 }, setlistSong: { fontSize: 16, flex: 1 }, galleryList: { gap: 10 }, galleryThumb: { width: 140, height: 140, borderRadius: 12, borderWidth: 1, }, deleteBtn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, paddingVertical: 14, borderRadius: 12, borderWidth: 1, borderColor: '#FF444430', backgroundColor: '#FF44440A', marginTop: 8, }, deleteBtnText: { color: '#FF4444', fontSize: 14, fontWeight: '600' }, });