Skip to content

Commit

Permalink
Update start/stop/completed icons, and add status feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ray committed Dec 28, 2024
1 parent b5ba4d0 commit c438a63
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
)),
]),
),
Expand Down Expand Up @@ -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
Expand All @@ -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: [
Expand All @@ -159,3 +165,4 @@ class TorrentListTile extends StatelessWidget {
});
}
}

37 changes: 37 additions & 0 deletions app/lib/screens/torrents/torrent_list_tile/torrent_status.dart
Original file line number Diff line number Diff line change
@@ -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('-'),
};
}
}
2 changes: 1 addition & 1 deletion app/lib/screens/torrents/torrents.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit c438a63

Please sign in to comment.