-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 featured image flow #23962
Merged
Merged
Improve featured image flow #23962
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
ab47169
Add initial MediaPicker implementation
kean 6ddf963
Add initial PostSettingsFeaturedImageCell implementation
kean 3338325
Add configurable MediaPicker content
kean bcd2738
Add ViewModel to PostSettingsFeaturedImageCell
kean ba566af
Add reuseIdentifier for featured image cells
kean dbfb9db
Pass selection from MediaPicker to PostSettingsFeaturedImageViewModel
kean d23bf0e
Show upload status using PostMediaUploadItemView
kean 6c9f7e7
Rename MediaUploadItemViewModel
kean b90111e
Add PostSettingsFeaturedImageUploadView to show upload progress
kean 20cae40
Simlify how the app shows media upload status
kean ff30855
Handle upload failure
kean 495d921
Implement featured image save
kean c83378b
Add support for showing a selected featured image
kean 8cdce43
Add support for removing featured image
kean 477227a
Simplify lightbox
kean 2ab52b7
Add support for camera as a source
kean a800eae
Add .siteMedia(blog:) source
kean 842dcfe
Add ImagePlayground source support
kean 0d5640d
Add ImagePlayground support in MediaPicker
kean 7483497
Add free photos and GIFs support to MediaPicker
kean d2c05f0
Remove unused media upload code from PostSettingsViewController
kean 7fbb68a
Remove WPTableViewActivityCell
kean 4e283d4
Remove WPProgressTableViewCell
kean 5e3dd5a
Remvove unused featured image size
kean ec09ca8
Remove more unused code
kean e4554a9
Remove unused code
kean e8b846b
Add SiteMediaImageView
kean 45b2fcc
Remove unused code
kean 7f4c780
Integrate FeaturedImageDelegate
kean 3d007fe
Fix SiteMediaImage background when loading with spinner
kean c2523d4
Fix animations
kean 017f72f
Add zoom transition
kean 0e100ad
Add shadow to more menu
kean 7ea1cf4
Make the entire cell tappable
kean 5d13e71
Add View action
kean 3f27e17
Add replace action
kean a828b2c
Show spinner when replacing an image
kean b0f3a4b
Remove unused reloadFeaturedImageCell
kean f44329d
Update release notse
kean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
20 changes: 20 additions & 0 deletions
20
Modules/Sources/WordPressUI/Extensions/SwiftUI+Extensions.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
import UIKit | ||
import SwiftUI | ||
|
||
public extension EdgeInsets { | ||
static let zero = EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0) | ||
} | ||
|
||
private struct PresentingViewControllerKey: EnvironmentKey { | ||
static let defaultValue = WeakEnvironmentValueWrapper<UIViewController>() | ||
} | ||
|
||
extension EnvironmentValues { | ||
public var presentingViewController: UIViewController? { | ||
get { | ||
self[PresentingViewControllerKey.self].value ?? UIViewController.topViewController | ||
} | ||
set { | ||
self[PresentingViewControllerKey.self].value = newValue | ||
} | ||
} | ||
} | ||
|
||
private final class WeakEnvironmentValueWrapper<T: AnyObject> { | ||
weak var value: T? | ||
} |
This file contains 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
This file contains 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
This file contains 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
27 changes: 0 additions & 27 deletions
27
WordPress/Classes/ViewRelated/Cells/PostFeaturedImageCell.swift
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
WordPress/Classes/ViewRelated/Cells/WPProgressTableViewCell.h
This file was deleted.
Oops, something went wrong.
124 changes: 0 additions & 124 deletions
124
WordPress/Classes/ViewRelated/Cells/WPProgressTableViewCell.m
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
WordPress/Classes/ViewRelated/Cells/WPTableViewActivityCell.h
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
WordPress/Classes/ViewRelated/Cells/WPTableViewActivityCell.m
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
WordPress/Classes/ViewRelated/Cells/WPTableViewActivityCell.xib
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
WordPress/Classes/ViewRelated/Media/MediaPicker/Helpers/MediaPickerMenuController.swift
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import Photos | ||
import PhotosUI | ||
|
||
final class MediaPickerMenuController: NSObject { | ||
var onSelection: ((MediaPickerSelection) -> Void)? | ||
|
||
fileprivate func didSelect(_ items: [MediaPickerItem], source: String) { | ||
let selection = MediaPickerSelection(items: items, source: source) | ||
DispatchQueue.main.async { | ||
self.onSelection?(selection) | ||
} | ||
} | ||
} | ||
|
||
extension MediaPickerMenuController: PHPickerViewControllerDelegate { | ||
public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { | ||
picker.presentingViewController?.dismiss(animated: true) | ||
if !results.isEmpty { | ||
self.didSelect(results.map(MediaPickerItem.pickerResult), source: "apple_photos") | ||
} | ||
} | ||
} | ||
|
||
extension MediaPickerMenuController: ImagePickerControllerDelegate { | ||
func imagePicker(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) { | ||
picker.presentingViewController?.dismiss(animated: true) | ||
if let image = info[.originalImage] as? UIImage { | ||
self.didSelect([.image(image)], source: "camera") | ||
} | ||
} | ||
} | ||
|
||
extension MediaPickerMenuController: SiteMediaPickerViewControllerDelegate { | ||
func siteMediaPickerViewController(_ viewController: SiteMediaPickerViewController, didFinishWithSelection selection: [Media]) { | ||
viewController.presentingViewController?.dismiss(animated: true) | ||
if !selection.isEmpty { | ||
self.didSelect(selection.map(MediaPickerItem.media), source: "site_media") | ||
} | ||
} | ||
} | ||
|
||
extension MediaPickerMenuController: ImagePlaygroundPickerDelegate { | ||
func imagePlaygroundViewController(_ viewController: UIViewController, didCreateImageAt imageURL: URL) { | ||
|
||
viewController.presentingViewController?.dismiss(animated: true) | ||
if let data = try? Data(contentsOf: imageURL), let image = UIImage(data: data) { | ||
self.didSelect([.image(image)], source: "image_playground") | ||
} else { | ||
wpAssertionFailure("failed to read the image created by ImagePlayground") | ||
} | ||
} | ||
} | ||
|
||
extension MediaPickerMenuController: ExternalMediaPickerViewDelegate { | ||
func externalMediaPickerViewController(_ viewController: ExternalMediaPickerViewController, didFinishWithSelection selection: [ExternalMediaAsset]) { | ||
viewController.presentingViewController?.dismiss(animated: true) | ||
if !selection.isEmpty { | ||
let source = viewController.source == .tenor ? "free_gifs" : "free_photos" | ||
self.didSelect(selection.map(MediaPickerItem.external), source: source) | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
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.
Why dispatch async here? For chaining dismising presenting view controllers, maybe?
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.
If that's the cause, maybe we can use
dismiss(animated:completion:)
in the call sites, which would be syntactically nicer than dispatch async?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.
I was debating this, but the problem with
dismiss(animated:completion:)
is that it you performonSelection
in thecompletion
callback, it feels too slow.DispatchQueue.main.async
is probably redundant here, but I added it just in case.