improve progress display

This commit is contained in:
wgh19
2024-05-31 18:39:28 +08:00
parent 6a95fb37ed
commit 5e53c57755
2 changed files with 48 additions and 32 deletions

View File

@@ -158,7 +158,8 @@
"Add to favorites": "添加收藏", "Add to favorites": "添加收藏",
"Follow the artist": "关注画师", "Follow the artist": "关注画师",
"Manga": "漫画", "Manga": "漫画",
"Actions": "操作" "Actions": "操作",
"Current quantity": "当前数量"
}, },
"zh_TW": { "zh_TW": {
"Search": "搜索", "Search": "搜索",
@@ -319,6 +320,7 @@
"Add to favorites": "添加收藏", "Add to favorites": "添加收藏",
"Follow the artist": "關注畫師", "Follow the artist": "關注畫師",
"Manga": "漫畫", "Manga": "漫畫",
"Actions": "操作" "Actions": "操作",
"Current quantity": "當前數量"
} }
} }

View File

@@ -15,7 +15,10 @@ class BatchDownloadButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Button( return Button(
child: const Icon(MdIcons.download, size: 20,), child: const Icon(
MdIcons.download,
size: 20,
),
onPressed: () { onPressed: () {
showDialog( showDialog(
context: context, context: context,
@@ -40,6 +43,8 @@ class _DownloadDialog extends StatefulWidget {
class _DownloadDialogState extends State<_DownloadDialog> { class _DownloadDialogState extends State<_DownloadDialog> {
int maxCount = 30; int maxCount = 30;
int currentCount = 0;
bool loading = false; bool loading = false;
bool cancel = false; bool cancel = false;
@@ -53,8 +58,11 @@ class _DownloadDialogState extends State<_DownloadDialog> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text('${"Maximum number of downloads".tl}:'), if (!loading) Text('${"Maximum number of downloads".tl}:'),
const SizedBox(height: 16,), if (loading) Text("${"Current quantity".tl}: $currentCount"),
const SizedBox(
height: 16,
),
SizedBox( SizedBox(
height: 42, height: 42,
width: 196, width: 196,
@@ -71,19 +79,23 @@ class _DownloadDialogState extends State<_DownloadDialog> {
largeChange: 30, largeChange: 30,
clearButton: false, clearButton: false,
), ),
) ),
], ],
).paddingVertical(8), ).paddingVertical(8),
), ),
actions: [ actions: [
Button(child: Text("Cancel".tl), onPressed: () { Button(
child: Text("Cancel".tl),
onPressed: () {
cancel = true; cancel = true;
context.pop(); context.pop();
}), }),
if (!loading) if (!loading)
FilledButton(onPressed: load, child: Text("Continue".tl)) FilledButton(onPressed: load, child: Text("Continue".tl))
else else
FilledButton(onPressed: (){}, child: const SizedBox( FilledButton(
onPressed: () {},
child: const SizedBox(
height: 20, height: 20,
width: 64, width: 64,
child: Center( child: Center(
@@ -130,15 +142,17 @@ class _DownloadDialogState extends State<_DownloadDialog> {
continue; continue;
} }
all.addAll(res.data); all.addAll(res.data);
setState(() {
currentCount = all.length;
});
nextUrl = res.subData ?? "end"; nextUrl = res.subData ?? "end";
} }
int i = 0; int i = 0;
for (var illust in all) { for (var illust in all) {
if(i > maxCount) return; if (i > maxCount) break;
DownloadManager().addDownloadingTask(illust); DownloadManager().addDownloadingTask(illust);
i++; i++;
} }
context.pop(); context.pop();
} }
} }