mod: later: show progress

Closes #569

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-30 11:28:34 +08:00
parent 7aa0289c1f
commit 7399915357
4 changed files with 37 additions and 3 deletions

View File

@@ -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,

View File

@@ -18,6 +18,8 @@ class HotVideoItemModel extends BaseRecVideoItemModel {
bool? checked; // 手动设置的
num? progress;
HotVideoItemModel.fromJson(Map<String, dynamic> 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

View File

@@ -72,7 +72,7 @@ class HisListItem {
String? authorFace;
int? authorMid;
int? viewAt;
int progress = 0;
int? progress;
String? badge;
String? showTitle;
int? duration;

View File

@@ -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!,
),
),
],