Skip to content

Commit

Permalink
MBL-1374: Handle long add-on names on late pledge confirmation page
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-at-kickstarter committed May 8, 2024
1 parent b162b61 commit aee4baf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ final class PostCampaignPledgeRewardsSummaryViewController: UIViewController {
self.tableView.registerCellClass(PostCampaignPledgeRewardsSummaryCell.self)
}

override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()

self.tableViewContainerHeightConstraint?.constant = self.tableView.intrinsicContentSize.height
}

private func setupConstraints() {
let tableViewContainerHeightConstraint = self.tableViewContainer.heightAnchor
.constraint(equalToConstant: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ final class PostCampaignPledgeRewardsSummaryCell: UITableViewCell, ValueCell {
self.selectionStyle = .none
self.separatorInset = UIEdgeInsets(leftRight: CheckoutConstants.PledgeView.Inset.leftRight)

self.amountLabel.setContentHuggingPriority(.required, for: .horizontal)

self.amountLabel.adjustsFontForContentSizeCategory = true

_ = self.rootStackView
|> rootStackViewStyle(self.traitCollection.preferredContentSizeCategory > .accessibilityLarge)

_ = self.titleLabel
|> titleLabelStyle

self.amountLabel.setContentHuggingPriority(.required, for: .horizontal)
self.amountLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
}

// MARK: - View model
Expand Down Expand Up @@ -76,6 +77,12 @@ final class PostCampaignPledgeRewardsSummaryCell: UITableViewCell, ValueCell {
_ = ([self.titleLabel, self.amountLabel], self.rootStackView)
|> ksr_addArrangedSubviewsToStackView()
}

override func layoutSubviews() {
super.layoutSubviews()
self.titleLabel.preferredMaxLayoutWidth = self.titleLabel.frame.size.width
super.layoutSubviews()
}
}

// MARK: - Styles
Expand All @@ -91,7 +98,7 @@ private let titleLabelStyle: LabelStyle = { label in
private func rootStackViewStyle(_ isAccessibilityCategory: Bool) -> (StackViewStyle) {
let alignment: UIStackView.Alignment = (isAccessibilityCategory ? .center : .top)
let axis: NSLayoutConstraint.Axis = (isAccessibilityCategory ? .vertical : .horizontal)
let distribution: UIStackView.Distribution = (isAccessibilityCategory ? .equalSpacing : .fill)
let distribution: UIStackView.Distribution = (isAccessibilityCategory ? .equalSpacing : .fillProportionally)
let spacing: CGFloat = (isAccessibilityCategory ? Styles.grid(1) : 0)

return { (stackView: UIStackView) in
Expand Down

0 comments on commit aee4baf

Please sign in to comment.