From 79fcd017ab16e182cee8a52ebdf05f68b6370958 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 20 Mar 2024 00:07:00 +0800 Subject: [PATCH 1/2] =?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 c7f22b131..babc18aac 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -112,10 +112,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), - ], - ), - ), - ), - ], + )), + ], + ), ), ); From 14338dc33d508dbd06d8766310fbf197493c6332 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 23 Mar 2024 17:23:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E8=AF=A6=E6=83=85=E9=A1=B5TabBar?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/images/video/danmu_close.svg | 1 + assets/images/video/danmu_open.svg | 1 + lib/pages/video/detail/view.dart | 47 ++++++++++++++--------------- pubspec.yaml | 1 + 4 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 assets/images/video/danmu_close.svg create mode 100644 assets/images/video/danmu_open.svg diff --git a/assets/images/video/danmu_close.svg b/assets/images/video/danmu_close.svg new file mode 100644 index 000000000..9f48027b0 --- /dev/null +++ b/assets/images/video/danmu_close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/images/video/danmu_open.svg b/assets/images/video/danmu_open.svg new file mode 100644 index 000000000..24e8d7a99 --- /dev/null +++ b/assets/images/video/danmu_open.svg @@ -0,0 +1 @@ +Layer 1 \ No newline at end of file diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index af901cd2f..a403e2980 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -5,6 +5,7 @@ import 'dart:ui'; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; import 'package:floating/floating.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart'; import 'package:flutter/material.dart'; @@ -334,9 +335,7 @@ class _VideoDetailPageState extends State dividerColor: Colors.transparent, tabs: vdCtr.tabs .map( - (String name) => Flexible( - child: Tab(text: name), - ), + (String name) => Tab(text: name), ) .toList(), ), @@ -359,30 +358,28 @@ class _VideoDetailPageState extends State const Text('发弹幕', style: TextStyle(fontSize: 12)), ), ), - const SizedBox(width: 4), SizedBox( - width: 34, - height: 32, - child: TextButton( - style: ButtonStyle( - padding: MaterialStateProperty.all(EdgeInsets.zero), + width: 38, + height: 38, + child: Obx( + () => IconButton( + onPressed: () { + plPlayerController?.isOpenDanmu.value = + !(plPlayerController?.isOpenDanmu.value ?? + false); + }, + icon: (plPlayerController?.isOpenDanmu.value ?? + false) + ? SvgPicture.asset( + 'assets/images/video/danmu_close.svg', + ) + : SvgPicture.asset( + 'assets/images/video/danmu_open.svg', + // ignore: deprecated_member_use + color: + Theme.of(context).colorScheme.primary, + ), ), - 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), diff --git a/pubspec.yaml b/pubspec.yaml index 5c25f0442..821664030 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -191,6 +191,7 @@ flutter: - assets/images/lv/ - assets/images/logo/ - assets/images/live/ + - assets/images/video/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware