Skip to content

Commit

Permalink
Merge pull request #483 from Adyen/format-project-github-action
Browse files Browse the repository at this point in the history
Format project
  • Loading branch information
mohammedDehairy authored May 5, 2021
2 parents d323485 + 33fb592 commit cc11366
Show file tree
Hide file tree
Showing 41 changed files with 128 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public final class StoredPaymentMethodComponent: PaymentComponent, PresentableCo

let displayInformation = storedPaymentMethod.localizedDisplayInformation(using: localizationParameters)
let alertController = UIAlertController(title: localizedString(.dropInStoredTitle,
localizationParameters, storedPaymentMethod.name),
localizationParameters, storedPaymentMethod.name),
message: displayInformation.title,
preferredStyle: .alert)

Expand All @@ -41,8 +41,8 @@ public final class StoredPaymentMethodComponent: PaymentComponent, PresentableCo
alertController.addAction(cancelAction)

let submitActionTitle = localizedSubmitButtonTitle(with: payment?.amount,
style: .immediate,
localizationParameters)
style: .immediate,
localizationParameters)
let submitAction = UIAlertAction(title: submitActionTitle, style: .default) { _ in
let details = StoredPaymentDetails(paymentMethod: self.storedPaymentMethod)
self.submit(data: PaymentComponentData(paymentMethodDetails: details))
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Formatters/NumericFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open class NumericFormatter: Adyen.Formatter {

/// :nodoc:
open func sanitizedValue(for value: String) -> String {
let sanitizedString = value.filter { $0.isNumber }
let sanitizedString = value.filter(\.isNumber)

// Converts all non-latin digits to latin digits
let latinString = sanitizedString.applyingTransform(StringTransform.toLatin, reverse: false) ?? sanitizedString
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Helpers/UIButtonHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension UIButton {
/// Sets `translatesAutoresizingMaskIntoConstraints` to `false`
/// Sets `adjustsFontForContentSizeCategory` to the `titleLabel` to `true`
/// - Parameter style: `ButtonStyle` to be applied
convenience public init(style: ButtonStyle) {
public convenience init(style: ButtonStyle) {
self.init()
translatesAutoresizingMaskIntoConstraints = false
adyen.apply(style)
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Helpers/UILabelHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extension UILabel {
/// Sets `translatesAutoresizingMaskIntoConstraints` to `false`
/// Sets `adjustsFontForContentSizeCategory` to `true`
/// - Parameter style: `TextStyle` to be applied
convenience public init(style: TextStyle) {
public convenience init(style: TextStyle) {
self.init()
translatesAutoresizingMaskIntoConstraints = false
adyen.apply(style)
Expand Down
2 changes: 1 addition & 1 deletion Adyen/Helpers/UIProgressViewHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import UIKit

extension UIProgressView {
convenience public init(style: ProgressViewStyle) {
public convenience init(style: ProgressViewStyle) {
self.init()

backgroundColor = style.backgroundColor
Expand Down
2 changes: 1 addition & 1 deletion Adyen/UI/Form/Items/Text/FormTextInputItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
public final class FormTextInputItem: FormTextItem {

/// :nodoc:
public override init(style: FormTextItemStyle = .init()) {
override public init(style: FormTextItemStyle = .init()) {
super.init(style: style)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class BasePickerInputControl: UIControl, PickerTextInputControl {
}

/// The phone code label.
internal lazy var valueLabel: UILabel = UILabel(style: style)
internal lazy var valueLabel = UILabel(style: style)

override internal var accessibilityIdentifier: String? {
didSet {
Expand Down
5 changes: 3 additions & 2 deletions Adyen/UI/View Controllers/ADYViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import UIKit

/// :nodoc:
/// `ADYViewController` serves as a height-aware `UIViewController`
final public class ADYViewController: UIViewController {
public final class ADYViewController: UIViewController {

/// :nodoc:
private let contentView: UIView
Expand Down Expand Up @@ -39,7 +39,8 @@ final public class ADYViewController: UIViewController {
return view.systemLayoutSizeFitting(
targetSize,
withHorizontalFittingPriority: .required,
verticalFittingPriority: .fittingSizeLevel)
verticalFittingPriority: .fittingSizeLevel
)
}

// swiftlint:disable:next unused_setter_value
Expand Down
8 changes: 4 additions & 4 deletions Adyen/Utilities/Localization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public func localizedString(_ key: LocalizationKey, _ parameters: LocalizationPa
private func fallbackLocalizedString(key: String) -> String {
let localizedFallback = NSLocalizedString(key, tableName: nil, bundle: Bundle.coreInternalResources, comment: "")

if localizedFallback != key && localizedFallback.isEmpty == false {
if localizedFallback != key, localizedFallback.isEmpty == false {
return localizedFallback
} else {
// Fallback to en-US
// Fallback to en-US
return Bundle.coreInternalResources.path(forResource: "en-US", ofType: "lproj")
.flatMap(Bundle.init(path: ))
.flatMap(Bundle.init(path:))
.map { NSLocalizedString(key, tableName: nil, bundle: $0, comment: "") } ?? key
}
}
Expand Down Expand Up @@ -118,7 +118,7 @@ public func localizedSubmitButtonTitle(with amount: Payment.Amount?,
_ parameters: LocalizationParameters?) -> String {
if let amount = amount, amount.value == 0 {
return localizedZeroPaymentAuthorisationButtonTitle(style: style,
parameters)
parameters)
}
guard let formattedAmount = amount?.formatted else {
return localizedString(.submitButton, parameters)
Expand Down
2 changes: 1 addition & 1 deletion AdyenActions/UI/UI Style/QRCodeComponentStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct QRCodeComponentStyle: ViewStyle {
public var logoCornerRounding: CornerRounding = .fixed(5)

/// :nodoc:
public var backgroundColor: UIColor = UIColor.Adyen.componentBackground
public var backgroundColor = UIColor.Adyen.componentBackground

/// Initializes the QR code component style with the default style
public init() {}
Expand Down
4 changes: 2 additions & 2 deletions AdyenActions/UI/View Controllers/QR Code/QRCodeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import Adyen
import UIKit

internal protocol QRCodeViewDelegate: class {
internal protocol QRCodeViewDelegate: AnyObject {

func copyToPasteboard()
}
Expand Down Expand Up @@ -44,7 +44,7 @@ internal final class QRCodeView: UIView, Localizable, Observer {
addCopyButton()
}

internal override func layoutSubviews() {
override internal func layoutSubviews() {
super.layoutSubviews()

copyButton.adyen.round(using: model.style.copyButton.cornerRounding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,26 @@ extension GenericVoucherView {
internal var text = TextStyle(
font: .preferredFont(forTextStyle: .footnote),
color: UIColor.Adyen.componentLabel,
textAlignment: .center)
textAlignment: .center
)

internal var amount = TextStyle(
font: UIFont.preferredFont(forTextStyle: .callout).adyen.font(with: .bold),
color: UIColor.Adyen.componentLabel,
textAlignment: .center)
textAlignment: .center
)

internal var codeText = TextStyle(
font: UIFont.preferredFont(forTextStyle: .title1).adyen.font(with: .bold),
color: UIColor.Adyen.componentLabel,
textAlignment: .center)
textAlignment: .center
)

internal var fieldValueText = TextStyle(
font: UIFont.preferredFont(forTextStyle: .footnote).adyen.font(with: .semibold),
color: UIColor.Adyen.componentLabel,
textAlignment: .center)
textAlignment: .center
)

internal var mainButton: ButtonStyle

Expand Down
4 changes: 2 additions & 2 deletions AdyenCard/Components/Card/CardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ internal class CardViewController: FormViewController {
let item = FormButtonItem(style: formStyle.mainButtonItem)
item.identifier = ViewIdentifierBuilder.build(scopeInstance: scope, postfix: "payButtonItem")
item.title = localizedSubmitButtonTitle(with: payment?.amount,
style: .immediate,
localizationParameters)
style: .immediate,
localizationParameters)
item.buttonSelectionHandler = { [weak self] in
self?.cardDelegate?.didSelectSubmitButton()
}
Expand Down
4 changes: 2 additions & 2 deletions AdyenCard/Components/Stored Card/StoredCardAlertManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ internal final class StoredCardAlertManager: NSObject, UITextFieldDelegate, Loca

private lazy var submitAction: UIAlertAction = {
let actionTitle = localizedSubmitButtonTitle(with: amount,
style: .immediate,
localizationParameters)
style: .immediate,
localizationParameters)
let action = UIAlertAction(title: actionTitle, style: .default) { [unowned self] _ in
self.submit()
}
Expand Down
4 changes: 2 additions & 2 deletions AdyenComponents/BLIK/BLIKComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public final class BLIKComponent: PaymentComponent, PresentableComponent, Locali
let item = FormButtonItem(style: style.mainButtonItem)
item.identifier = ViewIdentifierBuilder.build(scopeInstance: self, postfix: "payButtonItem")
item.title = localizedSubmitButtonTitle(with: payment?.amount,
style: .immediate,
localizationParameters)
style: .immediate,
localizationParameters)
item.buttonSelectionHandler = { [weak self] in
self?.didSelectSubmitButton()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public final class SEPADirectDebitComponent: PaymentComponent, PresentableCompon
let item = FormButtonItem(style: style.mainButtonItem)
item.identifier = ViewIdentifierBuilder.build(scopeInstance: self, postfix: "payButtonItem")
item.title = localizedSubmitButtonTitle(with: payment?.amount,
style: .immediate,
localizationParameters)
style: .immediate,
localizationParameters)
item.buttonSelectionHandler = { [weak self] in
self?.didSelectSubmitButton()
}
Expand Down
2 changes: 1 addition & 1 deletion AdyenDropIn/Components/PaymentMethodListComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal final class PaymentMethodListComponent: ComponentLoader, PresentableCom

let storedSection = ListSection(items: components.stored.map(item(for:)))
let regularSectionTitle = components.stored.isEmpty ? nil : localizedString(.paymentMethodsOtherMethods,
localizationParameters)
localizationParameters)
let regularSection = ListSection(title: regularSectionTitle,
items: components.regular.map(item(for:)))

Expand Down
8 changes: 5 additions & 3 deletions AdyenDropIn/Components/PreApplePayComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

import UIKit
import Adyen
import UIKit
#if canImport(AdyenComponents)
import AdyenComponents
#endif
Expand Down Expand Up @@ -47,7 +47,7 @@ internal final class PreApplePayComponent: Localizable, PresentableComponent, Fi
internal let requiresModalPresentation: Bool = true

/// :nodoc:
internal init (configuration: ApplePayComponent.Configuration) throws {
internal init(configuration: ApplePayComponent.Configuration) throws {
self._payment = configuration.payment
self.paymentMethod = configuration.paymentMethod

Expand All @@ -66,7 +66,9 @@ internal final class PreApplePayComponent: Localizable, PresentableComponent, Fi
hint: amount.formatted,
style: PreApplePayView.Model.Style(
hintLabel: TextStyle(font: .preferredFont(forTextStyle: .footnote), color: UIColor.Adyen.componentSecondaryLabel),
backgroundColor: UIColor.Adyen.componentBackground))
backgroundColor: UIColor.Adyen.componentBackground
)
)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ internal final class PreselectedPaymentMethodComponent: ComponentLoader,
private lazy var submitButtonItem: FormButtonItem = {
let item = FormButtonItem(style: style.mainButtonItem)
item.title = localizedSubmitButtonTitle(with: payment?.amount,
style: .immediate,
localizationParameters)
style: .immediate,
localizationParameters)
item.identifier = ViewIdentifierBuilder.build(scopeInstance: self, postfix: "submitButton")
let component = self.defaultComponent
item.buttonSelectionHandler = { [weak self] in
Expand Down
3 changes: 2 additions & 1 deletion AdyenDropIn/Utilities/ComponentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ internal final class ComponentManager {
summaryItems: applePay.summaryItems,
merchantIdentifier: applePay.merchantIdentifier,
requiredBillingContactFields: applePay.requiredBillingContactFields,
requiredShippingContactFields: applePay.requiredShippingContactFields)
requiredShippingContactFields: applePay.requiredShippingContactFields
)

do {
return try PreApplePayComponent(configuration: configuration)
Expand Down
4 changes: 2 additions & 2 deletions AdyenDropIn/Views/PreApplePayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

import UIKit
import Adyen
import PassKit
import UIKit

/// :nodoc
internal protocol PreApplePayViewDelegate: class {
internal protocol PreApplePayViewDelegate: AnyObject {

func pay()

Expand Down
10 changes: 5 additions & 5 deletions AdyenEncryption/CardEncryptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public enum CardEncryptor {
/// - Throws: `CardEncryptor.Error.invalidEncryptionArguments` when trying to encrypt a card with card number, securityCode,
/// expiryMonth, and expiryYear, all of them are nil.
public static func encrypt(number: String, with publicKey: String) throws -> String {
guard !number.isEmpty, number.allSatisfy({ $0.isNumber }) else {
guard !number.isEmpty, number.allSatisfy(\.isNumber) else {
throw Error.invalidNumber
}
let payload = CardPayload().add(number: number)
Expand All @@ -77,7 +77,7 @@ public enum CardEncryptor {
/// - Throws: `CardEncryptor.Error.invalidEncryptionArguments` when trying to encrypt a card with card number, securityCode,
/// expiryMonth, and expiryYear, all of them are nil.
public static func encrypt(securityCode: String, with publicKey: String) throws -> String {
guard !securityCode.isEmpty, securityCode.allSatisfy({ $0.isNumber }) else {
guard !securityCode.isEmpty, securityCode.allSatisfy(\.isNumber) else {
throw Error.invalidSecureCode
}
let payload = CardPayload().add(securityCode: securityCode)
Expand All @@ -95,7 +95,7 @@ public enum CardEncryptor {
/// - Throws: `CardEncryptor.Error.invalidEncryptionArguments` when trying to encrypt a card with card number, securityCode,
/// expiryMonth, and expiryYear, all of them are nil.
public static func encrypt(expirationMonth: String, with publicKey: String) throws -> String {
guard !expirationMonth.isEmpty, expirationMonth.allSatisfy({ $0.isNumber }) else {
guard !expirationMonth.isEmpty, expirationMonth.allSatisfy(\.isNumber) else {
throw Error.invalidExpiryMonth
}
let payload = CardPayload().add(expiryMonth: expirationMonth)
Expand All @@ -113,7 +113,7 @@ public enum CardEncryptor {
/// - Throws: `CardEncryptor.Error.invalidEncryptionArguments` when trying to encrypt a card with card number, securityCode,
/// expiryMonth, and expiryYear, all of them are nil.
public static func encrypt(expirationYear: String, with publicKey: String) throws -> String {
guard !expirationYear.isEmpty, expirationYear.allSatisfy({ $0.isNumber }) else {
guard !expirationYear.isEmpty, expirationYear.allSatisfy(\.isNumber) else {
throw Error.invalidExpiryYear
}
let payload = CardPayload().add(expiryYear: expirationYear)
Expand All @@ -130,7 +130,7 @@ public enum CardEncryptor {
/// - Throws: `CardEncryptor.Error.invalidEncryptionArguments` when trying to encrypt a card with card number, securityCode,
/// expiryMonth, and expiryYear, all of them are nil.
public static func encrypt(bin: String, with publicKey: String) throws -> String {
guard !bin.isEmpty, bin.allSatisfy({ $0.isNumber }) else {
guard !bin.isEmpty, bin.allSatisfy(\.isNumber) else {
throw Error.invalidBin
}
let payload = BinPayload().add(bin: bin)
Expand Down
2 changes: 1 addition & 1 deletion Demo/Common/Models/ComponentsItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal struct ComponentsItem: Hashable {

internal var isApplePay: Bool { title == "Apple Pay" }

internal let selectionHandler: (() -> Void)
internal let selectionHandler: () -> Void

internal init(title: String, selectionHandler: @escaping (() -> Void)) {
self.title = title
Expand Down
2 changes: 1 addition & 1 deletion Demo/UIKit/ComponentsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// This file is open source and available under the MIT license. See the LICENSE file for more info.
//

import UIKit
import PassKit
import UIKit

internal final class ComponentsView: UIView {

Expand Down
Loading

0 comments on commit cc11366

Please sign in to comment.