Skip to content

Commit bb2b482

Browse files
committed
Move isHidden
1 parent fc6670f commit bb2b482

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

WordPress/Classes/ViewRelated/Reader/ReaderPostCell.swift

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private final class ReaderPostCellView: UIView {
9999
var isCompact: Bool = true {
100100
didSet {
101101
guard oldValue != isCompact else { return }
102-
update(isCompact: isCompact)
102+
configureLayout(isCompact: isCompact)
103103
}
104104
}
105105

@@ -113,10 +113,10 @@ private final class ReaderPostCellView: UIView {
113113
override init(frame: CGRect) {
114114
super.init(frame: frame)
115115

116-
configureStyle()
117-
configureLayout()
118-
configureActions()
119-
configureAccessibility()
116+
setupStyle()
117+
setupLayout()
118+
setupActions()
119+
setupAccessibility()
120120
}
121121

122122
required init?(coder: NSCoder) {
@@ -127,16 +127,15 @@ private final class ReaderPostCellView: UIView {
127127
cancellables = []
128128
avatarView.prepareForReuse()
129129
imageView.prepareForReuse()
130-
imageView.isHidden = false
131130
}
132131

133-
private func configureStyle() {
132+
private func setupStyle() {
134133
avatarView.layer.cornerRadius = ReaderPostCell.avatarSize / 2
135134
avatarView.layer.masksToBounds = true
136135
avatarView.isErrorViewEnabled = false
137136

138137
buttonAuthor.maximumContentSizeCategory = .accessibilityLarge
139-
configureTimeLabel(timeLabel)
138+
setupTimeLabel(timeLabel)
140139
timeLabel.setContentCompressionResistancePriority(.init(800), for: .horizontal)
141140

142141
titleLabel.font = .preferredFont(forTextStyle: .headline)
@@ -156,9 +155,9 @@ private final class ReaderPostCellView: UIView {
156155
buttonMore.configuration?.contentInsets = .init(top: 12, leading: 8, bottom: 12, trailing: 20)
157156
}
158157

159-
private func configureLayout() {
158+
private func setupLayout() {
160159
let dot = UILabel()
161-
configureTimeLabel(dot)
160+
setupTimeLabel(dot)
162161
dot.text = " · "
163162

164163
// These seems to be an issue with `lineBreakMode` in `UIButton.Configuration`
@@ -196,17 +195,17 @@ private final class ReaderPostCellView: UIView {
196195
toolbarView.bottomAnchor.constraint(equalTo: bottomAnchor)
197196
])
198197

199-
update(isCompact: isCompact)
198+
configureLayout(isCompact: isCompact)
200199
}
201200

202-
private func configureTimeLabel(_ label: UILabel) {
201+
private func setupTimeLabel(_ label: UILabel) {
203202
label.font = .preferredFont(forTextStyle: .footnote)
204203
label.textColor = .secondaryLabel
205204
label.adjustsFontForContentSizeCategory = true
206205
label.maximumContentSizeCategory = .accessibilityMedium
207206
}
208207

209-
private func update(isCompact: Bool) {
208+
private func configureLayout(isCompact: Bool) {
210209
titleLabel.numberOfLines = 2
211210
detailsLabel.numberOfLines = isCompact ? 3 : 5
212211

@@ -237,7 +236,7 @@ private final class ReaderPostCellView: UIView {
237236

238237
// MARK: Actions
239238

240-
private func configureActions() {
239+
private func setupActions() {
241240
buttonAuthor.addTarget(self, action: #selector(buttonAuthorTapped), for: .primaryActionTriggered)
242241
buttonMore.showsMenuAsPrimaryAction = true
243242
buttonMore.menu = UIMenu(options: .displayInline, children: [
@@ -295,10 +294,10 @@ private final class ReaderPostCellView: UIView {
295294

296295
titleLabel.text = viewModel.title
297296
detailsLabel.text = viewModel.details
297+
298+
imageView.isHidden = viewModel.imageURL == nil
298299
if let imageURL = viewModel.imageURL {
299300
imageView.setImage(with: imageURL)
300-
} else {
301-
imageView.isHidden = true
302301
}
303302

304303
buttons.bookmark.configuration = {
@@ -391,7 +390,7 @@ private func kFormatted(_ count: Int) -> String {
391390
// MARK: - ReaderPostCellView (Accessibility)
392391

393392
private extension ReaderPostCellView {
394-
func configureAccessibility() {
393+
func setupAccessibility() {
395394
buttonAuthor.accessibilityHint = NSLocalizedString("reader.post.buttonSite.accessibilityHint", value: "Opens the site details", comment: "Accessibility hint for the site header")
396395
buttonMore.accessibilityLabel = NSLocalizedString("reader.post.moreMenu.accessibilityLabel", value: "More actions", comment: "Button accessibility label")
397396

0 commit comments

Comments
 (0)