From 7399915357717c1ce886460b95800d76ff396715 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sun, 30 Mar 2025 11:28:34 +0800 Subject: [PATCH] mod: later: show progress Closes #569 Signed-off-by: bggRGjQaUbCoE --- lib/common/widgets/video_card_h.dart | 30 +++++++++++++++++++++++++++- lib/models/model_hot_video_item.dart | 3 +++ lib/models/user/history.dart | 2 +- lib/pages/history/widgets/item.dart | 5 ++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/common/widgets/video_card_h.dart b/lib/common/widgets/video_card_h.dart index 456fac23..e3fbfc82 100644 --- a/lib/common/widgets/video_card_h.dart +++ b/lib/common/widgets/video_card_h.dart @@ -1,4 +1,5 @@ import 'package:PiliPlus/common/widgets/image_save.dart'; +import 'package:PiliPlus/common/widgets/video_progress_indicator.dart'; import 'package:PiliPlus/models/model_hot_video_item.dart'; import 'package:PiliPlus/models/model_video.dart'; import 'package:PiliPlus/models/search/result.dart'; @@ -53,6 +54,7 @@ class VideoCardH extends StatelessWidget { return Material( color: Colors.transparent, child: Stack( + clipBehavior: Clip.none, children: [ Semantics( label: Utils.videoItemSemantics(videoItem), @@ -125,7 +127,14 @@ class VideoCardH extends StatelessWidget { BoxConstraints boxConstraints) { final double maxWidth = boxConstraints.maxWidth; final double maxHeight = boxConstraints.maxHeight; + num? progress; + if (videoItem is HotVideoItemModel) { + progress = + (videoItem as HotVideoItemModel).progress; + } + return Stack( + clipBehavior: Clip.none, children: [ NetworkImgLayer( src: videoItem.pic, @@ -143,7 +152,26 @@ class VideoCardH extends StatelessWidget { top: 6.0, right: 6.0, ), - if (videoItem.duration > 0) + if (progress != null && progress != 0) ...[ + PBadge( + text: progress == -1 + ? '已看完' + : '${Utils.timeFormat(progress)}/${Utils.timeFormat(videoItem.duration)}', + right: 6, + bottom: 8, + type: 'gray', + ), + Positioned( + left: 0, + bottom: 0, + right: 0, + child: videoProgressIndicator( + progress == -1 + ? 1 + : progress / videoItem.duration, + ), + ) + ] else if (videoItem.duration > 0) PBadge( text: Utils.timeFormat(videoItem.duration), right: 6.0, diff --git a/lib/models/model_hot_video_item.dart b/lib/models/model_hot_video_item.dart index 8cbaeb8b..bf75f07b 100644 --- a/lib/models/model_hot_video_item.dart +++ b/lib/models/model_hot_video_item.dart @@ -18,6 +18,8 @@ class HotVideoItemModel extends BaseRecVideoItemModel { bool? checked; // 手动设置的 + num? progress; + HotVideoItemModel.fromJson(Map json) { aid = json["aid"]; cid = json["cid"]; @@ -44,6 +46,7 @@ class HotVideoItemModel extends BaseRecVideoItemModel { pgcLabel = json['pgc_label']; redirectUrl = json['redirect_url']; // uri = json['uri']; // 仅在稍后再看存在 + progress = json['progress']; } // @override diff --git a/lib/models/user/history.dart b/lib/models/user/history.dart index a6e9add3..092480f6 100644 --- a/lib/models/user/history.dart +++ b/lib/models/user/history.dart @@ -72,7 +72,7 @@ class HisListItem { String? authorFace; int? authorMid; int? viewAt; - int progress = 0; + int? progress; String? badge; String? showTitle; int? duration; diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index 3321a343..7e01a74b 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -154,6 +154,7 @@ class HistoryItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( + clipBehavior: Clip.none, children: [ AspectRatio( aspectRatio: StyleString.aspectRatio, @@ -162,6 +163,7 @@ class HistoryItem extends StatelessWidget { double maxWidth = boxConstraints.maxWidth; double maxHeight = boxConstraints.maxHeight; return Stack( + clipBehavior: Clip.none, children: [ NetworkImgLayer( src: (videoItem.cover.isNullOrEmpty @@ -246,6 +248,7 @@ class HistoryItem extends StatelessWidget { ), if (videoItem.duration != null && videoItem.duration != 0 && + videoItem.progress != null && videoItem.progress != 0) Positioned( left: 0, @@ -254,7 +257,7 @@ class HistoryItem extends StatelessWidget { child: videoProgressIndicator( videoItem.progress == -1 ? 1 - : videoItem.progress / videoItem.duration!, + : videoItem.progress! / videoItem.duration!, ), ), ],