From 932be48125f6c2340a0c78eac6eccec2e8e3e122 Mon Sep 17 00:00:00 2001 From: orz12 Date: Sat, 20 Jan 2024 21:05:01 +0800 Subject: [PATCH 01/15] =?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 0bbd53779..c40d439c5 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 f7392c880..182fbea02 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 0b5d5eb8f..3debcfb97 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 08693d243..7ef0e53fd 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/15] =?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 44f662a98..c1c439db1 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 8b97b605f..2665e2d45 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 c40d439c5..86ea2a5ac 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/15] =?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 182fbea02..f7392c880 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 40c666e3d1112269f01a9b877bdabfe7d69883ab Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 7 Feb 2024 00:52:25 +0800 Subject: [PATCH 04/15] =?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 b02182c65..cbc6659b5 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 05/15] =?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 d0faabaad..b311bfa10 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 575c8767f..4a92cdfb8 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 ba4a562de..f1043fd84 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 c262df387..95d3134ef 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 f7392c880..c5824d702 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 06/15] =?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 5c4677221..64559ffdb 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 560f09a5c..f59f94a28 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 2673e84c6..7a0a57eaf 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 6a26f0d29..74fb6e9aa 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 f693acf17..f3f91c9e1 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 42b663642..d732f3703 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 cdf800c49f41731240ae9657c8dcb7fd88104c92 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 13 Feb 2024 23:33:51 +0800 Subject: [PATCH 07/15] =?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 46efc4f92..d0bcbaec5 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 08/15] =?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 3af35efdb..8bc7d84ec 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 09/15] =?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 56da0a78b..ee7b82144 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 20dfe403b..39800b906 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 10/15] =?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 d0bcbaec5..dc2422165 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 11/15] =?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 f5897550c..7f3435ef8 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 1d3cd5c48..0663e94ed 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 12/15] =?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 a3c1e8e57..1c4008ffe 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 642fea6b1..abd25e0b8 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 37e3046f6..9b2ab15d1 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 13/15] =?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 f1043fd84..84753ff9b 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 14/15] =?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 4672b4bd0..723e1355b 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 f7042871a..0578bba24 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 51c296f33..0912724eb 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 3c0f54bfd74b50f25d46466fceab768f7f604d96 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 16 Feb 2024 21:46:48 +0800 Subject: [PATCH 15/15] =?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 9363beb3b..78747d1a0 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);