Skip to content

Commit

Permalink
✨ delete download comic
Browse files Browse the repository at this point in the history
  • Loading branch information
niuhuan committed Nov 16, 2023
1 parent 7c253a9 commit a7c79f7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/screens/components/download_comic_card.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:flutter/material.dart';

import '../../bridge_generated.dart';
Expand Down Expand Up @@ -112,7 +111,14 @@ class DownloadComicCard extends StatelessWidget {
),
);
}
if (comic.downloadStatus == 3) {
return Text(
"删除",
style: TextStyle(
color: Colors.red,
),
);
}
return Container();
}
}

29 changes: 29 additions & 0 deletions lib/screens/downloads_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,35 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
),
);
},
onLongPress: () async {
// confirm delete
final ok = await showDialog<bool>(
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),
)),
],
Expand Down

0 comments on commit a7c79f7

Please sign in to comment.