@@ -11,6 +11,7 @@ final class CardPresentPaymentsModalViewController: UIViewController {
1111
1212 @IBOutlet weak var containerView : UIView !
1313 @IBOutlet weak var mainStackView : UIStackView !
14+ @IBOutlet weak var bottomPaddingRegular : NSLayoutConstraint !
1415 @IBOutlet weak var primaryActionButtonsStackView : UIStackView !
1516 @IBOutlet weak var buttonsSpacer : UIView !
1617 @IBOutlet private weak var topTitleLabel : UILabel !
@@ -82,6 +83,7 @@ final class CardPresentPaymentsModalViewController: UIViewController {
8283
8384 heightConstraint. priority = . required
8485 widthConstraint. priority = . required
86+ configureSpacer ( )
8587 }
8688}
8789
@@ -117,8 +119,8 @@ private extension CardPresentPaymentsModalViewController {
117119
118120 func styleBottomLabels( ) {
119121 actionButtonsView. isHidden = true
120- buttonsSpacer. isHidden = false
121122 bottomLabels. isHidden = false
123+ configureSpacer ( )
122124
123125 styleBottomTitle ( )
124126 styleBottomSubtitle ( )
@@ -134,8 +136,8 @@ private extension CardPresentPaymentsModalViewController {
134136
135137 func styleActionButtons( ) {
136138 actionButtonsView. isHidden = false
137- buttonsSpacer. isHidden = true
138139 bottomLabels. isHidden = true
140+ configureSpacer ( )
139141
140142 stylePrimaryButton ( )
141143 styleSecondaryButton ( )
@@ -239,7 +241,7 @@ private extension CardPresentPaymentsModalViewController {
239241
240242 func hideActionButtonsView( ) {
241243 actionButtonsView. isHidden = true
242- buttonsSpacer . isHidden = false
244+ configureSpacer ( )
243245 }
244246
245247 func configurePrimaryButton( ) {
@@ -271,6 +273,30 @@ private extension CardPresentPaymentsModalViewController {
271273 auxiliaryButton. isHidden = false
272274 auxiliaryButton. setTitle ( viewModel. auxiliaryButtonTitle, for: . normal)
273275 }
276+
277+ func configureSpacer( ) {
278+ let enabled = !shouldShowActionButtons( )
279+
280+ if isRegularClassSize {
281+ buttonsSpacer. isHidden = true
282+ // For iPads, instead of a flexible spacer we expand the bottom margin with an extra 127px.
283+ // This would be the space equivalents to the primary and secondary buttons being visible
284+ // - 32px of spacing between buttons container and the rest of the content
285+ // - 40px for the primary button
286+ // - 15px of spacing between buttons
287+ // - 40px for the secondary button
288+ bottomPaddingRegular. constant = 42 + ( enabled ? 127 : 0 )
289+ } else {
290+ // For compact screens (iPhones, or iPad in split mode), we us a flexible spacer with a low
291+ // content hugging priority to ensure it takes all the available space, leaving the rest of
292+ // the visible items aligned to the top of the stack view
293+ buttonsSpacer. isHidden = !enabled
294+ }
295+ }
296+
297+ var isRegularClassSize : Bool {
298+ traitCollection. verticalSizeClass == . regular && traitCollection. horizontalSizeClass == . regular
299+ }
274300}
275301
276302// MARK: - View layout configuration
0 commit comments