From 932be48125f6c2340a0c78eac6eccec2e8e3e122 Mon Sep 17 00:00:00 2001 From: orz12 Date: Sat, 20 Jan 2024 21:05:01 +0800 Subject: [PATCH 01/35] =?UTF-8?q?mod:=20=E6=8E=A8=E8=8D=90=E3=80=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=A1=B5=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=A7=86=E9=A2=91=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E9=A1=B5=E6=97=A0=E6=B3=95=E7=AD=9B=E9=80=89=E5=92=8C=E5=9B=9E?= =?UTF-8?q?=E9=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/video_card_v.dart | 39 ++++++++++++------- lib/pages/search_panel/view.dart | 2 +- .../search_panel/widgets/video_panel.dart | 6 +-- lib/utils/utils.dart | 28 ++++++++++++- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index 0bbd5377..c40d439c 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; +import 'stat/danmu.dart'; +import 'stat/view.dart'; import '../../http/dynamics.dart'; import '../../http/search.dart'; import '../../http/user.dart'; @@ -322,21 +324,30 @@ class VideoStat extends StatelessWidget { @override Widget build(BuildContext context) { - return RichText( - maxLines: 1, - text: TextSpan( - style: TextStyle( - fontSize: MediaQuery.textScalerOf(context) - .scale(Theme.of(context).textTheme.labelSmall!.fontSize!), - color: Theme.of(context).colorScheme.outline, + return Row( + children: [ + StatView( + theme: 'gray', + view: videoItem.stat.view as int, ), - children: [ - if (videoItem.stat.view != '-') - TextSpan(text: '${videoItem.stat.view}观看'), - if (videoItem.stat.danmu != '-') - TextSpan(text: ' • ${videoItem.stat.danmu}弹幕'), - ], - ), + const SizedBox(width: 8), + StatDanMu( + theme: 'gray', + danmu: videoItem.stat.danmu as int, + ), + const Spacer(), + RichText( + maxLines: 1, + text: TextSpan( + style: TextStyle( + fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, + color: Theme.of(context).colorScheme.outline, + ), + text: Utils.formatTimestampToRelativeTime(videoItem.pubdate) + ), + ), + const SizedBox(width: 4), + ], ); } } diff --git a/lib/pages/search_panel/view.dart b/lib/pages/search_panel/view.dart index f7392c88..182fbea0 100644 --- a/lib/pages/search_panel/view.dart +++ b/lib/pages/search_panel/view.dart @@ -43,7 +43,7 @@ class _SearchPanelState extends State keyword: widget.keyword, searchType: widget.searchType, ), - tag: widget.searchType!.type + widget.keyword!, + tag: widget.searchType!.type, ); scrollController = _searchPanelController.scrollController; scrollController.addListener(() async { diff --git a/lib/pages/search_panel/widgets/video_panel.dart b/lib/pages/search_panel/widgets/video_panel.dart index 0b5d5eb8..3debcfb9 100644 --- a/lib/pages/search_panel/widgets/video_panel.dart +++ b/lib/pages/search_panel/widgets/video_panel.dart @@ -35,7 +35,7 @@ class SearchVideoPanel extends StatelessWidget { padding: index == 0 ? const EdgeInsets.only(top: 2) : EdgeInsets.zero, - child: VideoCardH(videoItem: i), + child: VideoCardH(videoItem: i, showPubdate: true), ); }, ), @@ -70,7 +70,7 @@ class SearchVideoPanel extends StatelessWidget { controller.selectedType.value = i['type']; ctr!.order.value = i['type'].toString().split('.').last; - SmartDialog.showLoading(msg: 'loooad'); + SmartDialog.showLoading(msg: 'loading'); await ctr!.onRefresh(); SmartDialog.dismiss(); }, @@ -201,7 +201,7 @@ class VideoPanelController extends GetxController { SearchPanelController ctr = Get.find(tag: 'video'); ctr.duration.value = i['value']; - SmartDialog.showLoading(msg: 'loooad'); + SmartDialog.showLoading(msg: 'loading'); await ctr.onRefresh(); SmartDialog.dismiss(); }, diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 08693d24..7ef0e53f 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -28,7 +28,13 @@ class Utils { return tempPath; } - static String numFormat(int number) { + static String numFormat(dynamic number) { + if (number == null) { + return '0'; + } + if (number is String) { + return number; + } final String res = (number / 10000).toString(); if (int.parse(res.split('.')[0]) >= 1) { return '${(number / 10000).toPrecision(1)}万'; @@ -58,6 +64,26 @@ class Utils { } } + // 完全相对时间显示 + static String formatTimestampToRelativeTime(timeStamp) { + var difference = DateTime.now() + .difference(DateTime.fromMillisecondsSinceEpoch(timeStamp * 1000)); + + if (difference.inDays > 365) { + return '${difference.inDays ~/ 365}年前'; + } else if (difference.inDays > 30) { + return '${difference.inDays ~/ 30}个月前'; + } else if (difference.inDays > 0) { + return '${difference.inDays}天前'; + } else if (difference.inHours > 0) { + return '${difference.inHours}小时前'; + } else if (difference.inMinutes > 0) { + return '${difference.inMinutes}分钟前'; + } else { + return '刚刚'; + } + } + // 时间显示,刚刚,x分钟前 static String dateFormat(timeStamp, {formatType = 'list'}) { // 当前时间 From 23c8b3418971e8d0c36217e6cc1508125027ef5b Mon Sep 17 00:00:00 2001 From: orz12 Date: Sat, 20 Jan 2024 21:43:01 +0800 Subject: [PATCH 02/35] =?UTF-8?q?fix:=20app=E7=AB=AF=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E5=B1=8F=E8=94=BD=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E9=87=8F=E4=B8=8E=E5=BC=B9=E5=B9=95=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=94=B9=E4=B8=BA=E5=8A=A8=E6=80=81=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/stat/danmu.dart | 2 +- lib/common/widgets/stat/view.dart | 2 +- lib/common/widgets/video_card_v.dart | 28 +++++++++++++++------------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/common/widgets/stat/danmu.dart b/lib/common/widgets/stat/danmu.dart index 44f662a9..c1c439db 100644 --- a/lib/common/widgets/stat/danmu.dart +++ b/lib/common/widgets/stat/danmu.dart @@ -3,7 +3,7 @@ import 'package:pilipala/utils/utils.dart'; class StatDanMu extends StatelessWidget { final String? theme; - final int? danmu; + final dynamic danmu; final String? size; const StatDanMu({Key? key, this.theme, this.danmu, this.size}) diff --git a/lib/common/widgets/stat/view.dart b/lib/common/widgets/stat/view.dart index 8b97b605..2665e2d4 100644 --- a/lib/common/widgets/stat/view.dart +++ b/lib/common/widgets/stat/view.dart @@ -3,7 +3,7 @@ import 'package:pilipala/utils/utils.dart'; class StatView extends StatelessWidget { final String? theme; - final int? view; + final dynamic view; final String? size; const StatView({Key? key, this.theme, this.view, this.size}) diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index c40d439c..86ea2a5a 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; +import '../../models/model_rec_video_item.dart'; import 'stat/danmu.dart'; import 'stat/view.dart'; import '../../http/dynamics.dart'; @@ -328,25 +329,26 @@ class VideoStat extends StatelessWidget { children: [ StatView( theme: 'gray', - view: videoItem.stat.view as int, + view: videoItem.stat.view, ), const SizedBox(width: 8), StatDanMu( theme: 'gray', - danmu: videoItem.stat.danmu as int, + danmu: videoItem.stat.danmu, ), - const Spacer(), - RichText( - maxLines: 1, - text: TextSpan( - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, - color: Theme.of(context).colorScheme.outline, - ), - text: Utils.formatTimestampToRelativeTime(videoItem.pubdate) + if (videoItem is RecVideoItemModel) ...[ + const Spacer(), + RichText( + maxLines: 1, + text: TextSpan( + style: TextStyle( + fontSize: Theme.of(context).textTheme.labelSmall!.fontSize, + color: Theme.of(context).colorScheme.outline, + ), + text: Utils.formatTimestampToRelativeTime(videoItem.pubdate)), ), - ), - const SizedBox(width: 4), + const SizedBox(width: 4), + ] ], ); } From 10d2995429bb20a9cc51e6b46e56d6bcf69665c8 Mon Sep 17 00:00:00 2001 From: orz12 Date: Sat, 27 Jan 2024 12:05:04 +0800 Subject: [PATCH 03/35] =?UTF-8?q?mod:=20=E5=AF=B9=E9=BD=90=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/search_panel/view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/search_panel/view.dart b/lib/pages/search_panel/view.dart index 182fbea0..f7392c88 100644 --- a/lib/pages/search_panel/view.dart +++ b/lib/pages/search_panel/view.dart @@ -43,7 +43,7 @@ class _SearchPanelState extends State keyword: widget.keyword, searchType: widget.searchType, ), - tag: widget.searchType!.type, + tag: widget.searchType!.type + widget.keyword!, ); scrollController = _searchPanelController.scrollController; scrollController.addListener(() async { From fb32388536146f57c0b6e8236ad4f2d014c9ec56 Mon Sep 17 00:00:00 2001 From: orz12 Date: Sun, 4 Feb 2024 16:41:44 +0800 Subject: [PATCH 04/35] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=84=A6=E7=82=B9=E6=81=A2=E5=A4=8D=E6=97=B6=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=92=AD=E6=94=BE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/services/audio_session.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/services/audio_session.dart b/lib/services/audio_session.dart index 98707652..57c42e05 100644 --- a/lib/services/audio_session.dart +++ b/lib/services/audio_session.dart @@ -20,11 +20,15 @@ class AudioSessionHandler { session.interruptionEventStream.listen((event) { final player = PlPlayerController.getInstance(); if (event.begin) { + if (player.playerStatus != PlayerStatus.playing) return; switch (event.type) { case AudioInterruptionType.duck: player.setVolume(player.volume.value * 0.5); break; case AudioInterruptionType.pause: + player.pause(isInterrupt: true); + _playInterrupted = true; + break; case AudioInterruptionType.unknown: player.pause(isInterrupt: true); _playInterrupted = true; @@ -36,7 +40,7 @@ class AudioSessionHandler { player.setVolume(player.volume.value * 2); break; case AudioInterruptionType.pause: - if (_playInterrupted) PlPlayerController.getInstance().play(); + if (_playInterrupted) player.play(); break; case AudioInterruptionType.unknown: break; @@ -47,7 +51,10 @@ class AudioSessionHandler { // 耳机拔出暂停 session.becomingNoisyEventStream.listen((_) { - PlPlayerController.getInstance().pause(); + final player = PlPlayerController.getInstance(); + if (player.playerStatus == PlayerStatus.playing) { + player.pause(); + } }); } } From 71ccb9c0e51dce5437a14e7311f36b13f0f2ac8a Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 6 Feb 2024 11:01:36 +0800 Subject: [PATCH 05/35] =?UTF-8?q?fix:=20=E6=94=B6=E8=97=8F=E5=9B=BD?= =?UTF-8?q?=E5=88=9B=E8=B7=B3=E8=BD=AC=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/fav_detail/widget/fav_video_card.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pages/fav_detail/widget/fav_video_card.dart b/lib/pages/fav_detail/widget/fav_video_card.dart index 9394fbe3..d988a0e1 100644 --- a/lib/pages/fav_detail/widget/fav_video_card.dart +++ b/lib/pages/fav_detail/widget/fav_video_card.dart @@ -27,7 +27,9 @@ class FavVideoCardH extends StatelessWidget { onTap: () async { // int? seasonId; String? epId; - if (videoItem.ogv != null && videoItem.ogv['type_name'] == '番剧') { + if (videoItem.ogv != null && + (videoItem.ogv['type_name'] == '番剧' || + videoItem.ogv['type_name'] == '国创')) { videoItem.cid = await SearchHttp.ab2c(bvid: bvid); // seasonId = videoItem.ogv['season_id']; epId = videoItem.epId; From 083739e562a5ec3d40c4597d79103611f264796a Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 6 Feb 2024 11:13:33 +0800 Subject: [PATCH 06/35] =?UTF-8?q?mod:=20=E6=94=B6=E8=97=8F=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E5=86=85=E5=AE=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fav_detail/widget/fav_video_card.dart | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/lib/pages/fav_detail/widget/fav_video_card.dart b/lib/pages/fav_detail/widget/fav_video_card.dart index d988a0e1..a4f22f6b 100644 --- a/lib/pages/fav_detail/widget/fav_video_card.dart +++ b/lib/pages/fav_detail/widget/fav_video_card.dart @@ -9,6 +9,7 @@ import 'package:pilipala/models/common/search_type.dart'; import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; +import '../../../common/widgets/badge.dart'; // 收藏视频卡片 - 水平布局 class FavVideoCardH extends StatelessWidget { @@ -86,22 +87,21 @@ class FavVideoCardH extends StatelessWidget { height: maxHeight, ), ), - Positioned( - right: 4, - bottom: 4, - child: Container( - padding: const EdgeInsets.symmetric( - vertical: 1, horizontal: 6), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: Colors.black54.withOpacity(0.4)), - child: Text( - Utils.timeFormat(videoItem.duration!), - style: const TextStyle( - fontSize: 11, color: Colors.white), - ), + PBadge( + text: Utils.timeFormat(videoItem.duration!), + right: 6.0, + bottom: 6.0, + type: 'gray', + ), + if (videoItem.ogv != null) ...[ + PBadge( + text: videoItem.ogv['type_name'], + top: 6.0, + right: 6.0, + bottom: null, + left: null, ), - ) + ], ], ); }, @@ -143,19 +143,30 @@ class VideoContent extends StatelessWidget { maxLines: 2, overflow: TextOverflow.ellipsis, ), + if (videoItem.ogv != null) ...[ + Text( + videoItem.intro, + style: TextStyle( + fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, + color: Theme.of(context).colorScheme.outline, + ), + ), + ], const Spacer(), Text( - Utils.dateFormat(videoItem.ctime!), + Utils.dateFormat(videoItem.favTime), style: TextStyle( fontSize: 11, color: Theme.of(context).colorScheme.outline), ), - Text( - videoItem.owner.name, - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, - color: Theme.of(context).colorScheme.outline, + if (videoItem.owner.name != '') ...[ + Text( + videoItem.owner.name, + style: TextStyle( + fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, + color: Theme.of(context).colorScheme.outline, + ), ), - ), + ], Row( children: [ StatView( From 40c666e3d1112269f01a9b877bdabfe7d69883ab Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 7 Feb 2024 00:52:25 +0800 Subject: [PATCH 07/35] =?UTF-8?q?mod:=20=E7=BD=91=E7=BB=9C=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=BB=84=E4=BB=B6=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/http_error.dart | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/common/widgets/http_error.dart b/lib/common/widgets/http_error.dart index b02182c6..cbc6659b 100644 --- a/lib/common/widgets/http_error.dart +++ b/lib/common/widgets/http_error.dart @@ -22,20 +22,27 @@ class HttpError extends StatelessWidget { "assets/images/error.svg", height: 200, ), - const SizedBox(height: 20), + const SizedBox(height: 30), Text( errMsg ?? '请求异常', textAlign: TextAlign.center, style: Theme.of(context).textTheme.titleSmall, ), - const SizedBox(height: 30), - OutlinedButton.icon( + const SizedBox(height: 20), + FilledButton.tonal( onPressed: () { fn!(); }, - icon: const Icon(Icons.arrow_forward_outlined, size: 20), - label: Text(btnText ?? '点击重试'), - ) + style: ButtonStyle( + backgroundColor: MaterialStateProperty.resolveWith((states) { + return Theme.of(context).colorScheme.primary.withAlpha(20); + }), + ), + child: Text( + btnText ?? '点击重试', + style: TextStyle(color: Theme.of(context).colorScheme.primary), + ), + ), ], ), ), From 191472d0c42c3cd09f9701ccd828e7fb13e21aa8 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 7 Feb 2024 01:17:35 +0800 Subject: [PATCH 08/35] =?UTF-8?q?mod:=20=E7=BD=91=E7=BB=9C=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=BC=82=E5=B8=B8=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/video.dart | 8 +++---- lib/pages/dynamics/view.dart | 28 ++---------------------- lib/pages/dynamics/widgets/up_panel.dart | 7 ++++++ lib/pages/search/view.dart | 10 ++++++--- lib/pages/search_panel/view.dart | 12 ++++++++-- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/lib/http/video.dart b/lib/http/video.dart index d0faabaa..b311bfa1 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -51,7 +51,7 @@ class VideoHttp { (i['owner'] != null && !blackMidsList.contains(i['owner']['mid']))) { RecVideoItemModel videoItem = RecVideoItemModel.fromJson(i); - if (!RecommendFilter.filter(videoItem)){ + if (!RecommendFilter.filter(videoItem)) { list.add(videoItem); } } @@ -98,7 +98,7 @@ class VideoHttp { (i['args'] != null && !blackMidsList.contains(i['args']['up_mid']))) { RecVideoItemAppModel videoItem = RecVideoItemAppModel.fromJson(i); - if (!RecommendFilter.filter(videoItem)){ + if (!RecommendFilter.filter(videoItem)) { list.add(videoItem); } } @@ -130,7 +130,7 @@ class VideoHttp { } return {'status': true, 'data': list}; } else { - return {'status': false, 'data': []}; + return {'status': false, 'data': [], 'msg': res.data['message']}; } } catch (err) { return {'status': false, 'data': [], 'msg': err}; @@ -217,7 +217,7 @@ class VideoHttp { List list = []; for (var i in res.data['data']) { HotVideoItemModel videoItem = HotVideoItemModel.fromJson(i); - if (!RecommendFilter.filter(videoItem, relatedVideos: true)){ + if (!RecommendFilter.filter(videoItem, relatedVideos: true)) { list.add(videoItem); } } diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index 575c8767..4a92cdfb 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -192,22 +192,6 @@ class _DynamicsPageState extends State ) ], ), - // Obx( - // () => Visibility( - // visible: _dynamicsController.userLogin.value, - // child: Positioned( - // right: 4, - // top: 0, - // bottom: 0, - // child: IconButton( - // padding: EdgeInsets.zero, - // onPressed: () => - // {feedBack(), _dynamicsController.resetSearch()}, - // icon: const Icon(Icons.history, size: 21), - // ), - // ), - // ), - // ), ], ), ), @@ -229,7 +213,8 @@ class _DynamicsPageState extends State return Obx(() => UpPanel(_dynamicsController.upData.value)); } else { return const SliverToBoxAdapter( - child: SizedBox(height: 80)); + child: SizedBox(height: 80), + ); } } else { return const SliverToBoxAdapter( @@ -240,15 +225,6 @@ class _DynamicsPageState extends State } }, ), - SliverToBoxAdapter( - child: Container( - height: 6, - color: Theme.of(context) - .colorScheme - .onInverseSurface - .withOpacity(0.5), - ), - ), FutureBuilder( future: _futureBuilderFuture, builder: (context, snapshot) { diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index ba4a562d..f1043fd8 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -121,6 +121,13 @@ class _UpPanelState extends State { ], ), ), + Container( + height: 6, + color: Theme.of(context) + .colorScheme + .onInverseSurface + .withOpacity(0.5), + ), ], )), ); diff --git a/lib/pages/search/view.dart b/lib/pages/search/view.dart index c262df38..95d3134e 100644 --- a/lib/pages/search/view.dart +++ b/lib/pages/search/view.dart @@ -187,9 +187,13 @@ class _SearchPageState extends State with RouteAware { ), ); } else { - return HttpError( - errMsg: data['msg'], - fn: () => setState(() {}), + return CustomScrollView( + slivers: [ + HttpError( + errMsg: data['msg'], + fn: () => setState(() {}), + ) + ], ); } } else { diff --git a/lib/pages/search_panel/view.dart b/lib/pages/search_panel/view.dart index f7392c88..c5824d70 100644 --- a/lib/pages/search_panel/view.dart +++ b/lib/pages/search_panel/view.dart @@ -105,7 +105,11 @@ class _SearchPanelState extends State slivers: [ HttpError( errMsg: data['msg'], - fn: () => setState(() {}), + fn: () { + setState(() { + _searchPanelController.onSearch(); + }); + }, ), ], ); @@ -116,7 +120,11 @@ class _SearchPanelState extends State slivers: [ HttpError( errMsg: '没有相关数据', - fn: () => setState(() {}), + fn: () { + setState(() { + _searchPanelController.onSearch(); + }); + }, ), ], ); From b0c56feef5c6169eb088aa257005f2863009e3b8 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 7 Feb 2024 02:47:11 +0800 Subject: [PATCH 09/35] =?UTF-8?q?mod:=20=E9=A6=96=E9=A1=B5=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E5=BC=82=E5=B8=B8=E8=AF=B7=E6=B1=82=E9=87=8D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 16 +++++++--------- lib/pages/bangumi/view.dart | 7 ++++--- lib/pages/hot/view.dart | 10 +++++++--- lib/pages/live/controller.dart | 4 +--- lib/pages/live/view.dart | 23 +++++++++-------------- lib/pages/rcmd/view.dart | 34 ++-------------------------------- 6 files changed, 30 insertions(+), 64 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 5c467722..64559ffd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,7 +25,6 @@ import 'package:pilipala/utils/recommend_filter.dart'; import 'package:catcher_2/catcher_2.dart'; import './services/loggeer.dart'; - void main() async { WidgetsFlutterBinding.ensureInitialized(); MediaKit.ensureInitialized(); @@ -55,14 +54,13 @@ void main() async { [FileHandler(await getLogsPath())], ); - Catcher2( - debugConfig: debugConfig, - releaseConfig: releaseConfig, - runAppFunction: () { - runApp(const MyApp()); - }, - ); - + // Catcher2( + // debugConfig: debugConfig, + // releaseConfig: releaseConfig, + // runAppFunction: () { + runApp(const MyApp()); + // }, + // ); // 小白条、导航栏沉浸 SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); diff --git a/lib/pages/bangumi/view.dart b/lib/pages/bangumi/view.dart index 560f09a5..f59f94a2 100644 --- a/lib/pages/bangumi/view.dart +++ b/lib/pages/bangumi/view.dart @@ -9,7 +9,6 @@ import 'package:pilipala/common/constants.dart'; import 'package:pilipala/common/widgets/http_error.dart'; import 'package:pilipala/pages/home/index.dart'; import 'package:pilipala/pages/main/index.dart'; -import 'package:pilipala/pages/rcmd/view.dart'; import 'controller.dart'; import 'widgets/bangumu_card_v.dart'; @@ -199,7 +198,10 @@ class _BangumiPageState extends State } else { return HttpError( errMsg: data['msg'], - fn: () => {}, + fn: () { + _futureBuilderFuture = + _bangumidController.queryBangumiListFeed(); + }, ); } } else { @@ -208,7 +210,6 @@ class _BangumiPageState extends State }, ), ), - const LoadingMore() ], ), ); diff --git a/lib/pages/hot/view.dart b/lib/pages/hot/view.dart index 2673e84c..7a0a57ea 100644 --- a/lib/pages/hot/view.dart +++ b/lib/pages/hot/view.dart @@ -89,8 +89,7 @@ class _HotPageState extends State with AutomaticKeepAliveClientMixin { if (data['status']) { return Obx( () => SliverList( - delegate: - SliverChildBuilderDelegate((context, index) { + delegate: SliverChildBuilderDelegate((context, index) { return VideoCardH( videoItem: _hotController.videoList[index], showPubdate: true, @@ -110,7 +109,12 @@ class _HotPageState extends State with AutomaticKeepAliveClientMixin { } else { return HttpError( errMsg: data['msg'], - fn: () => setState(() {}), + fn: () { + setState(() { + _futureBuilderFuture = + _hotController.queryHotFeed('init'); + }); + }, ); } } else { diff --git a/lib/pages/live/controller.dart b/lib/pages/live/controller.dart index 6a26f0d2..74fb6e9a 100644 --- a/lib/pages/live/controller.dart +++ b/lib/pages/live/controller.dart @@ -10,8 +10,7 @@ class LiveController extends GetxController { int count = 12; int _currentPage = 1; RxInt crossAxisCount = 2.obs; - RxList liveList = [LiveItemModel()].obs; - bool isLoadingMore = false; + RxList liveList = [].obs; bool flag = false; OverlayEntry? popupDialog; Box setting = GStrorage.setting; @@ -39,7 +38,6 @@ class LiveController extends GetxController { } _currentPage += 1; } - isLoadingMore = false; return res; } diff --git a/lib/pages/live/view.dart b/lib/pages/live/view.dart index f693acf1..f3f91c9e 100644 --- a/lib/pages/live/view.dart +++ b/lib/pages/live/view.dart @@ -11,7 +11,6 @@ import 'package:pilipala/common/widgets/http_error.dart'; import 'package:pilipala/common/widgets/overlay_pop.dart'; import 'package:pilipala/pages/home/index.dart'; import 'package:pilipala/pages/main/index.dart'; -import 'package:pilipala/pages/rcmd/index.dart'; import 'controller.dart'; import 'widgets/live_item.dart'; @@ -45,8 +44,8 @@ class _LivePageState extends State () { if (scrollController.position.pixels >= scrollController.position.maxScrollExtent - 200) { - EasyThrottle.throttle('liveList', const Duration(seconds: 1), () { - _liveController.isLoadingMore = true; + EasyThrottle.throttle('liveList', const Duration(milliseconds: 200), + () { _liveController.onLoad(); }); } @@ -108,24 +107,20 @@ class _LivePageState extends State } else { return HttpError( errMsg: data['msg'], - fn: () => {}, + fn: () { + setState(() { + _futureBuilderFuture = + _liveController.queryLiveList('init'); + }); + }, ); } } else { - // 缓存数据 - if (_liveController.liveList.length > 1) { - return contentGrid( - _liveController, _liveController.liveList); - } - // 骨架屏 - else { - return contentGrid(_liveController, []); - } + return contentGrid(_liveController, []); } }, ), ), - LoadingMore(ctr: _liveController) ], ), ), diff --git a/lib/pages/rcmd/view.dart b/lib/pages/rcmd/view.dart index 42b66364..d732f370 100644 --- a/lib/pages/rcmd/view.dart +++ b/lib/pages/rcmd/view.dart @@ -44,7 +44,7 @@ class _RcmdPageState extends State if (scrollController.position.pixels >= scrollController.position.maxScrollExtent - 200) { EasyThrottle.throttle( - 'my-throttler', const Duration(milliseconds: 500), () { + 'my-throttler', const Duration(milliseconds: 200), () { _rcmdController.isLoadingMore = true; _rcmdController.onLoad(); }); @@ -113,6 +113,7 @@ class _RcmdPageState extends State errMsg: data['msg'], fn: () { setState(() { + _rcmdController.isLoadingMore = true; _futureBuilderFuture = _rcmdController.queryRcmdFeed('init'); }); @@ -125,7 +126,6 @@ class _RcmdPageState extends State }, ), ), - LoadingMore(ctr: _rcmdController), ], ), ), @@ -188,33 +188,3 @@ class _RcmdPageState extends State ); } } - -class LoadingMore extends StatelessWidget { - final dynamic ctr; - const LoadingMore({super.key, this.ctr}); - - @override - Widget build(BuildContext context) { - return SliverToBoxAdapter( - child: Container( - height: MediaQuery.of(context).padding.bottom + 80, - padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), - child: GestureDetector( - onTap: () { - if (ctr != null) { - ctr!.isLoadingMore = true; - ctr!.onLoad(); - } - }, - child: Center( - child: Text( - '点击加载更多 👇', - style: TextStyle( - color: Theme.of(context).colorScheme.outline, fontSize: 13), - ), - ), - ), - ), - ); - } -} From d258474a5a69b75542ae040830c3cd9b7343b873 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 7 Feb 2024 22:23:29 +0800 Subject: [PATCH 10/35] =?UTF-8?q?mod:=20=E7=9B=B4=E6=92=AD=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=86=85=E5=AE=B9=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/images/live/default_bg.webp | Bin 0 -> 16312 bytes lib/http/api.dart | 4 + lib/http/live.dart | 19 +++ lib/main.dart | 2 - lib/models/live/room_info_h5.dart | 130 +++++++++++++++++++ lib/pages/live_room/controller.dart | 19 ++- lib/pages/live_room/view.dart | 193 +++++++++++++++------------- lib/plugin/pl_player/view.dart | 3 +- pubspec.yaml | 1 + 9 files changed, 279 insertions(+), 92 deletions(-) create mode 100644 assets/images/live/default_bg.webp create mode 100644 lib/models/live/room_info_h5.dart diff --git a/assets/images/live/default_bg.webp b/assets/images/live/default_bg.webp new file mode 100644 index 0000000000000000000000000000000000000000..a58259dea48887982df1f1be955cf73c489bf232 GIT binary patch literal 16312 zcmY+qb3mov7d3vfZJU#uCfjbZZM(_lWZQO4HYeM*t*MFcZ9d=khrgccp68r>Hr8Hi z-xMXq#A^8g05wq|1yuzO;zHohwQ*osAhagnK`?xA5;-zOh4fXq^X8njs4y0`ud?xB zsQ_{49xgtO=6v6+0`~k%u)JR?e3#-=Li`V<5W>|+Jo4(ua3?vT&lqhf=_am=$)Tek zJ0D3=uB^USA0TJo(8$CB{-EH{xP;Cpb0uvPe`jzShf- zbS{3M*o$_CH)^?P<<=73f{BI!DLOLbYXx|ezzI-!$6Oi z7~cknab|lydSH6%WOKOS_E4wyOPkwIcc#49>}_xBnIJ)bu*X+CY&@yCYL=#}UD+vH z1)@qH<-V7S%hb{}XR?Ujci(TF%dvF?nVorZYUK7S^5>f9u~p~68|4Pw~q zN@I&{a&zA2O$d&0OLX1{o(8Zjl+%JxBsbpZ$1)-k2%JY2dYrhi8wZ348q^1g&8A$z ziIF7Rl_KA)x+QUv?%6r&o4sL@+&UvSh~yb~%rGc;xt7b?Cvg1r^cT(ZfNg&FYjS*N zxm?>5RF~-Rxv~NIzk3r-1Ef%@&Cy4aB0WqZXGld{t8t{_#@5Snzt)Kok9=Av!2Z^y zMjnAzs12@^O)jr!Swja-Qk$OdUae$?zssjlbeV#VoT5`1&*h3_f~ZevH|<-cv1nI2 z_uWP@u(lTVD(efPaCuhBvKWsfIF(w8gcC%U|6!kZMvkL#0g3cS?T>P84P+;` zDYX02pQ7$zKjVeh@Mq-71`LJcJRFtccl^();ob9Bb$effv}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zWEUz^8c{4G;T!3+C)80dEKMT+qge8sopBKal&E({~LpdA4Ysv`p%^HWN8@p{g_0a+a_ozRYcbS z^R@`s)nTUHm^wp8a&ron7>Ay4wb;sN4kdX json) { + roomInfo = RoomInfo.fromJson(json['room_info']); + anchorInfo = AnchorInfo.fromJson(json['anchor_info']); + isRoomFeed = json['is_room_feed']; + watchedShow = json['watched_show']; + likeInfoV3 = LikeInfoV3.fromJson(json['like_info_v3']); + blockInfo = json['block_info']; + } +} + +class RoomInfo { + RoomInfo({ + this.uid, + this.roomId, + this.title, + this.cover, + this.description, + this.liveStatus, + this.liveStartTime, + this.areaId, + this.areaName, + this.parentAreaId, + this.parentAreaName, + this.online, + this.background, + this.appBackground, + this.liveId, + }); + + int? uid; + int? roomId; + String? title; + String? cover; + String? description; + int? liveStatus; + int? liveStartTime; + int? areaId; + String? areaName; + int? parentAreaId; + String? parentAreaName; + int? online; + String? background; + String? appBackground; + String? liveId; + + RoomInfo.fromJson(Map json) { + uid = json['uid']; + roomId = json['room_id']; + title = json['title']; + cover = json['cover']; + description = json['description']; + liveStatus = json['liveS_satus']; + liveStartTime = json['live_start_time']; + areaId = json['area_id']; + areaName = json['area_name']; + parentAreaId = json['parent_area_id']; + parentAreaName = json['parent_area_name']; + online = json['online']; + background = json['background']; + appBackground = json['app_background']; + liveId = json['live_id']; + } +} + +class AnchorInfo { + AnchorInfo({ + this.baseInfo, + this.relationInfo, + }); + + BaseInfo? baseInfo; + RelationInfo? relationInfo; + + AnchorInfo.fromJson(Map json) { + baseInfo = BaseInfo.fromJson(json['base_info']); + relationInfo = RelationInfo.fromJson(json['relation_info']); + } +} + +class BaseInfo { + BaseInfo({ + this.uname, + this.face, + }); + + String? uname; + String? face; + + BaseInfo.fromJson(Map json) { + uname = json['uname']; + face = json['face']; + } +} + +class RelationInfo { + RelationInfo({this.attention}); + + int? attention; + + RelationInfo.fromJson(Map json) { + attention = json['attention']; + } +} + +class LikeInfoV3 { + LikeInfoV3({this.totalLikes}); + + int? totalLikes; + + LikeInfoV3.fromJson(Map json) { + totalLikes = json['total_likes']; + } +} diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index 2f489fec..56da0a78 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -4,6 +4,8 @@ import 'package:pilipala/http/live.dart'; import 'package:pilipala/models/live/room_info.dart'; import 'package:pilipala/plugin/pl_player/index.dart'; +import '../../models/live/room_info_h5.dart'; + class LiveRoomController extends GetxController { String cover = ''; late int roomId; @@ -21,6 +23,7 @@ class LiveRoomController extends GetxController { // controlsStyle: ControlsStyle.live, // enabledButtons: const EnabledButtons(pip: true), // ); + Rx roomInfoH5 = RoomInfoH5Model().obs; @override void onInit() { @@ -37,10 +40,11 @@ class LiveRoomController extends GetxController { } } queryLiveInfo(); + queryLiveInfoH5(); } - playerInit(source) { - plPlayerController.setDataSource( + playerInit(source) async { + await plPlayerController.setDataSource( DataSource( videoSource: source, audioSource: null, @@ -66,7 +70,8 @@ class LiveRoomController extends GetxController { String videoUrl = (item.urlInfo?.first.host)! + item.baseUrl! + item.urlInfo!.first.extra!; - playerInit(videoUrl); + await playerInit(videoUrl); + return res; } } @@ -80,4 +85,12 @@ class LiveRoomController extends GetxController { volumeOff.value = true; } } + + Future queryLiveInfoH5() async { + var res = await LiveHttp.liveRoomInfoH5(roomId: roomId); + if (res['status']) { + roomInfoH5.value = res['data']; + } + return res; + } } diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 5ac382e6..f727bfd0 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -19,6 +19,8 @@ class LiveRoomPage extends StatefulWidget { class _LiveRoomPageState extends State { final LiveRoomController _liveRoomController = Get.put(LiveRoomController()); PlPlayerController? plPlayerController; + late Future? _futureBuilder; + late Future? _futureBuilderFuture; bool isShowCover = true; bool isPlay = true; @@ -39,6 +41,8 @@ class _LiveRoomPageState extends State { if (Platform.isAndroid) { floating = Floating(); } + _futureBuilder = _liveRoomController.queryLiveInfoH5(); + _futureBuilderFuture = _liveRoomController.queryLiveInfo(); } @override @@ -52,57 +56,110 @@ class _LiveRoomPageState extends State { @override Widget build(BuildContext context) { + Widget videoPlayerPanel = FutureBuilder( + future: _futureBuilderFuture, + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.hasData && snapshot.data['status']) { + return PLVideoPlayer( + controller: plPlayerController!, + bottomControl: BottomControl( + controller: plPlayerController, + liveRoomCtr: _liveRoomController, + floating: floating, + ), + ); + } else { + return const SizedBox(); + } + }, + ); + Widget childWhenDisabled = Scaffold( primary: true, - appBar: PreferredSize( - preferredSize: Size.fromHeight( - MediaQuery.of(context).orientation == Orientation.portrait ? 56 : 0, - ), - child: AppBar( - centerTitle: false, - titleSpacing: 0, - title: _liveRoomController.liveItem != null - ? Row( - children: [ - NetworkImgLayer( - width: 34, - height: 34, - type: 'avatar', - src: _liveRoomController.liveItem.face, - ), - const SizedBox(width: 10), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - _liveRoomController.liveItem.uname, - style: const TextStyle(fontSize: 14), - ), - const SizedBox(height: 1), - if (_liveRoomController.liveItem.watchedShow != null) - Text( - _liveRoomController - .liveItem.watchedShow['text_large'] ?? - '', - style: const TextStyle(fontSize: 12)), - ], - ), - ], - ) - : const SizedBox(), - // actions: [ - // SizedBox( - // height: 34, - // child: ElevatedButton(onPressed: () {}, child: const Text('关注')), - // ), - // const SizedBox(width: 12), - // ], - ), - ), - body: Column( + backgroundColor: Colors.black, + body: Stack( children: [ - Stack( + Obx( + () => + _liveRoomController.roomInfoH5.value.roomInfo?.appBackground != + '' + ? Positioned.fill( + child: Opacity( + opacity: 0.8, + child: NetworkImgLayer( + width: Get.width, + height: Get.height, + src: _liveRoomController + .roomInfoH5.value.roomInfo?.appBackground ?? + '', + ), + ), + ) + : Image.asset( + 'assets/images/live/default_bg.webp', + width: Get.width, + height: Get.height, + ), + ), + Column( children: [ + AppBar( + centerTitle: false, + titleSpacing: 0, + backgroundColor: Colors.transparent, + foregroundColor: Colors.white, + toolbarHeight: + MediaQuery.of(context).orientation == Orientation.portrait + ? 56 + : 0, + title: FutureBuilder( + future: _futureBuilder, + builder: (context, snapshot) { + if (snapshot.data == null) { + return const SizedBox(); + } + Map data = snapshot.data as Map; + if (data['status']) { + return Obx( + () => Row( + children: [ + NetworkImgLayer( + width: 34, + height: 34, + type: 'avatar', + src: _liveRoomController + .roomInfoH5.value.anchorInfo!.baseInfo!.face, + ), + const SizedBox(width: 10), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _liveRoomController.roomInfoH5.value + .anchorInfo!.baseInfo!.uname!, + style: const TextStyle(fontSize: 14), + ), + const SizedBox(height: 1), + if (_liveRoomController + .roomInfoH5.value.watchedShow != + null) + Text( + _liveRoomController.roomInfoH5.value + .watchedShow!['text_large'] ?? + '', + style: const TextStyle(fontSize: 12), + ), + ], + ), + ], + ), + ); + } else { + return const SizedBox(); + } + }, + ), + ), PopScope( canPop: plPlayerController?.isFullScreen.value != true, onPopInvoked: (bool didPop) { @@ -120,55 +177,19 @@ class _LiveRoomPageState extends State { Orientation.landscape ? Get.size.height : Get.size.width * 9 / 16, - child: plPlayerController!.videoPlayerController != null - ? PLVideoPlayer( - controller: plPlayerController!, - bottomControl: BottomControl( - controller: plPlayerController, - liveRoomCtr: _liveRoomController, - floating: floating, - ), - ) - : const SizedBox(), + child: videoPlayerPanel, ), ), - // if (_liveRoomController.liveItem != null && - // _liveRoomController.liveItem.cover != null) - // Visibility( - // visible: isShowCover, - // child: Positioned( - // top: 0, - // left: 0, - // right: 0, - // child: NetworkImgLayer( - // type: 'emote', - // src: _liveRoomController.liveItem.cover, - // width: Get.size.width, - // height: videoHeight, - // ), - // ), - // ), ], ), ], ), ); - Widget childWhenEnabled = AspectRatio( - aspectRatio: 16 / 9, - child: plPlayerController!.videoPlayerController != null - ? PLVideoPlayer( - controller: plPlayerController!, - bottomControl: BottomControl( - controller: plPlayerController, - liveRoomCtr: _liveRoomController, - ), - ) - : const SizedBox(), - ); if (Platform.isAndroid) { return PiPSwitcher( childWhenDisabled: childWhenDisabled, - childWhenEnabled: childWhenEnabled, + childWhenEnabled: videoPlayerPanel, + floating: floating, ); } else { return childWhenDisabled; diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 3980453b..d073945b 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -586,6 +586,7 @@ class _PLVideoPlayerState extends State ), /// 进度条 live模式下禁用 + Obx( () { final int value = _.sliderPositionSeconds.value; @@ -609,7 +610,7 @@ class _PLVideoPlayerState extends State } if (_.videoType.value == 'live') { - return nil; + return const SizedBox(); } if (value > max || max <= 0) { return nil; diff --git a/pubspec.yaml b/pubspec.yaml index 16df4ad7..9597eab7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -188,6 +188,7 @@ flutter: - assets/images/ - assets/images/lv/ - assets/images/logo/ + - assets/images/live/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware From c39e91073b616626d4b8109443b9d877bc1ba782 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 7 Feb 2024 22:57:30 +0800 Subject: [PATCH 11/35] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8=E5=86=85?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/about/index.dart | 25 ++++++ lib/utils/cache_manage.dart | 154 ++++++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 lib/utils/cache_manage.dart diff --git a/lib/pages/about/index.dart b/lib/pages/about/index.dart index 5df05d31..0f159ce7 100644 --- a/lib/pages/about/index.dart +++ b/lib/pages/about/index.dart @@ -7,6 +7,7 @@ import 'package:pilipala/http/index.dart'; import 'package:pilipala/models/github/latest.dart'; import 'package:pilipala/utils/utils.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../utils/cache_manage.dart'; class AboutPage extends StatefulWidget { const AboutPage({super.key}); @@ -17,6 +18,19 @@ class AboutPage extends StatefulWidget { class _AboutPageState extends State { final AboutController _aboutController = Get.put(AboutController()); + String cacheSize = ''; + + @override + void initState() { + super.initState(); + // 读取缓存占用 + getCacheSize(); + } + + Future getCacheSize() async { + final res = await CacheManage().loadApplicationCache(); + setState(() => cacheSize = res); + } @override Widget build(BuildContext context) { @@ -138,6 +152,17 @@ class _AboutPageState extends State { title: const Text('错误日志'), trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline), ), + ListTile( + onTap: () async { + var cleanStatus = await CacheManage().clearCacheAll(); + if (cleanStatus) { + getCacheSize(); + } + }, + title: const Text('清除缓存'), + subtitle: Text('图片及网络缓存 $cacheSize', style: subTitleStyle), + trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline), + ), ], ), ), diff --git a/lib/utils/cache_manage.dart b/lib/utils/cache_manage.dart new file mode 100644 index 00000000..e250ab70 --- /dev/null +++ b/lib/utils/cache_manage.dart @@ -0,0 +1,154 @@ +import 'dart:async'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; + +class CacheManage { + CacheManage._internal(); + + static final CacheManage cacheManage = CacheManage._internal(); + + factory CacheManage() => cacheManage; + + // 获取缓存目录 + Future loadApplicationCache() async { + /// clear all of image in memory + // clearMemoryImageCache(); + /// get ImageCache + // var res = getMemoryImageCache(); + + // 缓存大小 + double cacheSize = 0; + // cached_network_image directory + Directory tempDirectory = await getTemporaryDirectory(); + // get_storage directory + Directory docDirectory = await getApplicationDocumentsDirectory(); + + // 获取缓存大小 + if (tempDirectory.existsSync()) { + double value = await getTotalSizeOfFilesInDir(tempDirectory); + cacheSize += value; + } + + /// 获取缓存大小 dioCache + if (docDirectory.existsSync()) { + double value = 0; + String dioCacheFileName = + '${docDirectory.path}${Platform.pathSeparator}DioCache.db'; + var dioCacheFile = File(dioCacheFileName); + if (dioCacheFile.existsSync()) { + value = await getTotalSizeOfFilesInDir(dioCacheFile); + } + cacheSize += value; + } + + return formatSize(cacheSize); + } + + // 循环计算文件的大小(递归) + Future getTotalSizeOfFilesInDir(final FileSystemEntity file) async { + if (file is File) { + int length = await file.length(); + return double.parse(length.toString()); + } + if (file is Directory) { + final List children = file.listSync(); + double total = 0; + for (final FileSystemEntity child in children) { + total += await getTotalSizeOfFilesInDir(child); + } + return total; + } + return 0; + } + + // 缓存大小格式转换 + String formatSize(double value) { + List unitArr = ['B', 'K', 'M', 'G']; + int index = 0; + while (value > 1024) { + index++; + value = value / 1024; + } + String size = value.toStringAsFixed(2); + return size + unitArr[index]; + } + + // 清除缓存 + Future clearCacheAll() async { + bool cleanStatus = await SmartDialog.show( + useSystem: true, + animationType: SmartAnimationType.centerFade_otherSlide, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('提示'), + content: const Text('该操作将清除图片及网络请求缓存数据,确认清除?'), + actions: [ + TextButton( + onPressed: (() => {SmartDialog.dismiss()}), + child: Text( + '取消', + style: TextStyle(color: Theme.of(context).colorScheme.outline), + ), + ), + TextButton( + onPressed: () async { + SmartDialog.dismiss(); + SmartDialog.showLoading(msg: '正在清除...'); + try { + // 清除缓存 图片缓存 + await clearLibraryCache(); + Timer(const Duration(milliseconds: 500), () { + SmartDialog.dismiss().then((res) { + SmartDialog.showToast('清除完成'); + }); + }); + } catch (err) { + SmartDialog.dismiss(); + SmartDialog.showToast(err.toString()); + } + }, + child: const Text('确认'), + ) + ], + ); + }, + ).then((res) { + return true; + }); + return cleanStatus; + } + + /// 清除 Documents 目录下的 DioCache.db + Future clearApplicationCache() async { + Directory directory = await getApplicationDocumentsDirectory(); + if (directory.existsSync()) { + String dioCacheFileName = + '${directory.path}${Platform.pathSeparator}DioCache.db'; + var dioCacheFile = File(dioCacheFileName); + if (dioCacheFile.existsSync()) { + dioCacheFile.delete(); + } + } + } + + // 清除 Library/Caches 目录及文件缓存 + Future clearLibraryCache() async { + var appDocDir = await getTemporaryDirectory(); + if (appDocDir.existsSync()) { + await appDocDir.delete(recursive: true); + } + } + + /// 递归方式删除目录及文件 + Future deleteDirectory(FileSystemEntity file) async { + if (file is Directory) { + final List children = file.listSync(); + for (final FileSystemEntity child in children) { + await deleteDirectory(child); + } + } + await file.delete(); + } +} From 0d5d33a365a4b103fe886865bc890ce0c9976976 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 8 Feb 2024 10:29:26 +0800 Subject: [PATCH 12/35] =?UTF-8?q?feat:=20up=E6=8A=95=E7=A8=BF=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/member_archive/controller.dart | 14 +++++--- lib/pages/member_archive/view.dart | 44 ++++++------------------ 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/lib/pages/member_archive/controller.dart b/lib/pages/member_archive/controller.dart index 785cd764..4c41de4c 100644 --- a/lib/pages/member_archive/controller.dart +++ b/lib/pages/member_archive/controller.dart @@ -25,7 +25,7 @@ class MemberArchiveController extends GetxController { // 获取用户投稿 Future getMemberArchive(type) async { - if (type == 'onRefresh') { + if (type == 'init') { pn = 1; } var res = await MemberHttp.memberArchive( @@ -34,7 +34,12 @@ class MemberArchiveController extends GetxController { order: currentOrder['type']!, ); if (res['status']) { - archivesList.addAll(res['data'].list.vlist); + if (type == 'init') { + archivesList.value = res['data'].list.vlist; + } + if (type == 'onLoad') { + archivesList.addAll(res['data'].list.vlist); + } count = res['data'].page['count']; pn += 1; } @@ -42,13 +47,14 @@ class MemberArchiveController extends GetxController { } toggleSort() async { - pn = 1; - int index = orderList.indexOf(currentOrder); + List typeList = orderList.map((e) => e['type']!).toList(); + int index = typeList.indexOf(currentOrder['type']!); if (index == orderList.length - 1) { currentOrder.value = orderList.first; } else { currentOrder.value = orderList[index + 1]; } + getMemberArchive('init'); } // 上拉加载 diff --git a/lib/pages/member_archive/view.dart b/lib/pages/member_archive/view.dart index 5091026e..0b5417b4 100644 --- a/lib/pages/member_archive/view.dart +++ b/lib/pages/member_archive/view.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/common/widgets/video_card_h.dart'; import 'package:pilipala/utils/utils.dart'; +import '../../common/constants.dart'; import 'controller.dart'; class MemberArchivePage extends StatefulWidget { @@ -48,39 +49,16 @@ class _MemberArchivePageState extends State { titleSpacing: 0, centerTitle: false, title: Text('他的投稿', style: Theme.of(context).textTheme.titleMedium), - // actions: [ - // Obx( - // () => PopupMenuButton( - // padding: EdgeInsets.zero, - // tooltip: '投稿排序', - // icon: Icon( - // Icons.more_vert_outlined, - // color: Theme.of(context).colorScheme.outline, - // ), - // position: PopupMenuPosition.under, - // onSelected: (String type) {}, - // itemBuilder: (BuildContext context) => >[ - // for (var i in _memberArchivesController.orderList) ...[ - // PopupMenuItem( - // onTap: () {}, - // value: _memberArchivesController.currentOrder['label'], - // child: Row( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Text(i['label']!), - // if (_memberArchivesController.currentOrder['label'] == - // i['label']) ...[ - // const SizedBox(width: 10), - // const Icon(Icons.done, size: 20), - // ], - // ], - // ), - // ), - // ] - // ], - // ), - // ), - // ], + actions: [ + Obx( + () => TextButton.icon( + icon: const Icon(Icons.sort, size: 20), + onPressed: _memberArchivesController.toggleSort, + label: Text(_memberArchivesController.currentOrder['label']!), + ), + ), + const SizedBox(width: 6), + ], ), body: CustomScrollView( controller: _memberArchivesController.scrollController, From fb8b2de115a1ebb84a583500e5e7e0561f74922b Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 8 Feb 2024 21:27:22 +0800 Subject: [PATCH 13/35] =?UTF-8?q?feat:=20up=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/api.dart | 3 + lib/http/member.dart | 37 +++++++ lib/pages/follow/view.dart | 42 ++++++++ lib/pages/follow/widgets/follow_item.dart | 2 +- lib/pages/follow_search/controller.dart | 73 +++++++++++++ lib/pages/follow_search/index.dart | 4 + lib/pages/follow_search/view.dart | 121 ++++++++++++++++++++++ lib/router/app_pages.dart | 6 +- 8 files changed, 286 insertions(+), 2 deletions(-) create mode 100644 lib/pages/follow_search/controller.dart create mode 100644 lib/pages/follow_search/index.dart create mode 100644 lib/pages/follow_search/view.dart diff --git a/lib/http/api.dart b/lib/http/api.dart index 532ca341..77694de7 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -214,6 +214,9 @@ class Api { // https://api.bilibili.com/x/relation/tags static const String followingsClass = '/x/relation/tags'; + // 搜索follow + static const followSearch = '/x/relation/followings/search'; + // 粉丝 // vmid 用户id pn 页码 ps 每页个数,最大50 order: desc // order_type 排序规则 最近访问传空,最常访问传 attention diff --git a/lib/http/member.dart b/lib/http/member.dart index bf84b6eb..6b6df7fe 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -461,4 +461,41 @@ class MemberHttp { }; } } + + // 搜索follow + static Future getfollowSearch({ + required int mid, + required int ps, + required int pn, + required String name, + }) async { + Map data = { + 'vmid': mid, + 'pn': pn, + 'ps': ps, + 'order': 'desc', + 'order_type': 'attention', + 'gaia_source': 'main_web', + 'name': name, + 'web_location': 333.999, + }; + Map params = await WbiSign().makSign(data); + var res = await Request().get(Api.followSearch, data: { + ...data, + 'w_rid': params['w_rid'], + 'wts': params['wts'], + }); + if (res.data['code'] == 0) { + return { + 'status': true, + 'data': FollowDataModel.fromJson(res.data['data']) + }; + } else { + return { + 'status': false, + 'data': [], + 'msg': res.data['message'], + }; + } + } } diff --git a/lib/pages/follow/view.dart b/lib/pages/follow/view.dart index a9fcab4e..9633e7f0 100644 --- a/lib/pages/follow/view.dart +++ b/lib/pages/follow/view.dart @@ -37,6 +37,29 @@ class _FollowPageState extends State { : '${_followController.name}的关注', style: Theme.of(context).textTheme.titleMedium, ), + actions: [ + IconButton( + onPressed: () => Get.toNamed('/followSearch?mid=$mid'), + icon: const Icon(Icons.search_outlined), + ), + PopupMenuButton( + icon: const Icon(Icons.more_vert), + itemBuilder: (BuildContext context) => [ + PopupMenuItem( + onTap: () => Get.toNamed('/blackListPage'), + child: const Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.block, size: 19), + SizedBox(width: 10), + Text('黑名单管理'), + ], + ), + ) + ], + ), + const SizedBox(width: 6), + ], ), body: Obx( () => !_followController.isOwner.value @@ -87,3 +110,22 @@ class _FollowPageState extends State { ); } } + +class _FakeAPI { + static const List _kOptions = [ + 'aardvark', + 'bobcat', + 'chameleon', + ]; + // Searches the options, but injects a fake "network" delay. + static Future> search(String query) async { + await Future.delayed( + const Duration(seconds: 1)); // Fake 1 second delay. + if (query == '') { + return const Iterable.empty(); + } + return _kOptions.where((String option) { + return option.contains(query.toLowerCase()); + }); + } +} diff --git a/lib/pages/follow/widgets/follow_item.dart b/lib/pages/follow/widgets/follow_item.dart index ac9cc01b..d21a89bc 100644 --- a/lib/pages/follow/widgets/follow_item.dart +++ b/lib/pages/follow/widgets/follow_item.dart @@ -42,7 +42,7 @@ class FollowItem extends StatelessWidget { overflow: TextOverflow.ellipsis, ), dense: true, - trailing: ctr!.isOwner.value + trailing: ctr != null && ctr!.isOwner.value ? SizedBox( height: 34, child: TextButton( diff --git a/lib/pages/follow_search/controller.dart b/lib/pages/follow_search/controller.dart new file mode 100644 index 00000000..9fd1590d --- /dev/null +++ b/lib/pages/follow_search/controller.dart @@ -0,0 +1,73 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:pilipala/http/member.dart'; + +import '../../models/follow/result.dart'; + +class FollowSearchController extends GetxController { + Rx controller = TextEditingController().obs; + final FocusNode searchFocusNode = FocusNode(); + RxString searchKeyWord = ''.obs; + String hintText = '搜索'; + RxString loadingStatus = 'init'.obs; + late int mid = 1; + RxString uname = ''.obs; + int ps = 20; + int pn = 1; + RxList followList = [].obs; + RxInt total = 0.obs; + + @override + void onInit() { + super.onInit(); + mid = int.parse(Get.parameters['mid']!); + } + + // 清空搜索 + void onClear() { + if (searchKeyWord.value.isNotEmpty && controller.value.text != '') { + controller.value.clear(); + searchKeyWord.value = ''; + } else { + Get.back(); + } + } + + void onChange(value) { + searchKeyWord.value = value; + } + + // 提交搜索内容 + void submit() { + loadingStatus.value = 'loading'; + searchFollow(); + } + + Future searchFollow({type = 'init'}) async { + if (controller.value.text == '') { + return {'status': true, 'data': [].obs}; + } + if (type == 'init') { + ps = 1; + } + var res = await MemberHttp.getfollowSearch( + mid: mid, + ps: ps, + pn: pn, + name: controller.value.text, + ); + if (res['status']) { + if (type == 'init') { + followList.value = res['data'].list; + } else { + followList.addAll(res['data'].list); + } + total.value = res['data'].total; + } + return res; + } + + void onLoad() { + searchFollow(type: 'onLoad'); + } +} diff --git a/lib/pages/follow_search/index.dart b/lib/pages/follow_search/index.dart new file mode 100644 index 00000000..805d8c47 --- /dev/null +++ b/lib/pages/follow_search/index.dart @@ -0,0 +1,4 @@ +library follow_search; + +export './controller.dart'; +export './view.dart'; diff --git a/lib/pages/follow_search/view.dart b/lib/pages/follow_search/view.dart new file mode 100644 index 00000000..6be42676 --- /dev/null +++ b/lib/pages/follow_search/view.dart @@ -0,0 +1,121 @@ +import 'package:easy_debounce/easy_throttle.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:pilipala/common/widgets/http_error.dart'; +import 'package:pilipala/pages/follow_search/index.dart'; + +import '../follow/widgets/follow_item.dart'; + +class FollowSearchPage extends StatefulWidget { + const FollowSearchPage({super.key}); + + @override + State createState() => _FollowSearchPageState(); +} + +class _FollowSearchPageState extends State { + final FollowSearchController _followSearchController = + Get.put(FollowSearchController()); + late Future? _futureBuilder; + final ScrollController scrollController = ScrollController(); + + @override + void initState() { + super.initState(); + _futureBuilder = _followSearchController.searchFollow(); + scrollController.addListener( + () { + if (scrollController.position.pixels >= + scrollController.position.maxScrollExtent - 200) { + EasyThrottle.throttle( + 'my-throttler', const Duration(milliseconds: 500), () { + _followSearchController.onLoad(); + }); + } + }, + ); + } + + void reRequest() { + setState(() { + _futureBuilder = _followSearchController.searchFollow(); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + titleSpacing: 0, + actions: [ + IconButton( + onPressed: reRequest, + icon: const Icon(CupertinoIcons.search, size: 22), + ), + const SizedBox(width: 6), + ], + title: TextField( + autofocus: true, + focusNode: _followSearchController.searchFocusNode, + controller: _followSearchController.controller.value, + textInputAction: TextInputAction.search, + onChanged: (value) => _followSearchController.onChange(value), + decoration: InputDecoration( + hintText: _followSearchController.hintText, + border: InputBorder.none, + suffixIcon: IconButton( + icon: Icon( + Icons.clear, + size: 22, + color: Theme.of(context).colorScheme.outline, + ), + onPressed: () => _followSearchController.onClear(), + ), + ), + onSubmitted: (String value) => reRequest(), + ), + ), + body: FutureBuilder( + future: _futureBuilder, + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + var data = snapshot.data; + if (data == null) { + return CustomScrollView( + slivers: [ + HttpError(errMsg: snapshot.data['msg'], fn: reRequest) + ], + ); + } + if (data['status']) { + RxList followList = _followSearchController.followList; + return Obx( + () => followList.isNotEmpty + ? ListView.builder( + controller: scrollController, + itemCount: followList.length, + itemBuilder: ((context, index) { + return FollowItem( + item: followList[index], + ); + }), + ) + : CustomScrollView( + slivers: [HttpError(errMsg: '未搜索到结果', fn: reRequest)], + ), + ); + } else { + return CustomScrollView( + slivers: [ + HttpError(errMsg: snapshot.data['msg'], fn: reRequest) + ], + ); + } + } else { + return const SizedBox(); + } + }), + ); + } +} diff --git a/lib/router/app_pages.dart b/lib/router/app_pages.dart index ff506630..45d7cad1 100644 --- a/lib/router/app_pages.dart +++ b/lib/router/app_pages.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; +import 'package:pilipala/pages/follow_search/view.dart'; import 'package:pilipala/pages/setting/pages/logs.dart'; import '../pages/about/index.dart'; @@ -104,7 +105,8 @@ class Routes { CustomGetPage( name: '/replyReply', page: () => const VideoReplyReplyPanel()), // 推荐设置 - CustomGetPage(name: '/recommendSetting', page: () => const RecommendSetting()), + CustomGetPage( + name: '/recommendSetting', page: () => const RecommendSetting()), // 播放设置 CustomGetPage(name: '/playSetting', page: () => const PlaySetting()), // 外观设置 @@ -156,6 +158,8 @@ class Routes { name: '/memberSeasons', page: () => const MemberSeasonsPage()), // 日志 CustomGetPage(name: '/logs', page: () => const LogsPage()), + // 搜索关注 + CustomGetPage(name: '/followSearch', page: () => const FollowSearchPage()), ]; } From 94f3b7c1e4797fbf04f3ee7124af5e5a50ea2481 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 8 Feb 2024 21:33:02 +0800 Subject: [PATCH 14/35] =?UTF-8?q?fix:=20minePage=20=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/mine/controller.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pages/mine/controller.dart b/lib/pages/mine/controller.dart index d1e17a83..5ad9e852 100644 --- a/lib/pages/mine/controller.dart +++ b/lib/pages/mine/controller.dart @@ -119,7 +119,7 @@ class MineController extends GetxController { SmartDialog.showToast('账号未登录'); return; } - Get.toNamed('/follow?mid=${userInfo.value.mid}'); + Get.toNamed('/follow?mid=${userInfo.value.mid}', preventDuplicates: false); } pushFans() { @@ -127,7 +127,7 @@ class MineController extends GetxController { SmartDialog.showToast('账号未登录'); return; } - Get.toNamed('/fan?mid=${userInfo.value.mid}'); + Get.toNamed('/fan?mid=${userInfo.value.mid}', preventDuplicates: false); } pushDynamic() { @@ -135,6 +135,7 @@ class MineController extends GetxController { SmartDialog.showToast('账号未登录'); return; } - Get.toNamed('/memberDynamics?mid=${userInfo.value.mid}'); + Get.toNamed('/memberDynamics?mid=${userInfo.value.mid}', + preventDuplicates: false); } } From 10b928474bfc96ccc32fd33d0a6b3b1ad5c1eea6 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 8 Feb 2024 22:46:39 +0800 Subject: [PATCH 15/35] mod --- lib/pages/live/widgets/live_item.dart | 36 ++++++++++++------ lib/pages/live_room/view.dart | 55 +++++++++++++++++---------- 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/lib/pages/live/widgets/live_item.dart b/lib/pages/live/widgets/live_item.dart index 8fa797fb..9218d4fb 100644 --- a/lib/pages/live/widgets/live_item.dart +++ b/lib/pages/live/widgets/live_item.dart @@ -184,18 +184,32 @@ class VideoStat extends StatelessWidget { tileMode: TileMode.mirror, ), ), - child: RichText( - maxLines: 1, - textAlign: TextAlign.justify, - softWrap: false, - text: TextSpan( - style: const TextStyle(fontSize: 11, color: Colors.white), - children: [ - TextSpan(text: liveItem!.areaName!), - TextSpan(text: liveItem!.watchedShow!['text_small']), - ], - ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + liveItem!.areaName!, + style: const TextStyle(fontSize: 11, color: Colors.white), + ), + Text( + liveItem!.watchedShow!['text_small'], + style: const TextStyle(fontSize: 11, color: Colors.white), + ), + ], ), + + // child: RichText( + // maxLines: 1, + // textAlign: TextAlign.justify, + // softWrap: false, + // text: TextSpan( + // style: const TextStyle(fontSize: 11, color: Colors.white), + // children: [ + // TextSpan(text: liveItem!.areaName!), + // TextSpan(text: liveItem!.watchedShow!['text_small']), + // ], + // ), + // ), ); } } diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index f727bfd0..20dfe403 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -79,27 +79,40 @@ class _LiveRoomPageState extends State { backgroundColor: Colors.black, body: Stack( children: [ - Obx( - () => - _liveRoomController.roomInfoH5.value.roomInfo?.appBackground != - '' - ? Positioned.fill( - child: Opacity( - opacity: 0.8, - child: NetworkImgLayer( - width: Get.width, - height: Get.height, - src: _liveRoomController - .roomInfoH5.value.roomInfo?.appBackground ?? - '', - ), - ), - ) - : Image.asset( - 'assets/images/live/default_bg.webp', - width: Get.width, - height: Get.height, - ), + // Obx( + // () => Positioned.fill( + // child: Opacity( + // opacity: 0.8, + // child: _liveRoomController + // .roomInfoH5.value.roomInfo?.appBackground != + // '' && + // _liveRoomController + // .roomInfoH5.value.roomInfo?.appBackground != + // null + // ? NetworkImgLayer( + // width: Get.width, + // height: Get.height, + // src: _liveRoomController + // .roomInfoH5.value.roomInfo?.appBackground ?? + // '', + // ) + // : Image.asset( + // 'assets/images/live/default_bg.webp', + // width: Get.width, + // height: Get.height, + // ), + // ), + // ), + // ), + Positioned.fill( + child: Opacity( + opacity: 0.8, + child: Image.asset( + 'assets/images/live/default_bg.webp', + width: Get.width, + height: Get.height, + ), + ), ), Column( children: [ From d0f036ec35a20f30b09b87d89cec0d813081c368 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 9 Feb 2024 09:32:28 +0800 Subject: [PATCH 16/35] =?UTF-8?q?fix:=20=E8=AF=84=E8=AE=BA=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=A4=9A=E5=BC=A0=E5=9B=BE=E7=89=87=E6=8B=89=E4=BC=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/reply/widgets/reply_item.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 7991a366..d6778293 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -797,8 +797,7 @@ InlineSpan buildContent( ), ), ); - } - if (len > 1) { + } else if (len > 1) { List list = []; for (var i = 0; i < len; i++) { picList.add(content.pictures[i]['img_src']); @@ -816,10 +815,11 @@ InlineSpan buildContent( ); }, child: NetworkImgLayer( - src: content.pictures[i]['img_src'], - width: box.maxWidth, - height: box.maxWidth, - ), + src: content.pictures[i]['img_src'], + width: box.maxWidth, + height: box.maxWidth, + origAspectRatio: content.pictures[i]['img_width'] / + content.pictures[i]['img_height']), ); }, ), From 44a162762cc134ec2b752021d05c89096fd8f2e6 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 9 Feb 2024 23:24:26 +0800 Subject: [PATCH 17/35] =?UTF-8?q?fix:=20=E8=AF=84=E8=AE=BA=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=B7=AF=E7=94=B1=E8=B7=B3=E8=BD=AC=20issues=20#405?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/reply/widgets/reply_item.dart | 74 +++++++++++++------ lib/utils/url_utils.dart | 61 +++++++++++++++ 2 files changed, 113 insertions(+), 22 deletions(-) create mode 100644 lib/utils/url_utils.dart diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 7991a366..fb76f4d4 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -1,7 +1,6 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/common/widgets/badge.dart'; @@ -12,10 +11,9 @@ import 'package:pilipala/pages/preview/index.dart'; import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/reply_new/index.dart'; import 'package:pilipala/utils/feed_back.dart'; -import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/storage.dart'; +import 'package:pilipala/utils/url_utils.dart'; import 'package:pilipala/utils/utils.dart'; - import 'zan.dart'; Box setting = GStrorage.setting; @@ -541,7 +539,6 @@ InlineSpan buildContent( // fReplyItem 父级回复内容,用作二楼回复(回复详情)展示 final content = replyItem.content; final List spanChilds = []; - bool hasMatchMember = false; // 投票 if (content.vote.isNotEmpty) { @@ -591,7 +588,7 @@ InlineSpan buildContent( if (patternStr.isNotEmpty) { patternStr += "|"; } - patternStr += r'(\b\d{1,2}[::]\d{2}\b)'; + patternStr += r'(\b\d{1,2}[::]\d{2}(?:[::]\d{2})?\b)'; final RegExp pattern = RegExp(patternStr); List matchedStrs = []; void addPlainTextSpan(str) { @@ -639,7 +636,9 @@ InlineSpan buildContent( }, ), ); - } else if (RegExp(r'^\b[0-9]{1,2}[::][0-9]{2}\b$').hasMatch(matchStr)) { + } else if (RegExp(r'^\b\d{1,2}[::]\d{2}(?:[::]\d{2})?\b$') + .hasMatch(matchStr)) { + matchStr = matchStr.replaceAll(':', ':'); spanChilds.add( TextSpan( text: ' $matchStr ', @@ -650,7 +649,6 @@ InlineSpan buildContent( ..onTap = () { // 跳转到指定位置 try { - matchStr = matchStr.replaceAll(':', ':'); SmartDialog.showToast('跳转至:$matchStr'); Get.find(tag: Get.arguments['heroTag']) .plPlayerController @@ -692,16 +690,54 @@ InlineSpan buildContent( color: Theme.of(context).colorScheme.primary, ), recognizer: TapGestureRecognizer() - ..onTap = () { + ..onTap = () async { + final String title = content.jumpUrl[matchStr]['title']; if (appUrlSchema == '') { - final String str = Uri.parse(matchStr).pathSegments[0]; - final Map matchRes = IdUtils.matchAvorBv(input: str); - final List matchKeys = matchRes.keys.toList(); - if (matchKeys.isNotEmpty) { - if (matchKeys.first == 'BV') { + final String redirectUrl = + await UrlUtils.parseRedirectUrl(matchStr); + final String pathSegment = Uri.parse(redirectUrl).path; + final String lastPathSegment = + pathSegment.split('/').last; + if (lastPathSegment.startsWith('BV')) { + UrlUtils.matchUrlPush( + lastPathSegment, + title, + redirectUrl, + ); + } else { + Get.toNamed( + '/webview', + parameters: { + 'url': redirectUrl, + 'type': 'url', + 'pageTitle': title + }, + ); + } + } else { + if (appUrlSchema.startsWith('bilibili://search')) { + Get.toNamed('/searchResult', + parameters: {'keyword': title}); + } else if (matchStr.startsWith('https://b23.tv')) { + final String redirectUrl = + await UrlUtils.parseRedirectUrl(matchStr); + final String pathSegment = Uri.parse(redirectUrl).path; + final String lastPathSegment = + pathSegment.split('/').last; + if (lastPathSegment.startsWith('BV')) { + UrlUtils.matchUrlPush( + lastPathSegment, + title, + redirectUrl, + ); + } else { Get.toNamed( - '/searchResult', - parameters: {'keyword': matchRes['BV']}, + '/webview', + parameters: { + 'url': redirectUrl, + 'type': 'url', + 'pageTitle': title + }, ); } } else { @@ -710,16 +746,10 @@ InlineSpan buildContent( parameters: { 'url': matchStr, 'type': 'url', - 'pageTitle': '' + 'pageTitle': title }, ); } - } else { - if (appUrlSchema.startsWith('bilibili://search')) { - Get.toNamed('/searchResult', parameters: { - 'keyword': content.jumpUrl[matchStr]['title'] - }); - } } }, ) diff --git a/lib/utils/url_utils.dart b/lib/utils/url_utils.dart new file mode 100644 index 00000000..bac6cdfa --- /dev/null +++ b/lib/utils/url_utils.dart @@ -0,0 +1,61 @@ +import 'package:dio/dio.dart'; +import 'package:get/get.dart'; + +import '../http/search.dart'; +import 'id_utils.dart'; +import 'utils.dart'; + +class UrlUtils { + // 302重定向路由截取 + static Future parseRedirectUrl(String url) async { + late String redirectUrl; + final dio = Dio(); + dio.options.followRedirects = false; + dio.options.validateStatus = (status) { + return status == 200 || status == 301 || status == 302; + }; + final response = await dio.get(url); + if (response.statusCode == 302) { + redirectUrl = response.headers['location']?.first as String; + if (redirectUrl.endsWith('/')) { + redirectUrl = redirectUrl.substring(0, redirectUrl.length - 1); + } + } else { + if (url.endsWith('/')) { + url = url.substring(0, url.length - 1); + } + return url; + } + return redirectUrl; + } + + // 匹配url路由跳转 + static matchUrlPush( + String pathSegment, + String title, + String redirectUrl, + ) async { + final Map matchRes = IdUtils.matchAvorBv(input: pathSegment); + if (matchRes.containsKey('BV')) { + final String bv = matchRes['BV']; + final int cid = await SearchHttp.ab2c(bvid: bv); + final String heroTag = Utils.makeHeroTag(bv); + await Get.toNamed( + '/video?bvid=$bv&cid=$cid', + arguments: { + 'pic': '', + 'heroTag': heroTag, + }, + ); + } else { + await Get.toNamed( + '/webview', + parameters: { + 'url': redirectUrl, + 'type': 'url', + 'pageTitle': title, + }, + ); + } + } +} From 3d5ebe7e99a1340e14618ca934d5600ee591a3b8 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 10 Feb 2024 19:57:10 +0800 Subject: [PATCH 18/35] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E8=AF=84=E8=AE=BA=E9=87=8D=E5=A4=8D=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/reply/controller.dart | 3 +++ lib/pages/video/detail/reply/view.dart | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pages/video/detail/reply/controller.dart b/lib/pages/video/detail/reply/controller.dart index 5781cbba..bfcd0e80 100644 --- a/lib/pages/video/detail/reply/controller.dart +++ b/lib/pages/video/detail/reply/controller.dart @@ -53,6 +53,9 @@ class VideoReplyController extends GetxController { } Future queryReplyList({type = 'init'}) async { + if (isLoadingMore) { + return; + } isLoadingMore = true; if (type == 'init') { currentPage = 0; diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index b2c67b1e..9b7546af 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -75,7 +75,8 @@ class _VideoReplyPanelState extends State () { if (scrollController.position.pixels >= scrollController.position.maxScrollExtent - 300) { - EasyThrottle.throttle('replylist', const Duration(seconds: 2), () { + EasyThrottle.throttle('replylist', const Duration(milliseconds: 200), + () { _videoReplyController.onLoad(); }); } From 289cc99bc2a88cce0b0f6596a78ee0c40594bdb6 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 11 Feb 2024 09:10:45 +0800 Subject: [PATCH 19/35] mod --- lib/pages/member_archive/view.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pages/member_archive/view.dart b/lib/pages/member_archive/view.dart index 0b5417b4..43867323 100644 --- a/lib/pages/member_archive/view.dart +++ b/lib/pages/member_archive/view.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/common/widgets/video_card_h.dart'; import 'package:pilipala/utils/utils.dart'; -import '../../common/constants.dart'; import 'controller.dart'; class MemberArchivePage extends StatefulWidget { @@ -26,8 +25,7 @@ class _MemberArchivePageState extends State { final String heroTag = Utils.makeHeroTag(mid); _memberArchivesController = Get.put(MemberArchiveController(), tag: heroTag); - _futureBuilderFuture = - _memberArchivesController.getMemberArchive('onRefresh'); + _futureBuilderFuture = _memberArchivesController.getMemberArchive('init'); scrollController = _memberArchivesController.scrollController; scrollController.addListener( () { From e2fd01a6d5154d3f068a60b0bbecad3420447c04 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 11 Feb 2024 18:47:51 +0800 Subject: [PATCH 20/35] =?UTF-8?q?fix:=20video=20Storage=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 1 - lib/utils/storage.dart | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 5849f8a3..fc2149de 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -70,7 +70,6 @@ void main() async { statusBarColor: Colors.transparent, )); Data.init(); - GStrorage.lazyInit(); PiliSchame.init(); }); } diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 1b0b0c37..41ec0ce8 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -42,6 +42,8 @@ class GStrorage { return deletedEntries > 10; }, ); + // 视频设置 + video = await Hive.openBox('video'); } static void regAdapter() { @@ -52,11 +54,6 @@ class GStrorage { Hive.registerAdapter(HotSearchItemAdapter()); } - static Future lazyInit() async { - // 视频设置 - video = await Hive.openBox('video'); - } - static Future close() async { // user.compact(); // user.close(); From b264427be603759271d954535cfb12bfbd05eb16 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 11 Feb 2024 23:07:44 +0800 Subject: [PATCH 21/35] =?UTF-8?q?fix:=20=E5=88=87=E6=8D=A2=E5=90=88?= =?UTF-8?q?=E9=9B=86=E8=AF=84=E8=AE=BA=E4=B8=8D=E5=88=B7=E6=96=B0=20issues?= =?UTF-8?q?=20#326=20#525?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/controller.dart | 6 ++++-- lib/pages/video/detail/introduction/controller.dart | 1 + lib/pages/video/detail/reply/controller.dart | 1 + lib/pages/video/detail/reply/view.dart | 11 +++++++---- lib/pages/video/detail/view.dart | 7 +++++-- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index f36eb589..0162654f 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -19,6 +19,7 @@ import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/utils/video_utils.dart'; import 'package:screen_brightness/screen_brightness.dart'; +import '../../../utils/id_utils.dart'; import 'widgets/header_control.dart'; class VideoDetailController extends GetxController @@ -61,7 +62,7 @@ class VideoDetailController extends GetxController Box localCache = GStrorage.localCache; Box setting = GStrorage.setting; - int oid = 0; + RxInt oid = 0.obs; // 评论id 请求楼中楼评论使用 int fRpid = 0; @@ -135,13 +136,14 @@ class VideoDetailController extends GetxController defaultValue: VideoDecodeFormats.values.last.code); cacheAudioQa = setting.get(SettingBoxKey.defaultAudioQa, defaultValue: AudioQuality.hiRes.code); + oid.value = IdUtils.bv2av(Get.parameters['bvid']!); } showReplyReplyPanel() { PersistentBottomSheetController? ctr = scaffoldKey.currentState?.showBottomSheet((BuildContext context) { return VideoReplyReplyPanel( - oid: oid, + oid: oid.value, rpid: fRpid, closePanel: () => { fRpid = 0, diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index d1298fcc..fc92fb56 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -476,6 +476,7 @@ class VideoIntroController extends GetxController { final VideoDetailController videoDetailCtr = Get.find(tag: heroTag); videoDetailCtr.bvid = bvid; + videoDetailCtr.oid.value = aid; videoDetailCtr.cid.value = cid; videoDetailCtr.danmakuCid.value = cid; videoDetailCtr.queryVideoUrl(); diff --git a/lib/pages/video/detail/reply/controller.dart b/lib/pages/video/detail/reply/controller.dart index bfcd0e80..e564ef02 100644 --- a/lib/pages/video/detail/reply/controller.dart +++ b/lib/pages/video/detail/reply/controller.dart @@ -59,6 +59,7 @@ class VideoReplyController extends GetxController { isLoadingMore = true; if (type == 'init') { currentPage = 0; + noMore.value = ''; } if (noMore.value == '没有更多了') { return; diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index 9b7546af..8489cbb1 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -16,11 +16,13 @@ import 'widgets/reply_item.dart'; class VideoReplyPanel extends StatefulWidget { final String? bvid; + final int? oid; final int rpid; final String? replyLevel; const VideoReplyPanel({ this.bvid, + this.oid, this.rpid = 0, this.replyLevel, super.key, @@ -48,16 +50,17 @@ class _VideoReplyPanelState extends State @override void initState() { super.initState(); - int oid = widget.bvid != null ? IdUtils.bv2av(widget.bvid!) : 0; + // int oid = widget.bvid != null ? IdUtils.bv2av(widget.bvid!) : 0; heroTag = Get.arguments['heroTag']; replyLevel = widget.replyLevel ?? '1'; if (replyLevel == '2') { _videoReplyController = Get.put( - VideoReplyController(oid, widget.rpid.toString(), replyLevel), + VideoReplyController(widget.oid, widget.rpid.toString(), replyLevel), tag: widget.rpid.toString()); } else { - _videoReplyController = - Get.put(VideoReplyController(oid, '', replyLevel), tag: heroTag); + _videoReplyController = Get.put( + VideoReplyController(widget.oid, '', replyLevel), + tag: heroTag); } fabAnimationCtr = AnimationController( diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 3644fa41..14311cc9 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -570,8 +570,11 @@ class _VideoDetailPageState extends State ); }, ), - VideoReplyPanel( - bvid: videoDetailController.bvid, + Obx( + () => VideoReplyPanel( + bvid: videoDetailController.bvid, + oid: videoDetailController.oid.value, + ), ) ], ), From 89026e671c01b4b6d8fc686c44fa01b47c6d87dd Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 12 Feb 2024 10:07:29 +0800 Subject: [PATCH 22/35] =?UTF-8?q?mod:=20=E6=94=B6=E8=97=8F=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E7=9B=B8=E5=85=B3=20issues=20#51=20#534?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/video.dart | 8 +- .../fav_detail/widget/fav_video_card.dart | 174 +++++++++--------- .../video/detail/introduction/controller.dart | 5 +- 3 files changed, 100 insertions(+), 87 deletions(-) diff --git a/lib/http/video.dart b/lib/http/video.dart index d0faabaa..0df814be 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -51,7 +51,7 @@ class VideoHttp { (i['owner'] != null && !blackMidsList.contains(i['owner']['mid']))) { RecVideoItemModel videoItem = RecVideoItemModel.fromJson(i); - if (!RecommendFilter.filter(videoItem)){ + if (!RecommendFilter.filter(videoItem)) { list.add(videoItem); } } @@ -98,7 +98,7 @@ class VideoHttp { (i['args'] != null && !blackMidsList.contains(i['args']['up_mid']))) { RecVideoItemAppModel videoItem = RecVideoItemAppModel.fromJson(i); - if (!RecommendFilter.filter(videoItem)){ + if (!RecommendFilter.filter(videoItem)) { list.add(videoItem); } } @@ -217,7 +217,7 @@ class VideoHttp { List list = []; for (var i in res.data['data']) { HotVideoItemModel videoItem = HotVideoItemModel.fromJson(i); - if (!RecommendFilter.filter(videoItem, relatedVideos: true)){ + if (!RecommendFilter.filter(videoItem, relatedVideos: true)) { list.add(videoItem); } } @@ -322,7 +322,7 @@ class VideoHttp { if (res.data['code'] == 0) { return {'status': true, 'data': res.data['data']}; } else { - return {'status': false, 'data': []}; + return {'status': false, 'data': [], 'msg': res.data['message']}; } } diff --git a/lib/pages/fav_detail/widget/fav_video_card.dart b/lib/pages/fav_detail/widget/fav_video_card.dart index a4f22f6b..a3c1e8e5 100644 --- a/lib/pages/fav_detail/widget/fav_video_card.dart +++ b/lib/pages/fav_detail/widget/fav_video_card.dart @@ -130,97 +130,107 @@ class VideoContent extends StatelessWidget { return Expanded( child: Padding( padding: const EdgeInsets.fromLTRB(10, 2, 6, 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: Stack( children: [ - Text( - videoItem.title, - textAlign: TextAlign.start, - style: const TextStyle( - fontWeight: FontWeight.w500, - letterSpacing: 0.3, - ), - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - if (videoItem.ogv != null) ...[ - Text( - videoItem.intro, - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, - color: Theme.of(context).colorScheme.outline, - ), - ), - ], - const Spacer(), - Text( - Utils.dateFormat(videoItem.favTime), - style: TextStyle( - fontSize: 11, color: Theme.of(context).colorScheme.outline), - ), - if (videoItem.owner.name != '') ...[ - Text( - videoItem.owner.name, - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, - color: Theme.of(context).colorScheme.outline, - ), - ), - ], - Row( + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - StatView( - theme: 'gray', - view: videoItem.cntInfo['play'], + Text( + videoItem.title, + textAlign: TextAlign.start, + style: const TextStyle( + fontWeight: FontWeight.w500, + letterSpacing: 0.3, + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, ), - const SizedBox(width: 8), - StatDanMu(theme: 'gray', danmu: videoItem.cntInfo['danmaku']), - const Spacer(), - SizedBox( - width: 26, - height: 26, - child: IconButton( - style: ButtonStyle( - padding: MaterialStateProperty.all(EdgeInsets.zero), - ), - onPressed: () { - showDialog( - context: Get.context!, - builder: (context) { - return AlertDialog( - title: const Text('提示'), - content: const Text('要取消收藏吗?'), - actions: [ - TextButton( - onPressed: () => Get.back(), - child: Text( - '取消', - style: TextStyle( - color: Theme.of(context) - .colorScheme - .outline), - )), - TextButton( - onPressed: () async { - await callFn!(); - Get.back(); - }, - child: const Text('确定取消'), - ) - ], - ); - }, - ); - }, - icon: Icon( - Icons.clear_outlined, + if (videoItem.ogv != null) ...[ + Text( + videoItem.intro, + style: TextStyle( + fontSize: + Theme.of(context).textTheme.labelMedium!.fontSize, color: Theme.of(context).colorScheme.outline, - size: 18, ), ), + ], + const Spacer(), + Text( + Utils.dateFormat(videoItem.favTime), + style: TextStyle( + fontSize: 11, + color: Theme.of(context).colorScheme.outline), + ), + if (videoItem.owner.name != '') ...[ + Text( + videoItem.owner.name, + style: TextStyle( + fontSize: + Theme.of(context).textTheme.labelMedium!.fontSize, + color: Theme.of(context).colorScheme.outline, + ), + ), + ], + Padding( + padding: const EdgeInsets.only(top: 2), + child: Row( + children: [ + StatView( + theme: 'gray', + view: videoItem.cntInfo['play'], + ), + const SizedBox(width: 8), + StatDanMu( + theme: 'gray', danmu: videoItem.cntInfo['danmaku']), + const Spacer(), + ], + ), ), ], ), + Positioned( + right: 0, + bottom: -4, + child: IconButton( + style: ButtonStyle( + padding: MaterialStateProperty.all(EdgeInsets.zero), + ), + onPressed: () { + showDialog( + context: Get.context!, + builder: (context) { + return AlertDialog( + title: const Text('提示'), + content: const Text('要取消收藏吗?'), + actions: [ + TextButton( + onPressed: () => Get.back(), + child: Text( + '取消', + style: TextStyle( + color: + Theme.of(context).colorScheme.outline), + )), + TextButton( + onPressed: () async { + await callFn!(); + Get.back(); + }, + child: const Text('确定取消'), + ) + ], + ); + }, + ); + }, + icon: Icon( + Icons.clear_outlined, + color: Theme.of(context).colorScheme.outline, + size: 18, + ), + ), + ), ], ), ), diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index fc92fb56..4672b4bd 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -298,7 +298,6 @@ class VideoIntroController extends GetxController { await queryVideoInFolder(); int defaultFolderId = favFolderData.value.list!.first.id!; int favStatus = favFolderData.value.list!.first.favState!; - print('favStatus: $favStatus'); var result = await VideoHttp.favVideo( aid: IdUtils.bv2av(bvid), addIds: favStatus == 0 ? '$defaultFolderId' : '', @@ -310,6 +309,8 @@ class VideoIntroController extends GetxController { await queryHasFavVideo(); SmartDialog.showToast('✅ 操作成功'); } + } else { + SmartDialog.showToast(result['msg']); } return; } @@ -340,6 +341,8 @@ class VideoIntroController extends GetxController { await queryHasFavVideo(); SmartDialog.showToast('✅ 操作成功'); } + } else { + SmartDialog.showToast(result['msg']); } } From 5e59db85be3ccfd7a3ee9ad6cc50c97021f507e5 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 12 Feb 2024 16:51:05 +0800 Subject: [PATCH 23/35] =?UTF-8?q?fix:=20=E8=AF=84=E8=AE=BA=E7=AC=94?= =?UTF-8?q?=E8=AE=B0=E8=B7=B3=E8=BD=AC=20issues=20#472?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/reply/view.dart | 2 +- .../detail/reply/widgets/reply_item.dart | 55 +++++++++++++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index 8489cbb1..df8c75b1 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -114,7 +114,7 @@ class _VideoReplyPanelState extends State final VideoDetailController videoDetailCtr = Get.find(tag: heroTag); if (replyItem != null) { - videoDetailCtr.oid = replyItem.oid; + videoDetailCtr.oid.value = replyItem.oid; videoDetailCtr.fRpid = replyItem.rpid!; videoDetailCtr.firstFloor = replyItem; videoDetailCtr.showReplyReplyPanel(); diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 7991a366..a9e1044e 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -739,6 +739,47 @@ InlineSpan buildContent( }, ); + if (content.jumpUrl.keys.isNotEmpty) { + List unmatchedItems = content.jumpUrl.keys + .toList() + .where((item) => !content.message.contains(item)) + .toList(); + if (unmatchedItems.isNotEmpty) { + for (int i = 0; i < unmatchedItems.length; i++) { + String patternStr = unmatchedItems[i]; + spanChilds.addAll( + [ + if (content.jumpUrl[patternStr]?['prefix_icon'] != null) ...[ + WidgetSpan( + child: Image.network( + content.jumpUrl[patternStr]['prefix_icon'], + height: 19, + color: Theme.of(context).colorScheme.primary, + ), + ) + ], + TextSpan( + text: content.jumpUrl[patternStr]['title'], + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + Get.toNamed( + '/webview', + parameters: { + 'url': patternStr, + 'type': 'url', + 'pageTitle': content.jumpUrl[patternStr]['title'] + }, + ); + }, + ) + ], + ); + } + } + } // 图片渲染 if (content.pictures.isNotEmpty) { final List picList = []; @@ -753,11 +794,15 @@ InlineSpan buildContent( builder: (BuildContext context, BoxConstraints box) { double maxHeight = box.maxWidth * 0.6; // 设置最大高度 // double width = (box.maxWidth / 2).truncateToDouble(); - double height = ((box.maxWidth / - 2 * - pictureItem['img_height'] / - pictureItem['img_width'])) - .truncateToDouble(); + double height = 100; + try { + height = ((box.maxWidth / + 2 * + pictureItem['img_height'] / + pictureItem['img_width'])) + .truncateToDouble(); + } catch (_) {} + return GestureDetector( onTap: () { showDialog( From b817a0c80775c9ab5d7ca1521d98afc7e988f4da Mon Sep 17 00:00:00 2001 From: KoolShow <51787949+KoolShow@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:20:18 +0800 Subject: [PATCH 24/35] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E4=BB=A5=E5=8C=B9=E9=85=8D=E5=90=AB?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E7=9A=84=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/reply/widgets/reply_item.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 929d9c03..773ad3b1 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -591,7 +591,7 @@ InlineSpan buildContent( if (patternStr.isNotEmpty) { patternStr += "|"; } - patternStr += r'(\b\d{1,2}[::]\d{2}\b)'; + patternStr += r'(\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b)'; final RegExp pattern = RegExp(patternStr); List matchedStrs = []; void addPlainTextSpan(str) { @@ -639,7 +639,7 @@ InlineSpan buildContent( }, ), ); - } else if (RegExp(r'^\b[0-9]{1,2}[::][0-9]{2}\b$').hasMatch(matchStr)) { + } else if (RegExp(r'^\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b$').hasMatch(matchStr)) { spanChilds.add( TextSpan( text: ' $matchStr ', From cdf800c49f41731240ae9657c8dcb7fd88104c92 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 13 Feb 2024 23:33:51 +0800 Subject: [PATCH 25/35] =?UTF-8?q?mod:=20=E8=AF=84=E8=AE=BA=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E9=80=BB=E8=BE=91=20issues=20#420=20#331=20#297=20=20?= =?UTF-8?q?#152?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/reply/widgets/reply_item.dart | 259 ++++++++++-------- 1 file changed, 142 insertions(+), 117 deletions(-) diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 46efc4f9..d0bcbaec 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -1,5 +1,6 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; @@ -46,6 +47,17 @@ class ReplyItem extends StatelessWidget { replyReply!(replyItem); } }, + onLongPress: () { + feedBack(); + showModalBottomSheet( + context: context, + useRootNavigator: true, + isScrollControlled: true, + builder: (context) { + return MorePanel(item: replyItem); + }, + ); + }, child: Column( children: [ Padding( @@ -121,98 +133,6 @@ class ReplyItem extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // 头像、昵称 - // SizedBox( - // width: double.infinity, - // child: Stack( - // children: [ - // GestureDetector( - // behavior: HitTestBehavior.opaque, - // onTap: () { - // feedBack(); - // Get.toNamed('/member?mid=${replyItem!.mid}', arguments: { - // 'face': replyItem!.member!.avatar!, - // 'heroTag': heroTag - // }); - // }, - // child: Row( - // crossAxisAlignment: CrossAxisAlignment.center, - // mainAxisSize: MainAxisSize.min, - // children: [ - // lfAvtar(context, heroTag), - // const SizedBox(width: 12), - // Text( - // replyItem!.member!.uname!, - // style: TextStyle( - // color: replyItem!.member!.vip!['vipStatus'] > 0 - // ? const Color.fromARGB(255, 251, 100, 163) - // : Theme.of(context).colorScheme.outline, - // fontSize: 13, - // ), - // ), - // const SizedBox(width: 6), - // Image.asset( - // 'assets/images/lv/lv${replyItem!.member!.level}.png', - // height: 11, - // ), - // const SizedBox(width: 6), - // if (replyItem!.isUp!) - // const PBadge( - // text: 'UP', - // size: 'small', - // stack: 'normal', - // fs: 9, - // ), - // ], - // ), - // ), - // Positioned( - // top: 0, - // left: 0, - // right: 0, - // child: Container( - // width: double.infinity, - // height: 45, - // decoration: BoxDecoration( - // image: replyItem!.member!.userSailing!.cardbg != null - // ? DecorationImage( - // alignment: Alignment.centerRight, - // fit: BoxFit.fitHeight, - // image: NetworkImage( - // replyItem!.member!.userSailing!.cardbg!['image'], - // ), - // ) - // : null, - // ), - // ), - // ), - // if (replyItem!.member!.userSailing!.cardbg != null && - // replyItem!.member!.userSailing!.cardbg!['fan']['number'] > 0) - // Positioned( - // top: 10, - // left: Get.size.width / 7 * 5.8, - // child: DefaultTextStyle( - // style: TextStyle( - // fontFamily: 'fansCard', - // fontSize: 9, - // color: Theme.of(context).colorScheme.primary, - // ), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisAlignment: MainAxisAlignment.center, - // children: [ - // const Text('NO.'), - // Text( - // replyItem!.member!.userSailing!.cardbg!['fan'] - // ['num_desc'], - // ), - // ], - // ), - // ), - // ), - // ], - // ), - // ), /// fix Stack内GestureDetector onTap无效 GestureDetector( behavior: HitTestBehavior.opaque, @@ -289,30 +209,26 @@ class ReplyItem extends StatelessWidget { // title Container( margin: const EdgeInsets.only(top: 10, left: 45, right: 6, bottom: 4), - child: SelectableRegion( - focusNode: FocusNode(), - selectionControls: MaterialTextSelectionControls(), - child: Text.rich( - style: const TextStyle(height: 1.75), - maxLines: - replyItem!.content!.isText! && replyLevel == '1' ? 3 : 999, - overflow: TextOverflow.ellipsis, - TextSpan( - children: [ - if (replyItem!.isTop!) - const WidgetSpan( - alignment: PlaceholderAlignment.top, - child: PBadge( - text: 'TOP', - size: 'small', - stack: 'normal', - type: 'line', - fs: 9, - ), + child: Text.rich( + style: const TextStyle(height: 1.75), + maxLines: + replyItem!.content!.isText! && replyLevel == '1' ? 3 : 999, + overflow: TextOverflow.ellipsis, + TextSpan( + children: [ + if (replyItem!.isTop!) + const WidgetSpan( + alignment: PlaceholderAlignment.top, + child: PBadge( + text: 'TOP', + size: 'small', + stack: 'normal', + type: 'line', + fs: 9, ), - buildContent(context, replyItem!, replyReply, null), - ], - ), + ), + buildContent(context, replyItem!, replyReply, null), + ], ), ), ), @@ -445,6 +361,17 @@ class ReplyItemRow extends StatelessWidget { InkWell( // 一楼点击评论展开评论详情 onTap: () => replyReply!(replyItem), + onLongPress: () { + feedBack(); + showModalBottomSheet( + context: context, + useRootNavigator: true, + isScrollControlled: true, + builder: (context) { + return MorePanel(item: replies![i]); + }, + ); + }, child: Container( width: double.infinity, padding: EdgeInsets.fromLTRB( @@ -636,8 +563,8 @@ InlineSpan buildContent( }, ), ); - - } else if (RegExp(r'^\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b$').hasMatch(matchStr)) { + } else if (RegExp(r'^\b(?:\d+[::])?[0-5]?[0-9][::][0-5]?[0-9]\b$') + .hasMatch(matchStr)) { matchStr = matchStr.replaceAll(':', ':'); spanChilds.add( TextSpan( @@ -955,3 +882,101 @@ InlineSpan buildContent( // spanChilds.add(TextSpan(text: matchMember)); return TextSpan(children: spanChilds); } + +class MorePanel extends StatelessWidget { + final dynamic item; + const MorePanel({super.key, required this.item}); + + Future menuActionHandler(String type) async { + String message = item.content.message ?? item.content; + switch (type) { + case 'copyAll': + await Clipboard.setData(ClipboardData(text: message)); + SmartDialog.showToast('已复制'); + Get.back(); + break; + case 'copyFreedom': + Get.back(); + showDialog( + context: Get.context!, + builder: (context) { + return AlertDialog( + title: const Text('自由复制'), + content: SelectableText(message), + ); + }, + ); + break; + // case 'block': + // SmartDialog.showToast('加入黑名单'); + // break; + // case 'report': + // SmartDialog.showToast('举报'); + // break; + // case 'delete': + // SmartDialog.showToast('删除'); + // break; + default: + } + } + + @override + Widget build(BuildContext context) { + Color errorColor = Theme.of(context).colorScheme.error; + return Container( + padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), + // clipBehavior: Clip.hardEdge, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + InkWell( + onTap: () => Get.back(), + child: Container( + height: 48, + padding: const EdgeInsets.only(bottom: 2), + child: Center( + child: Container( + width: 32, + height: 3, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.outline, + borderRadius: const BorderRadius.all(Radius.circular(3))), + ), + ), + ), + ), + ListTile( + onTap: () async => await menuActionHandler('copyAll'), + minLeadingWidth: 0, + leading: const Icon(Icons.copy_all_outlined), + title: const Text('复制全部'), + ), + ListTile( + onTap: () async => await menuActionHandler('copyFreedom'), + minLeadingWidth: 0, + leading: const Icon(Icons.copy_outlined), + title: const Text('自由复制'), + ), + // ListTile( + // onTap: () async => await menuActionHandler('block'), + // minLeadingWidth: 0, + // leading: Icon(Icons.block_outlined, color: errorColor), + // title: Text('加入黑名单', style: TextStyle(color: errorColor)), + // ), + // ListTile( + // onTap: () async => await menuActionHandler('report'), + // minLeadingWidth: 0, + // leading: Icon(Icons.report_outlined, color: errorColor), + // title: Text('举报', style: TextStyle(color: errorColor)), + // ), + // ListTile( + // onTap: () async => await menuActionHandler('del'), + // minLeadingWidth: 0, + // leading: Icon(Icons.delete_outline, color: errorColor), + // title: Text('删除', style: TextStyle(color: errorColor)), + // ), + ], + ), + ); + } +} From 42ad9591558df4bfd0cbe34575f60ce2cee04b12 Mon Sep 17 00:00:00 2001 From: orz12 Date: Wed, 14 Feb 2024 08:38:01 +0800 Subject: [PATCH 26/35] =?UTF-8?q?fix:=20=E9=80=9F=E5=BA=A6=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=97=A0=E6=B3=95=E5=8F=96=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/widgets/header_control.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 3af35efd..8bc7d84e 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -438,7 +438,7 @@ class _HeaderControlState extends State { }), actions: [ TextButton( - onPressed: () => SmartDialog.dismiss(), + onPressed: () => Get.back(), child: Text( '取消', style: TextStyle(color: Theme.of(context).colorScheme.outline), From 3efad736aeefb10f3047b9e8e988be0be34b1138 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 14 Feb 2024 19:38:55 +0800 Subject: [PATCH 27/35] =?UTF-8?q?fix:=20=E7=9B=B4=E6=92=AD=E9=97=AA?= =?UTF-8?q?=E9=80=80=20issues=20#540?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/live_room/controller.dart | 10 ---------- lib/pages/live_room/view.dart | 16 ++++++---------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index 56da0a78..ee7b8214 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -3,7 +3,6 @@ import 'package:pilipala/http/constants.dart'; import 'package:pilipala/http/live.dart'; import 'package:pilipala/models/live/room_info.dart'; import 'package:pilipala/plugin/pl_player/index.dart'; - import '../../models/live/room_info_h5.dart'; class LiveRoomController extends GetxController { @@ -16,13 +15,6 @@ class LiveRoomController extends GetxController { RxBool volumeOff = false.obs; PlPlayerController plPlayerController = PlPlayerController.getInstance(videoType: 'live'); - - // MeeduPlayerController meeduPlayerController = MeeduPlayerController( - // colorTheme: Theme.of(Get.context!).colorScheme.primary, - // pipEnabled: true, - // controlsStyle: ControlsStyle.live, - // enabledButtons: const EnabledButtons(pip: true), - // ); Rx roomInfoH5 = RoomInfoH5Model().obs; @override @@ -39,8 +31,6 @@ class LiveRoomController extends GetxController { cover = liveItem.cover; } } - queryLiveInfo(); - queryLiveInfoH5(); } playerInit(source) async { diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 20dfe403..39800b90 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -29,22 +29,18 @@ class _LiveRoomPageState extends State { @override void initState() { super.initState(); - plPlayerController = _liveRoomController.plPlayerController; - plPlayerController!.onPlayerStatusChanged.listen( - (PlayerStatus status) { - if (status == PlayerStatus.playing) { - isShowCover = false; - setState(() {}); - } - }, - ); if (Platform.isAndroid) { floating = Floating(); } - _futureBuilder = _liveRoomController.queryLiveInfoH5(); + videoSourceInit(); _futureBuilderFuture = _liveRoomController.queryLiveInfo(); } + Future videoSourceInit() async { + _futureBuilder = _liveRoomController.queryLiveInfoH5(); + plPlayerController = _liveRoomController.plPlayerController; + } + @override void dispose() { plPlayerController!.dispose(); From d95fe9fe14465da7cce7faa36de973ce09d5d21a Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 15 Feb 2024 21:07:23 +0800 Subject: [PATCH 28/35] =?UTF-8?q?mod:=20MorePanel=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/reply/widgets/reply_item.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index d0bcbaec..dc242216 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -925,14 +925,13 @@ class MorePanel extends StatelessWidget { Color errorColor = Theme.of(context).colorScheme.error; return Container( padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), - // clipBehavior: Clip.hardEdge, child: Column( mainAxisSize: MainAxisSize.min, children: [ InkWell( onTap: () => Get.back(), child: Container( - height: 48, + height: 35, padding: const EdgeInsets.only(bottom: 2), child: Center( child: Container( @@ -948,14 +947,14 @@ class MorePanel extends StatelessWidget { ListTile( onTap: () async => await menuActionHandler('copyAll'), minLeadingWidth: 0, - leading: const Icon(Icons.copy_all_outlined), - title: const Text('复制全部'), + leading: const Icon(Icons.copy_all_outlined, size: 19), + title: Text('复制全部', style: Theme.of(context).textTheme.titleSmall), ), ListTile( onTap: () async => await menuActionHandler('copyFreedom'), minLeadingWidth: 0, - leading: const Icon(Icons.copy_outlined), - title: const Text('自由复制'), + leading: const Icon(Icons.copy_outlined, size: 19), + title: Text('自由复制', style: Theme.of(context).textTheme.titleSmall), ), // ListTile( // onTap: () async => await menuActionHandler('block'), From d57f84a1d7ca10b50e733f18a9a6a2e70a90cf94 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 15 Feb 2024 21:59:28 +0800 Subject: [PATCH 29/35] =?UTF-8?q?fix:=20=E8=B7=AF=E7=94=B1=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E4=BC=A0=E5=8F=82=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/fav_detail/view.dart | 6 ++++-- lib/pages/member/view.dart | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/pages/fav_detail/view.dart b/lib/pages/fav_detail/view.dart index f5897550..7f3435ef 100644 --- a/lib/pages/fav_detail/view.dart +++ b/lib/pages/fav_detail/view.dart @@ -24,11 +24,13 @@ class _FavDetailPageState extends State { Get.put(FavDetailController()); late StreamController titleStreamC; // a Future? _futureBuilderFuture; + late String mediaId; @override void initState() { super.initState(); _futureBuilderFuture = _favDetailController.queryUserFavFolderDetail(); + mediaId = Get.parameters['mediaId']!; titleStreamC = StreamController(); _controller.addListener( () { @@ -94,8 +96,8 @@ class _FavDetailPageState extends State { ), actions: [ IconButton( - onPressed: () => Get.toNamed( - '/favSearch?searchType=0&mediaId=${Get.parameters['mediaId']!}'), + onPressed: () => + Get.toNamed('/favSearch?searchType=0&mediaId=$mediaId'), icon: const Icon(Icons.search_outlined), ), // IconButton( diff --git a/lib/pages/member/view.dart b/lib/pages/member/view.dart index 1d3cd5c4..0663e94e 100644 --- a/lib/pages/member/view.dart +++ b/lib/pages/member/view.dart @@ -105,7 +105,7 @@ class _MemberPageState extends State actions: [ IconButton( onPressed: () => Get.toNamed( - '/memberSearch?mid=${Get.parameters['mid']}&uname=${_memberController.memberInfo.value.name!}'), + '/memberSearch?mid=$mid&uname=${_memberController.memberInfo.value.name!}'), icon: const Icon(Icons.search_outlined), ), PopupMenuButton( From 5bf7b69d790e8fd4f42114c15a0c4a93b14501a0 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 16 Feb 2024 09:33:59 +0800 Subject: [PATCH 30/35] =?UTF-8?q?feat:=20=E6=94=B6=E8=97=8F=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=BB=93=E6=9E=9C=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fav_detail/widget/fav_video_card.dart | 110 ++++++++++-------- lib/pages/fav_search/controller.dart | 20 ++++ lib/pages/fav_search/view.dart | 13 ++- 3 files changed, 92 insertions(+), 51 deletions(-) diff --git a/lib/pages/fav_detail/widget/fav_video_card.dart b/lib/pages/fav_detail/widget/fav_video_card.dart index a3c1e8e5..1c4008ff 100644 --- a/lib/pages/fav_detail/widget/fav_video_card.dart +++ b/lib/pages/fav_detail/widget/fav_video_card.dart @@ -15,9 +15,14 @@ import '../../../common/widgets/badge.dart'; class FavVideoCardH extends StatelessWidget { final dynamic videoItem; final Function? callFn; + final int? searchType; - const FavVideoCardH({Key? key, required this.videoItem, this.callFn}) - : super(key: key); + const FavVideoCardH({ + Key? key, + required this.videoItem, + this.callFn, + this.searchType, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -107,7 +112,11 @@ class FavVideoCardH extends StatelessWidget { }, ), ), - VideoContent(videoItem: videoItem, callFn: callFn) + VideoContent( + videoItem: videoItem, + callFn: callFn, + searchType: searchType, + ) ], ), ); @@ -123,7 +132,13 @@ class FavVideoCardH extends StatelessWidget { class VideoContent extends StatelessWidget { final dynamic videoItem; final Function? callFn; - const VideoContent({super.key, required this.videoItem, this.callFn}); + final int? searchType; + const VideoContent({ + super.key, + required this.videoItem, + this.callFn, + this.searchType, + }); @override Widget build(BuildContext context) { @@ -189,48 +204,51 @@ class VideoContent extends StatelessWidget { ), ], ), - Positioned( - right: 0, - bottom: -4, - child: IconButton( - style: ButtonStyle( - padding: MaterialStateProperty.all(EdgeInsets.zero), - ), - onPressed: () { - showDialog( - context: Get.context!, - builder: (context) { - return AlertDialog( - title: const Text('提示'), - content: const Text('要取消收藏吗?'), - actions: [ - TextButton( - onPressed: () => Get.back(), - child: Text( - '取消', - style: TextStyle( - color: - Theme.of(context).colorScheme.outline), - )), - TextButton( - onPressed: () async { - await callFn!(); - Get.back(); - }, - child: const Text('确定取消'), - ) - ], - ); - }, - ); - }, - icon: Icon( - Icons.clear_outlined, - color: Theme.of(context).colorScheme.outline, - size: 18, - ), - ), - ), + searchType != 1 + ? Positioned( + right: 0, + bottom: -4, + child: IconButton( + style: ButtonStyle( + padding: MaterialStateProperty.all(EdgeInsets.zero), + ), + onPressed: () { + showDialog( + context: Get.context!, + builder: (context) { + return AlertDialog( + title: const Text('提示'), + content: const Text('要取消收藏吗?'), + actions: [ + TextButton( + onPressed: () => Get.back(), + child: Text( + '取消', + style: TextStyle( + color: Theme.of(context) + .colorScheme + .outline), + )), + TextButton( + onPressed: () async { + await callFn!(); + Get.back(); + }, + child: const Text('确定取消'), + ) + ], + ); + }, + ); + }, + icon: Icon( + Icons.clear_outlined, + color: Theme.of(context).colorScheme.outline, + size: 18, + ), + ), + ) + : const SizedBox(), ], ), ), diff --git a/lib/pages/fav_search/controller.dart b/lib/pages/fav_search/controller.dart index 642fea6b..abd25e0b 100644 --- a/lib/pages/fav_search/controller.dart +++ b/lib/pages/fav_search/controller.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:pilipala/http/user.dart'; import 'package:pilipala/models/user/fav_detail.dart'; +import '../../http/video.dart'; + class FavSearchController extends GetxController { final ScrollController scrollController = ScrollController(); Rx controller = TextEditingController().obs; @@ -72,4 +75,21 @@ class FavSearchController extends GetxController { if (!hasMore) return; searchFav(type: 'onLoad'); } + + onCancelFav(int id) async { + var result = await VideoHttp.favVideo( + aid: id, addIds: '', delIds: mediaId.toString()); + if (result['status']) { + if (result['data']['prompt']) { + List dataList = favList; + for (var i in dataList) { + if (i.id == id) { + dataList.remove(i); + break; + } + } + SmartDialog.showToast('取消收藏'); + } + } + } } diff --git a/lib/pages/fav_search/view.dart b/lib/pages/fav_search/view.dart index 37e3046f..9b2ab15d 100644 --- a/lib/pages/fav_search/view.dart +++ b/lib/pages/fav_search/view.dart @@ -8,9 +8,7 @@ import 'package:pilipala/pages/fav_detail/widget/fav_video_card.dart'; import 'controller.dart'; class FavSearchPage extends StatefulWidget { - final int? sourceType; - final int? mediaId; - const FavSearchPage({super.key, this.sourceType, this.mediaId}); + const FavSearchPage({super.key}); @override State createState() => _FavSearchPageState(); @@ -19,11 +17,12 @@ class FavSearchPage extends StatefulWidget { class _FavSearchPageState extends State { final FavSearchController _favSearchCtr = Get.put(FavSearchController()); late ScrollController scrollController; + late int searchType; @override void initState() { super.initState(); - + searchType = int.parse(Get.parameters['searchType']!); scrollController = _favSearchCtr.scrollController; scrollController.addListener( () { @@ -100,7 +99,11 @@ class _FavSearchPageState extends State { } else { return FavVideoCardH( videoItem: _favSearchCtr.favList[index], - callFn: () => null, + searchType: searchType, + callFn: () => searchType != 1 + ? _favSearchCtr + .onCancelFav(_favSearchCtr.favList[index].id!) + : {}, ); } }, From 3d5c578fefcf581b83ec0aa6377dcddc1dcfe90e Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 16 Feb 2024 11:00:23 +0800 Subject: [PATCH 31/35] =?UTF-8?q?mod:=20=E5=8A=A8=E6=80=81=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2upPanel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/dynamics/widgets/up_panel.dart | 35 ++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index f1043fd8..84753ff9 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -36,8 +36,7 @@ class _UpPanelState extends State { } upList.insert( 0, - UpItem( - face: 'https://files.catbox.moe/8uc48f.png', uname: '全部动态', mid: -1), + UpItem(face: '', uname: '全部动态', mid: -1), ); userInfo = userInfoCache.get('userInfoCache'); upList.insert( @@ -56,7 +55,7 @@ class _UpPanelState extends State { floating: true, pinned: false, delegate: _SliverHeaderDelegate( - height: 124, + height: 126, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -178,6 +177,9 @@ class _UpPanelState extends State { }, onLongPress: () { feedBack(); + if (data.mid == -1) { + return; + } String heroTag = Utils.makeHeroTag(data.mid); Get.toNamed('/member?mid=${data.mid}', arguments: {'face': data.face, 'heroTag': heroTag}); @@ -205,12 +207,19 @@ class _UpPanelState extends State { backgroundColor: data.type == 'live' ? Theme.of(context).colorScheme.secondaryContainer : Theme.of(context).colorScheme.primary, - child: NetworkImgLayer( - width: 49, - height: 49, - src: data.face, - type: 'avatar', - ), + child: data.face != '' + ? NetworkImgLayer( + width: 50, + height: 50, + src: data.face, + type: 'avatar', + ) + : const CircleAvatar( + radius: 25, + backgroundImage: AssetImage( + 'assets/images/noface.jpeg', + ), + ), ), Padding( padding: const EdgeInsets.only(top: 4), @@ -278,13 +287,11 @@ class UpPanelSkeleton extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - width: 49, - height: 49, + width: 50, + height: 50, decoration: BoxDecoration( color: Theme.of(context).colorScheme.onInverseSurface, - borderRadius: const BorderRadius.all( - Radius.circular(24), - ), + borderRadius: BorderRadius.circular(50), ), ), Container( From 7a78729a4436416ef32aab0049a6ff79f79a4ed5 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 16 Feb 2024 18:23:34 +0800 Subject: [PATCH 32/35] =?UTF-8?q?fix:=20=E5=90=88=E9=9B=86=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=8E=A8=E8=8D=90=E8=A7=86=E9=A2=91=E6=9C=AA=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../video/detail/introduction/controller.dart | 5 ++ .../video/detail/related/controller.dart | 12 ++- lib/pages/video/detail/related/view.dart | 87 ++++++++++++------- 3 files changed, 71 insertions(+), 33 deletions(-) diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 4672b4bd..723e1355 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -18,6 +18,7 @@ import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/storage.dart'; import 'package:share_plus/share_plus.dart'; +import '../related/index.dart'; import 'widgets/group_panel.dart'; class VideoIntroController extends GetxController { @@ -478,11 +479,15 @@ class VideoIntroController extends GetxController { // 重新获取视频资源 final VideoDetailController videoDetailCtr = Get.find(tag: heroTag); + final ReleatedController releatedCtr = + Get.find(tag: heroTag); videoDetailCtr.bvid = bvid; videoDetailCtr.oid.value = aid; videoDetailCtr.cid.value = cid; videoDetailCtr.danmakuCid.value = cid; videoDetailCtr.queryVideoUrl(); + releatedCtr.bvid = bvid; + releatedCtr.queryRelatedVideo(); // 重新请求评论 try { /// 未渲染回复组件时可能异常 diff --git a/lib/pages/video/detail/related/controller.dart b/lib/pages/video/detail/related/controller.dart index f7042871..0578bba2 100644 --- a/lib/pages/video/detail/related/controller.dart +++ b/lib/pages/video/detail/related/controller.dart @@ -1,14 +1,22 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/http/video.dart'; +import '../../../../models/model_hot_video_item.dart'; class ReleatedController extends GetxController { // 视频aid String bvid = Get.parameters['bvid'] ?? ""; // 推荐视频列表 - List relatedVideoList = []; + RxList relatedVideoList = [].obs; OverlayEntry? popupDialog; - Future queryRelatedVideo() => VideoHttp.relatedVideoList(bvid: bvid); + Future queryRelatedVideo() async { + return VideoHttp.relatedVideoList(bvid: bvid).then((value) { + if (value['status']) { + relatedVideoList.value = value['data']; + } + return value; + }); + } } diff --git a/lib/pages/video/detail/related/view.dart b/lib/pages/video/detail/related/view.dart index 51c296f3..0912724e 100644 --- a/lib/pages/video/detail/related/view.dart +++ b/lib/pages/video/detail/related/view.dart @@ -7,48 +7,73 @@ import 'package:pilipala/common/widgets/overlay_pop.dart'; import 'package:pilipala/common/widgets/video_card_h.dart'; import './controller.dart'; -class RelatedVideoPanel extends StatelessWidget { - final ReleatedController _releatedController = - Get.put(ReleatedController(), tag: Get.arguments?['heroTag']); - RelatedVideoPanel({super.key}); +class RelatedVideoPanel extends StatefulWidget { + const RelatedVideoPanel({super.key}); + + @override + State createState() => _RelatedVideoPanelState(); +} + +class _RelatedVideoPanelState extends State + with AutomaticKeepAliveClientMixin { + late ReleatedController _releatedController; + late Future _futureBuilder; + + @override + bool get wantKeepAlive => true; + + @override + void initState() { + super.initState(); + _releatedController = + Get.put(ReleatedController(), tag: Get.arguments?['heroTag']); + _futureBuilder = _releatedController.queryRelatedVideo(); + } @override Widget build(BuildContext context) { + super.build(context); return FutureBuilder( - future: _releatedController.queryRelatedVideo(), + future: _futureBuilder, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done) { if (snapshot.data == null) { return const SliverToBoxAdapter(child: SizedBox()); } - if (snapshot.data!['status']) { + if (snapshot.data!['status'] && snapshot.data != null) { + RxList relatedVideoList = _releatedController.relatedVideoList; // 请求成功 - return SliverList( + return Obx( + () => SliverList( delegate: SliverChildBuilderDelegate((context, index) { - if (index == snapshot.data['data'].length) { - return SizedBox(height: MediaQuery.of(context).padding.bottom); - } else { - return Material( - child: VideoCardH( - videoItem: snapshot.data['data'][index], - showPubdate: true, - longPress: () { - try { - _releatedController.popupDialog = - _createPopupDialog(snapshot.data['data'][index]); - Overlay.of(context) - .insert(_releatedController.popupDialog!); - } catch (err) { - return {}; - } - }, - longPressEnd: () { - _releatedController.popupDialog?.remove(); - }, - ), - ); - } - }, childCount: snapshot.data['data'].length + 1)); + if (index == relatedVideoList.length) { + return SizedBox( + height: MediaQuery.of(context).padding.bottom); + } else { + return Material( + child: VideoCardH( + videoItem: relatedVideoList[index], + showPubdate: true, + longPress: () { + try { + _releatedController.popupDialog = + _createPopupDialog(_releatedController + .relatedVideoList[index]); + Overlay.of(context) + .insert(_releatedController.popupDialog!); + } catch (err) { + return {}; + } + }, + longPressEnd: () { + _releatedController.popupDialog?.remove(); + }, + ), + ); + } + }, childCount: relatedVideoList.length + 1), + ), + ); } else { // 请求错误 return HttpError(errMsg: '出错了', fn: () {}); From 8950658f0818344c7306ac073bce00a2e5c96416 Mon Sep 17 00:00:00 2001 From: orz12 Date: Fri, 16 Feb 2024 19:52:21 +0800 Subject: [PATCH 33/35] =?UTF-8?q?mod:=20=E5=9B=BE=E7=89=87=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E9=A1=B5=EF=BC=8C=E5=AE=89=E5=8D=93=E4=B9=9F=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E7=8A=B6=E6=80=81=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/preview/view.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/pages/preview/view.dart b/lib/pages/preview/view.dart index 1c37c833..dcffc973 100644 --- a/lib/pages/preview/view.dart +++ b/lib/pages/preview/view.dart @@ -102,15 +102,12 @@ class _ImagePreviewState extends State ); } - // 设置状态栏图标透明 + // 隐藏状态栏,避免遮挡图片内容 setStatusBar() async { - if (Platform.isIOS) { + if (Platform.isIOS || Platform.isAndroid) { await StatusBarControl.setHidden(true, animation: StatusBarAnimation.SLIDE); } - if (Platform.isAndroid) { - await StatusBarControl.setColor(Colors.transparent); - } } @override From 3c0f54bfd74b50f25d46466fceab768f7f604d96 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 16 Feb 2024 21:46:48 +0800 Subject: [PATCH 34/35] =?UTF-8?q?fix:=20app=E7=AB=AFmodel=20bvid=20null=20?= =?UTF-8?q?issues=20#546?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/home/rcmd/result.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/models/home/rcmd/result.dart b/lib/models/home/rcmd/result.dart index 9363beb3..78747d1a 100644 --- a/lib/models/home/rcmd/result.dart +++ b/lib/models/home/rcmd/result.dart @@ -1,3 +1,5 @@ +import 'package:pilipala/utils/id_utils.dart'; + class RecVideoItemAppModel { RecVideoItemAppModel({ this.id, @@ -50,14 +52,15 @@ class RecVideoItemAppModel { ? json['player_args']['aid'] : int.parse(json['param'] ?? '-1'); aid = json['player_args'] != null ? json['player_args']['aid'] : -1; - bvid = null; + bvid = json['player_args'] != null + ? IdUtils.av2bv(json['player_args']['aid']) + : ''; cid = json['player_args'] != null ? json['player_args']['cid'] : -1; pic = json['cover']; stat = RcmdStat.fromJson(json); // 改用player_args中的duration作为原始数据(秒数) - duration = json['player_args'] != null - ? json['player_args']['duration'] - : -1; + duration = + json['player_args'] != null ? json['player_args']['duration'] : -1; //duration = json['cover_right_text']; title = json['title']; owner = RcmdOwner.fromJson(json); From e8f63f611441f7f7df2bc1c35cf8cc69f197f8a4 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 17 Feb 2024 17:32:13 +0800 Subject: [PATCH 35/35] =?UTF-8?q?fix:=20up=E6=8A=95=E7=A8=BF=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E9=A1=B5=E5=A2=9E=E5=8A=A0=E6=9C=AA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A3=8E=E6=8E=A7=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/member.dart | 10 ++++++++-- lib/pages/member_archive/view.dart | 11 +++++++++-- lib/pages/member_dynamics/view.dart | 11 +++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/http/member.dart b/lib/http/member.dart index 6b6df7fe..82d2992b 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -101,10 +101,13 @@ class MemberHttp { 'data': MemberArchiveDataModel.fromJson(res.data['data']) }; } else { + Map errMap = { + -352: '风控校验失败,请检查登录状态', + }; return { 'status': false, 'data': [], - 'msg': res.data['message'], + 'msg': errMap[res.data['code']] ?? res.data['message'], }; } } @@ -123,10 +126,13 @@ class MemberHttp { 'data': DynamicsDataModel.fromJson(res.data['data']), }; } else { + Map errMap = { + -352: '风控校验失败,请检查登录状态', + }; return { 'status': false, 'data': [], - 'msg': res.data['message'], + 'msg': errMap[res.data['code']] ?? res.data['message'], }; } } diff --git a/lib/pages/member_archive/view.dart b/lib/pages/member_archive/view.dart index 43867323..3103683a 100644 --- a/lib/pages/member_archive/view.dart +++ b/lib/pages/member_archive/view.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/common/widgets/video_card_h.dart'; import 'package:pilipala/utils/utils.dart'; +import '../../common/widgets/http_error.dart'; import 'controller.dart'; class MemberArchivePage extends StatefulWidget { @@ -86,10 +87,16 @@ class _MemberArchivePageState extends State { : const SliverToBoxAdapter(), ); } else { - return const SliverToBoxAdapter(); + return HttpError( + errMsg: snapshot.data['msg'], + fn: () {}, + ); } } else { - return const SliverToBoxAdapter(); + return HttpError( + errMsg: snapshot.data['msg'], + fn: () {}, + ); } } else { return const SliverToBoxAdapter(); diff --git a/lib/pages/member_dynamics/view.dart b/lib/pages/member_dynamics/view.dart index fe7573fc..68aa72d7 100644 --- a/lib/pages/member_dynamics/view.dart +++ b/lib/pages/member_dynamics/view.dart @@ -4,6 +4,7 @@ import 'package:get/get.dart'; import 'package:pilipala/pages/member_dynamics/index.dart'; import 'package:pilipala/utils/utils.dart'; +import '../../common/widgets/http_error.dart'; import '../dynamics/widgets/dynamic_panel.dart'; class MemberDynamicsPage extends StatefulWidget { @@ -80,10 +81,16 @@ class _MemberDynamicsPageState extends State { : const SliverToBoxAdapter(), ); } else { - return const SliverToBoxAdapter(); + return HttpError( + errMsg: snapshot.data['msg'], + fn: () {}, + ); } } else { - return const SliverToBoxAdapter(); + return HttpError( + errMsg: snapshot.data['msg'], + fn: () {}, + ); } } else { return const SliverToBoxAdapter();