feat: Fix follow hashtags header layout

This commit is contained in:
Marcus Kida 2022-11-23 17:24:25 +01:00
parent 178a6e503a
commit 9d245d3205
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
2 changed files with 16 additions and 1 deletions

View File

@ -25,6 +25,8 @@ final class HashtagTimelineHeaderView: UIView {
let participantsDescLabel = UILabel()
let postsTodayDescLabel = UILabel()
private var widthConstraint: NSLayoutConstraint!
let followButton: UIButton = {
let button = RoundedEdgesButton(type: .custom)
button.cornerRadius = 10
@ -67,8 +69,12 @@ private extension HashtagTimelineHeaderView {
postCountDescLabel.text = "posts"
participantsDescLabel.text = "participants"
postsTodayDescLabel.text = "posts today"
widthConstraint = widthAnchor.constraint(equalToConstant: 0)
NSLayoutConstraint.activate([
widthConstraint,
titleLabel.topAnchor.constraint(equalTo: topAnchor, constant: .padding),
titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: .padding),
titleLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -CGFloat.padding),
@ -106,4 +112,8 @@ extension HashtagTimelineHeaderView {
titleLabel.text = "#\(entity.name)"
followButton.setTitle(entity.following == true ? "Unfollow" : "Follow", for: .normal)
}
func updateWidthConstraint(_ constant: CGFloat) {
widthConstraint.constant = constant
}
}

View File

@ -178,6 +178,11 @@ extension HashtagTimelineViewController {
}
headerView.update(tag)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
headerView.updateWidthConstraint(tableView.bounds.width)
}
}
extension HashtagTimelineViewController {