|
|
@ -26,7 +26,7 @@ class QqmusicPlaylistView extends GetView<QQMusicPlaylistController> { |
|
|
elevation: 0, |
|
|
elevation: 0, |
|
|
), |
|
|
), |
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50], |
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50], |
|
|
body: controller.playlist.isEmpty |
|
|
body: controller.playlist.isEmpty || controller.currentSong.value == null |
|
|
? Center( |
|
|
? Center( |
|
|
child: Column( |
|
|
child: Column( |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
@ -70,21 +70,43 @@ class QqmusicPlaylistView extends GetView<QQMusicPlaylistController> { |
|
|
// 构建当前播放音乐详情部分 |
|
|
// 构建当前播放音乐详情部分 |
|
|
Widget _buildCurrentPlayingSection(bool isDarkMode) { |
|
|
Widget _buildCurrentPlayingSection(bool isDarkMode) { |
|
|
return SingleChildScrollView( |
|
|
return SingleChildScrollView( |
|
|
// 添加滚动支持 |
|
|
|
|
|
child: Obx(() { |
|
|
child: Obx(() { |
|
|
|
|
|
// 添加空值检查 |
|
|
|
|
|
final currentSong = controller.currentSong.value; |
|
|
|
|
|
if (currentSong == null) { |
|
|
|
|
|
return Container( |
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 12.h), |
|
|
|
|
|
child: Column( |
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
|
children: [ |
|
|
|
|
|
Icon( |
|
|
|
|
|
Icons.music_note, |
|
|
|
|
|
size: 110.w, |
|
|
|
|
|
color: Colors.grey[400], |
|
|
|
|
|
), |
|
|
|
|
|
SizedBox(height: 12.h), |
|
|
|
|
|
Text( |
|
|
|
|
|
'暂无播放音乐', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
|
color: Colors.grey[600], |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return Container( |
|
|
return Container( |
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 12.h), |
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 12.h), |
|
|
child: Column( |
|
|
child: Column( |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
children: [ |
|
|
children: [ |
|
|
// 封面图片 - 响应式尺寸 |
|
|
// 封面图片 - 现在安全了 |
|
|
_buildCoverImage(controller.currentSong.value!.albumPic ?? '', |
|
|
_buildCoverImage(currentSong.albumPic ?? '', isDarkMode, size: 110.w), |
|
|
isDarkMode, // Handle nullable albumPic |
|
|
|
|
|
size: 110.w), |
|
|
|
|
|
SizedBox(height: 12.h), |
|
|
SizedBox(height: 12.h), |
|
|
// 歌曲信息 |
|
|
// 歌曲信息 - 现在安全了 |
|
|
_buildSongInfo(controller.currentSong.value!.name, |
|
|
_buildSongInfo(currentSong.name, currentSong.artist, isDarkMode), |
|
|
controller.currentSong.value!.artist, isDarkMode), |
|
|
|
|
|
SizedBox(height: 16.h), |
|
|
SizedBox(height: 16.h), |
|
|
// 进度条 |
|
|
// 进度条 |
|
|
_buildProgressBar(isDarkMode), |
|
|
_buildProgressBar(isDarkMode), |
|
|
@ -133,15 +155,15 @@ class QqmusicPlaylistView extends GetView<QQMusicPlaylistController> { |
|
|
|
|
|
|
|
|
// 构建歌单列表部分 |
|
|
// 构建歌单列表部分 |
|
|
Widget _buildPlaylistSection(bool isDarkMode) { |
|
|
Widget _buildPlaylistSection(bool isDarkMode) { |
|
|
return ListView.builder( |
|
|
return GetBuilder<QQMusicPlaylistController>( |
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 8.h), |
|
|
builder: (controller) { |
|
|
itemCount: controller.playlist.length, |
|
|
return ListView.builder( |
|
|
itemBuilder: (context, index) { |
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 8.h), |
|
|
final song = controller.playlist[index]; |
|
|
itemCount: controller.playlist.length, |
|
|
return _buildMusicItem( |
|
|
itemBuilder: (context, index) { |
|
|
context, |
|
|
final song = controller.playlist[index]; |
|
|
song, |
|
|
return _buildMusicItem(context, song, isDarkMode); |
|
|
isDarkMode, |
|
|
}, |
|
|
); |
|
|
); |
|
|
}, |
|
|
}, |
|
|
); |
|
|
); |
|
|
@ -236,9 +258,10 @@ class QqmusicPlaylistView extends GetView<QQMusicPlaylistController> { |
|
|
SizedBox(width: 14.w), |
|
|
SizedBox(width: 14.w), |
|
|
// 播放按钮 |
|
|
// 播放按钮 |
|
|
Obx(() { |
|
|
Obx(() { |
|
|
final currentIdInt = song.mid; |
|
|
// 使用 currentSong 的 mid 来判断是否是当前播放的歌曲 |
|
|
final isThisPlaying = controller.isPlaying.value && |
|
|
final isThisPlaying = controller.isPlaying.value && |
|
|
controller.currentIndex.value == currentIdInt; |
|
|
controller.currentSong.value?.mid == song.mid; |
|
|
|
|
|
|
|
|
final currentProgress = isThisPlaying |
|
|
final currentProgress = isThisPlaying |
|
|
? controller.totalDuration.value > 0 |
|
|
? controller.totalDuration.value > 0 |
|
|
? controller.currentPosition.value / |
|
|
? controller.currentPosition.value / |
|
|
@ -257,9 +280,9 @@ class QqmusicPlaylistView extends GetView<QQMusicPlaylistController> { |
|
|
Logger.d('MusicPlaylistView', |
|
|
Logger.d('MusicPlaylistView', |
|
|
'播放按钮被点击,当前播放状态: ${controller.isPlaying.value}'); |
|
|
'播放按钮被点击,当前播放状态: ${controller.isPlaying.value}'); |
|
|
Logger.d('MusicPlaylistView', |
|
|
Logger.d('MusicPlaylistView', |
|
|
'当前歌曲ID: ${controller.currentIndex.value}, 点击歌曲ID: $currentIdInt'); |
|
|
'当前歌曲ID: ${controller.currentSong.value?.mid}, 点击歌曲ID: ${song.mid}'); |
|
|
if (controller.isPlaying.value) { |
|
|
if (controller.isPlaying.value) { |
|
|
if (controller.currentIndex.value == currentIdInt) { |
|
|
if (controller.currentSong.value?.mid == song.mid) { |
|
|
Logger.d('MusicPlaylistView', '暂停当前播放的歌曲'); |
|
|
Logger.d('MusicPlaylistView', '暂停当前播放的歌曲'); |
|
|
await controller.togglePlayPause(); |
|
|
await controller.togglePlayPause(); |
|
|
} else { |
|
|
} else { |
|
|
@ -513,7 +536,9 @@ class QqmusicPlaylistView extends GetView<QQMusicPlaylistController> { |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
children: [ |
|
|
children: [ |
|
|
IconButton( |
|
|
IconButton( |
|
|
onPressed: () {}, |
|
|
onPressed: () async { |
|
|
|
|
|
await controller.previousSong(); |
|
|
|
|
|
}, |
|
|
iconSize: 32.w, |
|
|
iconSize: 32.w, |
|
|
padding: EdgeInsets.all(8.w), // 增大触摸区域 |
|
|
padding: EdgeInsets.all(8.w), // 增大触摸区域 |
|
|
icon: Icon( |
|
|
icon: Icon( |
|
|
|