mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Add a Save Image option to the Reader context menu.
This commit is contained in:
@@ -287,6 +287,12 @@ class _ReaderGestureDetectorState extends AutomaticGlobalState<_ReaderGestureDet
|
|||||||
text: "Copy Image".tl,
|
text: "Copy Image".tl,
|
||||||
onClick: () => copyImage(location),
|
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");
|
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 {
|
class _DragListener {
|
||||||
|
@@ -378,11 +378,12 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
Tooltip(
|
Tooltip(
|
||||||
message: "Collect the image".tl,
|
message: "Collect the image".tl,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: Icon(
|
icon:
|
||||||
isLiked() ? Icons.favorite : Icons.favorite_border),
|
Icon(isLiked() ? Icons.favorite : Icons.favorite_border),
|
||||||
onPressed: addImageFavorite),
|
onPressed: addImageFavorite,
|
||||||
),
|
),
|
||||||
if (App.isWindows)
|
),
|
||||||
|
if (App.isDesktop)
|
||||||
Tooltip(
|
Tooltip(
|
||||||
message: "${"Full Screen".tl}(F12)",
|
message: "${"Full Screen".tl}(F12)",
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
@@ -750,9 +751,7 @@ class _ReaderScaffoldState extends State<_ReaderScaffold> {
|
|||||||
? Icons.arrow_forward_ios
|
? Icons.arrow_forward_ios
|
||||||
: Icons.arrow_back_ios_outlined,
|
: Icons.arrow_back_ios_outlined,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: Theme.of(context)
|
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
.colorScheme
|
|
||||||
.onPrimaryContainer,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user