Skip to content
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 39 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
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 Jan 8, 2025
6ddf963
Add initial PostSettingsFeaturedImageCell implementation
kean Jan 8, 2025
3338325
Add configurable MediaPicker content
kean Jan 8, 2025
bcd2738
Add ViewModel to PostSettingsFeaturedImageCell
kean Jan 8, 2025
ba566af
Add reuseIdentifier for featured image cells
kean Jan 8, 2025
dbfb9db
Pass selection from MediaPicker to PostSettingsFeaturedImageViewModel
kean Jan 8, 2025
d23bf0e
Show upload status using PostMediaUploadItemView
kean Jan 8, 2025
6c9f7e7
Rename MediaUploadItemViewModel
kean Jan 8, 2025
b90111e
Add PostSettingsFeaturedImageUploadView to show upload progress
kean Jan 8, 2025
20cae40
Simlify how the app shows media upload status
kean Jan 8, 2025
ff30855
Handle upload failure
kean Jan 8, 2025
495d921
Implement featured image save
kean Jan 8, 2025
c83378b
Add support for showing a selected featured image
kean Jan 8, 2025
8cdce43
Add support for removing featured image
kean Jan 8, 2025
477227a
Simplify lightbox
kean Jan 8, 2025
2ab52b7
Add support for camera as a source
kean Jan 8, 2025
a800eae
Add .siteMedia(blog:) source
kean Jan 8, 2025
842dcfe
Add ImagePlayground source support
kean Jan 8, 2025
0d5640d
Add ImagePlayground support in MediaPicker
kean Jan 8, 2025
7483497
Add free photos and GIFs support to MediaPicker
kean Jan 8, 2025
d2c05f0
Remove unused media upload code from PostSettingsViewController
kean Jan 8, 2025
7fbb68a
Remove WPTableViewActivityCell
kean Jan 8, 2025
4e283d4
Remove WPProgressTableViewCell
kean Jan 8, 2025
5e3dd5a
Remvove unused featured image size
kean Jan 8, 2025
ec09ca8
Remove more unused code
kean Jan 8, 2025
e4554a9
Remove unused code
kean Jan 9, 2025
e8b846b
Add SiteMediaImageView
kean Jan 9, 2025
45b2fcc
Remove unused code
kean Jan 9, 2025
7f4c780
Integrate FeaturedImageDelegate
kean Jan 9, 2025
3d007fe
Fix SiteMediaImage background when loading with spinner
kean Jan 9, 2025
c2523d4
Fix animations
kean Jan 9, 2025
017f72f
Add zoom transition
kean Jan 9, 2025
0e100ad
Add shadow to more menu
kean Jan 9, 2025
7ea1cf4
Make the entire cell tappable
kean Jan 9, 2025
5d13e71
Add View action
kean Jan 9, 2025
3f27e17
Add replace action
kean Jan 9, 2025
a828b2c
Show spinner when replacing an image
kean Jan 9, 2025
b0f3a4b
Remove unused reloadFeaturedImageCell
kean Jan 9, 2025
f44329d
Update release notse
kean Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/Sources/AsyncImageKit/Views/AsyncImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ extension GIFImageView {
}
}

private func prepareForReuse() {
public func prepareForReuse() {
if isAnimatingGIF {
prepareForReuse()
} else {
Expand Down
20 changes: 20 additions & 0 deletions Modules/Sources/WordPressUI/Extensions/SwiftUI+Extensions.swift
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?
}
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* [*] Enable fast deceleration for filters on the Discover tab [#23954]
* [*] Disable universal links support for QR code login. You can only scan the codes using the app now. [#23953]
* [*] Add scroll-to-top button to Reader streams [#23957]

* [*] Add a quick way to replace a featured image for a post [#23962]

25.6
-----
Expand Down
1 change: 0 additions & 1 deletion WordPress/Classes/System/WordPress-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#import "PostServiceOptions.h"
#import "PostSettingsViewController.h"
#import "PostSettingsViewController_Internal.h"
#import "WPProgressTableViewCell.h"
#import "PostTag.h"
#import "PostTagService.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension HomeSiteHeaderViewController {
mediaMenu.makeCameraAction(delegate: presenter),
mediaMenu.makeImagePlaygroundAction(delegate: presenter),
mediaMenu.makeSiteMediaAction(blog: blog, delegate: presenter)
]
].compactMap { $0 }
if FeatureFlag.siteIconCreator.enabled {
actions.append(UIAction(
title: SiteIconAlertStrings.Actions.createWithEmoji,
Expand Down
27 changes: 0 additions & 27 deletions WordPress/Classes/ViewRelated/Cells/PostFeaturedImageCell.swift

This file was deleted.

15 changes: 0 additions & 15 deletions WordPress/Classes/ViewRelated/Cells/WPProgressTableViewCell.h

This file was deleted.

124 changes: 0 additions & 124 deletions WordPress/Classes/ViewRelated/Cells/WPProgressTableViewCell.m

This file was deleted.

9 changes: 0 additions & 9 deletions WordPress/Classes/ViewRelated/Cells/WPTableViewActivityCell.h

This file was deleted.

5 changes: 0 additions & 5 deletions WordPress/Classes/ViewRelated/Cells/WPTableViewActivityCell.m

This file was deleted.

36 changes: 0 additions & 36 deletions WordPress/Classes/ViewRelated/Cells/WPTableViewActivityCell.xib

This file was deleted.

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)
}
}
}
Loading