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

Fix transitions in Blogging Reminders flow, improve accessibility, add close buttons #23931

Merged
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
14 changes: 14 additions & 0 deletions Modules/Sources/WordPressUI/Extensions/UIButton+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import UIKit

extension UIButton.Configuration {
public static func primary() -> UIButton.Configuration {
var configuration = UIButton.Configuration.borderedProminent()
configuration.titleTextAttributesTransformer = .init { attributes in
var attributes = attributes
attributes.font = UIFont.preferredFont(forTextStyle: .headline)
return attributes
}
configuration.buttonSize = .large
return configuration
}
}
86 changes: 86 additions & 0 deletions Modules/Sources/WordPressUI/Views/BottomToolbarView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import UIKit
import Combine

/// A custom bottom toolbar implementation that, unlike the native toolbar,
/// can accommodate larger buttons but shares a lot of its behavior including
/// edge appearance.
public class BottomToolbarView: UIView {
private let separator = SeparatorView.horizontal()
private let effectView = UIVisualEffectView()
private var isEdgeAppearanceEnabled = false
private weak var scrollView: UIScrollView?
private var cancellable: AnyCancellable?

public let contentView = UIView()

public override init(frame: CGRect) {
super.init(frame: frame)

addSubview(effectView)
addSubview(separator)

separator.pinEdges([.top, .horizontal])
effectView.pinEdges()

effectView.contentView.addSubview(contentView)

contentView.pinEdges(to: effectView.contentView.safeAreaLayoutGuide, insets: UIEdgeInsets(.all, 20))
}

public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

public override func layoutSubviews() {
super.layoutSubviews()

updateScrollViewContentInsets()
}

public override func safeAreaInsetsDidChange() {
super.safeAreaInsetsDidChange()

updateScrollViewContentInsets()
}

/// - warning: If you use this view, you'll typically need to take over the
/// scroll view content inset adjustment.
public func configure(in viewController: UIViewController, scrollView: UIScrollView) {
viewController.view.addSubview(self)
pinEdges([.horizontal, .bottom])
self.scrollView = scrollView

cancellable = scrollView.publisher(for: \.contentOffset, options: [.new]).sink { [weak self] offset in
self?.updateEdgeAppearance(animated: true)
}
updateScrollViewContentInsets()
updateEdgeAppearance(animated: false)
}

private func updateEdgeAppearance(animated: Bool) {
guard let scrollView, let superview else { return }

let isContentOverlapping = superview.convert(scrollView.contentLayoutGuide.layoutFrame, from: scrollView).maxY > (frame.minY + 16)
setEdgeAppearanceEnabled(!isContentOverlapping, animated: animated)
}

private func setEdgeAppearanceEnabled(_ isEnabled: Bool, animated: Bool) {
guard isEdgeAppearanceEnabled != isEnabled else { return }
isEdgeAppearanceEnabled = isEnabled

UIView.animate(withDuration: animated ? 0 : 0.33, delay: 0.0, options: [.allowUserInteraction, .beginFromCurrentState]) {
self.effectView.effect = isEnabled ? nil : UIBlurEffect(style: .extraLight)
self.separator.alpha = isEnabled ? 0 : 1
}
}

// The toolbar does no extend the safe area because it itself depends on it,
// so it resorts to changing `contentInset` instead.
private func updateScrollViewContentInsets() {
guard let scrollView else { return }
let bottomInset = bounds.height - safeAreaInsets.bottom
if scrollView.contentInset.bottom != bottomInset {
scrollView.contentInset.bottom = bottomInset
}
}
}
25 changes: 25 additions & 0 deletions Modules/Sources/WordPressUI/Views/SeparatorView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import UIKit

public final class SeparatorView: UIView {
public static func horizontal() -> SeparatorView {
let view = SeparatorView()
view.heightAnchor.constraint(equalToConstant: 0.5).isActive = true
return view
}

public static func vertical() -> SeparatorView {
let view = SeparatorView()
view.widthAnchor.constraint(equalToConstant: 0.5).isActive = true
return view
}

public override init(frame: CGRect) {
super.init(frame: frame)

backgroundColor = .separator
}

public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
54 changes: 54 additions & 0 deletions Modules/Sources/WordPressUI/Views/SpacerView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import UIKit

public final class SpacerView: UIView {
public convenience init(minWidth: CGFloat) {
self.init()

widthAnchor.constraint(greaterThanOrEqualToConstant: minWidth).isActive = true
}

public convenience init(minHeight: CGFloat) {
self.init()

heightAnchor.constraint(greaterThanOrEqualToConstant: minHeight).isActive = true
}

public convenience init(width: CGFloat) {
self.init()

widthAnchor.constraint(equalToConstant: width).isActive = true
}

public convenience init(height: CGFloat) {
self.init()

heightAnchor.constraint(equalToConstant: height).isActive = true
}

public override init(frame: CGRect) {
super.init(frame: .zero)

// Make sure it compresses or expands before any other views if needed.
setContentCompressionResistancePriority(.init(10), for: .horizontal)
setContentCompressionResistancePriority(.init(10), for: .vertical)
setContentHuggingPriority(.init(10), for: .horizontal)
setContentHuggingPriority(.init(10), for: .vertical)
}

public override var intrinsicContentSize: CGSize {
CGSizeMake(0, 0) // Avoid ambiguous layout
}

public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}

override public class var layerClass: AnyClass {
CATransformLayer.self // Draws nothing
}

override public var backgroundColor: UIColor? {
get { return nil }
set { /* Do nothing */ }
}
}
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* [**] Add new lightbox screen for images with modern transitions and enhanced performance [#23922]
* [*] Add prefetching to Reader streams [#23928]
* [*] Fix an issue with blogging reminders prompt not being shown after publishing a new post [#23930]
* [*] Fix transitions in Blogging Reminders flow, improve accessibiliy, add close buttons [#23931]

25.6
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension InteractiveNotificationsManager: PushNotificationAuthorizer {

/// Main interface for scheduling blogging reminders
///
class BloggingRemindersScheduler {
final class BloggingRemindersScheduler {

// MARK: - Convenience Typealiases

Expand Down
2 changes: 1 addition & 1 deletion WordPress/Classes/Utility/Spotlight/SearchManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ fileprivate extension SearchManager {

let controller = PreviewWebKitViewController(post: apost, source: "spotlight_preview_post")
controller.trackOpenEvent()
let navWrapper = LightNavigationController(rootViewController: controller)
let navWrapper = UINavigationController(rootViewController: controller)
let rootViewController = RootViewCoordinator.sharedPresenter.rootViewController
if rootViewController.traitCollection.userInterfaceIdiom == .pad {
navWrapper.modalPresentationStyle = .fullScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ - (void)showViewSiteFromSource:(BlogDetailsNavigationSource)source
source:@"my_site_view_site"
withDeviceModes:true
onClose:nil];
LightNavigationController *navController = [[LightNavigationController alloc] initWithRootViewController:webViewController];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:webViewController];
if (self.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
navController.modalPresentationStyle = UIModalPresentationFullScreen;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import UIKit
import WordPressUI
import SwiftUI

public struct RestApiUpgradePrompt: View {
Expand Down Expand Up @@ -40,9 +42,3 @@ public struct RestApiUpgradePrompt: View {
}
}
}

#Preview {
RestApiUpgradePrompt(localizedFeatureName: "User Management") {
debugPrint("Tapped Get Started")
}
}

This file was deleted.

This file was deleted.

Loading