mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
@@ -7,13 +7,13 @@ class MultiSelectAppBarWidget extends StatelessWidget
|
||||
final MultiSelectBase ctr;
|
||||
final bool? visible;
|
||||
final AppBar child;
|
||||
final List<Widget>? children;
|
||||
final List<Widget>? actions;
|
||||
|
||||
const MultiSelectAppBarWidget({
|
||||
super.key,
|
||||
required this.ctr,
|
||||
this.visible,
|
||||
this.children,
|
||||
this.actions,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ class MultiSelectAppBarWidget extends StatelessWidget
|
||||
onPressed: () => ctr.handleSelect(checked: true),
|
||||
child: const Text('全选'),
|
||||
),
|
||||
...?children,
|
||||
...?actions,
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
visualDensity: VisualDensity.compact,
|
||||
|
||||
@@ -13,7 +13,7 @@ abstract class CommonSearchPageState<S extends StatefulWidget, R, T>
|
||||
|
||||
List<Widget>? get extraActions => null;
|
||||
|
||||
List<Widget>? get multiSelectChildren => null;
|
||||
List<Widget>? get multiSelectActions => null;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -84,7 +84,7 @@ abstract class CommonSearchPageState<S extends StatefulWidget, R, T>
|
||||
if (multiSelect) {
|
||||
return MultiSelectAppBarWidget(
|
||||
ctr: controller as MultiSelectBase,
|
||||
children: multiSelectChildren,
|
||||
actions: multiSelectActions,
|
||||
child: bar,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,6 +94,34 @@ class _DownloadDetailPageState extends State<DownloadDetailPage>
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: MultiSelectAppBarWidget(
|
||||
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(
|
||||
title: Text(widget.title),
|
||||
actions: [
|
||||
|
||||
@@ -57,7 +57,8 @@ class DetailItem extends StatelessWidget {
|
||||
final outline = theme.colorScheme.outline;
|
||||
final cid = entry.source?.cid ?? entry.pageData?.cid;
|
||||
final canDel = onDelete != null;
|
||||
void onLongPress() => canDel
|
||||
final enableMultiSelect = controller.enableMultiSelect.value;
|
||||
void onLongPress() => canDel && !enableMultiSelect
|
||||
? showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@@ -116,7 +117,7 @@ class DetailItem extends StatelessWidget {
|
||||
Get.to(const DownloadingPage());
|
||||
return;
|
||||
}
|
||||
if (controller.enableMultiSelect.value) {
|
||||
if (enableMultiSelect) {
|
||||
(onSelect ?? controller.onSelect).call(entry);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ 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 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
|
||||
Widget buildList(List<BiliDownloadEntryInfo> list) {
|
||||
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/select_mask.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/pages/download/controller.dart';
|
||||
import 'package:PiliPlus/pages/download/detail/view.dart';
|
||||
@@ -57,6 +58,38 @@ class _DownloadPageState extends State<DownloadPage> {
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: MultiSelectAppBarWidget(
|
||||
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(
|
||||
title: const Text('离线缓存'),
|
||||
actions: [
|
||||
@@ -169,7 +202,7 @@ class _DownloadPageState extends State<DownloadPage> {
|
||||
controller: _controller,
|
||||
);
|
||||
}
|
||||
return _buildItem(theme, item);
|
||||
return _buildItem(theme, item, enableMultiSelect);
|
||||
},
|
||||
itemCount: _controller.pages.length,
|
||||
),
|
||||
@@ -192,8 +225,14 @@ class _DownloadPageState extends State<DownloadPage> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildItem(ThemeData theme, DownloadPageInfo pageInfo) {
|
||||
void onLongPress() => showDialog(
|
||||
Widget _buildItem(
|
||||
ThemeData theme,
|
||||
DownloadPageInfo pageInfo,
|
||||
bool enableMultiSelect,
|
||||
) {
|
||||
void onLongPress() => enableMultiSelect
|
||||
? null
|
||||
: showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
|
||||
@@ -157,7 +157,7 @@ class _LaterPageState extends State<LaterPage>
|
||||
return MultiSelectAppBarWidget(
|
||||
visible: enableMultiSelect,
|
||||
ctr: currCtr(),
|
||||
children: [
|
||||
actions: [
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
visualDensity: VisualDensity.compact,
|
||||
|
||||
Reference in New Issue
Block a user