|
|
|
@ -158,9 +158,9 @@ class MiniPlayer extends StatelessWidget {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Obx(() {
|
|
|
|
|
final bool hasPlaylist = audioController.songList.isNotEmpty;
|
|
|
|
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onHorizontalDragEnd: hasPlaylist ? (DragEndDetails details) {
|
|
|
|
|
onHorizontalDragEnd: hasPlaylist
|
|
|
|
|
? (DragEndDetails details) {
|
|
|
|
|
if (audioController.songList.isEmpty) return;
|
|
|
|
|
final velocity = details.velocity.pixelsPerSecond.dx;
|
|
|
|
|
const threshold = 300.0;
|
|
|
|
@ -172,7 +172,8 @@ class MiniPlayer extends StatelessWidget {
|
|
|
|
|
audioController.playNext();
|
|
|
|
|
HapticFeedback.mediumImpact();
|
|
|
|
|
}
|
|
|
|
|
} : null,
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 64, // 增加高度使布局更加宽敞
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
@ -213,6 +214,9 @@ class MiniPlayer extends StatelessWidget {
|
|
|
|
|
BuildContext fromHeroContext,
|
|
|
|
|
BuildContext toHeroContext,
|
|
|
|
|
) {
|
|
|
|
|
if (!hasPlaylist) {
|
|
|
|
|
return const Icon(Icons.music_note, size: 30);
|
|
|
|
|
}
|
|
|
|
|
return ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
@ -220,7 +224,10 @@ class MiniPlayer extends StatelessWidget {
|
|
|
|
|
width: 48,
|
|
|
|
|
height: 48,
|
|
|
|
|
child: Image.network(
|
|
|
|
|
audioController.songList[audioController.currentSongIndex.value].pic,
|
|
|
|
|
audioController
|
|
|
|
|
.songList[
|
|
|
|
|
audioController.currentSongIndex.value]
|
|
|
|
|
.pic,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
errorBuilder: (context, error, stackTrace) =>
|
|
|
|
|
const Icon(Icons.music_note, size: 30),
|
|
|
|
@ -234,7 +241,8 @@ class MiniPlayer extends StatelessWidget {
|
|
|
|
|
child: Obx(() {
|
|
|
|
|
final currentSong = audioController.songList.isEmpty
|
|
|
|
|
? null
|
|
|
|
|
: audioController.songList[audioController.currentSongIndex.value];
|
|
|
|
|
: audioController.songList[
|
|
|
|
|
audioController.currentSongIndex.value];
|
|
|
|
|
return AnimatedSwitcher(
|
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
|
child: currentSong != null
|
|
|
|
@ -246,25 +254,6 @@ class MiniPlayer extends StatelessWidget {
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
errorBuilder: (context, error, stackTrace) =>
|
|
|
|
|
const Icon(Icons.music_note, size: 30),
|
|
|
|
|
// loadingBuilder: (context, child, loadingProgress) {
|
|
|
|
|
// if (loadingProgress == null) return child;
|
|
|
|
|
// return Container(
|
|
|
|
|
// color: Colors.grey[100],
|
|
|
|
|
// width: 48,
|
|
|
|
|
// height: 48,
|
|
|
|
|
// child: Center(
|
|
|
|
|
// child: CircularProgressIndicator(
|
|
|
|
|
// strokeWidth: 2,
|
|
|
|
|
// valueColor: const AlwaysStoppedAnimation<Color>(
|
|
|
|
|
// Color(0xff429482)),
|
|
|
|
|
// value: loadingProgress.expectedTotalBytes != null
|
|
|
|
|
// ? loadingProgress.cumulativeBytesLoaded /
|
|
|
|
|
// loadingProgress.expectedTotalBytes!
|
|
|
|
|
// : null,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// },
|
|
|
|
|
)
|
|
|
|
|
: const Icon(Icons.music_note, size: 30),
|
|
|
|
|
);
|
|
|
|
|