Skip to content

Commit

Permalink
Removed unncessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
neelSharma12 committed Feb 13, 2025
1 parent 0d76e55 commit a7cbd09
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

@_spi(AdyenInternal)
public protocol AccountIdentifier: CustomStringConvertible, Equatable {
var identifier: String { get }
var title: String { get }
}

/// A wrapper struct to use as item in ``FormIdentifierPickerItem``
@_spi(AdyenInternal)
public struct FormIdentifierPickerElement: AccountIdentifier {
public struct FormIdentifierPickerElement: CustomStringConvertible, Equatable {

public let identifier: String
public let title: String
Expand All @@ -30,14 +24,14 @@ public struct FormIdentifierPickerElement: AccountIdentifier {
@_spi(AdyenInternal)
public final class FormIdentifierPickerItem: BaseFormPickerItem<FormIdentifierPickerElement> {

override public init(
preselectedValue: BasePickerElement<FormIdentifierPickerElement>,
selectableValues: [BasePickerElement<FormIdentifierPickerElement>],
public init(
preselectedIdentifier: FormIdentifierPickerElement,
selectableIdentifiers: [FormIdentifierPickerElement],
style: FormTextItemStyle
) {
super.init(
preselectedValue: preselectedValue,
selectableValues: selectableValues,
preselectedValue: .init(identifier: preselectedIdentifier.identifier, element: preselectedIdentifier),
selectableValues: selectableIdentifiers.map { $0.toBaseFormPickerElement() },
style: style
)
}
Expand All @@ -46,3 +40,10 @@ public final class FormIdentifierPickerItem: BaseFormPickerItem<FormIdentifierPi
builder.build(with: self)
}
}

private extension FormIdentifierPickerElement {

func toBaseFormPickerElement() -> BasePickerElement<FormIdentifierPickerElement> {
.init(identifier: identifier, element: self)
}
}
33 changes: 21 additions & 12 deletions AdyenComponents/PayTo/PayToComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit

/// A component that provides PayTo flows for PayTo component.
public final class PayToComponent: PaymentComponent,
PresentableComponent {
PresentableComponent {

private enum ViewIdentifier {
static let flowSelectionTitleLabelItem = "flowSelectionTitleLabel"
Expand All @@ -20,12 +20,13 @@ public final class PayToComponent: PaymentComponent,
static let lastNameInputItem = "lastNameTextfield"
}

private enum AccountIdentifier: CustomStringConvertible, CaseIterable {
private enum AccountIdentifiers: CustomStringConvertible, CaseIterable {
case phone
case email
case abn
case organizationID

// TODO: Add translation
public var description: String {
switch self {
case .phone:
Expand All @@ -38,6 +39,20 @@ public final class PayToComponent: PaymentComponent,
return "Organization ID"
}
}

public var identifer: String {
switch self {
case .phone:
return "phone"
case .email:
return "email"
case .abn:
return "abn"
case .organizationID:
return "organizationID"
}
}

}

/// Configuration for PayTo Component.
Expand Down Expand Up @@ -153,19 +168,13 @@ public final class PayToComponent: PaymentComponent,

/// The identifier picker item.
internal lazy var identifierPickerItem: FormIdentifierPickerItem = {
let selectableValues = AccountIdentifier.allCases.map { account in
BasePickerElement(
identifier: account.description,
element: FormIdentifierPickerElement(
identifier: account.description,
title: account.description
)
)
let selectableValues = AccountIdentifiers.allCases.map { accountIdentifier in
FormIdentifierPickerElement(identifier: accountIdentifier.identifer, title: accountIdentifier.description)
}

let item = FormIdentifierPickerItem(
preselectedValue: selectableValues[0],
selectableValues: selectableValues,
preselectedIdentifier: selectableValues[0],
selectableIdentifiers: selectableValues,
style: configuration.style.textField
)
// TODO: Add translation
Expand Down

0 comments on commit a7cbd09

Please sign in to comment.