From c216c9bd653524bcd6a9cc613b4fd0bc96b35630 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 20 Mar 2024 00:07:00 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20tabbar=E6=A0=B7=E5=BC=8F&=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=AF=84=E8=AE=BA=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../video/detail/introduction/controller.dart | 7 +- lib/pages/video/detail/view.dart | 120 ++++++++++-------- 2 files changed, 71 insertions(+), 56 deletions(-) diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 6714b8876..8114bdaf4 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -85,10 +85,9 @@ class VideoIntroController extends GetxController { if (videoDetail.value.pages!.isNotEmpty && lastPlayCid.value == 0) { lastPlayCid.value = videoDetail.value.pages!.first.cid!; } - // Get.find(tag: heroTag).tabs.value = [ - // '简介', - // '评论 ${result['data']!.stat!.reply}' - // ]; + final VideoDetailController videoDetailCtr = + Get.find(tag: heroTag); + videoDetailCtr.tabs.value = ['简介', '评论 ${result['data']?.stat?.reply}']; // 获取到粉丝数再返回 await queryUserStat(); } diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 1dff90601..af901cd2f 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -319,62 +319,78 @@ class _VideoDetailPageState extends State ), ), ), - child: Row( - children: [ - const SizedBox(width: 20), - Expanded( - child: TabBar( - controller: vdCtr.tabCtr, - dividerColor: Colors.transparent, - tabs: vdCtr.tabs.map((String name) => Tab(text: name)).toList(), + child: Material( + child: Row( + children: [ + Flexible( + flex: 1, + child: Obx( + () => TabBar( + padding: EdgeInsets.zero, + controller: vdCtr.tabCtr, + labelStyle: const TextStyle(fontSize: 13), + labelPadding: + const EdgeInsets.symmetric(horizontal: 10.0), // 设置每个标签的宽度 + dividerColor: Colors.transparent, + tabs: vdCtr.tabs + .map( + (String name) => Flexible( + child: Tab(text: name), + ), + ) + .toList(), + ), + ), ), - ), - SizedBox( - width: 220, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - SizedBox( - height: 32, - child: TextButton( - style: ButtonStyle( - padding: MaterialStateProperty.all(EdgeInsets.zero), + Flexible( + flex: 1, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + SizedBox( + height: 32, + child: TextButton( + style: ButtonStyle( + padding: MaterialStateProperty.all(EdgeInsets.zero), + ), + onPressed: () => vdCtr.showShootDanmakuSheet(), + child: + const Text('发弹幕', style: TextStyle(fontSize: 12)), + ), ), - onPressed: () => vdCtr.showShootDanmakuSheet(), - child: const Text('发弹幕', style: TextStyle(fontSize: 12)), - ), - ), - const SizedBox(width: 4), - SizedBox( - width: 34, - height: 32, - child: TextButton( - style: ButtonStyle( - padding: MaterialStateProperty.all(EdgeInsets.zero), + const SizedBox(width: 4), + SizedBox( + width: 34, + height: 32, + child: TextButton( + style: ButtonStyle( + padding: MaterialStateProperty.all(EdgeInsets.zero), + ), + onPressed: () { + plPlayerController?.isOpenDanmu.value = + !(plPlayerController?.isOpenDanmu.value ?? + false); + }, + child: Obx(() => Text( + '弹', + style: TextStyle( + fontSize: 12, + color: (plPlayerController + ?.isOpenDanmu.value ?? + false) + ? Theme.of(context).colorScheme.primary + : Theme.of(context).colorScheme.outline, + ), + )), + ), ), - onPressed: () { - plPlayerController?.isOpenDanmu.value = - !(plPlayerController?.isOpenDanmu.value ?? false); - }, - child: Obx(() => Text( - '弹', - style: TextStyle( - fontSize: 12, - color: (plPlayerController?.isOpenDanmu.value ?? - false) - ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.outline, - ), - )), - ), + const SizedBox(width: 14), + ], ), - const SizedBox(width: 14), - ], - ), - ), - ), - ], + )), + ], + ), ), );