mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-15 05:40:12 +08:00
feat: video download
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
75
lib/pages/download/controller.dart
Normal file
75
lib/pages/download/controller.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/models_new/download/download_info.dart';
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DownloadPageController extends GetxController {
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
late final StreamSubscription _sub;
|
||||
final pages = RxList<DownloadPageInfo>();
|
||||
final flag = RxInt(0);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
_loadList();
|
||||
_sub = _downloadService.downloaFlag.listen((_) {
|
||||
_loadList();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_sub.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
Future<void> _loadList() async {
|
||||
await _downloadService.waitForInitialization;
|
||||
if (isClosed) return;
|
||||
if (_downloadService.downloadList.isEmpty) {
|
||||
pages.clear();
|
||||
return;
|
||||
}
|
||||
final list = <DownloadPageInfo>[];
|
||||
for (final entry in _downloadService.downloadList) {
|
||||
final pageId = entry.pageId;
|
||||
final page = list.firstWhereOrNull((e) => e.pageId == pageId);
|
||||
if (page != null) {
|
||||
final aSortKey = entry.sortKey;
|
||||
if (!entry.isCompleted) {
|
||||
if (page.entry case final lastEntry?) {
|
||||
if (aSortKey < lastEntry.sortKey) {
|
||||
page.entry = entry;
|
||||
}
|
||||
} else {
|
||||
page.entry = entry;
|
||||
}
|
||||
}
|
||||
final bSortKey = page.sortKey;
|
||||
if (aSortKey < bSortKey) {
|
||||
page
|
||||
..cover = entry.cover
|
||||
..sortKey = aSortKey;
|
||||
}
|
||||
page.entrys.add(entry);
|
||||
} else {
|
||||
list.add(
|
||||
DownloadPageInfo(
|
||||
pageId: pageId,
|
||||
dirPath: entry.pageDirPath,
|
||||
title: entry.title,
|
||||
cover: entry.cover,
|
||||
sortKey: entry.sortKey,
|
||||
seasonType: entry.ep?.seasonType,
|
||||
entrys: [entry],
|
||||
entry: entry.isCompleted ? null : entry,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
pages.value = list;
|
||||
flag.value++;
|
||||
}
|
||||
}
|
||||
117
lib/pages/download/detail/view.dart
Normal file
117
lib/pages/download/detail/view.dart
Normal file
@@ -0,0 +1,117 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/view_sliver_safe_area.dart';
|
||||
import 'package:PiliPlus/models_new/download/bili_download_entry_info.dart';
|
||||
import 'package:PiliPlus/pages/download/controller.dart';
|
||||
import 'package:PiliPlus/pages/download/detail/widgets/item.dart';
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DownloadDetailPage extends StatefulWidget {
|
||||
const DownloadDetailPage({
|
||||
super.key,
|
||||
required this.pageId,
|
||||
required this.title,
|
||||
required this.progress,
|
||||
});
|
||||
|
||||
final String pageId;
|
||||
final String title;
|
||||
final ValueNotifier progress;
|
||||
|
||||
@override
|
||||
State<DownloadDetailPage> createState() => _DownloadDetailPageState();
|
||||
}
|
||||
|
||||
class _DownloadDetailPageState extends State<DownloadDetailPage>
|
||||
with GridMixin {
|
||||
StreamSubscription? _sub;
|
||||
final _downloadItems = RxList<BiliDownloadEntryInfo>();
|
||||
final _controller = Get.find<DownloadPageController>();
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadList();
|
||||
_sub = _controller.flag.listen((_) {
|
||||
_loadList();
|
||||
});
|
||||
}
|
||||
|
||||
Future _closeSub() async {
|
||||
if (_sub != null) {
|
||||
await _sub?.cancel();
|
||||
_sub = null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_closeSub();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _loadList() {
|
||||
final list =
|
||||
_controller.pages
|
||||
.firstWhereOrNull((e) => e.pageId == widget.pageId)
|
||||
?.entrys
|
||||
?..sort((a, b) => a.sortKey.compareTo(b.sortKey));
|
||||
if (list != null) {
|
||||
_downloadItems.value = list;
|
||||
} else {
|
||||
_downloadItems.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(title: Text(widget.title)),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
ViewSliverSafeArea(
|
||||
sliver: Obx(() {
|
||||
if (_downloadItems.isNotEmpty) {
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
final entry = _downloadItems[index];
|
||||
return DetailItem(
|
||||
entry: entry,
|
||||
progress: widget.progress,
|
||||
downloadService: _downloadService,
|
||||
showTitle: false,
|
||||
onDelete: () async {
|
||||
if (_downloadItems.length == 1) {
|
||||
await _closeSub();
|
||||
await _downloadService.deletePage(
|
||||
pageDirPath: entry.pageDirPath,
|
||||
);
|
||||
if (context.mounted) {
|
||||
Get.back();
|
||||
}
|
||||
} else {
|
||||
_downloadService.deleteDownload(entry: entry);
|
||||
}
|
||||
GStorage.watchProgress.delete(entry.cid.toString());
|
||||
},
|
||||
);
|
||||
},
|
||||
itemCount: _downloadItems.length,
|
||||
);
|
||||
}
|
||||
return const HttpError();
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
290
lib/pages/download/detail/widgets/item.dart
Normal file
290
lib/pages/download/detail/widgets/item.dart
Normal file
@@ -0,0 +1,290 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/progress_bar/video_progress_indicator.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||
import 'package:PiliPlus/models/common/video/video_quality.dart';
|
||||
import 'package:PiliPlus/models_new/download/bili_download_entry_info.dart';
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:PiliPlus/utils/cache_manager.dart';
|
||||
import 'package:PiliPlus/utils/duration_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DetailItem extends StatelessWidget {
|
||||
const DetailItem({
|
||||
super.key,
|
||||
required this.entry,
|
||||
required this.progress,
|
||||
required this.downloadService,
|
||||
required this.onDelete,
|
||||
required this.showTitle,
|
||||
});
|
||||
|
||||
final BiliDownloadEntryInfo entry;
|
||||
final ValueNotifier progress;
|
||||
final DownloadService downloadService;
|
||||
final VoidCallback onDelete;
|
||||
final bool showTitle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final outline = theme.colorScheme.outline;
|
||||
final cid = entry.source?.cid ?? entry.pageData?.cid;
|
||||
void onLongPress() => showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定删除该视频?',
|
||||
onConfirm: onDelete,
|
||||
);
|
||||
},
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'删除',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
final res = await downloadService.downloadDanmaku(
|
||||
entry: entry,
|
||||
isUpdate: true,
|
||||
);
|
||||
if (res) {
|
||||
SmartDialog.showToast('更新成功');
|
||||
}
|
||||
},
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'更新弹幕',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
if (entry.isCompleted) {
|
||||
await PageUtils.toVideoPage(
|
||||
aid: entry.avid,
|
||||
cid: cid!,
|
||||
cover: entry.cover,
|
||||
title: entry.showTitle,
|
||||
extraArguments: {
|
||||
'sourceType': SourceType.file,
|
||||
'entry': entry,
|
||||
'dirPath': entry.entryDirPath,
|
||||
},
|
||||
);
|
||||
if (context.mounted) {
|
||||
Future.delayed(const Duration(milliseconds: 400), () {
|
||||
if (context.mounted) {
|
||||
// ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
|
||||
progress.notifyListeners();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
final curDownload = downloadService.curDownload.value;
|
||||
if (curDownload != null &&
|
||||
curDownload.cid == cid &&
|
||||
curDownload.status!.index <= 3) {
|
||||
downloadService.cancelDownload(
|
||||
isDelete: false,
|
||||
downloadNext: false,
|
||||
);
|
||||
} else {
|
||||
if (entry.status == DownloadStatus.wait) {
|
||||
downloadService.waitDownloadQueue.remove(entry);
|
||||
}
|
||||
downloadService.startDownload(entry);
|
||||
}
|
||||
}
|
||||
},
|
||||
onLongPress: onLongPress,
|
||||
onSecondaryTap: Utils.isMobile ? null : onLongPress,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: StyleString.safeSpace,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => NetworkImgLayer(
|
||||
src: entry.cover,
|
||||
width: constraints.maxWidth,
|
||||
height: constraints.maxHeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (entry.videoQuality case final videoQuality?)
|
||||
PBadge(
|
||||
text: VideoQuality.fromCode(videoQuality).shortDesc,
|
||||
right: 6.0,
|
||||
top: 6.0,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: progress,
|
||||
builder: (_, _, _) {
|
||||
final progress = GStorage.watchProgress.get(
|
||||
cid.toString(),
|
||||
);
|
||||
if (progress != null) {
|
||||
return Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
videoProgressIndicator(
|
||||
progress / entry.totalTimeMilli,
|
||||
),
|
||||
PBadge(
|
||||
text: progress >= entry.totalTimeMilli - 400
|
||||
? '已看完'
|
||||
: '${DurationUtils.formatDuration(
|
||||
progress ~/ 1000,
|
||||
)}/'
|
||||
'${DurationUtils.formatDuration(
|
||||
entry.totalTimeMilli ~/ 1000,
|
||||
)}',
|
||||
right: 6,
|
||||
bottom: 7,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return PBadge(
|
||||
text: DurationUtils.formatDuration(
|
||||
entry.totalTimeMilli ~/ 1000,
|
||||
),
|
||||
right: 6.0,
|
||||
bottom: 7.0,
|
||||
type: PBadgeType.gray,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Column(
|
||||
spacing: 5,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
showTitle ? entry.title : entry.showTitle,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.bodyMedium!.fontSize,
|
||||
height: 1.42,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: showTitle
|
||||
? entry.ep != null
|
||||
? 1
|
||||
: 2
|
||||
: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (showTitle) ...[
|
||||
if (entry.pageData?.part case final part?)
|
||||
if (part != entry.title)
|
||||
Text(
|
||||
part,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
if (entry.ep?.showTitle case final showTitle?)
|
||||
Text(
|
||||
showTitle,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (entry.isCompleted) ...[
|
||||
Positioned(
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
child: Text(
|
||||
'${CacheManager.formatSize(entry.totalBytes)}${entry.ownerName != null ? ' ${entry.ownerName}' : ''}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1.6,
|
||||
color: outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: entry.moreBtn(theme),
|
||||
),
|
||||
] else
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: entry.progressWidget(
|
||||
theme: theme,
|
||||
downloadService: downloadService,
|
||||
isPage: false,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
250
lib/pages/download/view.dart
Normal file
250
lib/pages/download/view.dart
Normal file
@@ -0,0 +1,250 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/view_sliver_safe_area.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models_new/download/download_info.dart';
|
||||
import 'package:PiliPlus/pages/download/controller.dart';
|
||||
import 'package:PiliPlus/pages/download/detail/view.dart';
|
||||
import 'package:PiliPlus/pages/download/detail/widgets/item.dart';
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DownloadPage extends StatefulWidget {
|
||||
const DownloadPage({super.key});
|
||||
|
||||
@override
|
||||
State<DownloadPage> createState() => _DownloadPageState();
|
||||
}
|
||||
|
||||
class _DownloadPageState extends State<DownloadPage> with GridMixin {
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
final _controller = Get.put(DownloadPageController());
|
||||
final _progress = ValueNotifier(null);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_progress.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(title: const Text('离线缓存')),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
ViewSliverSafeArea(
|
||||
sliver: Obx(() {
|
||||
if (_controller.pages.isNotEmpty) {
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
final item = _controller.pages[index];
|
||||
if (item.entrys.length == 1) {
|
||||
final entry = item.entrys.first;
|
||||
return DetailItem(
|
||||
entry: entry,
|
||||
progress: _progress,
|
||||
downloadService: _downloadService,
|
||||
showTitle: true,
|
||||
onDelete: () {
|
||||
_downloadService.deleteDownload(entry: entry);
|
||||
GStorage.watchProgress.delete(entry.cid.toString());
|
||||
},
|
||||
);
|
||||
}
|
||||
return _buildItem(theme, item);
|
||||
},
|
||||
itemCount: _controller.pages.length,
|
||||
);
|
||||
}
|
||||
return const HttpError();
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItem(ThemeData theme, DownloadPageInfo pageInfo) {
|
||||
final outline = theme.colorScheme.outline;
|
||||
final entry = pageInfo.entry;
|
||||
final isCompleted = entry == null;
|
||||
void onLongPress() => isCompleted
|
||||
? showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定删除?',
|
||||
onConfirm: () async {
|
||||
final watchProgress = GStorage.watchProgress;
|
||||
await Future.wait(
|
||||
pageInfo.entrys.map((e) {
|
||||
final cid = e.pageData?.cid ?? e.source?.cid;
|
||||
return watchProgress.delete(cid.toString());
|
||||
}),
|
||||
);
|
||||
_downloadService.deletePage(
|
||||
pageDirPath: pageInfo.dirPath,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'删除',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
final res = await Future.wait(
|
||||
pageInfo.entrys.map(
|
||||
(e) => _downloadService.downloadDanmaku(
|
||||
entry: e,
|
||||
isUpdate: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
if (res.every((e) => e)) {
|
||||
SmartDialog.showToast('更新成功');
|
||||
} else {
|
||||
SmartDialog.showToast('更新失败');
|
||||
}
|
||||
},
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'更新弹幕',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: null;
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: () => Get.to(
|
||||
DownloadDetailPage(
|
||||
pageId: pageInfo.pageId,
|
||||
title: pageInfo.title,
|
||||
progress: _progress,
|
||||
),
|
||||
),
|
||||
onLongPress: onLongPress,
|
||||
onSecondaryTap: Utils.isMobile ? null : onLongPress,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: StyleString.safeSpace,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => NetworkImgLayer(
|
||||
src: pageInfo.cover,
|
||||
width: constraints.maxWidth,
|
||||
height: constraints.maxHeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
PBadge(
|
||||
text: '${pageInfo.entrys.length}个视频',
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
isBold: false,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
if (pageInfo.seasonType case final pgcType?)
|
||||
PBadge(
|
||||
text: switch (pgcType) {
|
||||
-1 => '课程',
|
||||
1 => '番剧',
|
||||
2 => '电影',
|
||||
3 => '纪录片',
|
||||
4 => '国创',
|
||||
5 => '电视剧',
|
||||
7 => '综艺',
|
||||
_ => null,
|
||||
},
|
||||
right: 6.0,
|
||||
top: 6.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
pageInfo.title,
|
||||
textAlign: TextAlign.start,
|
||||
style: TextStyle(
|
||||
fontSize: theme.textTheme.bodyMedium!.fontSize,
|
||||
height: 1.42,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (isCompleted)
|
||||
Text(
|
||||
'已完成',
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1,
|
||||
color: outline,
|
||||
),
|
||||
)
|
||||
else
|
||||
entry.progressWidget(
|
||||
theme: theme,
|
||||
downloadService: _downloadService,
|
||||
isPage: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user