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 {

View File

@@ -378,11 +378,12 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
Tooltip(
message: "Collect the image".tl,
child: IconButton(
icon: Icon(
isLiked() ? Icons.favorite : Icons.favorite_border),
onPressed: addImageFavorite),
icon:
Icon(isLiked() ? Icons.favorite : Icons.favorite_border),
onPressed: addImageFavorite,
),
),
if (App.isWindows)
if (App.isDesktop)
Tooltip(
message: "${"Full Screen".tl}(F12)",
child: IconButton(
@@ -750,9 +751,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
? Icons.arrow_forward_ios
: Icons.arrow_back_ios_outlined,
size: 24,
color: Theme.of(context)
.colorScheme
.onPrimaryContainer,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
),