import { View, Text, ScrollView, TouchableOpacity, FlatList, ActivityIndicator } from 'react-native' import { useRouter } from 'expo-router' import { usePlayerStore } from '../src/store/playerStore' import { BottomNavBar } from '../src/components/BottomNavBar' import { useState, useEffect } from 'react' export default function PlaylistScreen() { const router = useRouter() const isPlaying = usePlayerStore(s => s.isPlaying) const togglePlay = usePlayerStore(s => s.togglePlay) const [songs, setSongs] = useState([]) const [playlists, setPlaylists] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { fetchData() }, []) const fetchData = async () => { try { const [plRes, songRes] = await Promise.all([ fetch('/api/playlists'), fetch('/api/songs?page=1&per_page=50'), ]) const plData = await plRes.json() const songData = await songRes.json() setPlaylists(plData.items || plData || []) setSongs(songData.items || []) } catch { setPlaylists([]) setSongs([]) } finally { setLoading(false) } } return ( router.push('/library' as any)}> {playlists.map((pl: any, i: number) => ( ))} {isPlaying ? '⏸' : '▶️'} {playlists[0]?.name || 'Playlist'} 📢 {loading ? ( ) : ( songs.map((song: any) => ( usePlayerStore.getState().setSong(song)} > 🎵 {song.title} {song.artist} {song.duration_sec ? `${Math.floor(song.duration_sec / 60)}:${(song.duration_sec % 60).toString().padStart(2, '0')}` : '--:--'} )) )} ) }