-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance BloggingRemindersFlow (#23931)
- Loading branch information
Showing
44 changed files
with
565 additions
and
768 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
Modules/Sources/WordPressUI/Extensions/UIButton+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 |
---|---|---|
@@ -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 | ||
} | ||
} |
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,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 | ||
} | ||
} | ||
} |
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,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") | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,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 */ } | ||
} | ||
} |
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
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
67 changes: 0 additions & 67 deletions
67
WordPress/Classes/ViewRelated/Blog/Blogging Reminders/BloggingRemindersAnimator.swift
This file was deleted.
Oops, something went wrong.
87 changes: 0 additions & 87 deletions
87
WordPress/Classes/ViewRelated/Blog/Blogging Reminders/BloggingRemindersFlow.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.