开始给原先适配期的状态擦屁股:现在是修复播放页与播放列表页的显示
This commit is contained in:
+67
-57
@@ -5,6 +5,7 @@ import 'package:media_kit/media_kit.dart';
|
||||
import 'package:audio_service/audio_service.dart' as audio_service;
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'services/audio_service.dart';
|
||||
import 'services/playback_service.dart';
|
||||
import 'services/app_lifecycle_service.dart';
|
||||
@@ -15,8 +16,8 @@ import 'pages/home_page.dart';
|
||||
import 'pages/player_page.dart';
|
||||
import 'pages/playlist_page.dart';
|
||||
import 'widgets/global_mini_player.dart';
|
||||
import 'utils/navigation.dart';
|
||||
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
final stopwatch = Stopwatch();
|
||||
|
||||
bool _appInitialized = false;
|
||||
@@ -363,65 +364,74 @@ class _QTPlayerAppState extends State<QTPlayerApp> {
|
||||
debugPrint(
|
||||
'🎨 [QTPlayerApp] build #$_buildCount ${stopwatch.elapsedMilliseconds}ms');
|
||||
|
||||
return MaterialApp(
|
||||
title: '清听',
|
||||
theme: ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
primaryColor: const Color(0xFF7C9A9E),
|
||||
colorScheme: const ColorScheme.dark(
|
||||
primary: Color(0xFF7C9A9E),
|
||||
secondary: Color(0xFFB8D4D0),
|
||||
surface: Color(0xFF1A1F1E),
|
||||
onSurface: Colors.white,
|
||||
),
|
||||
useMaterial3: true,
|
||||
// ⭐ 使用 AnnotatedRegion 包裹 MaterialApp,统一控制系统栏样式
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
systemNavigationBarColor: const Color(0xFF1A1F1E),
|
||||
systemNavigationBarIconBrightness: Brightness.light,
|
||||
),
|
||||
navigatorKey: navigatorKey,
|
||||
navigatorObservers: [MiniPlayerNavigatorObserver()],
|
||||
onGenerateRoute: _onGenerateRoute,
|
||||
builder: (context, child) {
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (child != null) child,
|
||||
AnimatedBuilder(
|
||||
animation: RouteManager(),
|
||||
builder: (context, _) {
|
||||
final routeManager = RouteManager();
|
||||
final shouldShow = routeManager.currentRoute != '/player' &&
|
||||
routeManager.currentRoute != '/playlist';
|
||||
child: MaterialApp(
|
||||
title: '清听',
|
||||
theme: ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
primaryColor: const Color(0xFF7C9A9E),
|
||||
colorScheme: const ColorScheme.dark(
|
||||
primary: Color(0xFF7C9A9E),
|
||||
secondary: Color(0xFFB8D4D0),
|
||||
surface: Color(0xFF1A1F1E),
|
||||
onSurface: Colors.white,
|
||||
),
|
||||
useMaterial3: true,
|
||||
),
|
||||
navigatorKey: navigatorKey,
|
||||
navigatorObservers: [MiniPlayerNavigatorObserver()],
|
||||
onGenerateRoute: _onGenerateRoute,
|
||||
builder: (context, child) {
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (child != null) child,
|
||||
AnimatedBuilder(
|
||||
animation: RouteManager(),
|
||||
builder: (context, _) {
|
||||
final routeManager = RouteManager();
|
||||
final shouldShow = routeManager.currentRoute != '/player' &&
|
||||
routeManager.currentRoute != '/playlist';
|
||||
|
||||
return AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
switchInCurve: Curves.easeOut,
|
||||
switchOutCurve: Curves.easeIn,
|
||||
transitionBuilder: (child, animation) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.1),
|
||||
end: Offset.zero,
|
||||
).animate(animation),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: shouldShow
|
||||
? const Align(
|
||||
key: ValueKey('mini_player_visible'),
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: GlobalMiniPlayer(),
|
||||
)
|
||||
: const SizedBox.shrink(
|
||||
key: ValueKey('mini_player_hidden'),
|
||||
return AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
switchInCurve: Curves.easeOut,
|
||||
switchOutCurve: Curves.easeIn,
|
||||
transitionBuilder: (child, animation) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.1),
|
||||
end: Offset.zero,
|
||||
).animate(animation),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: shouldShow
|
||||
? const Align(
|
||||
key: ValueKey('mini_player_visible'),
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: GlobalMiniPlayer(),
|
||||
)
|
||||
: const SizedBox.shrink(
|
||||
key: ValueKey('mini_player_hidden'),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user