import { View, Text, Pressable, Image, StyleSheet } from 'react-native'; import { useState, useEffect } from 'react'; import { useRouter } from 'expo-router'; import { subscribe, togglePlayback, playNext, playPrevious, getPlayerState } from '../lib/player'; import { Colors, Spacing, Typography } from '../constants/theme'; export default function MiniPlayer() { const router = useRouter(); const [state, setState] = useState(getPlayerState()); useEffect(() => { const unsub = subscribe(setState); return unsub; }, []); if (!state.trackId) return null; return ( router.push('/now-playing')} style={[styles.container, { backgroundColor: Colors.surface }]} > {/* Thumbnail */} {state.imageUrl ? ( ) : ( ♫ )} {/* Track info */} {state.title} {state.artist} {/* Skip controls */} {state.queue.length > 1 && ( { e.stopPropagation(); playPrevious(); }} style={[styles.skipButton, { opacity: state.hasPrevious ? 1 : 0.3 }]} disabled={!state.hasPrevious} > ⏮ )} {/* Play/pause */} { e.stopPropagation(); togglePlayback(); }} style={[styles.playButton, { backgroundColor: state.isPlaying ? Colors.playing : Colors.ai }]} > {state.isPlaying ? '⏸' : '▶'} {state.queue.length > 1 && ( { e.stopPropagation(); playNext(); }} style={[styles.skipButton, { opacity: state.hasNext ? 1 : 0.3 }]} disabled={!state.hasNext} > ⏭ )} {/* Queue indicator */} {state.queue.length > 1 && ( {state.queueIndex + 1}/{state.queue.length} )} ); } const styles = StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: Spacing.md, paddingVertical: Spacing.sm, borderTopWidth: 1, borderTopColor: Colors.border, gap: Spacing.sm, }, thumbnail: { width: 40, height: 40, borderRadius: 8, }, info: { flex: 1, justifyContent: 'center', }, playButton: { width: 36, height: 36, borderRadius: 18, justifyContent: 'center', alignItems: 'center', }, skipButton: { width: 28, height: 28, borderRadius: 14, justifyContent: 'center', alignItems: 'center', }, });