From 180ba110890e29b3269853216c9f290e5b271819 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 13 Jul 2023 14:16:55 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/dynamics/result.dart | 2 + lib/pages/dynamics/view.dart | 7 -- .../dynamics/widgets/live_rcmd_panel.dart | 5 +- lib/pages/dynamics/widgets/video_panel.dart | 6 +- lib/pages/liveRoom/controller.dart | 2 + lib/pages/liveRoom/view.dart | 102 ++++++++++-------- 6 files changed, 71 insertions(+), 53 deletions(-) diff --git a/lib/models/dynamics/result.dart b/lib/models/dynamics/result.dart index 7d5e9104e..ec845871d 100644 --- a/lib/models/dynamics/result.dart +++ b/lib/models/dynamics/result.dart @@ -576,6 +576,7 @@ class DynamicLiveModel { String? areaName; String? title; int? liveStartTime; + Map? watchedShow; DynamicLiveModel.fromJson(Map json) { content = json['content']; @@ -594,6 +595,7 @@ class DynamicLiveModel { areaName = livePlayInfo['area_name']; title = livePlayInfo['title']; liveStartTime = livePlayInfo['live_start_time']; + watchedShow = livePlayInfo['watched_show']; } } } diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index f9c1b8282..f82c864b6 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -140,13 +140,6 @@ class _DynamicsPageState extends State thumbDecoration: BoxDecoration( color: Theme.of(context).colorScheme.background, borderRadius: BorderRadius.circular(20), - border: Border.all( - width: 1, - color: Theme.of(context) - .colorScheme - .surfaceVariant - .withOpacity(0.7), - ), ), duration: const Duration(milliseconds: 300), curve: Curves.easeInOut, diff --git a/lib/pages/dynamics/widgets/live_rcmd_panel.dart b/lib/pages/dynamics/widgets/live_rcmd_panel.dart index 0a0a82f68..b37abfbe2 100644 --- a/lib/pages/dynamics/widgets/live_rcmd_panel.dart +++ b/lib/pages/dynamics/widgets/live_rcmd_panel.dart @@ -13,8 +13,9 @@ final DynamicsController _dynamicsController = Get.put(DynamicsController()); Widget liveRcmdPanel(item, context, {floor = 1}) { TextStyle authorStyle = TextStyle(color: Theme.of(context).colorScheme.primary); - int liveStatus = item.modules.moduleDynamic.major.liveRcmd.liveStatus; DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd; + int liveStatus = liveRcmd.liveStatus!; + Map watchedShow = liveRcmd.watchedShow!; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -74,6 +75,8 @@ Widget liveRcmdPanel(item, context, {floor = 1}) { src: item.modules.moduleDynamic.major.liveRcmd.cover, ), ), + pBadge(watchedShow['text_large'], context, 6, 56, null, null, + type: 'gray'), pBadge( liveStatus == 1 ? '直播中' : '直播结束', context, 6, 6, null, null), Positioned( diff --git a/lib/pages/dynamics/widgets/video_panel.dart b/lib/pages/dynamics/widgets/video_panel.dart index 63acd3754..0ae3aa49f 100644 --- a/lib/pages/dynamics/widgets/video_panel.dart +++ b/lib/pages/dynamics/widgets/video_panel.dart @@ -94,7 +94,7 @@ Widget videoSeasonWidget(item, context, type, {floor = 1}) { clipBehavior: Clip.hardEdge, decoration: BoxDecoration( gradient: const LinearGradient( - begin: Alignment.topCenter, + begin: Alignment.center, end: Alignment.bottomCenter, colors: [ Colors.transparent, @@ -115,7 +115,9 @@ Widget videoSeasonWidget(item, context, type, {floor = 1}) { color: Colors.white), child: Row( children: [ - Text(content.durationText ?? ''), + pBadge(content.durationText ?? '', context, null, + null, 0, 0, + type: 'gray'), if (content.durationText != null) const SizedBox(width: 10), Text(content.stat.play + '次围观'), diff --git a/lib/pages/liveRoom/controller.dart b/lib/pages/liveRoom/controller.dart index 5cabcb714..a4593ba2a 100644 --- a/lib/pages/liveRoom/controller.dart +++ b/lib/pages/liveRoom/controller.dart @@ -9,6 +9,7 @@ class LiveRoomController extends GetxController { String cover = ''; late int roomId; var liveItem; + late String heroTag; MeeduPlayerController meeduPlayerController = MeeduPlayerController( colorTheme: Theme.of(Get.context!).colorScheme.primary, @@ -22,6 +23,7 @@ class LiveRoomController extends GetxController { super.onInit(); if (Get.arguments != null) { var args = Get.arguments['liveItem']; + heroTag = Get.arguments['heroTag']; liveItem = args; roomId = liveItem.roomId!; if (args.pic != null && args.pic != '') { diff --git a/lib/pages/liveRoom/view.dart b/lib/pages/liveRoom/view.dart index 8aed05839..dc0694acf 100644 --- a/lib/pages/liveRoom/view.dart +++ b/lib/pages/liveRoom/view.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_meedu_media_kit/meedu_player.dart'; import 'package:get/get.dart'; @@ -16,11 +18,29 @@ class LiveRoomPage extends StatefulWidget { class _LiveRoomPageState extends State { final LiveRoomController _liveRoomController = Get.put(LiveRoomController()); MeeduPlayerController? _meeduPlayerController; + StreamSubscription? _playerEventSubs; + + bool isShowCover = true; + bool isPlay = true; @override void initState() { super.initState(); _meeduPlayerController = _liveRoomController.meeduPlayerController; + _playerEventSubs = _meeduPlayerController!.onPlayerStatusChanged.listen( + (PlayerStatus status) { + if (status == PlayerStatus.playing) { + isShowCover = false; + setState(() {}); + } + }, + ); + } + + @override + void dispose() { + _meeduPlayerController!.dispose(); + super.dispose(); } @override @@ -57,53 +77,49 @@ class _LiveRoomPageState extends State { ], ), ), - body: Stack( + body: Column( children: [ - Positioned( - top: 0, - left: 0, - right: 0, - child: NetworkImgLayer( - type: 'emote', - src: _liveRoomController.cover, - width: Get.size.width, - height: videoHeight + 45, - ), - ), - Positioned.fill( - child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), - child: Container( - decoration: BoxDecoration( - color: - Theme.of(context).colorScheme.background.withOpacity(0.1), + Hero( + tag: _liveRoomController.heroTag, + child: Stack( + children: [ + AspectRatio( + aspectRatio: 16 / 9, + child: MeeduVideoPlayer( + controller: _meeduPlayerController!, + ), + ), + Visibility( + visible: isShowCover, + child: Positioned( + top: 0, + left: 0, + right: 0, + child: NetworkImgLayer( + type: 'emote', + src: _liveRoomController.liveItem.cover, + width: Get.size.width, + height: videoHeight, + ), + ), + ), + ], + )), + if (_liveRoomController.liveItem.watchedShow != null) + Container( + height: 45, + padding: const EdgeInsets.only(left: 12, right: 12), + child: Row(children: [ + Text(_liveRoomController.liveItem.watchedShow['text_large']), + ]), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.background, + border: Border( + bottom: BorderSide( + color: Theme.of(context).dividerColor.withOpacity(0.1)), ), ), ), - ), - Scaffold( - backgroundColor: Colors.transparent, - body: Column( - children: [ - AspectRatio( - aspectRatio: 16 / 9, - child: MeeduVideoPlayer( - controller: _meeduPlayerController!, - ), - ), - if (_liveRoomController.liveItem.watchedShow != null) - Container( - color: Theme.of(context).colorScheme.background, - height: 45, - padding: const EdgeInsets.only(left: 12, right: 12), - child: Row(children: [ - Text(_liveRoomController - .liveItem.watchedShow['text_large']), - ]), - ), - ], - ), - ) ], ), );