@@ -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 ( ) {
134- avatarView. layer. cornerRadius = 14
132+ private func setupStyle ( ) {
133+ 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)
@@ -146,7 +145,7 @@ private final class ReaderPostCellView: UIView {
146145 detailsLabel. font = . preferredFont( forTextStyle: . subheadline)
147146 detailsLabel. textColor = . secondaryLabel
148147 detailsLabel. adjustsFontForContentSizeCategory = true
149- titleLabel . maximumContentSizeCategory = . accessibilityExtraLarge
148+ detailsLabel . maximumContentSizeCategory = . accessibilityExtraLarge
150149
151150 imageView. layer. cornerRadius = 8
152151 imageView. layer. masksToBounds = true
@@ -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: [
@@ -272,12 +271,11 @@ private final class ReaderPostCellView: UIView {
272271 }
273272
274273 private func makeMoreMenu( ) -> [ UIMenuElement ] {
275- guard let viewModel, let post = viewModel. post,
276- let viewController = viewModel. viewController else {
274+ guard let viewModel, let viewController = viewModel. viewController else {
277275 return [ ]
278276 }
279277 return ReaderPostMenu (
280- post: post,
278+ post: viewModel . post,
281279 topic: viewController. readerTopic,
282280 button: buttonMore,
283281 viewController: viewController
@@ -295,10 +293,10 @@ private final class ReaderPostCellView: UIView {
295293
296294 titleLabel. text = viewModel. title
297295 detailsLabel. text = viewModel. details
296+
297+ imageView. isHidden = viewModel. imageURL == nil
298298 if let imageURL = viewModel. imageURL {
299299 imageView. setImage ( with: imageURL)
300- } else {
301- imageView. isHidden = true
302300 }
303301
304302 buttons. bookmark. configuration = {
@@ -385,13 +383,13 @@ private func makeButton(systemImage: String, font: UIFont = UIFont.preferredFont
385383}
386384
387385private func kFormatted( _ count: Int ) -> String {
388- count >= 1000 ? String ( format : " %.0fK " , Double ( count ) / 1000 ) : String ( count )
386+ count. formatted ( . number . notation ( . compactName ) )
389387}
390388
391389// MARK: - ReaderPostCellView (Accessibility)
392390
393391private extension ReaderPostCellView {
394- func configureAccessibility ( ) {
392+ func setupAccessibility ( ) {
395393 buttonAuthor. accessibilityHint = NSLocalizedString ( " reader.post.buttonSite.accessibilityHint " , value: " Opens the site details " , comment: " Accessibility hint for the site header " )
396394 buttonMore. accessibilityLabel = NSLocalizedString ( " reader.post.moreMenu.accessibilityLabel " , value: " More actions " , comment: " Button accessibility label " )
397395
0 commit comments