From 3830380172c26c299b1132a33a0633fb7c3432f6 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 8 Oct 2024 23:46:40 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E9=A1=BA=E5=BA=8F=E6=92=AD?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/video/later.dart | 12 ++++-- .../video/detail/introduction/controller.dart | 40 +++++++++++++------ .../detail/widgets/watch_later_list.dart | 4 +- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/lib/models/video/later.dart b/lib/models/video/later.dart index f722a231..7829e1c7 100644 --- a/lib/models/video/later.dart +++ b/lib/models/video/later.dart @@ -1,6 +1,7 @@ class MediaVideoItemModel { MediaVideoItemModel({ this.id, + this.aid, this.offset, this.index, this.intro, @@ -14,12 +15,13 @@ class MediaVideoItemModel { this.likeState, this.favState, this.page, + this.cid, this.pages, this.title, this.type, this.upper, this.link, - this.bvId, + this.bvid, this.shortLink, this.rights, this.elecInfo, @@ -32,6 +34,7 @@ class MediaVideoItemModel { }); int? id; + int? aid; int? offset; int? index; String? intro; @@ -45,12 +48,13 @@ class MediaVideoItemModel { int? likeState; int? favState; int? page; + int? cid; List? pages; String? title; int? type; Upper? upper; String? link; - String? bvId; + String? bvid; String? shortLink; Rights? rights; dynamic elecInfo; @@ -64,6 +68,7 @@ class MediaVideoItemModel { factory MediaVideoItemModel.fromJson(Map json) => MediaVideoItemModel( id: json["id"], + aid: json["id"], offset: json["offset"], index: json["index"], intro: json["intro"], @@ -77,6 +82,7 @@ class MediaVideoItemModel { likeState: json["like_state"], favState: json["fav_state"], page: json["page"], + cid: json["pages"] == null ? -1 : json["pages"].first['id'], // json["pages"] 可能为null pages: json["pages"] == null ? [] @@ -85,7 +91,7 @@ class MediaVideoItemModel { type: json["type"], upper: Upper.fromJson(json["upper"]), link: json["link"], - bvId: json["bv_id"], + bvid: json["bv_id"], shortLink: json["short_link"], rights: Rights.fromJson(json["rights"]), elecInfo: json["elec_info"], diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 786d8172..83e5b012 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -413,7 +413,12 @@ class VideoIntroController extends GetxController { } // 修改分P或番剧分集 - Future changeSeasonOrbangu(bvid, cid, aid, cover) async { + Future changeSeasonOrbangu( + String bvid, + int cid, + int? aid, + String? cover, + ) async { // 重新获取视频资源 final VideoDetailController videoDetailCtr = Get.find(tag: heroTag); @@ -424,13 +429,14 @@ class VideoIntroController extends GetxController { releatedCtr.queryRelatedVideo(); } - videoDetailCtr.bvid = bvid; - videoDetailCtr.oid.value = aid ?? IdUtils.bv2av(bvid); - videoDetailCtr.cid.value = cid; - videoDetailCtr.danmakuCid.value = cid; - videoDetailCtr.cover.value = cover; - videoDetailCtr.queryVideoUrl(); - videoDetailCtr.clearSubtitleContent(); + videoDetailCtr + ..bvid = bvid + ..oid.value = aid ?? IdUtils.bv2av(bvid) + ..cid.value = cid + ..danmakuCid.value = cid + ..cover.value = cover ?? '' + ..queryVideoUrl() + ..clearSubtitleContent(); await videoDetailCtr.getSubtitle(); videoDetailCtr.setSubtitleContent(); // 重新请求评论 @@ -480,7 +486,13 @@ class VideoIntroController extends GetxController { final List episodes = []; bool isPages = false; late String cover; - if (videoDetail.value.ugcSeason != null) { + final VideoDetailController videoDetailCtr = + Get.find(tag: heroTag); + + /// 优先稍后再看、收藏夹 + if (videoDetailCtr.isWatchLaterVisible.value) { + episodes.addAll(videoDetailCtr.mediaList); + } else if (videoDetail.value.ugcSeason != null) { final UgcSeason ugcSeason = videoDetail.value.ugcSeason!; final List sections = ugcSeason.sections!; for (int i = 0; i < sections.length; i++) { @@ -497,10 +509,15 @@ class VideoIntroController extends GetxController { episodes.indexWhere((e) => e.cid == lastPlayCid.value); int nextIndex = currentIndex + 1; cover = episodes[nextIndex].cover; - final VideoDetailController videoDetailCtr = - Get.find(tag: heroTag); final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat; + int cid = episodes[nextIndex].cid!; + while (cid == -1) { + nextIndex += 1; + SmartDialog.showToast('当前视频暂不支持播放,自动跳过'); + cid = episodes[nextIndex].cid!; + } + // 列表循环 if (nextIndex >= episodes.length) { if (platRepeat == PlayRepeat.listCycle) { @@ -510,7 +527,6 @@ class VideoIntroController extends GetxController { return; } } - final int cid = episodes[nextIndex].cid!; final String rBvid = isPages ? bvid : episodes[nextIndex].bvid; final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!; changeSeasonOrbangu(rBvid, cid, rAid, cover); diff --git a/lib/pages/video/detail/widgets/watch_later_list.dart b/lib/pages/video/detail/widgets/watch_later_list.dart index b367ae40..8e83af4e 100644 --- a/lib/pages/video/detail/widgets/watch_later_list.dart +++ b/lib/pages/video/detail/widgets/watch_later_list.dart @@ -109,7 +109,7 @@ class _MediaListPanelState extends State { var item = mediaList[index]; return InkWell( onTap: () async { - String bvid = item.bvId!; + String bvid = item.bvid!; int? aid = item.id; String cover = item.cover ?? ''; final int cid = @@ -173,7 +173,7 @@ class _MediaListPanelState extends State { overflow: TextOverflow.ellipsis, style: TextStyle( fontWeight: FontWeight.w500, - color: item.bvId == widget.bvid + color: item.bvid == widget.bvid ? Theme.of(context) .colorScheme .primary From c634e602b9ba88f55b726d75fde186914e2656d0 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 9 Oct 2024 23:33:52 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E5=AD=97=E5=B9=95=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=87=E5=A4=A7=E6=97=B6=E9=A1=B5=E9=9D=A2=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/video.dart | 3 ++- lib/utils/subtitle.dart | 56 +++++++++++++++++++++++++++++++---------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/lib/http/video.dart b/lib/http/video.dart index 95ea6782..406e59f6 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -536,7 +536,8 @@ class VideoHttp { // 获取字幕内容 static Future> getSubtitleContent(url) async { var res = await Request().get('https:$url'); - final String content = SubTitleUtils.convertToWebVTT(res.data['body']); + final String content = + await SubTitleUtils.convertToWebVTT(res.data['body']); final List body = res.data['body']; return {'content': content, 'body': body}; } diff --git a/lib/utils/subtitle.dart b/lib/utils/subtitle.dart index 1b4088f3..9743711c 100644 --- a/lib/utils/subtitle.dart +++ b/lib/utils/subtitle.dart @@ -1,21 +1,51 @@ +import 'dart:async'; +import 'dart:isolate'; + class SubTitleUtils { // 格式整理 - static String convertToWebVTT(List jsonData) { - String webVTTContent = 'WEBVTT FILE\n\n'; + static Future convertToWebVTT(List jsonData) async { + final receivePort = ReceivePort(); + await Isolate.spawn(_convertToWebVTTIsolate, receivePort.sendPort); - for (int i = 0; i < jsonData.length; i++) { - final item = jsonData[i]; - double from = double.parse(item['from'].toString()); - double to = double.parse(item['to'].toString()); - int sid = (item['sid'] ?? 0) as int; - String content = item['content'] as String; + final sendPort = await receivePort.first as SendPort; + final response = ReceivePort(); + sendPort.send([jsonData, response.sendPort]); - webVTTContent += '$sid\n'; - webVTTContent += '${formatTime(from)} --> ${formatTime(to)}\n'; - webVTTContent += '$content\n\n'; + return await response.first as String; + } + + static void _convertToWebVTTIsolate(SendPort sendPort) async { + final port = ReceivePort(); + sendPort.send(port.sendPort); + + await for (final message in port) { + final List jsonData = message[0]; + final SendPort replyTo = message[1]; + + String webVTTContent = 'WEBVTT FILE\n\n'; + int chunkSize = 100; // 每次处理100条数据 + int totalChunks = (jsonData.length / chunkSize).ceil(); + + for (int chunk = 0; chunk < totalChunks; chunk++) { + int start = chunk * chunkSize; + int end = start + chunkSize; + if (end > jsonData.length) end = jsonData.length; + + for (int i = start; i < end; i++) { + final item = jsonData[i]; + double from = double.parse(item['from'].toString()); + double to = double.parse(item['to'].toString()); + int sid = (item['sid'] ?? 0) as int; + String content = item['content'] as String; + + webVTTContent += '$sid\n'; + webVTTContent += '${formatTime(from)} --> ${formatTime(to)}\n'; + webVTTContent += '$content\n\n'; + } + } + + replyTo.send(webVTTContent); } - - return webVTTContent; } static String formatTime(num seconds) { From 2e206f20cc3e5ce77ccb1f31ed875de23bfc1b46 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 10 Oct 2024 23:02:16 +0800 Subject: [PATCH 3/5] Update yml --- .github/workflows/beta_ci.yml | 3 +-- .github/workflows/release_ci.yml | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/beta_ci.yml b/.github/workflows/beta_ci.yml index 14b51780..9c40de6b 100644 --- a/.github/workflows/beta_ci.yml +++ b/.github/workflows/beta_ci.yml @@ -12,7 +12,6 @@ on: - ".idea/**" - "!.github/workflows/**" - jobs: update_version: name: Read and update version @@ -96,7 +95,7 @@ jobs: if: steps.cache-flutter.outputs.cache-hit != 'true' uses: subosito/flutter-action@v2 with: - flutter-version: 3.16.5 + flutter-version: 3.19.6 channel: any - name: 下载项目依赖 diff --git a/.github/workflows/release_ci.yml b/.github/workflows/release_ci.yml index 78230645..f7c06d29 100644 --- a/.github/workflows/release_ci.yml +++ b/.github/workflows/release_ci.yml @@ -36,7 +36,7 @@ jobs: if: steps.cache-flutter.outputs.cache-hit != 'true' uses: subosito/flutter-action@v2 with: - flutter-version: 3.16.5 + flutter-version: 3.19.6 channel: any - name: 下载项目依赖 @@ -98,7 +98,7 @@ jobs: uses: subosito/flutter-action@v2.10.0 with: cache: true - flutter-version: 3.16.5 + flutter-version: 3.19.6 - name: flutter build ipa run: | From caa066237d87591652a6648a79a98faaa415b104 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 10 Oct 2024 23:04:59 +0800 Subject: [PATCH 4/5] =?UTF-8?q?v1.0.25=20=E6=9B=B4=E6=96=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- change_log/1.0.25.1010.md | 39 +++++++++++++++++++++++++++++++++++++++ pubspec.yaml | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 change_log/1.0.25.1010.md diff --git a/change_log/1.0.25.1010.md b/change_log/1.0.25.1010.md new file mode 100644 index 00000000..951efcb1 --- /dev/null +++ b/change_log/1.0.25.1010.md @@ -0,0 +1,39 @@ +## 1.0.25 + +### 功能 ++ 直播弹幕 ++ 稍后再看、收藏夹播放全部 ++ 收藏夹新建、编辑 ++ 评论删除 ++ 评论保存为图片 ++ 动态页滑动切换up ++ up投稿筛选充电视频 ++ 直播tab展示关注up ++ up主页专栏展示 + +### 优化 ++ 视频详情页一键三连 ++ 动态页标识充电视频 ++ 播放器亮度、音量调整百分比展示 ++ 封面预览时视频标题可复制 ++ 竖屏直播布局 ++ 图片预览 ++ 专栏渲染优化 ++ 私信图片查看 + +### 修复 ++ 收藏夹点击异常 ++ 搜索up异常 ++ 系统通知已读异常 ++ [赞了我的]展示错误 ++ 部分up合集无法打开 ++ 切换合集视频投币个数未重置 ++ 搜索条件筛选面板无法滚动 ++ 部分机型导航条未沉浸 ++ 专栏图片渲染问题 ++ 专栏浏览历史记录 ++ 直播间历史记录 + + +更多更新日志可在Github上查看 +问题反馈、功能建议请查看「关于」页面。 diff --git a/pubspec.yaml b/pubspec.yaml index 617b0c7d..ac04a1b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.24+1024 +version: 1.0.25+1025 environment: sdk: ">=3.0.0 <4.0.0" From fb84ba04815edb98633e0515d464c5726c2a7dfd Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 11 Oct 2024 00:23:27 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E7=9B=B4=E6=92=AD=E9=97=B4=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E5=BC=82=E5=B8=B8=E3=80=81=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=BC=82=E5=B8=B8=E3=80=81imgQualit?= =?UTF-8?q?y/cover=E5=8F=96=E5=80=BC=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/network_img_layer.dart | 6 +- lib/pages/live_room/controller.dart | 2 +- lib/pages/live_room/view.dart | 214 +++++++++++----------- lib/pages/main/view.dart | 18 +- 4 files changed, 123 insertions(+), 117 deletions(-) diff --git a/lib/common/widgets/network_img_layer.dart b/lib/common/widgets/network_img_layer.dart index 0b715a89..fbedfbba 100644 --- a/lib/common/widgets/network_img_layer.dart +++ b/lib/common/widgets/network_img_layer.dart @@ -33,7 +33,11 @@ class NetworkImgLayer extends StatelessWidget { @override Widget build(BuildContext context) { - final int defaultImgQuality = GlobalDataCache().imgQuality; + int defaultImgQuality = 10; + try { + defaultImgQuality = GlobalDataCache().imgQuality; + } catch (_) {} + if (src == '' || src == null) { return placeholder(context); } diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index 34379f64..0d347bf2 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -64,7 +64,7 @@ class LiveRoomController extends GetxController { ? liveItem.pic : (liveItem.cover != null && liveItem.cover != '') ? liveItem.cover - : null; + : ''; } Request.getBuvid().then((value) => buvid = value); } diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index cff0c410..1e0814e9 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -108,6 +108,12 @@ class _LiveRoomPageState extends State @override Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); + final isPortrait = mediaQuery.orientation == Orientation.portrait; + final isLandscape = mediaQuery.orientation == Orientation.landscape; + + final padding = mediaQuery.padding; + Widget videoPlayerPanel = FutureBuilder( future: _futureBuilderFuture, builder: (BuildContext context, AsyncSnapshot snapshot) { @@ -187,10 +193,8 @@ class _LiveRoomPageState extends State children: [ Obx( () => SizedBox( - height: MediaQuery.of(context).padding.top + - (_liveRoomController.isPortrait.value || - MediaQuery.of(context).orientation == - Orientation.landscape + height: padding.top + + (_liveRoomController.isPortrait.value || isLandscape ? 0 : kToolbarHeight), ), @@ -201,21 +205,18 @@ class _LiveRoomPageState extends State if (plPlayerController.isFullScreen.value == true) { plPlayerController.triggerFullScreen(status: false); } - if (MediaQuery.of(context).orientation == - Orientation.landscape) { + if (isLandscape) { verticalScreen(); } }, child: Obx( () => Container( width: Get.size.width, - height: MediaQuery.of(context).orientation == - Orientation.landscape + height: isLandscape ? Get.size.height : !_liveRoomController.isPortrait.value ? Get.size.width * 9 / 16 - : Get.size.height - - MediaQuery.of(context).padding.top, + : Get.size.height - padding.top, clipBehavior: Clip.hardEdge, decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6)), @@ -229,7 +230,7 @@ class _LiveRoomPageState extends State // 定位 快速滑动到底部 Positioned( right: 20, - bottom: MediaQuery.of(context).padding.bottom + 80, + bottom: padding.bottom + 80, child: SlideTransition( position: Tween( begin: const Offset(0, 4), @@ -262,10 +263,7 @@ class _LiveRoomPageState extends State titleSpacing: 0, backgroundColor: Colors.transparent, foregroundColor: Colors.white, - toolbarHeight: - MediaQuery.of(context).orientation == Orientation.portrait - ? 56 - : 0, + toolbarHeight: isPortrait ? 56 : 0, title: FutureBuilder( future: _futureBuilder, builder: (context, snapshot) { @@ -317,35 +315,38 @@ class _LiveRoomPageState extends State ), // 消息列表 Obx( - () => Positioned( - top: MediaQuery.of(context).padding.top + - kToolbarHeight + - (_liveRoomController.isPortrait.value - ? Get.size.width - : Get.size.width * 9 / 16), - bottom: 90 + MediaQuery.of(context).padding.bottom, - left: 0, - right: 0, - child: buildMessageListUI( - context, - _liveRoomController, - _scrollController, + () => Align( + alignment: Alignment.bottomCenter, + child: Container( + margin: EdgeInsets.only( + bottom: 90 + padding.bottom, + ), + height: Get.size.height - + (padding.top + + kToolbarHeight + + (_liveRoomController.isPortrait.value + ? Get.size.width + : Get.size.width * 9 / 16) + + 100 + + padding.bottom), + child: buildMessageListUI( + context, + _liveRoomController, + _scrollController, + ), ), ), ), // 消息输入框 Visibility( - visible: MediaQuery.of(context).orientation == Orientation.portrait, + visible: isPortrait, child: Positioned( bottom: 0, left: 0, right: 0, child: Container( padding: EdgeInsets.only( - left: 14, - right: 14, - top: 4, - bottom: MediaQuery.of(context).padding.bottom + 20), + left: 14, right: 14, top: 4, bottom: padding.bottom + 20), decoration: BoxDecoration( color: Colors.grey.withOpacity(0.1), borderRadius: const BorderRadius.all(Radius.circular(20)), @@ -421,6 +422,7 @@ class _LiveRoomPageState extends State ], ), ); + if (Platform.isAndroid) { return PiPSwitcher( childWhenDisabled: childWhenDisabled, @@ -438,84 +440,82 @@ Widget buildMessageListUI( LiveRoomController liveRoomController, ScrollController scrollController, ) { - return Expanded( - child: Obx( - () => MediaQuery.removePadding( - context: context, - removeTop: true, - removeBottom: true, - child: ShaderMask( - shaderCallback: (Rect bounds) { - return LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Colors.transparent, - Colors.black.withOpacity(0.5), - Colors.black, - ], - stops: const [0.01, 0.05, 0.2], - ).createShader(bounds); + return Obx( + () => MediaQuery.removePadding( + context: context, + removeTop: true, + removeBottom: true, + child: ShaderMask( + shaderCallback: (Rect bounds) { + return LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.transparent, + Colors.black.withOpacity(0.5), + Colors.black, + ], + stops: const [0.01, 0.05, 0.2], + ).createShader(bounds); + }, + blendMode: BlendMode.dstIn, + child: GestureDetector( + onTap: () { + // 键盘失去焦点 + FocusScope.of(context).requestFocus(FocusNode()); }, - blendMode: BlendMode.dstIn, - child: GestureDetector( - onTap: () { - // 键盘失去焦点 - FocusScope.of(context).requestFocus(FocusNode()); - }, - child: ListView.builder( - controller: scrollController, - itemCount: liveRoomController.messageList.length, - itemBuilder: (context, index) { - final LiveMessageModel liveMsgItem = - liveRoomController.messageList[index]; - return Align( - alignment: Alignment.centerLeft, - child: Container( - decoration: BoxDecoration( - color: liveRoomController.isPortrait.value - ? Colors.black.withOpacity(0.3) - : Colors.grey.withOpacity(0.1), - borderRadius: const BorderRadius.all(Radius.circular(20)), - ), - margin: EdgeInsets.only( - top: index == 0 ? 20.0 : 0.0, - bottom: 6.0, - left: 14.0, - right: 14.0, - ), - padding: const EdgeInsets.symmetric( - vertical: 3.0, - horizontal: 10.0, - ), - child: Text.rich( - TextSpan( - style: const TextStyle(color: Colors.white), - children: [ - TextSpan( - text: '${liveMsgItem.userName}: ', - style: TextStyle( - color: Colors.white.withOpacity(0.6), - ), - recognizer: TapGestureRecognizer() - ..onTap = () { - // 处理点击事件 - print('Text clicked'); - }, + child: ListView.builder( + controller: scrollController, + itemCount: liveRoomController.messageList.length, + itemBuilder: (context, index) { + final LiveMessageModel liveMsgItem = + liveRoomController.messageList[index]; + return Align( + alignment: Alignment.centerLeft, + child: Container( + decoration: BoxDecoration( + color: liveRoomController.isPortrait.value + ? Colors.black.withOpacity(0.3) + : Colors.grey.withOpacity(0.1), + borderRadius: const BorderRadius.all(Radius.circular(20)), + ), + margin: EdgeInsets.only( + top: index == 0 ? 20.0 : 0.0, + bottom: 6.0, + left: 14.0, + right: 14.0, + ), + padding: const EdgeInsets.symmetric( + vertical: 3.0, + horizontal: 10.0, + ), + child: Text.rich( + TextSpan( + style: const TextStyle(color: Colors.white), + children: [ + TextSpan( + text: '${liveMsgItem.userName}: ', + style: TextStyle( + color: Colors.white.withOpacity(0.6), ), - TextSpan( - children: [ - ...buildMessageTextSpan(context, liveMsgItem) - ], - // text: liveMsgItem.message, - ), - ], - ), + recognizer: TapGestureRecognizer() + ..onTap = () { + // 处理点击事件 + print('Text clicked'); + }, + ), + TextSpan( + children: [ + ...buildMessageTextSpan(context, liveMsgItem) + ], + // text: liveMsgItem.message, + ), + ], ), ), - ); - }, - ), + ), + ); + }, ), ), ), diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 4399bf30..f829b0c1 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -24,8 +24,8 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { final MainController _mainController = Get.put(MainController()); late HomeController _homeController; RankController? _rankController; - DynamicsController? _dynamicController; - MediaController? _mediaController; + late DynamicsController _dynamicController; + late MediaController _mediaController; int? _lastSelectTime; //上次点击时间 Box setting = GStrorage.setting; @@ -76,28 +76,30 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { } if (currentPage is DynamicsPage) { - if (_dynamicController!.flag) { + if (_dynamicController.flag) { // 单击返回顶部 双击并刷新 if (DateTime.now().millisecondsSinceEpoch - _lastSelectTime! < 500) { - _dynamicController!.onRefresh(); + _dynamicController.onRefresh(); } else { - _dynamicController!.animateToTop(); + _dynamicController.animateToTop(); } _lastSelectTime = DateTime.now().millisecondsSinceEpoch; } - _dynamicController!.flag = true; + _dynamicController.flag = true; _mainController.clearUnread(); } else { - _dynamicController?.flag = false; + _dynamicController.flag = false; } if (currentPage is MediaPage) { - _mediaController!.queryFavFolder(); + _mediaController.queryFavFolder(); } } void controllerInit() { _homeController = Get.put(HomeController()); + _dynamicController = Get.put(DynamicsController()); + _mediaController = Get.put(MediaController()); if (_mainController.pagesIds.contains(1)) { _rankController = Get.put(RankController()); }