@@ -48,7 +48,8 @@ final class CommentContentTableViewCell: UITableViewCell, NibReusable {
4848 private var effectiveDepth : Int = 0 {
4949 didSet {
5050 guard oldValue != effectiveDepth else { return }
51- highlightBarLeadingSpacingConstraint. constant = effectiveDepth == 0 ? 0 : ( Self . depthInset * CGFloat( effectiveDepth) )
51+ highlightBarLeadingSpacingConstraint. constant =
52+ effectiveDepth == 0 ? 0 : ( Self . depthInset * CGFloat( effectiveDepth) )
5253 containerStackLeadingConstraint? . constant = ( Self . depthInset * CGFloat( effectiveDepth) ) + 16
5354 configureDepthSeparators ( depth: effectiveDepth)
5455 }
@@ -177,17 +178,23 @@ final class CommentContentTableViewCell: UITableViewCell, NibReusable {
177178 self . isContentExpanded = helper. isCommentExpanded ( comment. objectID)
178179 self . onContentLoaded = onContentLoaded
179180
180- viewModel. $state. sink { [ weak self] in
181- self ? . configure ( with: $0)
182- } . store ( in: & cancellables)
181+ viewModel. $state
182+ . sink { [ weak self] in
183+ self ? . configure ( with: $0)
184+ }
185+ . store ( in: & cancellables)
183186
184- viewModel. $avatar. sink { [ weak self] in
185- self ? . configureAvatar ( with: $0)
186- } . store ( in: & cancellables)
187+ viewModel. $avatar
188+ . sink { [ weak self] in
189+ self ? . configureAvatar ( with: $0)
190+ }
191+ . store ( in: & cancellables)
187192
188- viewModel. $content. sink { [ weak self] in
189- self ? . configureContent ( $0 ?? " " , helper: helper)
190- } . store ( in: & cancellables)
193+ viewModel. $content
194+ . sink { [ weak self] in
195+ self ? . configureContent ( $0 ?? " " , helper: helper)
196+ }
197+ . store ( in: & cancellables)
191198
192199 // Configure feature availability.
193200 isAccessoryButtonEnabled = comment. isApproved ( )
@@ -198,7 +205,11 @@ final class CommentContentTableViewCell: UITableViewCell, NibReusable {
198205 /// - Parameters:
199206 /// - comment: The `Comment` object to display.
200207 /// - onContentLoaded: Callback to be called once the content has been loaded. Provides the new content height as parameter.
201- func configureForPostDetails( with comment: Comment , helper: ReaderCommentsHelper , onContentLoaded: ( ( CGFloat ) -> Void ) ? ) {
208+ func configureForPostDetails(
209+ with comment: Comment ,
210+ helper: ReaderCommentsHelper ,
211+ onContentLoaded: ( ( CGFloat ) -> Void ) ?
212+ ) {
202213 configure ( viewModel: CommentCellViewModel ( comment: comment) , helper: helper, onContentLoaded: onContentLoaded)
203214
204215 containerStackLeadingConstraint. constant = 0
@@ -231,7 +242,7 @@ final class CommentContentTableViewCell: UITableViewCell, NibReusable {
231242
232243 func configureForCommentDetails( ) {
233244 containerStackView. isLayoutMarginsRelativeArrangement = true
234- containerStackView. directionalLayoutMargins = NSDirectionalEdgeInsets ( top : 4 , leading : 0 , bottom : 4 , trailing : 0 )
245+ containerStackView. layoutMargins = UIEdgeInsets ( . vertical , 4 )
235246 }
236247
237248 private func configure( with state: CommentCellViewModel . State ) {
@@ -250,15 +261,18 @@ final class CommentContentTableViewCell: UITableViewCell, NibReusable {
250261 depthSeparator? . isHidden = true
251262 }
252263 for level in 0 ..< depth {
253- let separatorView = depthSeparators [ level] ?? {
254- let separatorView = SeparatorView . vertical ( width: 1.0 )
255- depthSeparators [ level] = separatorView
256- contentView. addSubview ( separatorView)
257- separatorView. pinEdges ( [ . top, . bottom] )
258- let inset = - Self . depthInset * CGFloat( level + 1 )
259- separatorView. trailingAnchor. constraint ( equalTo: containerStackView. leadingAnchor, constant: inset) . isActive = true
260- return separatorView
261- } ( )
264+ let separatorView =
265+ depthSeparators [ level]
266+ ?? {
267+ let separatorView = SeparatorView . vertical ( width: 1.0 )
268+ depthSeparators [ level] = separatorView
269+ contentView. addSubview ( separatorView)
270+ separatorView. pinEdges ( [ . top, . bottom] )
271+ let inset = - Self . depthInset * CGFloat( level + 1 )
272+ separatorView. trailingAnchor. constraint ( equalTo: containerStackView. leadingAnchor, constant: inset)
273+ . isActive = true
274+ return separatorView
275+ } ( )
262276 separatorView. isHidden = false
263277 }
264278 }
@@ -274,7 +288,8 @@ final class CommentContentTableViewCell: UITableViewCell, NibReusable {
274288 backgroundView. backgroundColor = Style . highlightedBackgroundColor
275289 contentView. insertSubview ( backgroundView, belowSubview: containerStackView)
276290 backgroundView. pinEdges ( [ . vertical, . trailing] , to: contentView)
277- backgroundView. leadingAnchor. constraint ( equalTo: containerStackView. leadingAnchor, constant: - 16 ) . isActive = true
291+ backgroundView. leadingAnchor. constraint ( equalTo: containerStackView. leadingAnchor, constant: - 16 )
292+ . isActive = true
278293 highlightedBackgroundView = backgroundView
279294 }
280295 }
@@ -352,9 +367,16 @@ private extension CommentContentTableViewCell {
352367 var accessoryButtonImage : UIImage ? {
353368 switch accessoryButtonType {
354369 case . ellipsis:
355- return . init( systemName: " ellipsis " , withConfiguration: UIImage . SymbolConfiguration ( font: . preferredFont( forTextStyle: . footnote) ) ) ? . withTintColor ( . secondaryLabel)
370+ return . init(
371+ systemName: " ellipsis " ,
372+ withConfiguration: UIImage . SymbolConfiguration ( font: . preferredFont( forTextStyle: . footnote) )
373+ ) ?
374+ . withTintColor ( . secondaryLabel)
356375 case . info:
357- return . init( systemName: " info.circle " , withConfiguration: UIImage . SymbolConfiguration ( font: . preferredFont( forTextStyle: . footnote) ) )
376+ return . init(
377+ systemName: " info.circle " ,
378+ withConfiguration: UIImage . SymbolConfiguration ( font: . preferredFont( forTextStyle: . footnote) )
379+ )
358380 }
359381 }
360382
@@ -465,7 +487,8 @@ private extension CommentContentTableViewCell {
465487 func updateLikeButton( isLiked: Bool , likeCount: Int ) {
466488 likeButton. tintColor = isLiked ? UIAppColor . primary : displaySetting. color. secondaryForeground
467489 if var configuration = likeButton. configuration {
468- configuration. image = isLiked ? WPStyleGuide . ReaderDetail. likeSelectedToolbarIcon : WPStyleGuide . ReaderDetail. likeToolbarIcon
490+ configuration. image =
491+ isLiked ? WPStyleGuide . ReaderDetail. likeSelectedToolbarIcon : WPStyleGuide . ReaderDetail. likeToolbarIcon
469492 configuration. title = likeCount > 0 ? " \( likeCount) " : String . noLikes
470493 likeButton. accessibilityLabel = {
471494 switch likeCount {
@@ -478,18 +501,21 @@ private extension CommentContentTableViewCell {
478501 } else {
479502 wpAssertionFailure ( " missing configuration " )
480503 }
481- likeButton. accessibilityLabel = isLiked ? String ( likeCount) + . commentIsLiked : String ( likeCount) + . commentIsNotLiked
504+ likeButton. accessibilityLabel =
505+ isLiked ? String ( likeCount) + . commentIsLiked : String ( likeCount) + . commentIsNotLiked
482506 }
483507
484508 // MARK: Content Rendering
485509
486510 func configureContent( _ content: String , helper: ReaderCommentsHelper ) {
487- let renderer = self . renderer ?? {
488- let renderer = helper. makeWebRenderer ( )
489- renderer. delegate = self
490- self . renderer = renderer
491- return renderer
492- } ( )
511+ let renderer =
512+ self . renderer
513+ ?? {
514+ let renderer = helper. makeWebRenderer ( )
515+ renderer. delegate = self
516+ self . renderer = renderer
517+ return renderer
518+ } ( )
493519
494520 renderer. displaySettings = displaySetting
495521
@@ -525,7 +551,8 @@ private extension CommentContentTableViewCell {
525551 // point hiding a few pixels
526552 isContentExpanded = true
527553 }
528- let displayHeight = isContentExpanded ? effectiveContentHeight : min ( effectiveContentHeight, Self . maxCollapsedHeight)
554+ let displayHeight =
555+ isContentExpanded ? effectiveContentHeight : min ( effectiveContentHeight, Self . maxCollapsedHeight)
529556
530557 contentContainerHeightConstraint? . constant = displayHeight
531558
@@ -550,11 +577,14 @@ private extension CommentContentTableViewCell {
550577 let viewModel = ReaderUserProfileViewModel ( comment: comment)
551578 let profileVC = UIHostingController ( rootView: ReaderUserProfileView ( viewModel: viewModel) )
552579 let navigationVC = UINavigationController ( rootViewController: profileVC)
553- profileVC. navigationItem. leftBarButtonItem = UIBarButtonItem ( systemItem: . close, primaryAction: . init { [ weak profileVC] _ in
554- profileVC? . presentingViewController? . dismiss ( animated: true )
555- } )
580+ profileVC. navigationItem. leftBarButtonItem = UIBarButtonItem (
581+ systemItem: . close,
582+ primaryAction: . init { [ weak profileVC] _ in
583+ profileVC? . presentingViewController? . dismiss ( animated: true )
584+ }
585+ )
556586 navigationVC. sheetPresentationController? . detents = [ . medium( ) ]
557- UIViewController . topViewController ? . present ( navigationVC, animated: true )
587+ window ? . topmostPresentedViewController ? . present ( navigationVC, animated: true )
558588 }
559589
560590 @objc func accessoryButtonTapped( ) {
@@ -603,6 +633,12 @@ private extension String {
603633 static let likeButtonAccessibilityId = " like-comment-button "
604634 static let reply = NSLocalizedString ( " Reply " , comment: " Reply to a comment. " )
605635 static let noLikes = NSLocalizedString ( " Like " , comment: " Button title to Like a comment. " )
606- static let singularLikeFormat = NSLocalizedString ( " %1$d Like " , comment: " Singular button title to Like a comment. %1$d is a placeholder for the number of Likes. " )
607- static let pluralLikesFormat = NSLocalizedString ( " %1$d Likes " , comment: " Plural button title to Like a comment. %1$d is a placeholder for the number of Likes. " )
636+ static let singularLikeFormat = NSLocalizedString (
637+ " %1$d Like " ,
638+ comment: " Singular button title to Like a comment. %1$d is a placeholder for the number of Likes. "
639+ )
640+ static let pluralLikesFormat = NSLocalizedString (
641+ " %1$d Likes " ,
642+ comment: " Plural button title to Like a comment. %1$d is a placeholder for the number of Likes. "
643+ )
608644}
0 commit comments