Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

add edit button for history page

Predidit3cc601c8a167
diff --git a/lib/bean/card/bangumi_history_card.dart b/lib/bean/card/bangumi_history_card.dart
index 4f2be832..fb53b75d 100644
--- a/lib/bean/card/bangumi_history_card.dart
+++ b/lib/bean/card/bangumi_history_card.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
+import 'package:kazumi/pages/history/history_controller.dart';
import 'package:kazumi/plugins/plugins.dart';
import 'package:kazumi/utils/constans.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@@ -14,9 +15,10 @@ import 'package:kazumi/utils/logger.dart';
// 视频历史记录卡片 - 水平布局
class BangumiHistoryCardV extends StatefulWidget {
- const BangumiHistoryCardV({super.key, required this.historyItem});
+ const BangumiHistoryCardV({super.key, required this.historyItem, this.showDelete = true});
final History historyItem;
+ final bool showDelete;
@override
State<BangumiHistoryCardV> createState() => _BangumiHistoryCardVState();
@@ -27,6 +29,7 @@ class _BangumiHistoryCardVState extends State<BangumiHistoryCardV> {
final VideoPageController videoPageController =
Modular.get<VideoPageController>();
final PluginsController pluginsController = Modular.get<PluginsController>();
+ final HistoryController historyController = Modular.get<HistoryController>();
@override
Widget build(BuildContext context) {
@@ -145,21 +148,31 @@ class _BangumiHistoryCardVState extends State<BangumiHistoryCardV> {
],
),
),
- IconButton(
- icon: Icon(
- isFavorite ? Icons.favorite : Icons.favorite_outline),
- onPressed: () async {
- if (isFavorite) {
- favoriteController
- .deleteFavorite(widget.historyItem.bangumiItem);
- } else {
- favoriteController
- .addFavorite(widget.historyItem.bangumiItem);
- }
- setState(() {
- isFavorite = !isFavorite;
- });
- },
+ Column(
+ children: [
+ IconButton(
+ icon: Icon(
+ isFavorite ? Icons.favorite : Icons.favorite_outline),
+ onPressed: () async {
+ if (isFavorite) {
+ favoriteController
+ .deleteFavorite(widget.historyItem.bangumiItem);
+ } else {
+ favoriteController
+ .addFavorite(widget.historyItem.bangumiItem);
+ }
+ setState(() {
+ isFavorite = !isFavorite;
+ });
+ },
+ ),
+ widget.showDelete ? IconButton(
+ icon: const Icon(Icons.delete),
+ onPressed: () {
+ historyController.deleteHistory(widget.historyItem);
+ },
+ ) : Container(),
+ ],
),
],
),
diff --git a/lib/pages/history/history_page.dart b/lib/pages/history/history_page.dart
index a3ab34e9..cdee0cb5 100644
--- a/lib/pages/history/history_page.dart
+++ b/lib/pages/history/history_page.dart
@@ -24,6 +24,9 @@ class _HistoryPageState extends State<HistoryPage>
dynamic navigationBarState;
TabController? controller;
+ /// show delete button
+ bool showDelete = false;
+
@override
void initState() {
super.initState();
@@ -46,28 +49,35 @@ class _HistoryPageState extends State<HistoryPage>
WidgetsBinding.instance.addPostFrameCallback((_) {
navigationBarState.hideNavigate();
});
- return OrientationBuilder(
- builder: (context, orientation) {
- return Observer(builder: (context) {
- return PopScope(
- canPop: true,
- onPopInvokedWithResult: (bool didPop, Object? result) async {
- onBackPressed(context);
- },
- child: Scaffold(
- appBar: const SysAppBar(title: Text('历史记录')),
- body: renderBody(orientation),
- floatingActionButton: FloatingActionButton(
- child: const Icon(Icons.clear_all),
- onPressed: () {
- historyController.clearAll();
- },
- ),
+ return OrientationBuilder(builder: (context, orientation) {
+ return Observer(builder: (context) {
+ return PopScope(
+ canPop: true,
+ onPopInvokedWithResult: (bool didPop, Object? result) async {
+ onBackPressed(context);
+ },
+ child: Scaffold(
+ appBar: SysAppBar(
+ title: const Text('历史记录'),
+ actions: [
+ IconButton(onPressed: () {
+ setState(() {
+ showDelete = !showDelete;
+ });
+ }, icon: showDelete ? const Icon(Icons.edit_outlined) : const Icon(Icons.edit))
+ ],
),
- );
- });
- }
- );
+ body: renderBody(orientation),
+ floatingActionButton: FloatingActionButton(
+ child: const Icon(Icons.clear_all),
+ onPressed: () {
+ historyController.clearAll();
+ },
+ ),
+ ),
+ );
+ });
+ });
}
Widget renderBody(Orientation orientation) {
@@ -94,6 +104,7 @@ class _HistoryPageState extends State<HistoryPage>
(BuildContext context, int index) {
return historyController.histories.isNotEmpty
? BangumiHistoryCardV(
+ showDelete: showDelete,
historyItem: historyController.histories[index])
: null;
},