播放页部分调整,完整播放链路层级已打通

This commit is contained in:
2026-08-18 23:39:22 +08:00
parent 74a15ca7af
commit 85463c3716
4 changed files with 184 additions and 83 deletions
+14 -14
View File
@@ -2,15 +2,17 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../services/audio_service.dart';
import '../main.dart'; // ✅ 导入 navigatorKey
import 'playlist_page.dart'; // ✅ 导入 PlaylistPage
import '../main.dart';
import 'playlist_page.dart';
class PlayerPage extends StatefulWidget {
final VoidCallback onClose;
final VoidCallback onOpenPlaylist;
const PlayerPage({
super.key,
required this.onClose,
required this.onOpenPlaylist,
});
@override
@@ -81,7 +83,7 @@ class _PlayerPageState extends State<PlayerPage> {
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.white),
onPressed: widget.onClose, // ✅ 使用回调关闭
onPressed: widget.onClose,
),
title: const Text(
'正在播放',
@@ -93,17 +95,6 @@ class _PlayerPageState extends State<PlayerPage> {
),
centerTitle: true,
actions: [
IconButton(
icon:
const Icon(Icons.playlist_play_outlined, color: Colors.white54),
onPressed: () {
navigatorKey.currentState?.push(
MaterialPageRoute(
builder: (_) => const PlaylistPage(),
),
);
},
),
IconButton(
icon: const Icon(Icons.more_vert, color: Colors.white54),
onPressed: () {},
@@ -309,6 +300,15 @@ class _PlayerPageState extends State<PlayerPage> {
color: service.hasQueue ? Colors.white60 : Colors.grey[600],
padding: const EdgeInsets.all(12),
),
IconButton(
onPressed: widget.onOpenPlaylist,
icon: const Icon(
Icons.playlist_play_outlined,
color: Color(0xFFB8D4D0),
size: 26,
),
padding: const EdgeInsets.all(8),
),
const SizedBox(width: 4),
],
),
+9 -4
View File
@@ -4,7 +4,12 @@ import 'package:provider/provider.dart';
import '../services/audio_service.dart';
class PlaylistPage extends StatelessWidget {
const PlaylistPage({super.key});
final VoidCallback onClose;
const PlaylistPage({
super.key,
required this.onClose,
});
@override
Widget build(BuildContext context) {
@@ -28,7 +33,7 @@ class PlaylistPage extends StatelessWidget {
foregroundColor: Colors.white,
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios_new),
onPressed: () => Navigator.pop(context),
onPressed: onClose,
),
actions: [
IconButton(
@@ -55,7 +60,7 @@ class PlaylistPage extends StatelessWidget {
onPressed: () {
service.clearQueue();
Navigator.pop(context);
Navigator.pop(context);
onClose();
},
child: const Text(
'清空',
@@ -141,7 +146,7 @@ class PlaylistPage extends StatelessWidget {
: null,
onTap: () {
service.setQueue(queue, startIndex: index);
Navigator.pop(context);
onClose();
},
);
},