优化部分功能逻辑:元数据信息漂移

优化部分体验问题,包含动画、界面层级等
This commit is contained in:
2026-08-26 21:13:09 +08:00
parent 94d37fe263
commit 8f3f827429
3 changed files with 251 additions and 198 deletions
+91 -96
View File
@@ -9,16 +9,19 @@ class GlobalMiniPlayer extends StatelessWidget {
@override
Widget build(BuildContext context) {
// ⭐ 使用 Selector 监听完整的 Song 对象(包括 artwork
final song = context.select<AudioService, Song?>((s) => s.currentSong);
final isPlaying = context.select<AudioService, bool>((s) => s.isPlaying);
final bottomPadding = MediaQuery.of(context).padding.bottom;
// 如果没有歌曲,不显示
if (song == null) {
return const SizedBox.shrink();
}
return Stack(
clipBehavior: Clip.none,
children: [
// ⭐ 背景高度从 56 改为 60
// 背景条
Positioned(
left: 0,
right: 0,
@@ -28,6 +31,7 @@ class GlobalMiniPlayer extends StatelessWidget {
color: const Color(0xFF1A1F1E),
),
),
// 主内容
Positioned(
left: 0,
right: 0,
@@ -37,110 +41,101 @@ class GlobalMiniPlayer extends StatelessWidget {
bottom: Radius.circular(16),
),
child: Container(
height: 60, // ⭐ 从 56 改为 60
height: 60,
color: const Color(0xFF1A1F1E),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
if (song != null) {
child: ClipRRect(
// ⭐ 修复涟漪圆角问题
borderRadius: BorderRadius.circular(12),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
navigatorKey.currentState?.pushNamed('/player');
}
},
highlightColor: Colors.white.withOpacity(0.05),
splashColor: Colors.white.withOpacity(0.1),
child: Row(
children: [
const SizedBox(width: 12),
// 封面图容器尺寸从 40 改为 44(适配 60px 高度)
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: song != null
? const Color(0xFF2A3332)
: Colors.grey[800],
// ⭐ 如果 song.artwork 存在,显示封面图
image: song?.artwork != null
? DecorationImage(
image: MemoryImage(song!.artwork!),
fit: BoxFit.cover,
},
highlightColor: Colors.white.withOpacity(0.05),
splashColor: Colors.white.withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
child: Row(
children: [
const SizedBox(width: 12),
// 封面图
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: const Color(0xFF2A3332),
image: song.artwork != null
? DecorationImage(
image: MemoryImage(song.artwork!),
fit: BoxFit.cover,
)
: null,
),
child: song.artwork == null
? const Icon(
Icons.music_note,
color: Colors.white38,
size: 20,
)
: null,
),
child: song?.artwork == null
? Icon(
song != null
? Icons.music_note
: Icons.music_off,
color: song != null
? Colors.white38
: Colors.grey[600],
size: 20,
)
: null,
),
const SizedBox(width: 12),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
song != null ? song.title : '清听',
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.white,
decoration: TextDecoration.none,
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,
color: Colors.white,
decoration: TextDecoration.none,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
song != null ? song.artist : '未播放',
style: TextStyle(
fontSize: 12,
color: song != null
? Colors.grey[400]
: Colors.grey[600],
decoration: TextDecoration.none,
Text(
song.artist,
style: TextStyle(
fontSize: 12,
color: Colors.grey[400],
decoration: TextDecoration.none,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
],
),
),
),
IconButton(
icon: Icon(
song != null && isPlaying
? Icons.pause
: Icons.play_arrow,
color: song != null ? Colors.white : Colors.grey[600],
size: 24,
),
onPressed: () {
if (song != null) {
// 播放/暂停按钮
IconButton(
icon: Icon(
isPlaying ? Icons.pause : Icons.play_arrow,
color: Colors.white,
size: 24,
),
onPressed: () {
context.read<AudioService>().togglePlay();
}
},
),
IconButton(
icon: const Icon(
Icons.playlist_play_outlined,
color: Colors.grey,
size: 24,
},
),
onPressed: () {
if (song != null) {
// 播放列表按钮
IconButton(
icon: const Icon(
Icons.playlist_play_outlined,
color: Colors.grey,
size: 24,
),
onPressed: () {
navigatorKey.currentState?.pushNamed('/playlist');
}
},
),
const SizedBox(width: 4),
],
},
),
const SizedBox(width: 4),
],
),
),
),
),