mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
@@ -7,13 +7,13 @@ class MultiSelectAppBarWidget extends StatelessWidget
|
|||||||
final MultiSelectBase ctr;
|
final MultiSelectBase ctr;
|
||||||
final bool? visible;
|
final bool? visible;
|
||||||
final AppBar child;
|
final AppBar child;
|
||||||
final List<Widget>? children;
|
final List<Widget>? actions;
|
||||||
|
|
||||||
const MultiSelectAppBarWidget({
|
const MultiSelectAppBarWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.ctr,
|
required this.ctr,
|
||||||
this.visible,
|
this.visible,
|
||||||
this.children,
|
this.actions,
|
||||||
required this.child,
|
required this.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class MultiSelectAppBarWidget extends StatelessWidget
|
|||||||
onPressed: () => ctr.handleSelect(checked: true),
|
onPressed: () => ctr.handleSelect(checked: true),
|
||||||
child: const Text('全选'),
|
child: const Text('全选'),
|
||||||
),
|
),
|
||||||
...?children,
|
...?actions,
|
||||||
TextButton(
|
TextButton(
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ abstract class CommonSearchPageState<S extends StatefulWidget, R, T>
|
|||||||
|
|
||||||
List<Widget>? get extraActions => null;
|
List<Widget>? get extraActions => null;
|
||||||
|
|
||||||
List<Widget>? get multiSelectChildren => null;
|
List<Widget>? get multiSelectActions => null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -84,7 +84,7 @@ abstract class CommonSearchPageState<S extends StatefulWidget, R, T>
|
|||||||
if (multiSelect) {
|
if (multiSelect) {
|
||||||
return MultiSelectAppBarWidget(
|
return MultiSelectAppBarWidget(
|
||||||
ctr: controller as MultiSelectBase,
|
ctr: controller as MultiSelectBase,
|
||||||
children: multiSelectChildren,
|
actions: multiSelectActions,
|
||||||
child: bar,
|
child: bar,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,34 @@ class _DownloadDetailPageState extends State<DownloadDetailPage>
|
|||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
appBar: MultiSelectAppBarWidget(
|
appBar: MultiSelectAppBarWidget(
|
||||||
ctr: this,
|
ctr: this,
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
final allChecked = this.allChecked.toSet();
|
||||||
|
handleSelect();
|
||||||
|
final res = await Future.wait(
|
||||||
|
allChecked.map(
|
||||||
|
(e) => _downloadService.downloadDanmaku(
|
||||||
|
entry: e,
|
||||||
|
isUpdate: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (res.every((e) => e)) {
|
||||||
|
SmartDialog.showToast('更新成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast('更新失败');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'更新',
|
||||||
|
style: TextStyle(color: Get.theme.colorScheme.onSurface),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
child: AppBar(
|
child: AppBar(
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
actions: [
|
actions: [
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ class DetailItem extends StatelessWidget {
|
|||||||
final outline = theme.colorScheme.outline;
|
final outline = theme.colorScheme.outline;
|
||||||
final cid = entry.source?.cid ?? entry.pageData?.cid;
|
final cid = entry.source?.cid ?? entry.pageData?.cid;
|
||||||
final canDel = onDelete != null;
|
final canDel = onDelete != null;
|
||||||
void onLongPress() => canDel
|
final enableMultiSelect = controller.enableMultiSelect.value;
|
||||||
|
void onLongPress() => canDel && !enableMultiSelect
|
||||||
? showDialog(
|
? showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@@ -116,7 +117,7 @@ class DetailItem extends StatelessWidget {
|
|||||||
Get.to(const DownloadingPage());
|
Get.to(const DownloadingPage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (controller.enableMultiSelect.value) {
|
if (enableMultiSelect) {
|
||||||
(onSelect ?? controller.onSelect).call(entry);
|
(onSelect ?? controller.onSelect).call(entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:PiliPlus/services/download/download_service.dart';
|
|||||||
import 'package:PiliPlus/utils/grid.dart';
|
import 'package:PiliPlus/utils/grid.dart';
|
||||||
import 'package:flutter/material.dart'
|
import 'package:flutter/material.dart'
|
||||||
hide SliverGridDelegateWithMaxCrossAxisExtent;
|
hide SliverGridDelegateWithMaxCrossAxisExtent;
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class DownloadSearchPage extends StatefulWidget {
|
class DownloadSearchPage extends StatefulWidget {
|
||||||
@@ -47,6 +48,34 @@ class _DownloadSearchPageState
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Widget>? get multiSelectActions => [
|
||||||
|
TextButton(
|
||||||
|
style: TextButton.styleFrom(visualDensity: VisualDensity.compact),
|
||||||
|
onPressed: () async {
|
||||||
|
final allChecked = controller.allChecked.toSet();
|
||||||
|
controller.handleSelect();
|
||||||
|
final res = await Future.wait(
|
||||||
|
allChecked.map(
|
||||||
|
(e) => _downloadService.downloadDanmaku(
|
||||||
|
entry: e,
|
||||||
|
isUpdate: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (res.every((e) => e)) {
|
||||||
|
SmartDialog.showToast('更新成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast('更新失败');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'更新',
|
||||||
|
style: TextStyle(color: Get.theme.colorScheme.onSurface),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildList(List<BiliDownloadEntryInfo> list) {
|
Widget buildList(List<BiliDownloadEntryInfo> list) {
|
||||||
if (list.isNotEmpty) {
|
if (list.isNotEmpty) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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/loading_widget/http_error.dart';
|
||||||
import 'package:PiliPlus/common/widgets/select_mask.dart';
|
import 'package:PiliPlus/common/widgets/select_mask.dart';
|
||||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||||
|
import 'package:PiliPlus/models_new/download/bili_download_entry_info.dart';
|
||||||
import 'package:PiliPlus/models_new/download/download_info.dart';
|
import 'package:PiliPlus/models_new/download/download_info.dart';
|
||||||
import 'package:PiliPlus/pages/download/controller.dart';
|
import 'package:PiliPlus/pages/download/controller.dart';
|
||||||
import 'package:PiliPlus/pages/download/detail/view.dart';
|
import 'package:PiliPlus/pages/download/detail/view.dart';
|
||||||
@@ -57,6 +58,38 @@ class _DownloadPageState extends State<DownloadPage> {
|
|||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
appBar: MultiSelectAppBarWidget(
|
appBar: MultiSelectAppBarWidget(
|
||||||
ctr: _controller,
|
ctr: _controller,
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
final allChecked = _controller.allChecked.toSet();
|
||||||
|
_controller.handleSelect();
|
||||||
|
final list = <BiliDownloadEntryInfo>[];
|
||||||
|
for (var page in allChecked) {
|
||||||
|
list.addAll(page.entrys);
|
||||||
|
}
|
||||||
|
final res = await Future.wait(
|
||||||
|
list.map(
|
||||||
|
(e) => _downloadService.downloadDanmaku(
|
||||||
|
entry: e,
|
||||||
|
isUpdate: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (res.every((e) => e)) {
|
||||||
|
SmartDialog.showToast('更新成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast('更新失败');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'更新',
|
||||||
|
style: TextStyle(color: theme.colorScheme.onSurface),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
child: AppBar(
|
child: AppBar(
|
||||||
title: const Text('离线缓存'),
|
title: const Text('离线缓存'),
|
||||||
actions: [
|
actions: [
|
||||||
@@ -169,7 +202,7 @@ class _DownloadPageState extends State<DownloadPage> {
|
|||||||
controller: _controller,
|
controller: _controller,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return _buildItem(theme, item);
|
return _buildItem(theme, item, enableMultiSelect);
|
||||||
},
|
},
|
||||||
itemCount: _controller.pages.length,
|
itemCount: _controller.pages.length,
|
||||||
),
|
),
|
||||||
@@ -192,66 +225,72 @@ class _DownloadPageState extends State<DownloadPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildItem(ThemeData theme, DownloadPageInfo pageInfo) {
|
Widget _buildItem(
|
||||||
void onLongPress() => showDialog(
|
ThemeData theme,
|
||||||
context: context,
|
DownloadPageInfo pageInfo,
|
||||||
builder: (context) {
|
bool enableMultiSelect,
|
||||||
return AlertDialog(
|
) {
|
||||||
clipBehavior: Clip.hardEdge,
|
void onLongPress() => enableMultiSelect
|
||||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
? null
|
||||||
content: Column(
|
: showDialog(
|
||||||
mainAxisSize: MainAxisSize.min,
|
context: context,
|
||||||
children: [
|
builder: (context) {
|
||||||
ListTile(
|
return AlertDialog(
|
||||||
onTap: () {
|
clipBehavior: Clip.hardEdge,
|
||||||
Get.back();
|
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
showConfirmDialog(
|
content: Column(
|
||||||
context: context,
|
mainAxisSize: MainAxisSize.min,
|
||||||
title: '确定删除?',
|
children: [
|
||||||
onConfirm: () async {
|
ListTile(
|
||||||
await GStorage.watchProgress.deleteAll(
|
onTap: () {
|
||||||
pageInfo.entrys.map((e) => e.cid.toString()),
|
Get.back();
|
||||||
);
|
showConfirmDialog(
|
||||||
_downloadService.deletePage(
|
context: context,
|
||||||
pageDirPath: pageInfo.dirPath,
|
title: '确定删除?',
|
||||||
);
|
onConfirm: () async {
|
||||||
},
|
await GStorage.watchProgress.deleteAll(
|
||||||
);
|
pageInfo.entrys.map((e) => e.cid.toString()),
|
||||||
},
|
);
|
||||||
dense: true,
|
_downloadService.deletePage(
|
||||||
title: const Text(
|
pageDirPath: pageInfo.dirPath,
|
||||||
'删除',
|
);
|
||||||
style: TextStyle(fontSize: 14),
|
},
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
ListTile(
|
dense: true,
|
||||||
onTap: () async {
|
title: const Text(
|
||||||
Get.back();
|
'删除',
|
||||||
final res = await Future.wait(
|
style: TextStyle(fontSize: 14),
|
||||||
pageInfo.entrys.map(
|
|
||||||
(e) => _downloadService.downloadDanmaku(
|
|
||||||
entry: e,
|
|
||||||
isUpdate: true,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
ListTile(
|
||||||
if (res.every((e) => e)) {
|
onTap: () async {
|
||||||
SmartDialog.showToast('更新成功');
|
Get.back();
|
||||||
} else {
|
final res = await Future.wait(
|
||||||
SmartDialog.showToast('更新失败');
|
pageInfo.entrys.map(
|
||||||
}
|
(e) => _downloadService.downloadDanmaku(
|
||||||
},
|
entry: e,
|
||||||
dense: true,
|
isUpdate: true,
|
||||||
title: const Text(
|
),
|
||||||
'更新弹幕',
|
),
|
||||||
style: TextStyle(fontSize: 14),
|
);
|
||||||
|
if (res.every((e) => e)) {
|
||||||
|
SmartDialog.showToast('更新成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast('更新失败');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dense: true,
|
||||||
|
title: const Text(
|
||||||
|
'更新弹幕',
|
||||||
|
style: TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
),
|
);
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
final first = pageInfo.entrys.first;
|
final first = pageInfo.entrys.first;
|
||||||
return Material(
|
return Material(
|
||||||
type: MaterialType.transparency,
|
type: MaterialType.transparency,
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class _LaterPageState extends State<LaterPage>
|
|||||||
return MultiSelectAppBarWidget(
|
return MultiSelectAppBarWidget(
|
||||||
visible: enableMultiSelect,
|
visible: enableMultiSelect,
|
||||||
ctr: currCtr(),
|
ctr: currCtr(),
|
||||||
children: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
|
|||||||
Reference in New Issue
Block a user