Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-06-13 11:49:38 +08:00
parent f824477ddb
commit c05fbde3fa
106 changed files with 2780 additions and 3200 deletions

View File

@@ -1,3 +1,4 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:flutter/material.dart';
import 'package:material_color_utilities/material_color_utilities.dart';
@@ -68,7 +69,7 @@ class ColorPalette extends StatelessWidget {
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
color: theme.colorScheme.onInverseSurface,
borderRadius: const BorderRadius.all(Radius.circular(10)),
borderRadius: StyleString.mdRadius,
),
child: child,
);

View File

@@ -78,6 +78,7 @@ class NetworkImgLayer extends StatelessWidget {
placeholder: (BuildContext context, String url) =>
getPlaceHolder?.call() ?? placeholder(context),
imageBuilder: imageBuilder,
errorWidget: (context, url, error) => placeholder(context),
);
}

View File

@@ -49,136 +49,132 @@ class VideoCardH extends StatelessWidget {
}
}
return Material(
color: Colors.transparent,
type: MaterialType.transparency,
child: Stack(
clipBehavior: Clip.none,
children: [
Semantics(
label: Utils.videoItemSemantics(videoItem),
excludeSemantics: true,
child: InkWell(
onLongPress: onLongPress ??
() => imageSaveDialog(
bvid: videoItem.bvid,
title: videoItem.title,
cover: videoItem.cover,
),
onTap: onTap ??
() async {
if (type == 'ketang') {
SmartDialog.showToast('课堂视频暂不支持播放');
return;
} else if (type == 'live_room') {
if (videoItem case SearchVideoItemModel item) {
int? roomId = item.id;
if (roomId != null) {
Get.toNamed('/liveRoom?roomid=$roomId');
}
} else {
SmartDialog.showToast(
'err: live_room : ${videoItem.runtimeType}');
}
return;
}
if (videoItem case HotVideoItemModel item) {
if (item.redirectUrl?.isNotEmpty == true &&
PageUtils.viewPgcFromUri(item.redirectUrl!)) {
return;
}
}
try {
final int? cid = videoItem.cid ??
await SearchHttp.ab2c(
aid: videoItem.aid, bvid: videoItem.bvid);
if (cid != null) {
PageUtils.toVideoPage(
'bvid=${videoItem.bvid}&cid=$cid',
arguments: {
'videoItem': videoItem,
'heroTag': Utils.makeHeroTag(videoItem.aid)
},
);
}
} catch (err) {
SmartDialog.showToast(err.toString());
}
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: StyleString.safeSpace,
vertical: 5,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (context, boxConstraints) {
final double maxWidth = boxConstraints.maxWidth;
final double maxHeight = boxConstraints.maxHeight;
num? progress;
if (videoItem case HotVideoItemModel item) {
progress = item.progress;
}
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
src: videoItem.cover,
width: maxWidth,
height: maxHeight,
),
if (videoItem case HotVideoItemModel item)
PBadge(
text: item.pgcLabel,
top: 6.0,
right: 6.0,
),
if (progress != null && progress != 0) ...[
PBadge(
text: progress == -1
? '已看完'
: '${Utils.timeFormat(progress)}/${Utils.timeFormat(videoItem.duration)}',
right: 6,
bottom: 8,
type: PBadgeType.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,
bottom: 6.0,
type: PBadgeType.gray,
),
if (type != 'video')
PBadge(
text: type,
left: 6.0,
bottom: 6.0,
type: PBadgeType.primary,
),
],
);
},
),
InkWell(
onLongPress: onLongPress ??
() => imageSaveDialog(
bvid: videoItem.bvid,
title: videoItem.title,
cover: videoItem.cover,
),
const SizedBox(width: 10),
content(context),
],
),
onTap: onTap ??
() async {
if (type == 'ketang') {
SmartDialog.showToast('课堂视频暂不支持播放');
return;
} else if (type == 'live_room') {
if (videoItem case SearchVideoItemModel item) {
int? roomId = item.id;
if (roomId != null) {
Get.toNamed('/liveRoom?roomid=$roomId');
}
} else {
SmartDialog.showToast(
'err: live_room : ${videoItem.runtimeType}');
}
return;
}
if (videoItem case HotVideoItemModel item) {
if (item.redirectUrl?.isNotEmpty == true &&
PageUtils.viewPgcFromUri(item.redirectUrl!)) {
return;
}
}
try {
final int? cid = videoItem.cid ??
await SearchHttp.ab2c(
aid: videoItem.aid, bvid: videoItem.bvid);
if (cid != null) {
PageUtils.toVideoPage(
'bvid=${videoItem.bvid}&cid=$cid',
arguments: {
'videoItem': videoItem,
'heroTag': Utils.makeHeroTag(videoItem.aid)
},
);
}
} catch (err) {
SmartDialog.showToast(err.toString());
}
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: StyleString.safeSpace,
vertical: 5,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (context, boxConstraints) {
final double maxWidth = boxConstraints.maxWidth;
final double maxHeight = boxConstraints.maxHeight;
num? progress;
if (videoItem case HotVideoItemModel item) {
progress = item.progress;
}
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
src: videoItem.cover,
width: maxWidth,
height: maxHeight,
),
if (videoItem case HotVideoItemModel item)
PBadge(
text: item.pgcLabel,
top: 6.0,
right: 6.0,
),
if (progress != null && progress != 0) ...[
PBadge(
text: progress == -1
? '已看完'
: '${Utils.timeFormat(progress)}/${Utils.timeFormat(videoItem.duration)}',
right: 6,
bottom: 8,
type: PBadgeType.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,
bottom: 6.0,
type: PBadgeType.gray,
),
if (type != 'video')
PBadge(
text: type,
left: 6.0,
bottom: 6.0,
type: PBadgeType.primary,
),
],
);
},
),
),
const SizedBox(width: 10),
content(context),
],
),
),
),

View File

@@ -97,50 +97,46 @@ class VideoCardV extends StatelessWidget {
return Stack(
clipBehavior: Clip.none,
children: [
Semantics(
label: Utils.videoItemSemantics(videoItem),
excludeSemantics: true,
child: Card(
clipBehavior: Clip.hardEdge,
margin: EdgeInsets.zero,
child: InkWell(
onTap: () => onPushDetail(Utils.makeHeroTag(videoItem.aid)),
onLongPress: () => imageSaveDialog(
title: videoItem.title,
cover: videoItem.cover,
bvid: videoItem.bvid,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
src: videoItem.cover,
width: maxWidth,
height: maxHeight,
),
if (videoItem.duration > 0)
PBadge(
bottom: 6,
right: 7,
size: PBadgeSize.small,
type: PBadgeType.gray,
text: Utils.timeFormat(videoItem.duration),
)
],
);
}),
),
content(context)
],
),
Card(
clipBehavior: Clip.hardEdge,
child: InkWell(
onTap: () => onPushDetail(Utils.makeHeroTag(videoItem.aid)),
onLongPress: () => imageSaveDialog(
title: videoItem.title,
cover: videoItem.cover,
bvid: videoItem.bvid,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
src: videoItem.cover,
width: maxWidth,
height: maxHeight,
radius: 0,
),
if (videoItem.duration > 0)
PBadge(
bottom: 6,
right: 7,
size: PBadgeSize.small,
type: PBadgeType.gray,
text: Utils.timeFormat(videoItem.duration),
)
],
);
}),
),
content(context)
],
),
),
),

View File

@@ -57,9 +57,7 @@ class VideoCustomActions {
'访问:${videoItem.owner.name}',
'visit',
const Icon(MdiIcons.accountCircleOutline, size: 16),
() => Get.toNamed('/member?mid=${videoItem.owner.mid}', arguments: {
'heroTag': '${videoItem.owner.mid}',
}),
() => Get.toNamed('/member?mid=${videoItem.owner.mid}'),
),
if (videoItem is! SpaceArchiveItem)
VideoCustomAction(