Skip to content

Commit 50cf4e8

Browse files
authored
Fix ReaderReadMoreView gradient (#24150)
* Fix ReaderReadMoreView gradient * Repalce copy
1 parent 101228a commit 50cf4e8

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,13 @@ final class ReaderReadMoreView: UIView, UIAdaptivePresentationControllerDelegate
2323

2424
textView.adjustsFontForContentSizeCategory = true
2525

26-
let string = NSMutableAttributedString(string: Strings.viewForMore, attributes: [
27-
.font: UIFont.preferredFont(forTextStyle: .body),
28-
.foregroundColor: UIColor.label
26+
let string = NSMutableAttributedString(string: Strings.viewFullPost, attributes: [
27+
.font: UIFont.preferredFont(forTextStyle: .body)
2928
])
30-
let range = string.mutableString.range(of: "%@")
31-
if range.location != NSNotFound {
32-
let replacement = NSMutableString(string: post.blogNameForDisplay() ?? Strings.blog)
33-
string.replaceCharacters(in: range, with: String(replacement))
34-
if let postURL = post.permaLink.flatMap(URL.init) {
35-
string.addAttribute(.link, value: postURL, range: NSRange(location: range.location, length: replacement.length))
36-
self.postURL = postURL
37-
}
29+
if let postURL = post.permaLink.flatMap(URL.init) {
30+
string.addAttribute(.link, value: postURL, range: NSRange(location: 0, length: string.length))
31+
self.postURL = postURL
3832
}
39-
4033
textView.attributedText = string
4134

4235
infoIconView.tintColor = .secondaryLabel
@@ -103,15 +96,25 @@ private final class GradientAlphaMaskView: UIView {
10396
super.init(frame: frame)
10497

10598
gradientLayer.frame = bounds
106-
gradientLayer.colors = [UIColor.white.withAlphaComponent(0.33).cgColor, UIColor.white.cgColor]
10799
gradientLayer.locations = [0.0, 1.0]
100+
refreshColors()
108101

109102
gradientLayer.startPoint = CGPoint(x: 0.5, y: 0.0)
110103
gradientLayer.endPoint = CGPoint(x: 0.5, y: 0.5)
111104

112105
self.layer.addSublayer(gradientLayer)
113106
}
114107

108+
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
109+
super.traitCollectionDidChange(previousTraitCollection)
110+
111+
refreshColors()
112+
}
113+
114+
private func refreshColors() {
115+
gradientLayer.colors = [UIColor.systemBackground.withAlphaComponent(0).cgColor, UIColor.systemBackground.cgColor]
116+
}
117+
115118
required init?(coder: NSCoder) {
116119
fatalError("init(coder:) has not been implemented")
117120
}
@@ -124,7 +127,7 @@ private final class GradientAlphaMaskView: UIView {
124127
}
125128

126129
private enum Strings {
127-
static let viewForMore = NSLocalizedString("reader.postDetails.viewMoreOn", value: "Visit %@ for the full post", comment: "Reader post details view")
130+
static let viewFullPost = NSLocalizedString("reader.postDetails.viewFullPost", value: "View full post", comment: "Button title")
128131
static let blog = NSLocalizedString("reader.postDetails.blog", value: "blog", comment: "Reader post details view placeholder when blog name not avail")
129132
static let details = NSLocalizedString("reader.postDetails.viewModeDescription", value: "The owner of this site only allows us to show a brief summary of their content. To view the full post, you'll have to visit their site.", comment: "Reader post details view")
130133
}

0 commit comments

Comments
 (0)