From acafb86a188d9856c978adec75b8c477a9621d61 Mon Sep 17 00:00:00 2001 From: orz12 Date: Fri, 22 Mar 2024 00:45:34 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E5=85=A8=E5=B1=8F=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=EF=BC=9B=E4=BF=AE=E5=A4=8D=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../video/detail/widgets/header_control.dart | 47 +++++++++++++++++-- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 6eec4604..ed7167c8 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -56,6 +56,7 @@ class _HeaderControlState extends State { late VideoDetailData videoDetail; late StreamSubscription fullScreenStatusListener; late bool horizontalScreen; + RxString now = ''.obs; @override void initState() { @@ -68,6 +69,7 @@ class _HeaderControlState extends State { videoIntroController = Get.put(VideoIntroController(), tag: heroTag); horizontalScreen = setting.get(SettingBoxKey.horizontalScreen, defaultValue: false); + startClock(); } void listenFullScreenStatus() { @@ -1037,11 +1039,20 @@ class _HeaderControlState extends State { ); } + startClock() { + Timer.periodic(const Duration(seconds: 1), (Timer t) { + if (!mounted) { + return; + } + now.value = DateTime.now().toString().split(' ')[1].substring(0, 8); + }); + } + @override Widget build(BuildContext context) { final _ = widget.controller!; - final bool isLandscape = - MediaQuery.of(context).orientation == Orientation.landscape; + // final bool isLandscape = + // MediaQuery.of(context).orientation == Orientation.landscape; return AppBar( backgroundColor: Colors.transparent, foregroundColor: Colors.white, @@ -1077,13 +1088,20 @@ class _HeaderControlState extends State { )), if ((videoIntroController.videoDetail.value.title != null) && (isFullScreen || - (!isFullScreen && isLandscape && !horizontalScreen))) ...[ + (!isFullScreen && + MediaQuery.of(context).orientation == + Orientation.landscape && + !horizontalScreen))) ...[ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ ConstrainedBox( constraints: BoxConstraints( - maxWidth: isLandscape ? 400 : 140, maxHeight: 25), + maxWidth: MediaQuery.of(context).orientation == + Orientation.landscape + ? 400 + : 140, + maxHeight: 25), child: Marquee( text: videoIntroController.videoDetail.value.title!, style: const TextStyle( @@ -1115,7 +1133,7 @@ class _HeaderControlState extends State { ), ) ], - ) + ), ] else ...[ SizedBox( width: 42, @@ -1138,6 +1156,25 @@ class _HeaderControlState extends State { )), ], const Spacer(), + if ((isFullScreen && + MediaQuery.of(context).orientation == + Orientation.landscape) || + (!isFullScreen && + MediaQuery.of(context).orientation == Orientation.landscape && + !horizontalScreen)) ...[ + // const Spacer(), + // show current datetime + Obx( + () => Text( + now.value, + style: const TextStyle( + color: Colors.white, + fontSize: 13, + ), + ), + ), + const SizedBox(width: 15,), + ], // ComBtn( // icon: const Icon( // FontAwesomeIcons.cropSimple,