diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index a43ee0712..a6a7d2c21 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -296,10 +296,10 @@ class VideoContent extends StatelessWidget { maxLines: videoItem.videos > 1 ? 1 : 2, overflow: TextOverflow.ellipsis, ), - if (videoItem.showTitle != null) ...[ + if (videoItem.isFullScreen != null) ...[ const SizedBox(height: 2), Text( - videoItem.showTitle, + videoItem.isFullScreen, textAlign: TextAlign.start, style: TextStyle( fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 41ba739d6..c2aa54217 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:io'; import 'dart:math'; @@ -20,6 +21,7 @@ import 'package:PiliPalaX/http/danmaku.dart'; import 'package:PiliPalaX/services/shutdown_timer_service.dart'; import '../../../../models/video_detail_res.dart'; import '../introduction/index.dart'; +import 'package:marquee/marquee.dart'; class HeaderControl extends StatefulWidget implements PreferredSizeWidget { const HeaderControl({ @@ -49,29 +51,30 @@ class _HeaderControlState extends State { final Box videoStorage = GStrorage.video; late List speedsList; double buttonSpace = 8; - bool showTitle = false; + bool isFullScreen = false; late String heroTag; late VideoIntroController videoIntroController; late VideoDetailData videoDetail; + late StreamSubscription fullScreenStatusListener; + late bool horizontalScreen; @override void initState() { super.initState(); videoInfo = widget.videoDetailCtr!.data; speedsList = widget.controller!.speedsList; - fullScreenStatusListener(); + listenFullScreenStatus(); heroTag = Get.arguments['heroTag']; videoIntroController = Get.put(VideoIntroController(), tag: heroTag); + horizontalScreen = + setting.get(SettingBoxKey.horizontalScreen, defaultValue: false); } - void fullScreenStatusListener() { - widget.videoDetailCtr!.plPlayerController.isFullScreen - .listen((bool isFullScreen) { - if (isFullScreen) { - showTitle = true; - } else { - showTitle = false; - } + void listenFullScreenStatus() { + fullScreenStatusListener = widget + .videoDetailCtr!.plPlayerController.isFullScreen + .listen((bool status) { + isFullScreen = status; setState(() {}); }); } @@ -79,8 +82,10 @@ class _HeaderControlState extends State { @override void dispose() { widget.floating?.dispose(); + fullScreenStatusListener.cancel(); super.dispose(); } + /// 设置面板 void showSettingSheet() { showModalBottomSheet( @@ -1085,6 +1090,7 @@ class _HeaderControlState extends State { titleSpacing: 14, title: Row( children: [ + // SizedBox(width: MediaQuery.of(context).padding.left,), ComBtn( icon: const Icon( FontAwesomeIcons.arrowLeft, @@ -1098,8 +1104,7 @@ class _HeaderControlState extends State { { if (MediaQuery.of(context).orientation == Orientation.landscape && - !setting.get(SettingBoxKey.horizontalScreen, - defaultValue: false)) + !horizontalScreen) { verticalScreen(), }, @@ -1108,18 +1113,34 @@ class _HeaderControlState extends State { }, ), SizedBox(width: buttonSpace), - if (showTitle && isLandscape) ...[ + if (isFullScreen || + (!isFullScreen && isLandscape && !horizontalScreen)) ...[ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ConstrainedBox( - constraints: BoxConstraints(maxWidth: 200), - child: Text( - videoIntroController.videoDetail.value.title!, + constraints: BoxConstraints( + maxWidth: isLandscape ? 400 : 100, maxHeight: 20), + child: Marquee( + text: videoIntroController.videoDetail.value.title!, style: const TextStyle( color: Colors.white, fontSize: 16, ), + scrollAxis: Axis.horizontal, + crossAxisAlignment: CrossAxisAlignment.start, + blankSpace: 200, + velocity: 40, + startAfter: const Duration(seconds: 1), + showFadingOnlyWhenScrolling: true, + fadingEdgeStartFraction: 0.1, + fadingEdgeEndFraction: 0.1, + numberOfRounds: 1, + startPadding: 0, + accelerationDuration: const Duration(seconds: 1), + accelerationCurve: Curves.linear, + decelerationDuration: const Duration(milliseconds: 500), + decelerationCurve: Curves.easeOut, ), ), if (videoIntroController.isShowOnlineTotal) @@ -1159,19 +1180,21 @@ class _HeaderControlState extends State { // fuc: () => _.screenshot(), // ), SizedBox( - width: 56, + width: 34, height: 34, - child: TextButton( + child: IconButton( style: ButtonStyle( padding: MaterialStateProperty.all(EdgeInsets.zero), ), onPressed: () => showShootDanmakuSheet(), - child: const Text( - '发弹幕', - style: textStyle, + icon: const Icon( + Icons.add_card_outlined, + size: 19, + color: Colors.white, ), ), ), + SizedBox(width: buttonSpace), SizedBox( width: 34, height: 34, @@ -1225,7 +1248,7 @@ class _HeaderControlState extends State { ], Obx( () => SizedBox( - width: 45, + width: 34, height: 34, child: TextButton( style: ButtonStyle( diff --git a/pubspec.lock b/pubspec.lock index 1f081d1f4..d9d4baa72 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -465,6 +465,14 @@ packages: url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted version: "6.2.1" + fading_edge_scrollview: + dependency: transitive + description: + name: fading_edge_scrollview + sha256: c25c2231652ce774cc31824d0112f11f653881f43d7f5302c05af11942052031 + url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" + source: hosted + version: "3.0.0" fake_async: dependency: transitive description: @@ -830,6 +838,14 @@ packages: url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted version: "6.0.1" + marquee: + dependency: "direct main" + description: + name: marquee + sha256: "4b5243d2804373bdc25fc93d42c3b402d6ec1f4ee8d0bb72276edd04ae7addb8" + url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" + source: hosted + version: "2.2.3" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4523cb52a..9302d1eb2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -142,6 +142,7 @@ dependencies: path: 1.8.3 #瀑布流 waterfall_flow: ^3.0.3 + marquee: ^2.2.3 dev_dependencies: flutter_test: