diff --git a/app/lib/screens/torrents/torrent_list_tile.dart b/app/lib/screens/torrents/torrent_list_tile/torrent_list_tile.dart similarity index 76% rename from app/lib/screens/torrents/torrent_list_tile.dart rename to app/lib/screens/torrents/torrent_list_tile/torrent_list_tile.dart index c1597ed..21a9442 100644 --- a/app/lib/screens/torrents/torrent_list_tile.dart +++ b/app/lib/screens/torrents/torrent_list_tile/torrent_list_tile.dart @@ -4,6 +4,7 @@ import 'package:pikatorrent/dialogs/remove_torrent.dart'; import 'package:pikatorrent/engine/torrent.dart'; import 'package:pikatorrent/models/torrents.dart'; import 'package:pikatorrent/screens/torrents/sheets/torrent_details/torrent_details.dart'; +import 'package:pikatorrent/screens/torrents/torrent_list_tile/torrent_status.dart'; import 'package:pikatorrent/utils/app_links.dart'; import 'package:pikatorrent/utils/device.dart'; import 'package:pretty_bytes/pretty_bytes.dart'; @@ -49,10 +50,13 @@ class TorrentListTile extends StatelessWidget { torrentsModel.fetchTorrents(); }, icon: torrent.status == TorrentStatus.stopped - ? const Icon(Icons.play_circle_outline) - : const Icon(Icons.pause_circle_outline), - tooltip: - torrent.status == TorrentStatus.stopped ? 'Start' : 'Stop', + ? const Icon(Icons.pause) + : torrent.progress == 1 + ? const Icon(Icons.download_done) + : const Icon(Icons.download), + tooltip: torrent.status == TorrentStatus.stopped + ? 'Start' + : 'Stop', )), ]), ), @@ -101,12 +105,10 @@ class TorrentListTile extends StatelessWidget { subtitle: Row(children: [ Expanded( - child: Text('${percent.floor().toString()}%', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 12, - color: percent == 100 ? Colors.lightGreen : null)), - ), + child: TorrentStatusText( + torrent: torrent, + percent: percent, + )), Expanded( child: Text( torrent.size != null @@ -116,23 +118,27 @@ class TorrentListTile extends StatelessWidget { const TextStyle(fontWeight: FontWeight.bold, fontSize: 12)), ), Expanded( - child: Row(children: [ - const Icon( - Icons.arrow_circle_down, - size: 16, - color: Colors.lightGreen, - ), - const SizedBox(width: 8), - Expanded( - child: Text( - overflow: TextOverflow.ellipsis, - torrent.rateDownload != null - ? '${prettyBytes(torrent.rateDownload!.toDouble())}/s' - : '-', - style: const TextStyle( - fontWeight: FontWeight.bold, fontSize: 12)), - ), - ]), + child: torrent.progress != 1 + ? Row(children: [ + const Icon( + Icons.arrow_circle_down, + size: 16, + color: Colors.lightGreen, + ), + const SizedBox(width: 8), + Expanded( + child: Text( + overflow: TextOverflow.ellipsis, + torrent.rateDownload != null + ? '${prettyBytes(torrent.rateDownload!.toDouble())}/s' + : '-', + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 12)), + ), + ]) + : const SizedBox( + width: 0, + ), ), Expanded( child: Row(children: [ @@ -159,3 +165,4 @@ class TorrentListTile extends StatelessWidget { }); } } + diff --git a/app/lib/screens/torrents/torrent_list_tile/torrent_status.dart b/app/lib/screens/torrents/torrent_list_tile/torrent_status.dart new file mode 100644 index 0000000..4fbee2c --- /dev/null +++ b/app/lib/screens/torrents/torrent_list_tile/torrent_status.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; +import 'package:pikatorrent/engine/torrent.dart'; + +class TorrentStatusText extends StatelessWidget { + final Torrent torrent; + final double percent; + + const TorrentStatusText( + {super.key, required this.torrent, required this.percent}); + + @override + Widget build(BuildContext context) { + return switch (torrent.status) { + TorrentStatus.stopped => const Text('Paused', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12)), + TorrentStatus.queuedToCheck => const Text('Queued to check', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12)), + TorrentStatus.checking => const Text('Checking', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12)), + TorrentStatus.queuedToDownload => const Text('Queued to download', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12)), + TorrentStatus.downloading => Text('${percent.floor().toString()}%', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 12, + color: Colors.lightGreen)), + TorrentStatus.queuedToSeed => const Text('Queued to seed', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12)), + TorrentStatus.seeding => const Text('Seeding', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 12, + color: Colors.lightBlue)), + null => const Text('-'), + }; + } +} diff --git a/app/lib/screens/torrents/torrents.dart b/app/lib/screens/torrents/torrents.dart index 249705d..25a2dac 100644 --- a/app/lib/screens/torrents/torrents.dart +++ b/app/lib/screens/torrents/torrents.dart @@ -7,7 +7,7 @@ import 'package:pikatorrent/models/torrents.dart'; import 'package:pikatorrent/screens/torrents/filter_labels_button.dart'; import 'package:pikatorrent/screens/torrents/sort_button.dart'; import 'package:pikatorrent/screens/torrents/text_search.dart'; -import 'package:pikatorrent/screens/torrents/torrent_list_tile.dart'; +import 'package:pikatorrent/screens/torrents/torrent_list_tile/torrent_list_tile.dart'; import 'package:pikatorrent/utils/app_links.dart'; import 'package:pikatorrent/utils/device.dart'; import 'package:provider/provider.dart';