Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new Detached address input #1501

Merged
merged 27 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-carthage-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:

carthage:
runs-on: macos-12
runs-on: macos-12-xl
steps:
- uses: actions/checkout@v4
- uses: n1hility/cancel-previous-runs@v3
Expand Down
10 changes: 4 additions & 6 deletions Adyen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@
8140A3762A3327B500896403 /* AdyenComponents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9175E55259393E800D653BE /* AdyenComponents.framework */; };
814276622A7145F50081E896 /* AddressInputFormViewController+ViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 814276612A7145F50081E896 /* AddressInputFormViewController+ViewModel.swift */; };
8149CCB62B0B855F007235E2 /* ThreeDS2PlusDACoreActionHandlerTests+Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8149CCB52B0B855F007235E2 /* ThreeDS2PlusDACoreActionHandlerTests+Constants.swift */; };
81616BE52B271CF900D341FF /* FormVerticalStackItemView+IsValid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81616BE32B271C8D00D341FF /* FormVerticalStackItemView+IsValid.swift */; };
81616BE62B271CFB00D341FF /* FormVerticalStackItemView+IsValid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81616BE32B271C8D00D341FF /* FormVerticalStackItemView+IsValid.swift */; };
8169B9EC2A0506CC00AAC9F8 /* Adyen.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2C0E03322097917008616F6 /* Adyen.framework */; };
81825CB82AC59C3300F91912 /* UIView+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CB72AC59C3300F91912 /* UIView+Search.swift */; };
81825CB92AC59C3300F91912 /* UIView+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81825CB72AC59C3300F91912 /* UIView+Search.swift */; };
Expand Down Expand Up @@ -223,6 +221,7 @@
81EF2FDF2AF3AAF1001FE82F /* InstantPaymentComponentExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81EF2FDD2AF3AAF1001FE82F /* InstantPaymentComponentExample.swift */; };
81EF2FE12AF3D75C001FE82F /* InstantPaymentComponentAdvancedFlowExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81EF2FE02AF3D75C001FE82F /* InstantPaymentComponentAdvancedFlowExample.swift */; };
81EF2FE22AF3D75C001FE82F /* InstantPaymentComponentAdvancedFlowExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81EF2FE02AF3D75C001FE82F /* InstantPaymentComponentAdvancedFlowExample.swift */; };
81F177AE2B4C49B9009CAD96 /* PresenterMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81F177AD2B4C49B9009CAD96 /* PresenterMock.swift */; };
81F1EBA42AD97095002AA93F /* ListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E28098BF220DBF970087928F /* ListItem.swift */; };
81FAFB442AAF715F00828999 /* Adyen.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2C0E03322097917008616F6 /* Adyen.framework */; };
A009837D279859DC007E68C4 /* ACHDirectDebitComponentTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A009837C279859DC007E68C4 /* ACHDirectDebitComponentTests.swift */; };
Expand Down Expand Up @@ -1414,7 +1413,6 @@
813EF9EF2A6551C300C65D15 /* ViewControllerPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewControllerPresenter.swift; sourceTree = "<group>"; };
814276612A7145F50081E896 /* AddressInputFormViewController+ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AddressInputFormViewController+ViewModel.swift"; sourceTree = "<group>"; };
8149CCB52B0B855F007235E2 /* ThreeDS2PlusDACoreActionHandlerTests+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ThreeDS2PlusDACoreActionHandlerTests+Constants.swift"; sourceTree = "<group>"; };
81616BE32B271C8D00D341FF /* FormVerticalStackItemView+IsValid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FormVerticalStackItemView+IsValid.swift"; sourceTree = "<group>"; };
81825CB72AC59C3300F91912 /* UIView+Search.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Search.swift"; sourceTree = "<group>"; };
81825CBA2AC59C4000F91912 /* UIViewController+Search.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+Search.swift"; sourceTree = "<group>"; };
81825CC02AC59C6400F91912 /* XCTestCase+RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTestCase+RootViewController.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1465,6 +1463,7 @@
81EA6C112A44836E0071A141 /* FormAddressItemTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormAddressItemTests.swift; sourceTree = "<group>"; };
81EF2FDD2AF3AAF1001FE82F /* InstantPaymentComponentExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstantPaymentComponentExample.swift; sourceTree = "<group>"; };
81EF2FE02AF3D75C001FE82F /* InstantPaymentComponentAdvancedFlowExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstantPaymentComponentAdvancedFlowExample.swift; sourceTree = "<group>"; };
81F177AD2B4C49B9009CAD96 /* PresenterMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresenterMock.swift; sourceTree = "<group>"; };
A009837C279859DC007E68C4 /* ACHDirectDebitComponentTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ACHDirectDebitComponentTests.swift; sourceTree = "<group>"; };
A009837E27986B50007E68C4 /* BankDetailsEncryptorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankDetailsEncryptorTests.swift; sourceTree = "<group>"; };
A0113D9A2763887800AD395C /* ActionNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNavigationBar.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2974,7 +2973,6 @@
813BF1102B2364E00096940E /* XCTestCase+FirstResponder.swift */,
81B505782A7BE209009B4CB3 /* UIBarButtonItem+XCTest.swift */,
819CC3332B14C53200D2EEE9 /* PaymentMethods+Equatable.swift */,
81616BE32B271C8D00D341FF /* FormVerticalStackItemView+IsValid.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -3977,6 +3975,7 @@
F99F08592383EAC800EBB948 /* FormatterMock.swift */,
F9639B4824E28DC80073F38A /* IntervalCalculatorMock.swift */,
F9EDB795239663F800CFB3C9 /* PaymentComponentMock.swift */,
81F177AD2B4C49B9009CAD96 /* PresenterMock.swift */,
F96A25422371AB75007DBF0B /* PaymentComponentDelegateMock.swift */,
F9EDB793239663C200CFB3C9 /* PaymentMethodMock.swift */,
F9639B5124E29E340073F38A /* PresentationDelegateMock.swift */,
Expand Down Expand Up @@ -6795,6 +6794,7 @@
E216D3C7221AF5650013CBCF /* IBANFormatterTests.swift in Sources */,
F9639B5024E29D2D0073F38A /* AwaitComponentTests.swift in Sources */,
F97C83F725BF0C2800D7F85C /* DokuComponentTests.swift in Sources */,
81F177AE2B4C49B9009CAD96 /* PresenterMock.swift in Sources */,
F924C072246BEEF0006DDAB8 /* CardDetailsTests.swift in Sources */,
F9FE39E32679E09200F02A9B /* LoadingViewTests.swift in Sources */,
F96A25472372C39F007DBF0B /* ApplePayDetailsTest.swift in Sources */,
Expand All @@ -6820,7 +6820,6 @@
C9C21914276767ED0042E9BE /* BACSConfirmationViewControllerTests.swift in Sources */,
E7085C1E2629FDD700D0153B /* RedirectListnerTests.swift in Sources */,
E74CE3DF26727EB1008231D2 /* DropInDelegateMock.swift in Sources */,
81616BE62B271CFB00D341FF /* FormVerticalStackItemView+IsValid.swift in Sources */,
A020EC5A29ED33F90050B2FE /* CashAppPayComponentTests.swift in Sources */,
F967581527D25B1600A16FB6 /* SelfRetainingAPIClientTests.swift in Sources */,
E262128D22A8FE6700F2B133 /* PaymentMethodTests.swift in Sources */,
Expand Down Expand Up @@ -7290,7 +7289,6 @@
0022095C29A4C65E00B2BACD /* BoletoComponentUITests.swift in Sources */,
F9CCA3D2296ECCFA00AD643D /* XCTestCaseExtension.swift in Sources */,
F9CCA3DE296ED1F400AD643D /* XCTestCase+SnapshotTesting.swift in Sources */,
81616BE52B271CF900D341FF /* FormVerticalStackItemView+IsValid.swift in Sources */,
81825CBC2AC59C4000F91912 /* UIViewController+Search.swift in Sources */,
F9CCA3C6296ECB9900AD643D /* QRCodeActionComponentUITests.swift in Sources */,
81825CB92AC59C3300F91912 /* UIView+Search.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2023 Adyen N.V.
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//
Expand Down Expand Up @@ -76,8 +76,10 @@ open class AbstractPersonalInformationComponent: PaymentComponent, PresentableCo
formViewController.append(FormSpacerItem(numberOfSpaces: 2))
}

private func add(_ field: PersonalInformation,
into formViewController: FormViewController) {
private func add(
_ field: PersonalInformation,
into formViewController: FormViewController
) {
switch field {
case .email:
emailItemInjector?.inject(into: formViewController)
Expand Down Expand Up @@ -146,13 +148,14 @@ open class AbstractPersonalInformationComponent: PaymentComponent, PresentableCo
return AddressFormItemInjector(value: configuration.shopperInformation?.billingAddress,
initialCountry: initialCountry,
identifier: identifier,
style: configuration.style.addressStyle,
style: configuration.style,
presenter: self,
addressViewModelBuilder: addressViewModelBuilder())
addressViewModelBuilder: addressViewModelBuilder(),
addressType: .billing)
}()

@_spi(AdyenInternal)
public var addressItem: FormAddressItem? { addressItemInjector?.item }
public var addressItem: FormAddressPickerItem? { addressItemInjector?.item }

internal lazy var deliveryAddressItemInjector: AddressFormItemInjector? = {
guard fields.contains(.deliveryAddress) else { return nil }
Expand All @@ -161,13 +164,14 @@ open class AbstractPersonalInformationComponent: PaymentComponent, PresentableCo
return AddressFormItemInjector(value: configuration.shopperInformation?.deliveryAddress,
initialCountry: initialCountry,
identifier: identifier,
style: configuration.style.addressStyle,
style: configuration.style,
presenter: self,
addressViewModelBuilder: addressViewModelBuilder())
addressViewModelBuilder: addressViewModelBuilder(),
addressType: .delivery)
}()

@_spi(AdyenInternal)
public var deliveryAddressItem: FormAddressItem? { deliveryAddressItemInjector?.item }
public var deliveryAddressItem: FormAddressPickerItem? { deliveryAddressItemInjector?.item }

internal lazy var phoneItemInjector: PhoneFormItemInjector? = {
guard fields.contains(.phone) else { return nil }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//
// Copyright (c) 2023 Adyen N.V.
// Copyright (c) 2024 Adyen N.V.
//
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

import Foundation
import UIKit

internal final class AddressFormItemInjector: FormItemInjector, Localizable {

Expand All @@ -16,41 +16,60 @@ internal final class AddressFormItemInjector: FormItemInjector, Localizable {

internal var identifier: String

internal let style: AddressStyle
internal let style: FormComponentStyle

internal let addressViewModelBuilder: AddressViewModelBuilder

private weak var presenter: ViewControllerPresenter?

private let addressType: FormAddressPickerItem.AddressType

internal lazy var item: FormAddressItem = {
let addressItem = FormAddressItem(initialCountry: initialCountry,
configuration: .init(
style: style,
localizationParameters: localizationParameters
),
identifier: identifier,
presenter: presenter,
addressViewModelBuilder: addressViewModelBuilder)
value.map { addressItem.value = $0 }
return addressItem
internal lazy var item: FormAddressPickerItem = {
.init(
for: addressType,
initialCountry: initialCountry,
supportedCountryCodes: nil,
prefillAddress: value,
style: style,
localizationParameters: localizationParameters,
identifier: identifier,
addressViewModelBuilder: addressViewModelBuilder,
presenter: self,
lookupProvider: nil
)
}()

internal init(value: PostalAddress?,
initialCountry: String,
identifier: String,
style: AddressStyle,
presenter: ViewControllerPresenter?,
addressViewModelBuilder: AddressViewModelBuilder) {
internal init(
value: PostalAddress?,
initialCountry: String,
identifier: String,
style: FormComponentStyle,
presenter: ViewControllerPresenter?,
addressViewModelBuilder: AddressViewModelBuilder,
addressType: FormAddressPickerItem.AddressType
) {
self.value = value
self.initialCountry = initialCountry
self.identifier = identifier
self.style = style
self.presenter = presenter
self.addressViewModelBuilder = addressViewModelBuilder
self.addressType = addressType
}

internal func inject(into formViewController: FormViewController) {
formViewController.append(item)
}

}

extension AddressFormItemInjector: ViewControllerPresenter {

internal func presentViewController(_ viewController: UIViewController, animated: Bool) {
presenter?.presentViewController(viewController, animated: animated)
}

internal func dismissViewController(animated: Bool) {
presenter?.dismissViewController(animated: animated)
}
}
Loading