mod: save image: dissable dialog

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-28 21:32:53 +08:00
parent b00708b498
commit e34fce6d0e
2 changed files with 17 additions and 5 deletions

View File

@@ -334,7 +334,7 @@ class _InteractiveviewerGalleryState extends State<InteractiveviewerGallery>
onTap: () {
DownloadUtils.downloadImg(
context,
widget.sources[currentIndex!],
widget.sources as List<String>,
);
},
child: const Text("保存全部图片"),

View File

@@ -93,10 +93,19 @@ class DownloadUtils {
if (!await checkPermissionDependOnSdkInt(context)) {
return;
}
bool dispose = false;
for (int i = 0; i < imgList.length; i++) {
SmartDialog.showLoading(
msg:
'正在下载原图${imgList.length > 1 ? '${i + 1}/${imgList.length}' : ''}');
msg:
'正在下载原图${imgList.length > 1 ? '${i + 1}/${imgList.length}' : ''}',
clickMaskDismiss: true,
onDismiss: () {
dispose = true;
if (i != imgList.length - 1) {
SmartDialog.showToast('已取消下载剩余图片');
}
},
);
var response = await Request().get(
imgList[i],
options: Options(responseType: ResponseType.bytes),
@@ -117,9 +126,12 @@ class DownloadUtils {
SmartDialog.dismiss();
}
if (result.isSuccess) {
await SmartDialog.showToast('$picName」已保存 ');
SmartDialog.showToast('$picName」已保存 ');
} else {
await SmartDialog.showToast('保存失败,${result.errorMessage}');
SmartDialog.showToast('保存失败,${result.errorMessage}');
}
if (dispose) {
break;
}
}
} catch (err) {