Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
24.3
-----

* [**] Multiple pre-publishing sheet fixes and improvements [#22606]

24.2
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class InvitePersonViewController: UITableViewController {

private var sortedInviteLinks: [InviteLinks] {
guard
let links = blog.inviteLinks?.array as? [InviteLinks]
let links = Array(blog.inviteLinks ?? []) as? [InviteLinks]
else {
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,17 +601,15 @@ class AbstractPostListViewController: UIViewController,
let action = AbstractPostHelper.editorPublishAction(for: post)

func showPrepublishingFlow(for post: Post) {
let prepublishing = PrepublishingViewController(post: post, identifiers: PrepublishingIdentifier.defaultIdentifiers) { [weak self] result in
let viewController = PrepublishingViewController(post: post, identifiers: PrepublishingIdentifier.defaultIdentifiers) { [weak self] result in
switch result {
case .completed(let post):
self?.didConfirmPublish(for: post)
case .dismissed:
break
}
}
let navigationController = PrepublishingNavigationController(rootViewController: prepublishing, shouldDisplayPortrait: false)
let bottomSheet = BottomSheetViewController(childViewController: navigationController, customHeaderSpacing: 0)
bottomSheet.show(from: self)
viewController.presentAsSheet(from: self)
}

func showPublishingConfirmation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Foundation
@objc weak var delegate: PostCategoriesViewControllerDelegate?

var onCategoriesChanged: (() -> Void)?
var onTableViewHeightDetermined: (() -> Void)?

private var blog: Blog
private var originalSelection: [PostCategory]?
Expand Down Expand Up @@ -50,9 +49,6 @@ import Foundation
if !hasSyncedCategories {
syncCategories()
}

preferredContentSize = tableView.contentSize
onTableViewHeightDetermined?()
}

override func viewWillDisappear(_ animated: Bool) {
Expand Down
10 changes: 8 additions & 2 deletions WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ extension PostEditor {
settingsViewController = PostSettingsViewController(post: post)
}
settingsViewController.featuredImageDelegate = self as? FeaturedImageDelegate
settingsViewController.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(settingsViewController, animated: true)
let closeButton = UIBarButtonItem(systemItem: .close, primaryAction: .init(handler: { [weak self] _ in
self?.navigationController?.dismiss(animated: true)
}))
closeButton.accessibilityIdentifier = "close"
settingsViewController.navigationItem.leftBarButtonItem = closeButton

let navigation = UINavigationController(rootViewController: settingsViewController)
self.navigationController?.present(navigation, animated: true)
}

private func createPostRevisionBeforePreview(completion: @escaping (() -> Void)) {
Expand Down
13 changes: 2 additions & 11 deletions WordPress/Classes/ViewRelated/Post/PostEditor+Publish.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ extension PublishingEditor {
// End editing to avoid issues with accessibility
view.endEditing(true)

let prepublishing = PrepublishingViewController(post: post, identifiers: prepublishingIdentifiers) { [weak self] result in
let viewController = PrepublishingViewController(post: post, identifiers: prepublishingIdentifiers) { [weak self] result in
switch result {
case .completed(let post):
self?.post = post
Expand All @@ -246,16 +246,7 @@ extension PublishingEditor {
dismissAction()
}
}

let isTitleDisplayed = prepublishingIdentifiers.contains { $0 == .title }
let shouldDisplayPortrait = WPDeviceIdentification.isiPhone() && isTitleDisplayed
let prepublishingNavigationController = PrepublishingNavigationController(rootViewController: prepublishing, shouldDisplayPortrait: shouldDisplayPortrait)
let bottomSheet = BottomSheetViewController(childViewController: prepublishingNavigationController, customHeaderSpacing: 0)
if let sourceView = prepublishingSourceView {
bottomSheet.show(from: self, sourceView: sourceView)
} else {
bottomSheet.show(from: self.topmostPresentedViewController)
}
viewController.presentAsSheet(from: topmostPresentedViewController)
}

/// Displays a publish confirmation alert with two options: "Keep Editing" and String for Action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class PostTagPickerViewController: UIViewController {
}
}

var onContentViewHeightDetermined: (() -> Void)?

override func viewDidLoad() {
super.viewDidLoad()

Expand Down Expand Up @@ -118,7 +116,6 @@ class PostTagPickerViewController: UIViewController {
super.viewWillAppear(animated)

textView.becomeFirstResponder()
updateContainerHeight()
}

override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -164,14 +161,6 @@ class PostTagPickerViewController: UIViewController {

tableView.contentInset.bottom += presentedVC?.yPosition ?? 0
}

fileprivate func updateContainerHeight() {
descriptionLabel.layoutIfNeeded()
textViewContainer.layoutIfNeeded()
let contentHeight = tableView.contentSize.height + descriptionLabel.bounds.size.height + textViewContainer.bounds.height
preferredContentSize = CGSize(width: view.bounds.width, height: max(300.0, contentHeight))
onContentViewHeightDetermined?()
}
}

// MARK: - Tags Loading
Expand Down
Original file line number Diff line number Diff line change
@@ -1,97 +1,83 @@
import UIKit
import Gridicons

protocol PrepublishingHeaderViewDelegate: AnyObject {
func closeButtonTapped()
}

class PrepublishingHeaderView: UITableViewHeaderFooterView, NibLoadable {

@IBOutlet weak var blogImageView: UIImageView!
@IBOutlet weak var publishingToLabel: UILabel!
@IBOutlet weak var blogTitleLabel: UILabel!
@IBOutlet weak var closeButtonView: UIView!
@IBOutlet weak var leadingConstraint: NSLayoutConstraint!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var separator: UIView!

weak var delegate: PrepublishingHeaderViewDelegate?

func configure(_ blog: Blog) {
blogImageView.downloadSiteIcon(for: blog)
blogTitleLabel.text = blog.title
}

// MARK: - Close button

func toggleCloseButton(visible: Bool) {
closeButtonView.layer.opacity = visible ? 1 : 0
closeButtonView.isHidden = visible ? false : true
leadingConstraint.constant = visible ? 0 : Constants.leftRightInset
layoutIfNeeded()
}

@IBAction func closeButtonTapped(_ sender: Any) {
delegate?.closeButtonTapped()
}
final class PrepublishingHeaderView: UIView {
private let blogImageView = UIImageView()
private let publishingToLabel = UILabel()
private let blogTitleLabel = UILabel()

// MARK: - Style
let closeButton = UIButton(type: .system)
let separator = UIView()

override func awakeFromNib() {
super.awakeFromNib()
configureBackgroundView()
configureBackButton()
configurePublishingToLabel()
configureBlogTitleLabel()
configureBlogImage()
configureSeparator()
}

override func prepareForReuse() {
super.prepareForReuse()
override init(frame: CGRect) {
super.init(frame: frame)

self.delegate = nil
}
blogImageView.layer.masksToBounds = true
blogImageView.layer.cornerRadius = 6
blogImageView.layer.cornerCurve = .continuous

private func configureBackgroundView() {
backgroundView = UIView()
backgroundView?.backgroundColor = .basicBackground
}
publishingToLabel.text = Strings.publishingTo.uppercased()
publishingToLabel.font = WPStyleGuide.fontForTextStyle(.caption1)
publishingToLabel.textColor = .secondaryLabel

private func configureBackButton() {
closeButtonView.isHidden = true
closeButton.setImage(.gridicon(.cross, size: Constants.backButtonSize), for: .normal)
closeButton.accessibilityLabel = Constants.close
closeButton.accessibilityHint = Constants.doubleTapToDismiss
blogTitleLabel.font = WPStyleGuide.fontForTextStyle(.headline)

// Only show close button for accessibility purposes
toggleCloseButton(visible: UIAccessibility.isVoiceOverRunning)
}

private func configurePublishingToLabel() {
publishingToLabel.text = publishingToLabel.text?.uppercased()
publishingToLabel.font = WPStyleGuide.TableViewHeaderDetailView.titleFont
publishingToLabel.textColor = WPStyleGuide.TableViewHeaderDetailView.titleColor
}
closeButton.configuration = {
var configuration = UIButton.Configuration.plain()
configuration.image = UIImage(systemName: "xmark.circle.fill")
configuration.contentInsets = NSDirectionalEdgeInsets(top: 12, leading: 14, bottom: 14, trailing: 14)
configuration.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(paletteColors: [.secondaryLabel, .secondarySystemFill])
.applying(UIImage.SymbolConfiguration(font: WPStyleGuide.fontForTextStyle(.headline, fontWeight: .semibold)))
return configuration
}()
closeButton.accessibilityLabel = Strings.close

private func configureBlogImage() {
blogImageView.layer.cornerRadius = Constants.imageRadius
blogImageView.clipsToBounds = true
WPStyleGuide.applyBorderStyle(separator)
separator.alpha = 0

NSLayoutConstraint.activate([
blogImageView.widthAnchor.constraint(equalToConstant: 44),
blogImageView.heightAnchor.constraint(equalToConstant: 44),
])

let labelsStackView = UIStackView(arrangedSubviews: [publishingToLabel, blogTitleLabel])
labelsStackView.axis = .vertical
labelsStackView.alignment = .leading

let stackView = UIStackView(arrangedSubviews: [blogImageView, labelsStackView])
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.alignment = .center
stackView.spacing = 12
addSubview(stackView)
pinSubviewToAllEdges(stackView, insets: UIEdgeInsets(top: 16, left: 20, bottom: 12, right: 20))

addSubview(separator)
separator.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
separator.leadingAnchor.constraint(equalTo: leadingAnchor),
separator.trailingAnchor.constraint(equalTo: trailingAnchor),
separator.bottomAnchor.constraint(equalTo: bottomAnchor)
])

addSubview(closeButton)
closeButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
closeButton.trailingAnchor.constraint(equalTo: trailingAnchor),
closeButton.topAnchor.constraint(equalTo: topAnchor),
blogTitleLabel.trailingAnchor.constraint(lessThanOrEqualTo: closeButton.leadingAnchor)
])
}

private func configureBlogTitleLabel() {
WPStyleGuide.applyPostTitleStyle(blogTitleLabel)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func configureSeparator() {
WPStyleGuide.applyBorderStyle(separator)
func configure(_ blog: Blog) {
blogImageView.downloadSiteIcon(for: blog)
blogTitleLabel.text = blog.title
}
}

private enum Constants {
static let backButtonSize = CGSize(width: 28, height: 28)
static let imageRadius: CGFloat = 4
static let leftRightInset: CGFloat = 16
static let close = NSLocalizedString("Close", comment: "Voiceover accessibility label informing the user that this button dismiss the current view")
static let doubleTapToDismiss = NSLocalizedString("Double tap to dismiss", comment: "Voiceover accessibility hint informing the user they can double tap a modal alert to dismiss it")
}
private enum Strings {
static let close = NSLocalizedString("prepublishing.pubishingTo", value: "Close", comment: "Voiceover accessibility label informing the user that this button dismiss the current view")
static let publishingTo = NSLocalizedString("prepublishing.pubishingTo", value: "Publishing to", comment: "Label in the header in the pre-publishing sheet")
}
Loading