-
Notifications
You must be signed in to change notification settings - Fork 845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(flutter_quill_extensions): improve image save #2403
Conversation
…, replace gal and gal_linux with quill_native_bridge
flutter_quill_extensions/lib/src/common/utils/file_path_utils.dart
Outdated
Show resolved
Hide resolved
flutter_quill_extensions/lib/src/editor/image/image_save_utils.dart
Outdated
Show resolved
Hide resolved
flutter_quill_extensions/lib/src/editor/image/image_save_utils.dart
Outdated
Show resolved
Hide resolved
…e to static instance inside ImageSaver class
flutter_quill_extensions/lib/src/editor/image/image_save_utils.dart
Outdated
Show resolved
Hide resolved
…custom implementation), addressing #2403 (comment) and #2403 (comment)
…t to ensure not accidentally changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for review, most of the changes are new keys added to quill_en.arb
, tests, or changes to the macOS and iOS example app for Swift package manager integration.
…Dart 3.5 Due to adding Swift package manager integration to the iOS and macOS example. For more details: https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-app-developers
Merged as I wasn’t sure if more time was needed for review, and we have other issues to focus on as well. |
Description
Fix broken image save functionality in
flutter_quill_extensions
, improve the default behavior, support web and desktop platforms (platforms that don't have gallery app), add unit tests, support Swift package manager, remove extra dependencies.The current behavior of image save functionality is broken on non-mobile platforms, and the way that the extensions package handles the errors and results (error and success messages) is confusing. The goal of this package is to implement an opinioned solution for loading images and videos but it seems most users avoid this package, I plan on replacing it with new packages (
quill_image
andquill_video
, see #2276), and that will be later.This PR addresses:
gal_linux
implementation was confusing due to the way it was handled. It's not officially supported and was implemented by myself. There is no way to implement it correctly without some changes to thegal
platform interface.quill_native_bridge
implements bothsaveImageToGallery
andsaveImage
.gal
andgal_linux
withquill_native_bridge
. It supports:saveImageToGallery
: Saves to system gallery (Android, iOS, macOS). Not supported on web/Linux; Windows support is possible but not useful; It's not common behavior for Windows users and saving images using the system file save dialog will integrate with the Windows photos app in both cases.saveImage
: Prompts for a save location on the desktop and downloads image on the web.openGalleryApp
: Opens the system gallery app. Not supported on web/Linux.flutter_quill_extensions
:pathAdded back since it's needed once again and there is no reason to re-implement it.ImagePicker
from image_picker and other Flutter plugins).Added
prefersGallerySave
toImageOptionsMenu
which determines if it should prefer saving the image to the system gallery (when supported) instead of using the system file save dialog, currently only macOS is applicable since that's the only platform that supports bothsaveImage
andsaveImageToGallery
. If Windows or Linux were supported, they would be applicable too.Part of FlutterQuill/quill-native-bridge#9. Tests were added there too though native unit tests are still missing (will be fixed soon).
Soon, will replace flutter_keyboard_visibility_temp_fork (related #2290).
Related Issues
Demostration
This feature is platform-specific, expand each section for more details with videos:
Android
Saving using
saveImageToGallery
(backed by AndroidMediaStore
) on Android API 29 and later:AndroidApi29.mov
The system gallery handles name conflicts.
Saving using
saveImageToGallery
(backed byjava.io.File
andMediaScannerConnection
) on Android API 28 and earlier (requires to write to external storage runtime permission):AndroidApi28.mov
On Android API 28 and earlier, the quill_native_bridge creates a unique image file name to avoid platform errors.
iOS
Saving using
saveImageToGallery
(backed by iOSPHPhotoLibrary
, requires runtime permission):iOSPHPotoLibrary.mov
The system gallery handles name conflicts.
macOS
Saving using
saveImage
(backed by macOSNSSavePanel
):MacOSNSPanel.mov
The system save dialog confirms overwrite if the file already exists.
Saving using
saveImageToGallery
(backed by macOSPHPhotoLibrary
, requires runtime permission):macOSPHPotoLibrary.mov
The system gallery handles name conflicts.
Web
Saving using
saveImage
:Web.mov
It creates
Blob
object URL, createsa
element, sets thehref
anddownload
attributes, clicks thea
element programmatically to download the image file, and then revokes the blob object URL.The browser handles name conflicts.
Whether the browser will ask the user where they want to save the image will depend on the user's preferences in the settings.
Linux
Saving using
saveImage
(backed byfile_selector_linux
):Linux.mp4
Depending on the Linux desktop environment, the system save dialog might not confirm name conflicts.
Windows
Saving using
saveImage
(backed byfile_selector_windows
):Windows.mp4
The system save dialog confirms overwrite if the file already exists.
Messages
The messages have been improved and changed in an optioned way so most users don't need to override the default. It no longer shows
Saved using the network
orSaved using the local storage
.The unknown error message:
An unexpected error occurred while saving the image. Please try again.
The permission denied message:
Couldn’t save the image due to missing permission
The success snack bar message will depend on how the image is saved (platform-specific):
Image downloaded successfully.
with no action button.Image saved to your gallery.
with action labeledOpen Gallery
.Image saved successfully.
with action labeledOpen File Location
on Windows and Linux orOpen File
on macOS.
Type of Change