diff --git a/Mastodon/Diffiable/Section/Status/StatusSection.swift b/Mastodon/Diffiable/Section/Status/StatusSection.swift index 9bb34466..c6cde80f 100644 --- a/Mastodon/Diffiable/Section/Status/StatusSection.swift +++ b/Mastodon/Diffiable/Section/Status/StatusSection.swift @@ -1035,6 +1035,7 @@ extension StatusSection { } snapshot.appendItems(pollItems, toSection: .main) cell.statusView.pollTableViewDataSource?.apply(snapshot, animatingDifferences: false, completion: nil) + cell.statusView.pollTableViewHeightLayoutConstraint.constant = PollOptionTableViewCell.height * CGFloat(poll.options.count) } static func configureActionToolBar( diff --git a/Mastodon/Scene/Share/View/Content/StatusView.swift b/Mastodon/Scene/Share/View/Content/StatusView.swift index c1294bff..49452e1b 100644 --- a/Mastodon/Scene/Share/View/Content/StatusView.swift +++ b/Mastodon/Scene/Share/View/Content/StatusView.swift @@ -287,6 +287,7 @@ extension StatusView { headerContainerStackView.trailingAnchor.constraint(equalTo: headerContainerView.trailingAnchor), headerContainerView.bottomAnchor.constraint(equalTo: headerContainerStackView.bottomAnchor, constant: StatusView.containerStackViewSpacing).priority(.defaultHigh), ]) + headerContainerStackView.setContentCompressionResistancePriority(.required - 5, for: .vertical) containerStackView.addArrangedSubview(headerContainerView) defer { containerStackView.bringSubviewToFront(headerContainerView) @@ -418,17 +419,21 @@ extension StatusView { NSLayoutConstraint.activate([ pollTableViewHeightLayoutConstraint, ]) - - statusPollTableViewHeightObservation = pollTableView.observe(\.contentSize, options: .new, changeHandler: { [weak self] tableView, _ in - guard let self = self else { return } - guard self.pollTableView.contentSize.height != .zero else { - self.pollTableViewHeightLayoutConstraint.constant = 44 - return - } - self.pollTableViewHeightLayoutConstraint.constant = self.pollTableView.contentSize.height - }) - + + // statusPollTableViewHeightObservation = pollTableView.observe(\.contentSize, options: .new, changeHandler: { [weak self] tableView, _ in + // guard let self = self else { return } + // guard self.pollTableView.contentSize.height != .zero else { + // self.pollTableViewHeightLayoutConstraint.constant = 44 + // return + // } + // self.pollTableViewHeightLayoutConstraint.constant = self.pollTableView.contentSize.height + // }) + + pollStatusStackView.translatesAutoresizingMaskIntoConstraints = false statusContainerStackView.addArrangedSubview(pollStatusStackView) + NSLayoutConstraint.activate([ + pollStatusStackView.heightAnchor.constraint(equalToConstant: 30).priority(.required - 10) + ]) pollStatusStackView.axis = .horizontal pollStatusStackView.addArrangedSubview(pollVoteCountLabel) pollStatusStackView.addArrangedSubview(pollStatusDotLabel) diff --git a/Mastodon/Scene/Share/View/TableviewCell/PollOptionTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/PollOptionTableViewCell.swift index fdcaa95f..16b39feb 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/PollOptionTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/PollOptionTableViewCell.swift @@ -10,6 +10,8 @@ import Combine final class PollOptionTableViewCell: UITableViewCell { + static let height: CGFloat = PollOptionView.height + var disposeBag = Set() let pollOptionView = PollOptionView()