From a7c79f745ab33e18135b2ff44b837c72b76ecd5b Mon Sep 17 00:00:00 2001 From: niuhuan Date: Thu, 16 Nov 2023 12:58:11 +0800 Subject: [PATCH] :sparkles: delete download comic --- .../components/download_comic_card.dart | 10 +++++-- lib/screens/downloads_screen.dart | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/screens/components/download_comic_card.dart b/lib/screens/components/download_comic_card.dart index 1b9310b..a1e939d 100644 --- a/lib/screens/components/download_comic_card.dart +++ b/lib/screens/components/download_comic_card.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import '../../bridge_generated.dart'; @@ -112,7 +111,14 @@ class DownloadComicCard extends StatelessWidget { ), ); } + if (comic.downloadStatus == 3) { + return Text( + "删除", + style: TextStyle( + color: Colors.red, + ), + ); + } return Container(); } } - diff --git a/lib/screens/downloads_screen.dart b/lib/screens/downloads_screen.dart index 695b775..0caaef5 100644 --- a/lib/screens/downloads_screen.dart +++ b/lib/screens/downloads_screen.dart @@ -82,6 +82,35 @@ class _DownloadsScreenState extends State { ), ); }, + onLongPress: () async { + // confirm delete + final ok = await showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text("确认删除"), + content: const Text("删除后将无法恢复"), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: const Text("取消"), + ), + TextButton( + onPressed: () { + Navigator.of(context).pop(true); + }, + child: const Text("确认"), + ), + ], + ), + ); + if (ok == true) { + await api.deleteDownloadComic( + comicPathWord: e.pathWord); + await _init(); + } + }, child: DownloadComicCard(e), )), ],