diff --git a/Example/Example/Sources/UI/Modules/AlternativePayment/Methods/Router/AlternativePaymentMethodsRouter.swift b/Example/Example/Sources/UI/Modules/AlternativePayment/Methods/Router/AlternativePaymentMethodsRouter.swift index a93c9881e..747108d61 100644 --- a/Example/Example/Sources/UI/Modules/AlternativePayment/Methods/Router/AlternativePaymentMethodsRouter.swift +++ b/Example/Example/Sources/UI/Modules/AlternativePayment/Methods/Router/AlternativePaymentMethodsRouter.swift @@ -29,6 +29,7 @@ final class AlternativePaymentMethodsRouter: RouterType { } .with(configuration: configuration) .build() + viewController.isModalInPresentation = true self.viewController?.present(viewController, animated: true) case let .alternativePayment(request): let viewController = POAlternativePaymentMethodViewControllerBuilder() diff --git a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/Buttons/NativeAlternativePaymentMethodButtonsView.swift b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/Buttons/NativeAlternativePaymentMethodButtonsView.swift index 5abd6e456..dc80a0284 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/Buttons/NativeAlternativePaymentMethodButtonsView.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/Buttons/NativeAlternativePaymentMethodButtonsView.swift @@ -36,17 +36,19 @@ final class NativeAlternativePaymentMethodButtonsView: UIView { guard actions.primary != nil || actions.secondary != nil else { return 0 } - let buttonsHeight: CGFloat + let numberOfActions: Int switch style.axis { case .horizontal: - buttonsHeight = Constants.buttonHeight + numberOfActions = 1 case .vertical: - let numberOfActions = [actions.primary, actions.secondary].compactMap { $0 }.count - return CGFloat(numberOfActions) * Constants.buttonHeight + Constants.spacing * CGFloat(numberOfActions - 1) + numberOfActions = [actions.primary, actions.secondary].compactMap { $0 }.count @unknown default: assertionFailure("Unexpected axis.") - return 0 + numberOfActions = 1 } + let buttonsHeight = + Constants.buttonHeight * CGFloat(numberOfActions) + + Constants.spacing * CGFloat(numberOfActions - 1) return Constants.verticalInset * 2 + buttonsHeight } @@ -59,7 +61,7 @@ final class NativeAlternativePaymentMethodButtonsView: UIView { private enum Constants { static let spacing: CGFloat = 16 static let verticalInset: CGFloat = 16 - static let buttonHeight: CGFloat = 40 + static let buttonHeight: CGFloat = 44 static let separatorHeight: CGFloat = 1 } diff --git a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/NativeAlternativePaymentMethodViewController.swift b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/NativeAlternativePaymentMethodViewController.swift index 0457f6c0b..137e8c5c9 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/NativeAlternativePaymentMethodViewController.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/View/NativeAlternativePaymentMethodViewController.swift @@ -199,6 +199,15 @@ final class NativeAlternativePaymentMethodViewController CGFloat { + if let identifier = collectionViewDataSource.sectionIdentifier(for: section), identifier.isTight { + return Constants.tightLineSpacing + } + return Constants.lineSpacing + } + // MARK: - Scroll View Delegate func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { @@ -259,12 +268,7 @@ final class NativeAlternativePaymentMethodViewController = { @@ -513,9 +517,10 @@ final class NativeAlternativePaymentMethodViewController, NativeAlternativePaymentMethodViewModel { @@ -102,7 +103,7 @@ final class DefaultNativeAlternativePaymentMethodViewModel: private func configureWithStartingState() { let sections = [ - State.Section(id: .init(id: nil, header: nil), items: [.loader]) + State.Section(id: .init(id: nil, header: nil, isTight: false), items: [.loader]) ] let startedState = State.Started( sections: sections, @@ -113,12 +114,13 @@ final class DefaultNativeAlternativePaymentMethodViewModel: state = .started(startedState) } + // swiftlint:disable:next function_body_length private func convertToState(startedState: InteractorState.Started, isSubmitting: Bool) -> State { let titleItem = State.TitleItem( text: configuration.title ?? Text.title(startedState.gatewayDisplayName) ) var sections = [ - State.Section(id: .init(id: nil, header: nil), items: [.title(titleItem)]) + State.Section(id: .init(id: nil, header: nil, isTight: false), items: [.title(titleItem)]) ] let shouldCenterCodeInput = startedState.parameters.count == 1 for (offset, parameter) in startedState.parameters.enumerated() { @@ -137,10 +139,17 @@ final class DefaultNativeAlternativePaymentMethodViewModel: if let message = value.recentErrorMessage { items.append(.error(State.ErrorItem(description: message, isCentered: isCentered))) } + let isTight = items.contains { item in + if case .radio = item { + return true + } + return false + } let section = State.Section( id: .init( id: parameter.key, - header: .init(title: parameter.displayName, isCentered: isCentered) + header: .init(title: parameter.displayName, isCentered: isCentered), + isTight: isTight ), items: items ) @@ -180,7 +189,7 @@ final class DefaultNativeAlternativePaymentMethodViewModel: ) let startedState = State.Started( sections: [ - .init(id: .init(id: nil, header: nil), items: [item]) + .init(id: .init(id: nil, header: nil, isTight: false), items: [item]) ], actions: .init(primary: nil, secondary: secondaryAction), isEditingAllowed: false, @@ -208,7 +217,7 @@ final class DefaultNativeAlternativePaymentMethodViewModel: ) let startedState = State.Started( sections: [ - .init(id: .init(id: nil, header: nil), items: [.submitted(submittedItem)]) + .init(id: .init(id: nil, header: nil, isTight: false), items: [.submitted(submittedItem)]) ], actions: .init(primary: nil, secondary: nil), isEditingAllowed: false, @@ -393,3 +402,5 @@ final class DefaultNativeAlternativePaymentMethodViewModel: cancelActionTimers = [:] } } + +// swiftlint:enable type_body_length file_length diff --git a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/ViewModel/NativeAlternativePaymentMethodViewModelState.swift b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/ViewModel/NativeAlternativePaymentMethodViewModelState.swift index b72b914b1..01f1e1387 100644 --- a/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/ViewModel/NativeAlternativePaymentMethodViewModelState.swift +++ b/Sources/ProcessOut/Sources/UI/Modules/NativeAlternativePaymentMethod/ViewModel/NativeAlternativePaymentMethodViewModelState.swift @@ -154,6 +154,9 @@ enum NativeAlternativePaymentMethodViewModelState { /// Section header if any. let header: SectionHeader? + + /// Boolean value indicating whether section items should be laid out tightly. + let isTight: Bool } struct Section { diff --git a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/Button/Button.swift b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/Button/Button.swift index f0860bee2..fc6d91926 100644 --- a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/Button/Button.swift +++ b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/Button/Button.swift @@ -105,7 +105,7 @@ final class Button: UIControl { // MARK: - Private Nested Types private enum Constants { - static let height: CGFloat = 40 + static let height: CGFloat = 44 static let minimumEdgesSpacing: CGFloat = 4 static let maximumFontSize: CGFloat = 22 static let animationDuration: TimeInterval = 0.25 diff --git a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/CodeTextField/CodeTextField.swift b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/CodeTextField/CodeTextField.swift index 5d0b704dc..d09d5227e 100644 --- a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/CodeTextField/CodeTextField.swift +++ b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/CodeTextField/CodeTextField.swift @@ -311,7 +311,7 @@ final class CodeTextField: UIControl, UITextInput { // MARK: - Private Nested Types private enum Constants { - static let height: CGFloat = 40 + static let height: CGFloat = 44 static let spacing: CGFloat = 8 static let minimumSpacing: CGFloat = 6 } diff --git a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/Picker/Picker.swift b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/Picker/Picker.swift index 7d335a44e..29b3f4bb2 100644 --- a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/Picker/Picker.swift +++ b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/Picker/Picker.swift @@ -58,7 +58,7 @@ final class Picker: UIControl { // MARK: - Private Nested Types private enum Constants { - static let height: CGFloat = 40 + static let height: CGFloat = 44 static let horizontalInset: CGFloat = 12 static let maximumFontSize: CGFloat = 22 static let animationDuration: TimeInterval = 0.25 diff --git a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/RadioButton/RadioButton.swift b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/RadioButton/RadioButton.swift index 0bc32ea94..46bc3296f 100644 --- a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/RadioButton/RadioButton.swift +++ b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/RadioButton/RadioButton.swift @@ -34,7 +34,7 @@ final class RadioButton: UIControl { // MARK: - Private Nested Types private enum Constants { - static let minimumHeight: CGFloat = 40 + static let minimumHeight: CGFloat = 44 static let knobSize: CGFloat = 18 static let animationDuration: TimeInterval = 0.25 static let horizontalSpacing: CGFloat = 8 diff --git a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/TextField/TextFieldContainerView.swift b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/TextField/TextFieldContainerView.swift index 489472aad..819001cec 100644 --- a/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/TextField/TextFieldContainerView.swift +++ b/Sources/ProcessOut/Sources/UI/Shared/DesignSystem/Views/TextField/TextFieldContainerView.swift @@ -52,7 +52,7 @@ final class TextFieldContainerView: UIView { private enum Constants { static let animationDuration: TimeInterval = 0.35 static let maximumFontSize: CGFloat = 22 - static let height: CGFloat = 40 + static let height: CGFloat = 44 static let horizontalInset: CGFloat = 12 }