feat: quick save image to photos on long press#387
Open
MufanQiu wants to merge 1 commit into
Open
Conversation
Add an opt-in setting (off by default) under Post appearance. When enabled, long-pressing an image in a post shows a quick action menu to save the image directly to the photo library or view it, reusing SDWebImage's cached data so the original (non-thumbnail) image is saved. A high-priority long-press gesture is used so the image's own actions are not swallowed by the post-level context menu, and the gesture is disabled when the setting is off.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in preference to enable a long-press “quick actions” menu on in-post images, allowing users to save the full-size image directly to the Photos library (or view it) without changing the default long-press behavior when the setting is off.
Changes:
- Added a new
quickSaveImagepreference and exposed it under Settings → Appearance → Post. - Implemented a high-priority long-press gesture on
ContentImageViewto present a confirmation dialog (Save / View). - Added zh-Hans localizations for the new UI strings and toasts.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app/Shared/Views/PreferencesView.swift | Adds a new toggle in Post appearance settings to enable quick-save behavior. |
| app/Shared/Views/ContentImageView.swift | Adds long-press quick action dialog and implements saving via PHPhotoLibrary using SDWebImage cached data. |
| app/Shared/Storage/PreferencesStorage.swift | Persists the new quickSaveImage setting via @AppStorage. |
| app/Shared/Localization/zh-Hans.lproj/Localizable.strings | Adds translations for the new setting label, actions, and related toast strings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+138
to
+141
| guard let image else { | ||
| ToastModel.showAuto(.error("Save Failed")) | ||
| return | ||
| } |
| } completionHandler: { success, _ in | ||
| DispatchQueue.main.async { | ||
| if success { | ||
| ToastModel.showAuto(.success("Saved")) |
Comment on lines
+151
to
+155
| let options = PHAssetResourceCreationOptions() | ||
| options.originalFilename = url.lastPathComponent | ||
| let request = PHAssetCreationRequest.forAsset() | ||
| request.addResource(with: .photo, data: data, options: options) | ||
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add an opt-in "Quick Save Image on Long Press" setting. When enabled,
long-pressing an image inside a post shows a quick action menu to save the
image directly to the photo library (or view it), instead of going through
Select Attachments → tap image → save.
The setting lives under Settings → Appearance → Post and is off by
default, so existing long-press behavior (the post-level context menu) is
unchanged unless the user opts in.
How
ContentImageViewgains asaveImageToPhotos()that reusesSDWebImageManager's cached data, so the original (non-thumbnail) image issaved, and requests add-only Photos permission before writing.
LongPressGesturethat presents aconfirmationDialog. This is needed because the image lives inside thepost-level
.contextMenusubtree; without a high-priority gesture the image'sown actions get swallowed by the post context menu. The gesture's mask is set
to
.nonewhen the setting is off (or outside a real post), so it doesn'tinterfere with the existing context menu at all in the default configuration.
Screenshots
Testing
saving writes the full-size image to Photos; with the setting off, the normal
post context menu appears as before.