Skip to content

Commit 6c439ee

Browse files
committed
8355 Hide IPP image and progress views in landscape
In the past, we hid the image when the IPP payment flow was used in landscape. With the addition of the progress view in #8079 c: 83f1d4c we added another place where the image view could be shown or hidden (as the progress view replaces the image.) That introduced a bug where images would be shown in landscape, breaking the rest of the IPP layout. This commit moves all the `isHidden` changes to the `resetHeightAndWidth`, which is responsible for whether and which view should be shown.
1 parent a50ecf5 commit 6c439ee

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

WooCommerce/Classes/ViewRelated/CardPresentPayments/CardPresentPaymentsModalViewController.swift

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,39 @@ final class CardPresentPaymentsModalViewController: UIViewController, CardReader
7171
private func resetHeightAndWidth() {
7272
if traitCollection.containsTraits(in: UITraitCollection(verticalSizeClass: .compact)) {
7373
primaryActionButtonsStackView.axis = .horizontal
74-
imageView.isHidden = true
7574

7675
mainStackView.distribution = .fillProportionally
7776
heightConstraint.constant = Constants.modalWidth
7877
widthConstraint.constant = Constants.modalHeight
7978
} else {
8079
primaryActionButtonsStackView.axis = .vertical
81-
imageView.isHidden = false
80+
8281
mainStackView.distribution = .fill
8382
heightConstraint.constant = Constants.modalHeight
8483
widthConstraint.constant = Constants.modalWidth
8584
}
8685

86+
updateImageAndLoadingVisibility()
87+
8788
heightConstraint.priority = .required
8889
widthConstraint.priority = .required
8990
configureSpacer()
9091
}
92+
93+
private func updateImageAndLoadingVisibility() {
94+
if traitCollection.containsTraits(in: UITraitCollection(verticalSizeClass: .compact)) {
95+
imageView.isHidden = true
96+
loadingView?.isHidden = true
97+
} else {
98+
if viewModel.showLoadingIndicator {
99+
imageView.isHidden = true
100+
loadingView?.isHidden = false
101+
} else {
102+
imageView.isHidden = false
103+
loadingView?.isHidden = true
104+
}
105+
}
106+
}
91107
}
92108

93109

@@ -202,8 +218,6 @@ private extension CardPresentPaymentsModalViewController {
202218

203219
configureImageView()
204220

205-
configureLoadingIndicator()
206-
207221
if shouldShowActionButtons() {
208222
configureActionButtonsView()
209223
styleActionButtons()
@@ -214,6 +228,8 @@ private extension CardPresentPaymentsModalViewController {
214228
if shouldShowBottomLabels() {
215229
configureBottomLabels()
216230
}
231+
232+
resetHeightAndWidth()
217233
}
218234

219235
func configureTopTitle() {
@@ -248,11 +264,6 @@ private extension CardPresentPaymentsModalViewController {
248264

249265
func configureImageView() {
250266
imageView.image = viewModel.image
251-
imageView.isHidden = viewModel.showLoadingIndicator
252-
}
253-
254-
func configureLoadingIndicator() {
255-
loadingView?.isHidden = !viewModel.showLoadingIndicator
256267
}
257268

258269
func setButtonsActions() {

0 commit comments

Comments
 (0)