Add a Save Image option to the Reader context menu.

This commit is contained in:
2025-04-23 15:51:58 +08:00
parent 8cc3702e1a
commit 92d22c977c
2 changed files with 23 additions and 7 deletions

View File

@@ -287,6 +287,12 @@ class _ReaderGestureDetectorState extends AutomaticGlobalState<_ReaderGestureDet
text: "Copy Image".tl,
onClick: () => copyImage(location),
),
if (!reader.isLoading)
MenuEntry(
icon: Icons.download_outlined,
text: "Save Image".tl,
onClick: () => saveImage(location),
),
],
);
}
@@ -319,6 +325,17 @@ class _ReaderGestureDetectorState extends AutomaticGlobalState<_ReaderGestureDet
context.showMessage(message: "No Image");
}
}
void saveImage(Offset location) async {
var controller = reader._imageViewController;
var image = await controller!.getImageByOffset(location);
if (image != null) {
var filetype = detectFileType(image);
saveFile(filename: "image${filetype.ext}", data: image);
} else {
context.showMessage(message: "No Image");
}
}
}
class _DragListener {