From 4b9f251dae58d7ae7510478f1225c7f7cfa62d77 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sat, 2 Aug 2025 18:41:56 +0800 Subject: [PATCH] opt live room Signed-off-by: bggRGjQaUbCoE --- lib/pages/live_room/view.dart | 244 +++++++++++++------------- lib/pages/live_room/widgets/chat.dart | 16 +- lib/plugin/pl_player/view.dart | 3 +- 3 files changed, 137 insertions(+), 126 deletions(-) diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 2ecaf298..a3e875d4 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -152,7 +152,11 @@ class _LiveRoomPageState extends State } } - Widget videoPlayerPanel({Color? fill, Alignment? alignment}) { + Widget videoPlayerPanel({ + Color? fill, + Alignment? alignment, + bool needDm = true, + }) { return PopScope( canPop: !isFullScreen, onPopInvokedWithResult: (bool didPop, Object? result) { @@ -180,35 +184,39 @@ class _LiveRoomPageState extends State liveRoomCtr: _liveRoomController, onRefresh: _liveRoomController.queryLiveUrl, ), - danmuWidget: Obx( - () => AnimatedOpacity( - opacity: plPlayerController.enableShowDanmaku.value ? 1 : 0, - duration: const Duration(milliseconds: 100), - child: DanmakuScreen( - createdController: (DanmakuController e) { - plPlayerController.danmakuController = - _liveRoomController.controller = e; - }, - option: DanmakuOption( - fontSize: _getFontSize(isFullScreen), - fontWeight: plPlayerController.fontWeight, - area: plPlayerController.showArea, - opacity: plPlayerController.danmakuOpacity, - hideTop: plPlayerController.blockTypes.contains(5), - hideScroll: plPlayerController.blockTypes.contains(2), - hideBottom: plPlayerController.blockTypes.contains(4), - duration: - plPlayerController.danmakuDuration / - plPlayerController.playbackSpeed, - staticDuration: - plPlayerController.danmakuStaticDuration / - plPlayerController.playbackSpeed, - strokeWidth: plPlayerController.strokeWidth, - lineHeight: plPlayerController.danmakuLineHeight, + danmuWidget: !needDm + ? null + : Obx( + () => AnimatedOpacity( + opacity: plPlayerController.enableShowDanmaku.value + ? 1 + : 0, + duration: const Duration(milliseconds: 100), + child: DanmakuScreen( + createdController: (DanmakuController e) { + plPlayerController.danmakuController = + _liveRoomController.controller = e; + }, + option: DanmakuOption( + fontSize: _getFontSize(isFullScreen), + fontWeight: plPlayerController.fontWeight, + area: plPlayerController.showArea, + opacity: plPlayerController.danmakuOpacity, + hideTop: plPlayerController.blockTypes.contains(5), + hideScroll: plPlayerController.blockTypes.contains(2), + hideBottom: plPlayerController.blockTypes.contains(4), + duration: + plPlayerController.danmakuDuration / + plPlayerController.playbackSpeed, + staticDuration: + plPlayerController.danmakuStaticDuration / + plPlayerController.playbackSpeed, + strokeWidth: plPlayerController.strokeWidth, + lineHeight: plPlayerController.danmakuLineHeight, + ), + ), + ), ), - ), - ), - ), ); } return const SizedBox.shrink(); @@ -284,33 +292,10 @@ class _LiveRoomPageState extends State if (_liveRoomController.isPortrait.value) { return _buildPP; } - return Column( - children: [ - _buildAppBar, - Obx( - () { - final size = Get.size; - return Container( - color: Colors.black, - width: size.width, - height: isFullScreen - ? size.height - : size.width * 9 / 16, - child: videoPlayerPanel(), - ); - }, - ), - ..._buildBottomWidget, - ], - ); + return _buildPH; }, ) - : Column( - children: [ - Obx(() => _buildAppBar), - _buildBodyH, - ], - ), + : _buildBodyH, ), ], ), @@ -318,48 +303,62 @@ class _LiveRoomPageState extends State ); } - Widget get _buildPP => Stack( - clipBehavior: Clip.none, - children: [ - _buildAppBar, - Column( - children: [ - Expanded( - child: Stack( - clipBehavior: Clip.none, - children: [ - Obx( - () => Container( - margin: isFullScreen - ? null - : const EdgeInsets.only(top: 56), - color: Colors.black, - child: videoPlayerPanel( - alignment: isFullScreen ? null : Alignment.topCenter, - ), - ), + Widget get _buildPH { + final isFullScreen = this.isFullScreen; + final size = Get.size; + Widget child = SizedBox( + width: size.width, + height: isFullScreen ? size.height : size.width * 9 / 16, + child: videoPlayerPanel(), + ); + if (isFullScreen) { + return child; + } + return Column( + children: [ + _buildAppBar, + child, + ..._buildBottomWidget, + ], + ); + } + + Widget get _buildPP { + final isFullScreen = this.isFullScreen; + + final child = videoPlayerPanel( + alignment: isFullScreen ? null : Alignment.topCenter, + needDm: isFullScreen, + ); + + if (isFullScreen) { + return child; + } + + return Column( + children: [ + _buildAppBar, + Expanded( + child: Stack( + clipBehavior: Clip.none, + children: [ + Positioned.fill(child: child), + Positioned( + left: 0, + right: 0, + bottom: 55, + child: SizedBox( + height: Get.height * 0.32, + child: _buildChatWidget(true), ), - Obx( - () => isFullScreen - ? const SizedBox.shrink() - : Positioned( - left: 0, - right: 0, - bottom: 55, - child: SizedBox( - height: 125, - child: _buildChatWidget(true), - ), - ), - ), - ], - ), + ), + ], ), - Obx(() => isFullScreen ? const SizedBox.shrink() : _buildInputWidget), - ], - ), - ], - ); + ), + _buildInputWidget, + ], + ); + } PreferredSizeWidget get _buildAppBar { final color = Theme.of(context).colorScheme.onSurfaceVariant; @@ -482,31 +481,40 @@ class _LiveRoomPageState extends State double videoWidth = clampDouble(context.height / context.width * 1.08, 0.58, 0.75) * context.width; - return Expanded( - child: Row( - children: [ - Obx( - () { - final size = Get.size; - return Container( - margin: EdgeInsets.only( - bottom: MediaQuery.paddingOf(context).bottom, - ), - color: isFullScreen ? Colors.black : null, - width: isFullScreen ? size.width : videoWidth, - height: isFullScreen ? size.height : size.width * 9 / 16, - child: videoPlayerPanel(fill: Colors.transparent), - ); - }, + return Obx( + () { + final isFullScreen = this.isFullScreen; + final size = Get.size; + Widget child = Container( + margin: EdgeInsets.only( + bottom: MediaQuery.paddingOf(context).bottom, ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: _buildBottomWidget, + width: isFullScreen ? size.width : videoWidth, + height: isFullScreen ? size.height : size.width * 9 / 16, + child: videoPlayerPanel(fill: Colors.transparent), + ); + if (isFullScreen) { + return child; + } + return Column( + children: [ + _buildAppBar, + Expanded( + child: Row( + children: [ + child, + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: _buildBottomWidget, + ), + ), + ], + ), ), - ), - ], - ), + ], + ); + }, ); } @@ -519,7 +527,7 @@ class _LiveRoomPageState extends State padding: const EdgeInsets.symmetric(vertical: 16), child: LiveRoomChat( key: chatKey, - isPP: isPP, + isPP: isPP ?? false, roomId: _roomId, liveRoomController: _liveRoomController, ), diff --git a/lib/pages/live_room/widgets/chat.dart b/lib/pages/live_room/widgets/chat.dart index 520cbbbe..023f8ce7 100644 --- a/lib/pages/live_room/widgets/chat.dart +++ b/lib/pages/live_room/widgets/chat.dart @@ -11,16 +11,22 @@ class LiveRoomChat extends StatelessWidget { super.key, required this.roomId, required this.liveRoomController, - this.isPP, + this.isPP = false, }); final int roomId; final LiveRoomController liveRoomController; - final bool? isPP; + final bool isPP; bool get disableAutoScroll => liveRoomController.disableAutoScroll.value; @override Widget build(BuildContext context) { + late final bg = isPP + ? Colors.black.withValues(alpha: 0.4) + : const Color(0x15FFFFFF); + late final nameColor = isPP + ? Colors.white.withValues(alpha: 0.9) + : Colors.white.withValues(alpha: 0.6); return Stack( clipBehavior: Clip.none, children: [ @@ -42,9 +48,7 @@ class LiveRoomChat extends StatelessWidget { vertical: 5, ), decoration: BoxDecoration( - color: isPP == true - ? Colors.black.withValues(alpha: 0.3) - : const Color(0x15FFFFFF), + color: bg, borderRadius: const BorderRadius.all(Radius.circular(18)), ), child: Text.rich( @@ -53,7 +57,7 @@ class LiveRoomChat extends StatelessWidget { TextSpan( text: '${item['name']}: ', style: TextStyle( - color: Colors.white.withValues(alpha: 0.6), + color: nameColor, fontSize: 14, ), recognizer: TapGestureRecognizer() diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index fbfa3273..9a957a41 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -1317,7 +1317,6 @@ class _PLVideoPlayerState extends State }, ), - // if (BuildConfig.isDebug) // Positioned( // right: 25, // top: 125, @@ -1325,7 +1324,7 @@ class _PLVideoPlayerState extends State // onPressed: () { // transformationController.value = Matrix4.identity() // ..translate(0.5, 0.5) - // ..scale(1.2) + // ..scale(0.5) // ..translate(-0.5, -0.5); // showRestoreScaleBtn.value = true;