mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
improve progress display
This commit is contained in:
@@ -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": "當前數量"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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,15 +58,18 @@ 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,
|
||||||
child: NumberBox(
|
child: NumberBox(
|
||||||
value: maxCount,
|
value: maxCount,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if(!loading) {
|
if (!loading) {
|
||||||
setState(() => maxCount = value ?? maxCount);
|
setState(() => maxCount = value ?? maxCount);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -71,35 +79,39 @@ 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(
|
||||||
cancel = true;
|
child: Text("Cancel".tl),
|
||||||
context.pop();
|
onPressed: () {
|
||||||
}),
|
cancel = true;
|
||||||
if(!loading)
|
context.pop();
|
||||||
|
}),
|
||||||
|
if (!loading)
|
||||||
FilledButton(onPressed: load, child: Text("Continue".tl))
|
FilledButton(onPressed: load, child: Text("Continue".tl))
|
||||||
else
|
else
|
||||||
FilledButton(onPressed: (){}, child: const SizedBox(
|
FilledButton(
|
||||||
height: 20,
|
onPressed: () {},
|
||||||
width: 64,
|
child: const SizedBox(
|
||||||
child: Center(
|
height: 20,
|
||||||
child: SizedBox.square(
|
width: 64,
|
||||||
dimension: 18,
|
child: Center(
|
||||||
child: ProgressRing(
|
child: SizedBox.square(
|
||||||
strokeWidth: 1.6,
|
dimension: 18,
|
||||||
|
child: ProgressRing(
|
||||||
|
strokeWidth: 1.6,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
))
|
||||||
),
|
|
||||||
))
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load() async{
|
void load() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = true;
|
loading = true;
|
||||||
});
|
});
|
||||||
@@ -109,17 +121,17 @@ class _DownloadDialogState extends State<_DownloadDialog> {
|
|||||||
List<Illust> all = [];
|
List<Illust> all = [];
|
||||||
String? nextUrl;
|
String? nextUrl;
|
||||||
int retryCount = 0;
|
int retryCount = 0;
|
||||||
while(nextUrl != "end" && all.length < maxCount) {
|
while (nextUrl != "end" && all.length < maxCount) {
|
||||||
if(nextUrl != null) {
|
if (nextUrl != null) {
|
||||||
request = Network().getIllustsWithNextUrl(nextUrl);
|
request = Network().getIllustsWithNextUrl(nextUrl);
|
||||||
}
|
}
|
||||||
var res = await request;
|
var res = await request;
|
||||||
if(cancel || !mounted) {
|
if (cancel || !mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(res.error) {
|
if (res.error) {
|
||||||
retryCount++;
|
retryCount++;
|
||||||
if(retryCount > 3) {
|
if (retryCount > 3) {
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = false;
|
loading = false;
|
||||||
});
|
});
|
||||||
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user