Skip to content

Commit c63b7ca

Browse files
authored
feat: Added long press to delete torrent (#51)
* feat: Added long press to delete torrrent
1 parent 21c0a3b commit c63b7ca

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

lib/components/torrent_tile.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import 'package:rutorrentflutter/models/torrent.dart';
99
import '../api/api_conf.dart';
1010
import 'package:rutorrentflutter/utilities/constants.dart';
1111

12+
import 'custom_dialog.dart';
13+
1214
class TorrentTile extends StatelessWidget {
1315
final Torrent torrent;
1416
TorrentTile(this.torrent);
@@ -46,6 +48,24 @@ class TorrentTile extends StatelessWidget {
4648
return Consumer<Api>(
4749
builder: (context, api, child) {
4850
return GestureDetector(
51+
onLongPress: () {
52+
showDialog(
53+
context: context,
54+
builder: (context) => CustomDialog(
55+
title: 'Remove Torrent',
56+
optionRightText: 'Remove Torrent and Delete Data',
57+
optionLeftText: 'Remove Torrent',
58+
optionRightOnPressed: () {
59+
ApiRequests.removeTorrentWithData(
60+
torrent.api, torrent.hash);
61+
Navigator.pop(context);
62+
},
63+
optionLeftOnPressed: () {
64+
ApiRequests.removeTorrent(torrent.api, torrent.hash);
65+
Navigator.pop(context);
66+
},
67+
));
68+
},
4969
behavior: HitTestBehavior.opaque,
5070
onTap: () {
5171
Navigator.push(

pubspec.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ packages:
167167
url: "https://pub.dartlang.org"
168168
source: hosted
169169
version: "1.0.11"
170+
flutter_slidable:
171+
dependency: "direct main"
172+
description:
173+
name: flutter_slidable
174+
url: "https://pub.dartlang.org"
175+
source: hosted
176+
version: "0.5.7"
170177
flutter_svg:
171178
dependency: "direct main"
172179
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies:
3232
flutter_vlc_player: ^3.0.6
3333
package_info: ^0.4.3
3434
wakelock: ^0.2.0+1
35+
flutter_slidable: ^0.5.7
3536
flutter_svg: ^0.19.1
3637

3738
dev_dependencies:

0 commit comments

Comments
 (0)