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: () { onTap: () {
DownloadUtils.downloadImg( DownloadUtils.downloadImg(
context, context,
widget.sources[currentIndex!], widget.sources as List<String>,
); );
}, },
child: const Text("保存全部图片"), child: const Text("保存全部图片"),

View File

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