mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
184 lines
6.4 KiB
Dart
184 lines
6.4 KiB
Dart
import 'package:PiliPalaX/common/widgets/image_save.dart';
|
|
import 'package:PiliPalaX/common/widgets/stat/danmu.dart';
|
|
import 'package:PiliPalaX/common/widgets/stat/view.dart';
|
|
import 'package:PiliPalaX/common/widgets/video_popup_menu.dart';
|
|
import 'package:PiliPalaX/models/space_archive/item.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
import 'package:get/get.dart';
|
|
import '../../utils/utils.dart';
|
|
import '../constants.dart';
|
|
import 'badge.dart';
|
|
import 'network_img_layer.dart';
|
|
|
|
// 视频卡片 - 水平布局
|
|
class VideoCardHMemberVideo extends StatelessWidget {
|
|
const VideoCardHMemberVideo({
|
|
super.key,
|
|
required this.videoItem,
|
|
this.onTap,
|
|
this.bvid,
|
|
});
|
|
final Item videoItem;
|
|
final VoidCallback? onTap;
|
|
final dynamic bvid;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final int aid = int.tryParse(videoItem.param ?? '') ?? -1;
|
|
final String bvid = videoItem.bvid ?? '';
|
|
final String heroTag = Utils.makeHeroTag(aid);
|
|
return Stack(
|
|
children: [
|
|
InkWell(
|
|
onLongPress: () => imageSaveDialog(
|
|
context: context,
|
|
title: videoItem.title,
|
|
cover: videoItem.cover,
|
|
),
|
|
onTap: () async {
|
|
if (onTap != null) {
|
|
onTap!();
|
|
return;
|
|
}
|
|
try {
|
|
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.firstCid}',
|
|
arguments: {'heroTag': heroTag});
|
|
} catch (err) {
|
|
SmartDialog.showToast(err.toString());
|
|
}
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: StyleString.safeSpace,
|
|
vertical: 5,
|
|
),
|
|
child: LayoutBuilder(
|
|
builder: (BuildContext context, BoxConstraints boxConstraints) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
AspectRatio(
|
|
aspectRatio: StyleString.aspectRatio,
|
|
child: LayoutBuilder(
|
|
builder: (BuildContext context,
|
|
BoxConstraints boxConstraints) {
|
|
final double maxWidth = boxConstraints.maxWidth;
|
|
final double maxHeight = boxConstraints.maxHeight;
|
|
return Stack(
|
|
children: [
|
|
Hero(
|
|
tag: heroTag,
|
|
child: NetworkImgLayer(
|
|
src: videoItem.cover,
|
|
// videoItem.season?['cover'] ?? videoItem.cover,
|
|
width: maxWidth,
|
|
height: maxHeight,
|
|
),
|
|
),
|
|
// if (videoItem.season != null)
|
|
// PBadge(
|
|
// text: '合集: ${videoItem.season?['count']}',
|
|
// right: 6.0,
|
|
// bottom: 6.0,
|
|
// type: 'gray',
|
|
// )
|
|
// else
|
|
if (videoItem.duration != null)
|
|
PBadge(
|
|
text: Utils.timeFormat(videoItem.duration),
|
|
right: 6.0,
|
|
bottom: 6.0,
|
|
type: 'gray',
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
videoContent(context)
|
|
],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 0,
|
|
right: 12,
|
|
child: VideoPopupMenu(
|
|
size: 29,
|
|
iconSize: 17,
|
|
videoItem: videoItem,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget videoContent(context) {
|
|
return Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(10, 0, 6, 0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
...[
|
|
Expanded(
|
|
child: Text(
|
|
// videoItem.season?['title'] ?? videoItem.title ?? '',
|
|
videoItem.title ?? '',
|
|
textAlign: TextAlign.start,
|
|
style: TextStyle(
|
|
fontWeight: videoItem.bvid == bvid ? FontWeight.bold : null,
|
|
fontSize: Theme.of(context).textTheme.bodyMedium!.fontSize,
|
|
height: 1.42,
|
|
letterSpacing: 0.3,
|
|
color: videoItem.bvid == bvid
|
|
? Theme.of(context).colorScheme.primary
|
|
: null,
|
|
),
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
Text(
|
|
videoItem.season != null
|
|
? Utils.dateFormat(videoItem.season?['mtime'])
|
|
: videoItem.publishTimeText ?? '',
|
|
maxLines: 1,
|
|
style: TextStyle(
|
|
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
|
height: 1,
|
|
color: Theme.of(context).colorScheme.outline,
|
|
overflow: TextOverflow.clip,
|
|
),
|
|
),
|
|
const SizedBox(height: 3),
|
|
Row(
|
|
children: [
|
|
statView(
|
|
context: context,
|
|
theme: 'gray',
|
|
// view: videoItem.season?['view_content'] ??
|
|
// videoItem.viewContent,
|
|
view: videoItem.viewContent,
|
|
),
|
|
const SizedBox(width: 8),
|
|
statDanMu(
|
|
context: context,
|
|
theme: 'gray',
|
|
// danmu: videoItem.season?['danmaku'] ?? videoItem.danmaku,
|
|
danmu: videoItem.danmaku,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|