royalcat
d8ee8a3a24
All checks were successful
docker / build-docker (linux/amd64) (push) Successful in 1m34s
docker / build-docker (linux/386) (push) Successful in 1m37s
docker / build-docker (linux/arm64/v8) (push) Successful in 7m37s
docker / build-docker (linux/arm64) (push) Successful in 7m44s
docker / build-docker (linux/arm/v7) (push) Successful in 8m12s
55 lines
1.8 KiB
Dart
55 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:tstor_ui/api/client.dart';
|
|
import 'package:tstor_ui/api/torrent.graphql.dart';
|
|
import 'package:tstor_ui/components/download.dart';
|
|
|
|
class DownloadsScreen extends StatefulWidget {
|
|
const DownloadsScreen({super.key});
|
|
|
|
@override
|
|
State<DownloadsScreen> createState() => _DownloadsScreenState();
|
|
}
|
|
|
|
class _DownloadsScreenState extends State<DownloadsScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FutureBuilder(
|
|
future: client.query$ListTorrents(),
|
|
builder: (context, snapshot) {
|
|
if (!snapshot.hasData || snapshot.data == null) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
|
|
final torrents = snapshot.data!.parsedData!.torrents;
|
|
|
|
return ListView.builder(
|
|
itemCount: torrents.length,
|
|
itemBuilder: (context, index) {
|
|
final torrent = torrents[index];
|
|
return ListTile(
|
|
title: Text(torrent.name),
|
|
subtitle: DownloadProgress(
|
|
torrent.bytesCompleted, torrent.bytesCompleted + torrent.bytesMissing),
|
|
trailing: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
IconButton(
|
|
onPressed: () => client.mutate$MarkTorrentDownload(
|
|
Options$Mutation$MarkTorrentDownload(
|
|
variables: Variables$Mutation$MarkTorrentDownload(
|
|
infohash: torrent.infohash,
|
|
),
|
|
),
|
|
),
|
|
icon: const Icon(Icons.download),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|