-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve share sheet #576
Improve share sheet #576
Conversation
(We get more options this way)
(This way it is more close to the QE height)
📲 You can test the changes from this Pull Request in Gravatar Prototype Build by scanning the QR code below to install the corresponding build.
|
eabc511
to
2faafb9
Compare
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.
Working great 🎉
Just a small option to consider on comments, but not a blocker 👍
|
||
func fetchAndSaveToFile(avatar: AvatarImageModel) async -> URL? { | ||
guard let image = await fetchOriginalSizeAvatar(for: avatar), | ||
let imageData = image.jpegData(compressionQuality: 1) else { return nil } | ||
let fileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("image.jpg") | ||
do { | ||
try imageData.write(to: fileURL) | ||
return fileURL | ||
} catch { | ||
toastManager.showToast(Localized.avatarShareFail, type: .error) | ||
} | ||
return nil | ||
} |
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.
Generally is good to have these functions which explicitaly do two things to have them split, even if they are two small functions like:
let image = fetchFullImage(of: avatar)`
let imageFileURL = image.saveToFile()
Maybe in this way we can also show the share sheet even if writing to storage fails 🤔
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.
Yeah totally makes sense to have a separate UIImage extension method like saveToFile()
. I'll add it.
Maybe in this way we can also show the share sheet even if writing to storage fails
This is doable but I would consider this as an edge case. For sake of keeping our logic simple, I'd say let's just share the file for now.
An improvement on #566
Description
I noticed that if we first write the image to a file and then share that file's URL, then there are more relevant options in the share sheet:
Also, updated the share sheet's initial height as same as QE's initial height (in horizontal mode it's not exactly same but it's close). So we see small or no height adjustment done by the system while share sheet is being opened.
Another thing is, I changed the word "download" as "share" in the error message.
Last but not least, I share the jpegData as there's a noticeable time difference between sharing pngData and jpegData. I set the compression quality to 1 (highest), and the shared image's quality seems good to me.
Testing Steps
(It can be good to compare with the previous version.)
Demo app > QE > avatar [...] menu > share