Skip to content

Commit 4763a7f

Browse files
committed
create payto specific picker subclass
1 parent 4b35863 commit 4763a7f

5 files changed

Lines changed: 39 additions & 5 deletions

File tree

Adyen.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
A0113D9B2763887800AD395C /* ActionNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0113D9A2763887800AD395C /* ActionNavigationBar.swift */; };
353353
A013F98126AFF72D00602633 /* BrazilSocialSecurityNumberFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A07B2CE526A5B5440008185C /* BrazilSocialSecurityNumberFormatter.swift */; };
354354
A018094826FDD345003A8DE3 /* FormCardNumberContainerItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A018094726FDD345003A8DE3 /* FormCardNumberContainerItem.swift */; };
355+
A01948342D8827FD00AA27AC /* PayToFormPickerItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01948332D8827A300AA27AC /* PayToFormPickerItemView.swift */; };
355356
A01DCF0B26BD67BB00BC35B3 /* FormCardExpiryDateItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01DCF0A26BD67BB00BC35B3 /* FormCardExpiryDateItem.swift */; };
356357
A01DFBBF2BA887BF00205881 /* ThreadSafeAnalyticsEventDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01DFBBE2BA887BF00205881 /* ThreadSafeAnalyticsEventDataSource.swift */; };
357358
A01DFBC52BB6F9FA00205881 /* ValidationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01DFBC42BB6F9FA00205881 /* ValidationError.swift */; };
@@ -1775,6 +1776,7 @@
17751776
A00F73A42B3DB67B00E9252B /* AdyenSession+StoredPaymentMethodsDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AdyenSession+StoredPaymentMethodsDelegate.swift"; sourceTree = "<group>"; };
17761777
A0113D9A2763887800AD395C /* ActionNavigationBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionNavigationBar.swift; sourceTree = "<group>"; };
17771778
A018094726FDD345003A8DE3 /* FormCardNumberContainerItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormCardNumberContainerItem.swift; sourceTree = "<group>"; };
1779+
A01948332D8827A300AA27AC /* PayToFormPickerItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayToFormPickerItemView.swift; sourceTree = "<group>"; };
17781780
A01D775529B250C10075BD70 /* CashAppPayDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CashAppPayDetails.swift; sourceTree = "<group>"; };
17791781
A01DCF0A26BD67BB00BC35B3 /* FormCardExpiryDateItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormCardExpiryDateItem.swift; sourceTree = "<group>"; };
17801782
A01DFBBE2BA887BF00205881 /* ThreadSafeAnalyticsEventDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadSafeAnalyticsEventDataSource.swift; sourceTree = "<group>"; };
@@ -2730,6 +2732,7 @@
27302732
000888762D4CF5DB009C03E1 /* PayTo */ = {
27312733
isa = PBXGroup;
27322734
children = (
2735+
A01948332D8827A300AA27AC /* PayToFormPickerItemView.swift */,
27332736
000888772D4CF5F5009C03E1 /* PayToComponent.swift */,
27342737
A0BFBB532D6F2670003F543E /* PayToItemsProvider.swift */,
27352738
A0BFBB552D6F45AB003F543E /* PayToPayIdentifier.swift */,
@@ -7575,6 +7578,7 @@
75757578
C9D8EB9E27452D3B006D8CA1 /* BACSItemsFactory.swift in Sources */,
75767579
81D2186D2CC7D57700B7FC4C /* PayByBankUSComponent.swift in Sources */,
75777580
F9175ED32593951900D653BE /* MBWayDetails.swift in Sources */,
7581+
A01948342D8827FD00AA27AC /* PayToFormPickerItemView.swift in Sources */,
75787582
F9175EAB259394FF00D653BE /* ApplePayDetails.swift in Sources */,
75797583
F9175EE22593952600D653BE /* BLIKComponent.swift in Sources */,
75807584
C9D8EBA02745556B006D8CA1 /* BACSDirectDebitDetails.swift in Sources */,

Adyen/UI/Form/Items/Value Pickers/Abstract/BaseFormPickerItemView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import UIKit
88

99
/// Represents a picker item view.
1010
@_spi(AdyenInternal)
11-
public final class BaseFormPickerItemView<T: CustomStringConvertible & Equatable>:
11+
open class BaseFormPickerItemView<T: CustomStringConvertible & Equatable>:
1212
FormValueItemView<BasePickerElement<T>, FormTextItemStyle, BaseFormPickerItem<T>>,
1313
UIPickerViewDelegate,
1414
UIPickerViewDataSource {
@@ -49,7 +49,7 @@ public final class BaseFormPickerItemView<T: CustomStringConvertible & Equatable
4949
}
5050
}
5151

52-
override public var canBecomeFirstResponder: Bool { true }
52+
override open var canBecomeFirstResponder: Bool { true }
5353

5454
@discardableResult
5555
override public func becomeFirstResponder() -> Bool {

Adyen/UI/Form/Items/Value Pickers/Identifier Picker/FormStringPickerItem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct FormStringPickerElement: CustomStringConvertible, Equatable {
2222

2323
/// A identifier picker form item
2424
@_spi(AdyenInternal)
25-
public final class FormStringPickerItem: BaseFormPickerItem<FormStringPickerElement> {
25+
open class FormStringPickerItem: BaseFormPickerItem<FormStringPickerElement> {
2626

2727
public init(
2828
preselectedStringValue: FormStringPickerElement,
@@ -40,7 +40,7 @@ public final class FormStringPickerItem: BaseFormPickerItem<FormStringPickerElem
4040
)
4141
}
4242

43-
override public func build(with builder: FormItemViewBuilder) -> AnyFormItemView {
43+
override open func build(with builder: FormItemViewBuilder) -> AnyFormItemView {
4444
builder.build(with: self)
4545
}
4646
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Copyright (c) 2025 Adyen N.V.
3+
//
4+
// This file is open source and available under the MIT license. See the LICENSE file for more info.
5+
//
6+
7+
@_spi(AdyenInternal) import Adyen
8+
import UIKit
9+
10+
internal class PayToIdentifierItem: FormStringPickerItem {
11+
12+
override internal func build(with builder: FormItemViewBuilder) -> any AnyFormItemView {
13+
PayToFormPickerItemView(item: self)
14+
}
15+
}
16+
17+
/// Picker subclass view specific to PayTo with its own logic to prevent opening the picker at initial load.
18+
internal class PayToFormPickerItemView: BaseFormPickerItemView<FormStringPickerElement> {
19+
20+
// To prevent this picker to become first responder initially
21+
override internal var canBecomeFirstResponder: Bool { false }
22+
23+
}
24+
25+
extension FormItemViewBuilder {
26+
27+
internal func build(with item: PayToIdentifierItem) -> PayToFormPickerItemView {
28+
PayToFormPickerItemView(item: item)
29+
}
30+
}

AdyenComponents/PayTo/PayToItemsProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ internal class PayToItemsProvider: PayToItemsProviding {
176176

177177
AdyenAssertion.assert(message: "selectableValues should be greater than 0", condition: selectableValues.isEmpty)
178178

179-
let item = FormStringPickerItem(
179+
let item = PayToIdentifierItem(
180180
preselectedStringValue: selectableValues[0],
181181
selectableStringValues: selectableValues,
182182
style: style.textField

0 commit comments

Comments
 (0)