This commit is contained in:
royalcat 2024-05-13 19:56:20 +03:00
parent 0d7aac068c
commit 974814c281
20 changed files with 1532 additions and 716 deletions

View file

@ -16,51 +16,53 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
@override
Widget build(BuildContext context) {
return FutureBuilder(
key: GlobalKey(),
future: client.query$ListTorrents(Options$Query$ListTorrents(
variables: Variables$Query$ListTorrents(downloading: filterDownloading),
)),
builder: (context, snapshot) {
final torrents = snapshot.data?.parsedData?.torrents;
return SafeArea(
child: FutureBuilder(
key: GlobalKey(),
future: client.query$ListTorrents(Options$Query$ListTorrents(
variables: Variables$Query$ListTorrents(downloading: filterDownloading),
)),
builder: (context, snapshot) {
final torrents = snapshot.data?.parsedData?.torrents;
return NestedScrollView(
floatHeaderSlivers: true,
headerSliverBuilder: (context, innerBoxIsScrolled) => [
HideableHeaderSliver(
height: 80,
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Wrap(
spacing: 8,
runSpacing: 8,
children: [
FilterChip(
label: const Text("Downloading"),
selected: filterDownloading,
onSelected: (value) => setState(() {
filterDownloading = value;
}),
),
],
return NestedScrollView(
floatHeaderSlivers: true,
headerSliverBuilder: (context, innerBoxIsScrolled) => [
HideableHeaderSliver(
height: 80,
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Wrap(
spacing: 8,
runSpacing: 8,
children: [
FilterChip(
label: const Text("Downloading"),
selected: filterDownloading,
onSelected: (value) => setState(() {
filterDownloading = value;
}),
),
],
),
),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
onPressed: () => setState(() {}),
),
],
),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
onPressed: () => setState(() {}),
),
],
),
],
body: snapshot.hasData && torrents != null
? ListView.builder(
itemCount: torrents.length,
itemBuilder: (context, index) => TorrentTile(torrent: torrents[index]),
)
: const Center(child: CircularProgressIndicator()),
);
},
],
body: snapshot.hasData && torrents != null
? ListView.builder(
itemCount: torrents.length,
itemBuilder: (context, index) => TorrentTile(torrent: torrents[index]),
)
: const Center(child: CircularProgressIndicator()),
);
},
),
);
}
}

View file

@ -72,68 +72,74 @@ class _FileViewScreenState extends State<FileViewScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: TextField(
controller: pathController,
onEditingComplete: () => cd(pathController.text),
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
cd("..");
},
child: Scaffold(
appBar: AppBar(
title: TextField(
controller: pathController,
onEditingComplete: () => cd(pathController.text),
),
leading: IconButton(
onPressed: () => cd(".."),
icon: const Icon(Icons.arrow_upward),
),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
onPressed: refresh,
)
],
),
leading: IconButton(
onPressed: () => cd(".."),
icon: const Icon(Icons.arrow_upward),
body: FutureBuilder(
key: GlobalKey(),
future: listDirFuture,
initialData: null,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}
final data = snapshot.data!;
if (data.exception != null) {
return Text("Error\n${data.exception.toString()}");
}
final entry = snapshot.data?.parsedData?.fsEntry;
if (entry == null) {
return const Center(child: Text("Entry not exists"));
}
final entries = _getEntries(entry);
if (entries == null || entries.isEmpty) {
return const Center(child: Text("Empty dir"));
}
return CustomScrollView(
slivers: [
EntryHeaderSliver(entry: entry),
SliverList.builder(
itemCount: entries.length,
itemBuilder: (context, index) {
return DirEntry(
entry: entries[index],
onTap: (name, isFile) {
if (!isFile) {
cd(name);
}
},
);
},
),
],
);
},
),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
onPressed: refresh,
)
],
),
body: FutureBuilder(
key: GlobalKey(),
future: listDirFuture,
initialData: null,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}
final data = snapshot.data!;
if (data.exception != null) {
return Text("Error\n${data.exception.toString()}");
}
final entry = snapshot.data?.parsedData?.fsEntry;
if (entry == null) {
return const Center(child: Text("Entry not exists"));
}
final entries = _getEntries(entry);
if (entries == null || entries.isEmpty) {
return const Center(child: Text("Empty dir"));
}
return CustomScrollView(
slivers: [
EntryHeaderSliver(entry: entry),
SliverList.builder(
itemCount: entries.length,
itemBuilder: (context, index) {
return DirEntry(
entry: entries[index],
onTap: (name, isFile) {
if (!isFile) {
cd(name);
}
},
);
},
),
],
);
},
),
);
}