// lib/widgets/mini_player_bar.dart import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../services/audio_service.dart'; class MiniPlayerBar extends StatelessWidget { const MiniPlayerBar({super.key}); @override Widget build(BuildContext context) { final service = context.watch(); final song = service.currentSong!; return Container( height: 64, decoration: BoxDecoration( color: const Color(0xFF1A1F1E), border: const Border(top: BorderSide(color: Colors.white10, width: 0.5)), boxShadow: [ BoxShadow( color: Colors.black26, blurRadius: 8, offset: const Offset(0, -2)), ], ), child: Row( children: [ const SizedBox(width: 12), // ---- 封面方图 ---- Container( width: 44, height: 44, decoration: BoxDecoration( color: const Color(0xFF2A3332), borderRadius: BorderRadius.circular(6), ), child: const Icon(Icons.music_note, color: Colors.white38, size: 22), ), const SizedBox(width: 12), // ---- 歌曲信息 ---- Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( song.title, style: const TextStyle( fontSize: 14, fontWeight: FontWeight.w500), maxLines: 1, overflow: TextOverflow.ellipsis, ), Text( song.artist, style: TextStyle(fontSize: 12, color: Colors.grey[400]), maxLines: 1, overflow: TextOverflow.ellipsis, ), ], ), ), // ---- 控制按钮:播放/暂停 + 展开列表 ---- IconButton( icon: Icon( service.isPlaying ? Icons.pause : Icons.play_arrow, color: Colors.white, ), onPressed: () => context.read().togglePlay(), ), IconButton( icon: const Icon(Icons.playlist_play_outlined, color: Colors.white54), onPressed: () { // 后续:展开当前播放列表 }, ), const SizedBox(width: 4), ], ), ); } }