Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,6 @@ final class ReaderCommentsTableViewController: UIViewController, UITableViewData
return viewModel
}

// MARK: - UITableViewDataDelegate

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
containerViewController?.getHeaderView()
}

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
containerViewController?.getHeaderView() == nil ? 0 : UITableView.automaticDimension
}

// MARK: - UIScrollViewDelegate

func scrollViewDidScroll(_ scrollView: UIScrollView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,69 @@ final class ReaderCommentsViewController: UIViewController, WPContentSyncHelperD

private func setupNavigationBar() {
navigationItem.backButtonTitle = ""
title = Strings.title
navigationItem.largeTitleDisplayMode = .never
updateNavigationTitle()
}

private func updateNavigationTitle() {
guard allowsPushingPostDetails, let post else {
title = Strings.title
navigationItem.titleView = nil
return
}

let titleButton = UIButton(type: .system)
titleButton.addTarget(self, action: #selector(navigationTitleTapped), for: .touchUpInside)

// Container stack view
let stackView = UIStackView()
stackView.axis = .vertical
stackView.alignment = .center
stackView.spacing = 2
stackView.isUserInteractionEnabled = false

// Main title label
let titleLabel = UILabel()
titleLabel.text = Strings.title
titleLabel.font = .preferredFont(forTextStyle: .headline)
titleLabel.textColor = .label
titleLabel.textAlignment = .center
titleLabel.maximumContentSizeCategory = .extraLarge

// Subtitle with post name and indicator
let subtitleContainer = UIStackView()
subtitleContainer.axis = .horizontal
subtitleContainer.alignment = .center
subtitleContainer.spacing = 4

let subtitleLabel = UILabel()
subtitleLabel.text = post.titleForDisplay()
subtitleLabel.font = .preferredFont(forTextStyle: .caption1)
subtitleLabel.textColor = .secondaryLabel
subtitleLabel.textAlignment = .center
subtitleLabel.maximumContentSizeCategory = .extraLarge

let chevronImageView = UIImageView()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about the image seems off – I'm not sure if it's the text baseline or if it's not quite the right size.

Will it work with dynamic type with a hard-coded point size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The labels can only grow so much: subtitleLabel.maximumContentSizeCategory = .extraLarge. There isn't space in the navigation bar. Let me check again how well it looks with the maximum size.

let chevronImage = UIImage(systemName: "chevron.right.circle")?
.withConfiguration(UIImage.SymbolConfiguration(pointSize: 12, weight: .regular))
chevronImageView.image = chevronImage
chevronImageView.tintColor = UIAppColor.primary
chevronImageView.contentMode = .scaleAspectFit

subtitleContainer.addArrangedSubview(subtitleLabel)
subtitleContainer.addArrangedSubview(chevronImageView)

stackView.addArrangedSubview(titleLabel)
stackView.addArrangedSubview(subtitleContainer)

titleButton.addSubview(stackView)
stackView.pinEdges()

navigationItem.titleView = titleButton
}

@objc private func navigationTitleTapped() {
handleHeaderTapped()
}

private func setupView() {
Expand All @@ -120,19 +181,6 @@ final class ReaderCommentsViewController: UIViewController, WPContentSyncHelperD
activityIndicator.pinCenter()
}

func getHeaderView() -> UIView? {
guard allowsPushingPostDetails, let post else {
return nil
}
return CommentTableHeaderView(
title: post.titleForDisplay(),
subtitle: .commentThread,
showsDisclosureIndicator: allowsPushingPostDetails
) { [weak self] in
self?.handleHeaderTapped()
}
}

// MARK: - Fetch Post

private func fetchPost() {
Expand All @@ -157,6 +205,7 @@ final class ReaderCommentsViewController: UIViewController, WPContentSyncHelperD

private func configure(with post: ReaderPost) {
self.post = post
updateNavigationTitle()

if post.isWPCom || post.isJetpack {
let tableVC = ReaderCommentsTableViewController(post: post)
Expand Down