mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: later: show progress
Closes #569 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -72,7 +72,7 @@ class HisListItem {
|
||||
String? authorFace;
|
||||
int? authorMid;
|
||||
int? viewAt;
|
||||
int progress = 0;
|
||||
int? progress;
|
||||
String? badge;
|
||||
String? showTitle;
|
||||
int? duration;
|
||||
|
||||
@@ -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!,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user