Skip to content

Commit 9f2ef57

Browse files
authored
iOS 26: Update readable guide for Reader Article view (#24813)
* Update readable guide for Reader Article * Didsable accessibility for button that sohuld not change size
1 parent 2bc660f commit 9f2ef57

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailViewController.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
173173

174174
headerContainerView.clipsToBounds = true
175175
headerContainerView.backgroundColor = .systemBackground
176-
headerContainerView.layer.cornerRadius = DesignConstants.radius(.large)
177-
headerContainerView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner]
178176
}
179177

180178
// Fixes swipe to go back not working when leftBarButtonItem is set
@@ -235,6 +233,14 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
235233
scrollView
236234
}
237235

236+
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
237+
super.traitCollectionDidChange(previousTraitCollection)
238+
239+
let isCompact = traitCollection.horizontalSizeClass == .compact
240+
headerContainerView.layer.cornerRadius = isCompact ? DesignConstants.radius(.large) : 0
241+
headerContainerView.layer.maskedCorners = isCompact ? [.layerMaxXMinYCorner, .layerMinXMinYCorner] : []
242+
}
243+
238244
func render(_ post: ReaderPost) {
239245
configureDiscoverAttribution(post)
240246

@@ -444,13 +450,10 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
444450

445451
/// Apply view styles
446452
@MainActor private func applyStyles() {
447-
guard let readableGuide = webView.superview?.readableContentGuide else {
448-
return
449-
}
450-
453+
webView.pinEdges(.horizontal, to: view, insets: UIEdgeInsets(.horizontal, 16), priority: .init(950))
451454
NSLayoutConstraint.activate([
452-
webView.rightAnchor.constraint(equalTo: readableGuide.rightAnchor, constant: -Constants.margin),
453-
webView.leftAnchor.constraint(equalTo: readableGuide.leftAnchor, constant: Constants.margin)
455+
webView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
456+
webView.widthAnchor.constraint(lessThanOrEqualToConstant: UIFontMetrics(forTextStyle: .body).scaledValue(for: Constants.preferredArticleWidth))
454457
])
455458

456459
webView.translatesAutoresizingMaskIntoConstraints = false
@@ -853,7 +856,7 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
853856
}
854857

855858
private enum Constants {
856-
static let margin: CGFloat = UIDevice.isPad() ? 0 : 8
859+
static let preferredArticleWidth: CGFloat = 680
857860
}
858861

859862
// MARK: - Managed object observer

WordPress/Classes/ViewRelated/Reader/Detail/Views/ReaderDetailToolbar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class ReaderDetailToolbar {
176176
// Set font
177177
configuration.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
178178
var outgoing = incoming
179-
outgoing.font = .preferredFont(forTextStyle: .subheadline)
179+
outgoing.font = .system(size: 15)
180180
return outgoing
181181
}
182182

WordPress/Classes/ViewRelated/Reader/Detail/Views/ReaderHeroView.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class ReaderHeroView: UIView {
1212
traitCollection.horizontalSizeClass == .compact ? 40 : 20
1313
}
1414

15-
let bottomExtensionHeight = DesignConstants.radius(.large)
15+
private(set) var bottomExtensionHeight: CGFloat = 0
1616

1717
var imageURL: URL?
1818

@@ -65,6 +65,17 @@ final class ReaderHeroView: UIView {
6565
}
6666
}
6767

68+
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
69+
super.traitCollectionDidChange(previousTraitCollection)
70+
71+
// Extend below the header of the article to support corner radius
72+
let newValue = traitCollection.horizontalSizeClass == .compact ? DesignConstants.radius(.large) : 0
73+
if bottomExtensionHeight != newValue {
74+
bottomExtensionHeight = newValue
75+
setNeedsLayout()
76+
}
77+
}
78+
6879
func configureTapGesture(in scrollView: UIScrollView, _ closure: @escaping (AsyncImageView) -> Void) {
6980
let tap = UITapGestureRecognizer(target: self, action: #selector(didTap))
7081
tap.cancelsTouchesInView = false

0 commit comments

Comments
 (0)