From aee4bafdad5517437592d54becbd5a52fcc4fcab Mon Sep 17 00:00:00 2001 From: Amy Date: Wed, 8 May 2024 12:46:25 -0400 Subject: [PATCH] MBL-1374: Handle long add-on names on late pledge confirmation page --- ...CampaignPledgeRewardsSummaryViewController.swift | 6 ++++++ .../PostCampaignPledgeRewardsSummaryCell.swift | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Kickstarter-iOS/Features/PledgePaymentMethods/Controller/PostCampaignPledgeRewardsSummaryViewController.swift b/Kickstarter-iOS/Features/PledgePaymentMethods/Controller/PostCampaignPledgeRewardsSummaryViewController.swift index d7c0914b26..af81f4d925 100644 --- a/Kickstarter-iOS/Features/PledgePaymentMethods/Controller/PostCampaignPledgeRewardsSummaryViewController.swift +++ b/Kickstarter-iOS/Features/PledgePaymentMethods/Controller/PostCampaignPledgeRewardsSummaryViewController.swift @@ -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) diff --git a/Kickstarter-iOS/Features/PledgePaymentMethods/Views/Cells/PostCampaignPledgeRewardsSummaryCell.swift b/Kickstarter-iOS/Features/PledgePaymentMethods/Views/Cells/PostCampaignPledgeRewardsSummaryCell.swift index 1595b7a1f8..f3ae91207b 100644 --- a/Kickstarter-iOS/Features/PledgePaymentMethods/Views/Cells/PostCampaignPledgeRewardsSummaryCell.swift +++ b/Kickstarter-iOS/Features/PledgePaymentMethods/Views/Cells/PostCampaignPledgeRewardsSummaryCell.swift @@ -34,8 +34,6 @@ 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 @@ -43,6 +41,9 @@ final class PostCampaignPledgeRewardsSummaryCell: UITableViewCell, ValueCell { _ = self.titleLabel |> titleLabelStyle + + self.amountLabel.setContentHuggingPriority(.required, for: .horizontal) + self.amountLabel.setContentCompressionResistancePriority(.required, for: .horizontal) } // MARK: - View model @@ -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 @@ -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