Skip to content

Commit

Permalink
[NT-1240] Prevent UIStackViews from inheriting margins (#1192)
Browse files Browse the repository at this point in the history
* Add insetsLayoutMarginsFromSafeArea = false

* Set additional insetsLayoutMarginsFromSafeArea to false

* Removing unneeded insetsLayoutMarginsFromSafeArea

* Removing push file

Co-authored-by: Isabel Barrera <ifbarrera@me.com>
  • Loading branch information
justinswart and ifbarrera committed May 13, 2020
1 parent e4e7bd7 commit 44b3cf5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
16 changes: 11 additions & 5 deletions Kickstarter-iOS/Views/Cells/PledgePaymentMethodCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ final class PledgePaymentMethodCell: UITableViewCell, ValueCell {

NSLayoutConstraint.activate([
self.cardImageView.widthAnchor.constraint(equalToConstant: Styles.grid(10)),
self.checkmarkImageView.widthAnchor.constraint(
equalTo: self.cardImageView.widthAnchor, multiplier: 0.4
),
self.checkmarkImageView.widthAnchor.constraint(equalToConstant: Styles.grid(4)),
self.checkmarkImageView.heightAnchor.constraint(equalTo: self.cardImageView.heightAnchor)
])
}
Expand All @@ -93,10 +91,9 @@ final class PledgePaymentMethodCell: UITableViewCell, ValueCell {
|> labelsStackViewStyle

_ = self.cardImageAndLabelsStackView
|> checkoutAdaptableStackViewStyle(
|> cardImageAndLabelsStackViewStyle(
self.traitCollection.preferredContentSizeCategory.isAccessibilityCategory
)
|> adaptableStackViewStyle

_ = self.unavailableCardTypeLabel
|> unavailableCardTypeLabelStyle
Expand Down Expand Up @@ -177,6 +174,14 @@ private let adaptableStackViewStyle: StackViewStyle = { stackView in
|> \.spacing .~ Styles.grid(2)
}

private func cardImageAndLabelsStackViewStyle(_ isAccessibilityCategory: Bool) -> StackViewStyle {
return { stackView in
stackView
|> checkoutAdaptableStackViewStyle(isAccessibilityCategory)
|> adaptableStackViewStyle
}
}

private let checkmarkImageViewStyle: ImageViewStyle = { imageView in
imageView
|> \.contentMode .~ .center
Expand Down Expand Up @@ -212,6 +217,7 @@ private let rootStackViewStyle: StackViewStyle = { stackView in
|> \.axis .~ .horizontal
|> \.layoutMargins .~ .init(all: Styles.grid(2))
|> \.isLayoutMarginsRelativeArrangement .~ true
|> \.insetsLayoutMarginsFromSafeArea .~ false
|> \.spacing .~ Styles.grid(2)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,22 @@ final class PledgePaymentMethodLoadingCell: UITableViewCell, ValueCell {
_ = self.rootStackView
|> \.spacing .~ Styles.grid(2)
|> \.isLayoutMarginsRelativeArrangement .~ true
|> \.insetsLayoutMarginsFromSafeArea .~ false
|> \.layoutMargins .~ .init(all: Styles.grid(2))

_ = self.contentStackView
|> \.axis .~ .vertical
|> \.distribution .~ .fillEqually
|> \.spacing .~ Styles.gridHalf(3)
|> \.isLayoutMarginsRelativeArrangement .~ true
|> \.insetsLayoutMarginsFromSafeArea .~ false
|> \.layoutMargins .~ .init(topBottom: Styles.grid(1))

_ = self.subtitleStackView
|> \.insetsLayoutMarginsFromSafeArea .~ false

_ = self.titleStackView
|> \.insetsLayoutMarginsFromSafeArea .~ false
}

func configureWith(value _: Void) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ final class PledgeAmountViewController: UIViewController {
}
}

override func didMove(toParent parent: UIViewController?) {
override func didMove(toParent _: UIViewController?) {
self.verticalSpacer.isHidden = true
}

Expand Down

0 comments on commit 44b3cf5

Please sign in to comment.