mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-28 22:40:13 +08:00
opt download (#1755)
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,14 +1,25 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/models_new/download/download_info.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select/base.dart'
|
||||
show BaseMultiSelectMixin;
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DownloadPageController extends GetxController {
|
||||
class DownloadPageController extends GetxController
|
||||
with BaseMultiSelectMixin<DownloadPageInfo> {
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
final pages = RxList<DownloadPageInfo>();
|
||||
final flag = RxInt(0);
|
||||
|
||||
@override
|
||||
List<DownloadPageInfo> get list => pages;
|
||||
@override
|
||||
RxList<DownloadPageInfo> get state => pages;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -35,15 +46,6 @@ class DownloadPageController extends GetxController {
|
||||
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
|
||||
@@ -61,7 +63,6 @@ class DownloadPageController extends GetxController {
|
||||
sortKey: entry.sortKey,
|
||||
seasonType: entry.ep?.seasonType,
|
||||
entrys: [entry],
|
||||
entry: entry.isCompleted ? null : entry,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -69,4 +70,32 @@ class DownloadPageController extends GetxController {
|
||||
pages.value = list;
|
||||
flag.value++;
|
||||
}
|
||||
|
||||
@override
|
||||
void onRemove() {
|
||||
showConfirmDialog(
|
||||
context: Get.context!,
|
||||
title: '确定删除选中视频?',
|
||||
onConfirm: () async {
|
||||
SmartDialog.showLoading();
|
||||
final allChecked = this.allChecked.toList();
|
||||
final watchProgress = GStorage.watchProgress;
|
||||
for (var page in allChecked) {
|
||||
await watchProgress.deleteAll(
|
||||
page.entrys.map((e) => e.cid.toString()),
|
||||
);
|
||||
await _downloadService.deletePage(
|
||||
pageDirPath: page.dirPath,
|
||||
refresh: false,
|
||||
);
|
||||
}
|
||||
_downloadService.flagNotifier.refresh();
|
||||
if (enableMultiSelect.value) {
|
||||
rxCount.value = 0;
|
||||
enableMultiSelect.value = false;
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/appbar/appbar.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.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_new/download/bili_download_entry_info.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select/base.dart'
|
||||
show BaseMultiSelectMixin;
|
||||
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:flutter/material.dart'
|
||||
hide SliverGridDelegateWithMaxCrossAxisExtent;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DownloadDetailPage extends StatefulWidget {
|
||||
@@ -28,11 +34,15 @@ class DownloadDetailPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DownloadDetailPageState extends State<DownloadDetailPage>
|
||||
with GridMixin {
|
||||
with BaseMultiSelectMixin<BiliDownloadEntryInfo> {
|
||||
StreamSubscription? _sub;
|
||||
final _downloadItems = RxList<BiliDownloadEntryInfo>();
|
||||
final _controller = Get.find<DownloadPageController>();
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
@override
|
||||
RxList<BiliDownloadEntryInfo> get list => _downloadItems;
|
||||
@override
|
||||
RxList<BiliDownloadEntryInfo> get state => _downloadItems;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -71,47 +81,125 @@ class _DownloadDetailPageState extends State<DownloadDetailPage>
|
||||
|
||||
@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());
|
||||
},
|
||||
);
|
||||
return Obx(() {
|
||||
final enableMultiSelect = this.enableMultiSelect.value;
|
||||
return PopScope(
|
||||
canPop: !enableMultiSelect,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (enableMultiSelect) {
|
||||
handleSelect();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: MultiSelectAppBarWidget(
|
||||
ctr: this,
|
||||
child: AppBar(
|
||||
title: Text(widget.title),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: '多选',
|
||||
onPressed: () {
|
||||
if (enableMultiSelect) {
|
||||
handleSelect();
|
||||
} else {
|
||||
this.enableMultiSelect.value = true;
|
||||
}
|
||||
},
|
||||
itemCount: _downloadItems.length,
|
||||
);
|
||||
}
|
||||
return const HttpError();
|
||||
}),
|
||||
icon: const Icon(Icons.edit_note),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
ViewSliverSafeArea(
|
||||
sliver: Obx(() {
|
||||
if (_downloadItems.isNotEmpty) {
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 2,
|
||||
mainAxisExtent: 100,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
),
|
||||
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 (mounted) {
|
||||
Get.back();
|
||||
}
|
||||
} else {
|
||||
_downloadService.deleteDownload(
|
||||
entry: entry,
|
||||
removeList: true,
|
||||
);
|
||||
}
|
||||
GStorage.watchProgress.delete(entry.cid.toString());
|
||||
},
|
||||
controller: this,
|
||||
);
|
||||
},
|
||||
itemCount: _downloadItems.length,
|
||||
);
|
||||
}
|
||||
return const HttpError();
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onRemove() {
|
||||
showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定删除选中视频?',
|
||||
onConfirm: () async {
|
||||
SmartDialog.showLoading();
|
||||
final watchProgress = GStorage.watchProgress;
|
||||
final allChecked = this.allChecked.toSet();
|
||||
final isDeleteAll = allChecked.length == _downloadItems.length;
|
||||
if (isDeleteAll) {
|
||||
await _closeSub();
|
||||
}
|
||||
for (var entry in allChecked) {
|
||||
await watchProgress.deleteAll(
|
||||
allChecked.map((e) => e.cid.toString()),
|
||||
);
|
||||
await _downloadService.deleteDownload(
|
||||
entry: entry,
|
||||
removeList: true,
|
||||
refresh: false,
|
||||
);
|
||||
}
|
||||
_downloadService.flagNotifier.refresh();
|
||||
if (isDeleteAll) {
|
||||
SmartDialog.dismiss();
|
||||
if (mounted) {
|
||||
Get.back();
|
||||
}
|
||||
} else {
|
||||
if (enableMultiSelect.value) {
|
||||
rxCount.value = 0;
|
||||
enableMultiSelect.value = false;
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,13 @@ 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/common/widgets/select_mask.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/pages/common/multi_select/base.dart';
|
||||
import 'package:PiliPlus/pages/download/downloading/view.dart';
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:PiliPlus/utils/cache_manager.dart';
|
||||
import 'package:PiliPlus/utils/duration_utils.dart';
|
||||
@@ -26,75 +29,97 @@ class DetailItem extends StatelessWidget {
|
||||
const DetailItem({
|
||||
super.key,
|
||||
required this.entry,
|
||||
required this.progress,
|
||||
this.progress,
|
||||
required this.downloadService,
|
||||
required this.onDelete,
|
||||
this.onDelete,
|
||||
required this.showTitle,
|
||||
this.isCurr = false,
|
||||
//
|
||||
required this.controller,
|
||||
this.checked,
|
||||
this.onSelect,
|
||||
});
|
||||
|
||||
final BiliDownloadEntryInfo entry;
|
||||
final ValueNotifier progress;
|
||||
final ValueNotifier? progress;
|
||||
final DownloadService downloadService;
|
||||
final VoidCallback onDelete;
|
||||
final VoidCallback? onDelete;
|
||||
final bool showTitle;
|
||||
final bool isCurr;
|
||||
//
|
||||
final MultiSelectBase controller;
|
||||
final bool? checked;
|
||||
final ValueChanged<BiliDownloadEntryInfo>? onSelect;
|
||||
|
||||
@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),
|
||||
final canDel = onDelete != null;
|
||||
void onLongPress() => canDel
|
||||
? 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('更新成功');
|
||||
} else {
|
||||
SmartDialog.showToast('更新失败');
|
||||
}
|
||||
},
|
||||
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('更新成功');
|
||||
} else {
|
||||
SmartDialog.showToast('更新失败');
|
||||
}
|
||||
},
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'更新弹幕',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
);
|
||||
},
|
||||
)
|
||||
: null;
|
||||
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
if (!canDel) {
|
||||
Get.to(const DownloadingPage());
|
||||
return;
|
||||
}
|
||||
if (controller.enableMultiSelect.value) {
|
||||
(onSelect ?? controller.onSelect).call(entry);
|
||||
return;
|
||||
}
|
||||
if (entry.isCompleted) {
|
||||
await PageUtils.toVideoPage(
|
||||
aid: entry.avid,
|
||||
@@ -111,7 +136,7 @@ class DetailItem extends StatelessWidget {
|
||||
Future.delayed(const Duration(milliseconds: 400), () {
|
||||
if (context.mounted) {
|
||||
// ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member
|
||||
progress.notifyListeners();
|
||||
progress?.notifyListeners();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -125,9 +150,6 @@ class DetailItem extends StatelessWidget {
|
||||
downloadNext: false,
|
||||
);
|
||||
} else {
|
||||
if (entry.status == DownloadStatus.wait) {
|
||||
downloadService.waitDownloadQueue.remove(entry);
|
||||
}
|
||||
downloadService.startDownload(entry);
|
||||
}
|
||||
}
|
||||
@@ -186,49 +208,62 @@ class DetailItem extends StatelessWidget {
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (progress != null)
|
||||
ValueListenableBuilder(
|
||||
valueListenable: progress!,
|
||||
builder: (_, _, _) {
|
||||
final progress = GStorage.watchProgress.get(
|
||||
cid.toString(),
|
||||
);
|
||||
}
|
||||
return PBadge(
|
||||
text: DurationUtils.formatDuration(
|
||||
entry.totalTimeMilli ~/ 1000,
|
||||
),
|
||||
right: 6.0,
|
||||
bottom: 7.0,
|
||||
type: PBadgeType.gray,
|
||||
);
|
||||
},
|
||||
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,
|
||||
);
|
||||
},
|
||||
)
|
||||
else if (entry.totalTimeMilli != 0)
|
||||
PBadge(
|
||||
text: DurationUtils.formatDuration(
|
||||
entry.totalTimeMilli ~/ 1000,
|
||||
),
|
||||
right: 6,
|
||||
bottom: 7,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
Positioned.fill(
|
||||
child: selectMask(theme, checked ?? entry.checked ?? false),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -303,11 +338,40 @@ class DetailItem extends StatelessWidget {
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: entry.progressWidget(
|
||||
theme: theme,
|
||||
downloadService: downloadService,
|
||||
isPage: false,
|
||||
),
|
||||
child: isCurr
|
||||
? RepaintBoundary(
|
||||
child: Obx(
|
||||
() {
|
||||
final curDownload =
|
||||
downloadService.curDownload.value;
|
||||
if (curDownload != null) {
|
||||
final status = curDownload.status;
|
||||
final color =
|
||||
status != DownloadStatus.pause
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.outline;
|
||||
return progressWidget(
|
||||
statusMsg: status!.message,
|
||||
progressStr:
|
||||
status ==
|
||||
DownloadStatus
|
||||
.downloading ||
|
||||
status == DownloadStatus.pause
|
||||
? '${CacheManager.formatSize(curDownload.downloadedBytes)}/${CacheManager.formatSize(curDownload.totalBytes)}'
|
||||
: '',
|
||||
progress: curDownload.totalBytes == 0
|
||||
? 0
|
||||
: curDownload.downloadedBytes /
|
||||
curDownload.totalBytes,
|
||||
color: color,
|
||||
highlightColor: theme.highlightColor,
|
||||
);
|
||||
}
|
||||
return entryProgress(theme);
|
||||
},
|
||||
),
|
||||
)
|
||||
: entryProgress(theme),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -318,4 +382,62 @@ class DetailItem extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget entryProgress(ThemeData theme) => progressWidget(
|
||||
statusMsg: entry.status?.message ?? '暂停中',
|
||||
progressStr: entry.totalBytes == 0
|
||||
? ''
|
||||
: '${CacheManager.formatSize(entry.downloadedBytes)}/${CacheManager.formatSize(entry.totalBytes)}',
|
||||
progress: entry.totalBytes == 0
|
||||
? 0
|
||||
: entry.downloadedBytes / entry.totalBytes,
|
||||
color: theme.colorScheme.outline,
|
||||
highlightColor: theme.highlightColor,
|
||||
);
|
||||
|
||||
Widget progressWidget({
|
||||
required String statusMsg,
|
||||
required String progressStr,
|
||||
required double progress,
|
||||
required Color color,
|
||||
required Color highlightColor,
|
||||
}) {
|
||||
return Column(
|
||||
spacing: 6,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
statusMsg,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
progressStr,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
LinearProgressIndicator(
|
||||
// ignore: deprecated_member_use
|
||||
year2023: true,
|
||||
minHeight: 2.5,
|
||||
borderRadius: StyleString.mdRadius,
|
||||
color: color,
|
||||
backgroundColor: highlightColor,
|
||||
value: progress,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
130
lib/pages/download/downloading/view.dart
Normal file
130
lib/pages/download/downloading/view.dart
Normal file
@@ -0,0 +1,130 @@
|
||||
import 'package:PiliPlus/common/widgets/appbar/appbar.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.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_new/download/bili_download_entry_info.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select/base.dart'
|
||||
show BaseMultiSelectMixin;
|
||||
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:flutter/material.dart'
|
||||
hide SliverGridDelegateWithMaxCrossAxisExtent;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DownloadingPage extends StatefulWidget {
|
||||
const DownloadingPage({super.key});
|
||||
|
||||
@override
|
||||
State<DownloadingPage> createState() => _DownloadingPageState();
|
||||
}
|
||||
|
||||
class _DownloadingPageState extends State<DownloadingPage>
|
||||
with BaseMultiSelectMixin<BiliDownloadEntryInfo> {
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
late final _waitDownloadQueue = _downloadService.waitDownloadQueue;
|
||||
@override
|
||||
RxList<BiliDownloadEntryInfo> get list => _waitDownloadQueue;
|
||||
@override
|
||||
RxList<BiliDownloadEntryInfo> get state => _waitDownloadQueue;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(() {
|
||||
final enableMultiSelect = this.enableMultiSelect.value;
|
||||
return PopScope(
|
||||
canPop: !enableMultiSelect,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (enableMultiSelect) {
|
||||
handleSelect();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: MultiSelectAppBarWidget(
|
||||
ctr: this,
|
||||
child: AppBar(
|
||||
title: const Text('正在缓存'),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: '多选',
|
||||
onPressed: () {
|
||||
if (enableMultiSelect) {
|
||||
handleSelect();
|
||||
} else {
|
||||
this.enableMultiSelect.value = true;
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.edit_note),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
ViewSliverSafeArea(
|
||||
sliver: Obx(() {
|
||||
if (_waitDownloadQueue.isNotEmpty) {
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 2,
|
||||
mainAxisExtent: 100,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
),
|
||||
itemCount: _waitDownloadQueue.length,
|
||||
itemBuilder: (context, index) {
|
||||
final entry = _waitDownloadQueue[index];
|
||||
final isCurr = entry.cid == _downloadService.curCid;
|
||||
return DetailItem(
|
||||
entry: entry,
|
||||
downloadService: _downloadService,
|
||||
showTitle: true,
|
||||
isCurr: isCurr,
|
||||
onDelete: () => _downloadService.deleteDownload(
|
||||
entry: entry,
|
||||
removeQueue: true,
|
||||
),
|
||||
controller: this,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return const HttpError();
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onRemove() {
|
||||
showConfirmDialog(
|
||||
context: context,
|
||||
title: '确定删除选中视频?',
|
||||
onConfirm: () async {
|
||||
SmartDialog.showLoading();
|
||||
final allChecked = this.allChecked.toList();
|
||||
for (var entry in allChecked) {
|
||||
await _downloadService.deleteDownload(
|
||||
entry: entry,
|
||||
refresh: false,
|
||||
downloadNext: false,
|
||||
);
|
||||
}
|
||||
_downloadService.waitDownloadQueue.removeWhere(allChecked.contains);
|
||||
if (_downloadService.curDownload.value == null) {
|
||||
_downloadService.nextDownload();
|
||||
}
|
||||
if (enableMultiSelect.value) {
|
||||
rxCount.value = 0;
|
||||
enableMultiSelect.value = false;
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
79
lib/pages/download/search/controller.dart
Normal file
79
lib/pages/download/search/controller.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/download/bili_download_entry_info.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select/base.dart'
|
||||
show BaseMultiSelectMixin;
|
||||
import 'package:PiliPlus/pages/common/search/common_search_controller.dart';
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DownloadSearchController
|
||||
extends
|
||||
CommonSearchController<
|
||||
List<BiliDownloadEntryInfo>,
|
||||
BiliDownloadEntryInfo
|
||||
>
|
||||
with BaseMultiSelectMixin<BiliDownloadEntryInfo> {
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
|
||||
@override
|
||||
List<BiliDownloadEntryInfo> get list => loadingState.value.data!;
|
||||
@override
|
||||
Rx<LoadingState<List<BiliDownloadEntryInfo>?>> get state => loadingState;
|
||||
|
||||
@override
|
||||
Future<LoadingState<List<BiliDownloadEntryInfo>>> customGetData() async {
|
||||
final text = editController.text.toLowerCase();
|
||||
return Success(
|
||||
_downloadService.downloadList
|
||||
.where(
|
||||
(e) =>
|
||||
e.title.toLowerCase().contains(text) ||
|
||||
e.showTitle.toLowerCase().contains(text),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
void onRemoveSingle(int index, BiliDownloadEntryInfo entry) {
|
||||
loadingState
|
||||
..value.data!.removeAt(index)
|
||||
..refresh();
|
||||
_downloadService.deleteDownload(
|
||||
entry: entry,
|
||||
removeList: true,
|
||||
);
|
||||
GStorage.watchProgress.delete(entry.cid.toString());
|
||||
}
|
||||
|
||||
@override
|
||||
void onRemove() {
|
||||
showConfirmDialog(
|
||||
context: Get.context!,
|
||||
title: '确定删除选中视频?',
|
||||
onConfirm: () async {
|
||||
SmartDialog.showLoading();
|
||||
final allChecked = this.allChecked.toList();
|
||||
for (var entry in allChecked) {
|
||||
await GStorage.watchProgress.delete(entry.cid.toString());
|
||||
await _downloadService.deleteDownload(
|
||||
entry: entry,
|
||||
removeList: true,
|
||||
refresh: false,
|
||||
);
|
||||
}
|
||||
loadingState
|
||||
..value.data!.removeWhere(allChecked.contains)
|
||||
..refresh();
|
||||
_downloadService.flagNotifier.refresh();
|
||||
if (enableMultiSelect.value) {
|
||||
rxCount.value = 0;
|
||||
enableMultiSelect.value = false;
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
75
lib/pages/download/search/view.dart
Normal file
75
lib/pages/download/search/view.dart
Normal file
@@ -0,0 +1,75 @@
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/models_new/download/bili_download_entry_info.dart';
|
||||
import 'package:PiliPlus/pages/common/search/common_search_page.dart';
|
||||
import 'package:PiliPlus/pages/download/detail/widgets/item.dart';
|
||||
import 'package:PiliPlus/pages/download/search/controller.dart';
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart'
|
||||
hide SliverGridDelegateWithMaxCrossAxisExtent;
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class DownloadSearchPage extends StatefulWidget {
|
||||
const DownloadSearchPage({
|
||||
super.key,
|
||||
required this.progress,
|
||||
});
|
||||
|
||||
final ValueNotifier progress;
|
||||
|
||||
@override
|
||||
State<DownloadSearchPage> createState() => _DownloadSearchPageState();
|
||||
}
|
||||
|
||||
class _DownloadSearchPageState
|
||||
extends
|
||||
CommonSearchPageState<
|
||||
DownloadSearchPage,
|
||||
List<BiliDownloadEntryInfo>,
|
||||
BiliDownloadEntryInfo
|
||||
> {
|
||||
@override
|
||||
DownloadSearchController controller = Get.put(DownloadSearchController());
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
|
||||
@override
|
||||
List<Widget>? get extraActions => [
|
||||
IconButton(
|
||||
tooltip: '多选',
|
||||
onPressed: () {
|
||||
if (controller.enableMultiSelect.value) {
|
||||
controller.handleSelect();
|
||||
} else {
|
||||
controller.enableMultiSelect.value = true;
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.edit_note),
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget buildList(List<BiliDownloadEntryInfo> list) {
|
||||
if (list.isNotEmpty) {
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 2,
|
||||
mainAxisExtent: 100,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final entry = list[index];
|
||||
return DetailItem(
|
||||
entry: entry,
|
||||
progress: widget.progress,
|
||||
downloadService: _downloadService,
|
||||
showTitle: true,
|
||||
onDelete: () => controller.onRemoveSingle(index, entry),
|
||||
controller: controller,
|
||||
);
|
||||
},
|
||||
itemCount: list.length,
|
||||
);
|
||||
}
|
||||
return const HttpError();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,24 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/appbar/appbar.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/common/widgets/select_mask.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/pages/download/search/view.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/material.dart'
|
||||
hide SliverGridDelegateWithMaxCrossAxisExtent;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -26,7 +29,7 @@ class DownloadPage extends StatefulWidget {
|
||||
State<DownloadPage> createState() => _DownloadPageState();
|
||||
}
|
||||
|
||||
class _DownloadPageState extends State<DownloadPage> with GridMixin {
|
||||
class _DownloadPageState extends State<DownloadPage> {
|
||||
final _downloadService = Get.find<DownloadService>();
|
||||
final _controller = Get.put(DownloadPageController());
|
||||
final _progress = ValueNotifier(null);
|
||||
@@ -40,123 +43,232 @@ class _DownloadPageState extends State<DownloadPage> with GridMixin {
|
||||
@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);
|
||||
final padding = MediaQuery.viewPaddingOf(context);
|
||||
return Obx(() {
|
||||
final enableMultiSelect = _controller.enableMultiSelect.value;
|
||||
return PopScope(
|
||||
canPop: !enableMultiSelect,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (enableMultiSelect) {
|
||||
_controller.handleSelect();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: MultiSelectAppBarWidget(
|
||||
ctr: _controller,
|
||||
child: AppBar(
|
||||
title: const Text('离线缓存'),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: '搜索',
|
||||
onPressed: () async {
|
||||
await _downloadService.waitForInitialization;
|
||||
if (!mounted) return;
|
||||
Get.to(DownloadSearchPage(progress: _progress));
|
||||
},
|
||||
itemCount: _controller.pages.length,
|
||||
);
|
||||
}
|
||||
return const HttpError();
|
||||
}),
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: '多选',
|
||||
onPressed: () {
|
||||
if (enableMultiSelect) {
|
||||
_controller.handleSelect();
|
||||
} else {
|
||||
_controller.enableMultiSelect.value = true;
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.edit_note),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(left: padding.left, right: padding.right),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
Obx(() {
|
||||
final entry =
|
||||
_downloadService.waitDownloadQueue.firstWhereOrNull(
|
||||
(e) => e.cid == _downloadService.curCid,
|
||||
) ??
|
||||
_downloadService.waitDownloadQueue.firstOrNull;
|
||||
if (entry != null) {
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.only(left: 12, bottom: 7),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: Text(
|
||||
'正在缓存 (${_downloadService.waitDownloadQueue.length})',
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 100,
|
||||
child: DetailItem(
|
||||
entry: entry,
|
||||
progress: _progress,
|
||||
downloadService: _downloadService,
|
||||
showTitle: true,
|
||||
isCurr: true,
|
||||
controller: _controller,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return const SliverToBoxAdapter();
|
||||
}),
|
||||
Obx(() {
|
||||
if (_controller.pages.isNotEmpty) {
|
||||
return SliverMainAxisGroup(
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 12,
|
||||
bottom: 7,
|
||||
top: _downloadService.waitDownloadQueue.isEmpty
|
||||
? 0
|
||||
: 7,
|
||||
),
|
||||
sliver: const SliverToBoxAdapter(
|
||||
child: Text('已缓存视频'),
|
||||
),
|
||||
),
|
||||
SliverGrid.builder(
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 2,
|
||||
mainAxisExtent: 100,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
),
|
||||
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,
|
||||
removeList: true,
|
||||
);
|
||||
GStorage.watchProgress.delete(
|
||||
entry.cid.toString(),
|
||||
);
|
||||
},
|
||||
checked: item.checked ?? false,
|
||||
onSelect: (_) => _controller.onSelect(item),
|
||||
controller: _controller,
|
||||
);
|
||||
}
|
||||
return _buildItem(theme, item);
|
||||
},
|
||||
itemCount: _controller.pages.length,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
if (_downloadService.waitDownloadQueue.isNotEmpty) {
|
||||
return const SliverToBoxAdapter();
|
||||
}
|
||||
return const HttpError();
|
||||
}),
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(height: padding.bottom + 100),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
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: () async {
|
||||
await GStorage.watchProgress.deleteAll(
|
||||
pageInfo.entrys.map((e) => e.cid.toString()),
|
||||
);
|
||||
_downloadService.deletePage(
|
||||
pageDirPath: pageInfo.dirPath,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'删除',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: null;
|
||||
),
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
final first = pageInfo.entrys.first;
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: () => Get.to(
|
||||
DownloadDetailPage(
|
||||
pageId: pageInfo.pageId,
|
||||
title: pageInfo.title,
|
||||
progress: _progress,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
if (_controller.enableMultiSelect.value) {
|
||||
_controller.onSelect(pageInfo);
|
||||
return;
|
||||
}
|
||||
Get.to(
|
||||
DownloadDetailPage(
|
||||
pageId: pageInfo.pageId,
|
||||
title: pageInfo.title,
|
||||
progress: _progress,
|
||||
),
|
||||
);
|
||||
},
|
||||
onLongPress: onLongPress,
|
||||
onSecondaryTap: Utils.isMobile ? null : onLongPress,
|
||||
child: Padding(
|
||||
@@ -202,6 +314,9 @@ class _DownloadPageState extends State<DownloadPage> with GridMixin {
|
||||
right: 6.0,
|
||||
top: 6.0,
|
||||
),
|
||||
Positioned.fill(
|
||||
child: selectMask(theme, pageInfo.checked ?? false),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
@@ -222,22 +337,24 @@ class _DownloadPageState extends State<DownloadPage> with GridMixin {
|
||||
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,
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: .end,
|
||||
mainAxisAlignment: .spaceBetween,
|
||||
children: [
|
||||
if (first.ownerName case final ownerName?)
|
||||
Text(
|
||||
ownerName,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
height: 1.6,
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
)
|
||||
else
|
||||
const Spacer(),
|
||||
pageInfo.entrys.first.moreBtn(theme),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user