From c57aced96a39edb2d8ad25646d0c21b95732ce49 Mon Sep 17 00:00:00 2001 From: stechiu Date: Thu, 11 Jan 2024 12:59:34 -0800 Subject: [PATCH 01/11] Renamed size names. Reduced number of sizes. --- .../PaymentButtonEnums+Extension.swift | 4 +- .../PayPalWebButtonsView.swift | 6 +- .../SwiftUIPaymentButtonDemo.swift | 24 +++--- Sources/PaymentButtons/ImageAsset.swift | 21 ++--- Sources/PaymentButtons/PayPalButton.swift | 8 +- .../PaymentButtons/PayPalCreditButton.swift | 8 +- .../PaymentButtons/PayPalPayLaterButton.swift | 8 +- Sources/PaymentButtons/PaymentButton.swift | 31 +++---- .../PaymentButtons/PaymentButtonColor.swift | 2 +- .../PaymentButtons/PaymentButtonEdges.swift | 22 ++--- .../PaymentButtons/PaymentButtonSize.swift | 82 ++++--------------- 11 files changed, 77 insertions(+), 139 deletions(-) diff --git a/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift b/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift index 80b1faad5..aab8b8efa 100644 --- a/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift +++ b/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift @@ -36,7 +36,7 @@ extension PayPalCreditButton.Color: CaseIterable { extension PaymentButtonEdges: CaseIterable { public static var allCases: [PaymentButtonEdges] { - [.hardEdges, .softEdges, .rounded] + [.pill, .rounded, .sharp] } static func allCasesAsString() -> [String] { @@ -47,7 +47,7 @@ extension PaymentButtonEdges: CaseIterable { extension PaymentButtonSize: CaseIterable { public static var allCases: [PaymentButtonSize] { - [.mini, .miniWithWordmark, .collapsed, .expanded, .full] + [.mini, .regular] } static func allCasesAsString() -> [String] { diff --git a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift index 85e551926..4839361ad 100644 --- a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift +++ b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift @@ -12,15 +12,15 @@ struct PayPalWebButtonsView: View { payPalWebViewModel.paymentButtonTapped(funding: .paypal) } .frame(maxWidth: .infinity, maxHeight: 40) - PayPalButton.Representable(color: .gold, size: .miniWithWordmark) { + PayPalButton.Representable(color: .gold, size: .mini) { payPalWebViewModel.paymentButtonTapped(funding: .paypal) } .frame(maxWidth: .infinity, maxHeight: 40) - PayPalCreditButton.Representable(color: .black, edges: .softEdges, size: .expanded) { + PayPalCreditButton.Representable(color: .black, edges: .pill, size: .regular) { payPalWebViewModel.paymentButtonTapped(funding: .paypalCredit) } .frame(maxWidth: .infinity, maxHeight: 40) - PayPalPayLaterButton.Representable(color: .silver, edges: .rounded, size: .full) { + PayPalPayLaterButton.Representable(color: .silver, edges: .pill, size: .regular) { payPalWebViewModel.paymentButtonTapped(funding: .paylater) } .frame(maxWidth: .infinity, maxHeight: 40) diff --git a/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift b/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift index f4849a2fd..556339997 100644 --- a/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift +++ b/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift @@ -56,17 +56,6 @@ struct SwiftUIPaymentButtonDemo: View { } .id(pickerId) - Picker("Edges", selection: $edgesIndex) { - ForEach(edges.indices, id: \.self) { index in - Text(edges[index]) - } - } - .pickerStyle(SegmentedPickerStyle()) - .onChange(of: edgesIndex) { _ in - selectedEdge = PaymentButtonEdges.allCases[edgesIndex] - buttonId += 1 - } - Picker("sizes", selection: $sizesIndex) { ForEach(sizes.indices, id: \.self) { index in Text(sizes[index]) @@ -80,7 +69,18 @@ struct SwiftUIPaymentButtonDemo: View { switch selectedFunding { case .payPal: - if selectedSize == .expanded || selectedSize == .full { + if selectedSize == .regular { + Picker("Edges", selection: $edgesIndex) { + ForEach(edges.indices, id: \.self) { index in + Text(edges[index]) + } + } + .pickerStyle(SegmentedPickerStyle()) + .onChange(of: edgesIndex) { _ in + selectedEdge = PaymentButtonEdges.allCases[edgesIndex] + buttonId += 1 + } + Picker("label", selection: $labelIndex) { ForEach(labels.indices, id: \.self) { index in Text(labels[index]) diff --git a/Sources/PaymentButtons/ImageAsset.swift b/Sources/PaymentButtons/ImageAsset.swift index 29f89a7d6..03bf9209f 100644 --- a/Sources/PaymentButtons/ImageAsset.swift +++ b/Sources/PaymentButtons/ImageAsset.swift @@ -6,27 +6,18 @@ enum ImageAsset { switch button.fundingSource { case .payPal: imageAssetString = "paypal" - + case .payLater: imageAssetString = "paypal" - - if button.size == .collapsed { - imageAssetString = "paypal_monogram" - } - + case .credit: - if button.size == .collapsed { - imageAssetString = "credit_monogram" - } else if button.size != .miniWithWordmark && button.size != .mini { + if button.size != .mini { imageAssetString = "credit" } } - - if button.size == .mini { - imageAssetString = "paypal_monogram" - } else if button.size == .miniWithWordmark { - imageAssetString = "paypal_vertical" - } + if button.size == .mini { + imageAssetString = "paypal_vertical" + } return UIImage(named: imageAssetString, in: PaymentButton.bundle, compatibleWith: nil) } diff --git a/Sources/PaymentButtons/PayPalButton.swift b/Sources/PaymentButtons/PayPalButton.swift index 0cf974c5c..71554f6ec 100644 --- a/Sources/PaymentButtons/PayPalButton.swift +++ b/Sources/PaymentButtons/PayPalButton.swift @@ -99,8 +99,8 @@ public final class PayPalButton: PaymentButton { public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .gold, - edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .collapsed, + edges: PaymentButtonEdges = .rounded, + size: PaymentButtonSize = .regular, label: Label? = nil ) { self.init( @@ -135,8 +135,8 @@ public extension PayPalButton { public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalButton.Color = .gold, - edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .collapsed, + edges: PaymentButtonEdges = .rounded, + size: PaymentButtonSize = .regular, label: PayPalButton.Label? = nil, _ action: @escaping () -> Void = { } ) { diff --git a/Sources/PaymentButtons/PayPalCreditButton.swift b/Sources/PaymentButtons/PayPalCreditButton.swift index eb747b380..adb1b02bd 100644 --- a/Sources/PaymentButtons/PayPalCreditButton.swift +++ b/Sources/PaymentButtons/PayPalCreditButton.swift @@ -26,8 +26,8 @@ public final class PayPalCreditButton: PaymentButton { public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .darkBlue, - edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .collapsed + edges: PaymentButtonEdges = .rounded, + size: PaymentButtonSize = .regular ) { self.init( fundingSource: PaymentButtonFundingSource.credit, @@ -59,8 +59,8 @@ public extension PayPalCreditButton { public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalCreditButton.Color = .darkBlue, - edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .collapsed, + edges: PaymentButtonEdges = .rounded, + size: PaymentButtonSize = .regular, _ action: @escaping () -> Void = { } ) { self.button = PayPalCreditButton( diff --git a/Sources/PaymentButtons/PayPalPayLaterButton.swift b/Sources/PaymentButtons/PayPalPayLaterButton.swift index 9485eabef..686048a94 100644 --- a/Sources/PaymentButtons/PayPalPayLaterButton.swift +++ b/Sources/PaymentButtons/PayPalPayLaterButton.swift @@ -26,8 +26,8 @@ public final class PayPalPayLaterButton: PaymentButton { public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .gold, - edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .collapsed, + edges: PaymentButtonEdges = .rounded, + size: PaymentButtonSize = .regular, _ action: @escaping () -> Void = { } ) { self.init( @@ -58,8 +58,8 @@ public extension PayPalPayLaterButton { public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalPayLaterButton.Color = .gold, - edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .collapsed, + edges: PaymentButtonEdges = .rounded, + size: PaymentButtonSize = .regular, _ action: @escaping () -> Void = { } ) { self.button = PayPalPayLaterButton( diff --git a/Sources/PaymentButtons/PaymentButton.swift b/Sources/PaymentButtons/PaymentButton.swift index c473f9aac..8928b927c 100644 --- a/Sources/PaymentButtons/PaymentButton.swift +++ b/Sources/PaymentButtons/PaymentButton.swift @@ -114,29 +114,22 @@ public class PaymentButton: UIButton { private var imageHeight: CGFloat { // For pay later or paypal credit return different image height switch size { - case .mini: - return 20.0 - case .miniWithWordmark: + case .mini: return 24.0 - case .collapsed: - return 15.0 - - case .expanded: + case .regular: return 20.0 - case .full: - return 26.0 } } private var supportsPrefixLabel: Bool { switch size { - case .mini, .miniWithWordmark, .collapsed: + case .mini: return false - case .expanded, .full: + case .regular: if let label = label { return label.position == .prefix } @@ -147,14 +140,15 @@ public class PaymentButton: UIButton { private var supportsSuffixLabel: Bool { switch size { - case .mini, .miniWithWordmark: + case .mini: return false - case .collapsed: - return fundingSource == .payLater +// case .collapsed: +// return fundingSource == .payLater - case .expanded, .full: + case .regular: if let label = label { + fundingSource == .payLater return label.position == .suffix } return false @@ -239,9 +233,8 @@ public class PaymentButton: UIButton { // MARK: - Override Function override public func layoutSubviews() { super.layoutSubviews() - if size == .mini || size == .miniWithWordmark { - let minValue = min(containerView.bounds.width, containerView.bounds.height) - containerView.layer.cornerRadius = minValue / 2 + if size == .mini { + containerView.layer.cornerRadius = 4.0 } else { containerView.layer.cornerRadius = edges.cornerRadius(for: containerView) } @@ -255,7 +248,7 @@ public class PaymentButton: UIButton { // Size to fit switch size { - case .mini, .miniWithWordmark: + case .mini: let maxValue = max(image.size.width, image.size.height) imageView.bounds = CGRect( x: 0, diff --git a/Sources/PaymentButtons/PaymentButtonColor.swift b/Sources/PaymentButtons/PaymentButtonColor.swift index c09c285ec..9872c5274 100644 --- a/Sources/PaymentButtons/PaymentButtonColor.swift +++ b/Sources/PaymentButtons/PaymentButtonColor.swift @@ -23,7 +23,7 @@ public enum PaymentButtonColor: String { var color: UIColor { switch self { case .gold: - return UIColor(hexString: "#FFC439") + return UIColor(hexString: "#FFD140") case .white: return UIColor(hexString: "#FFFFFF") diff --git a/Sources/PaymentButtons/PaymentButtonEdges.swift b/Sources/PaymentButtons/PaymentButtonEdges.swift index 6cc1545b8..0952e73e2 100644 --- a/Sources/PaymentButtons/PaymentButtonEdges.swift +++ b/Sources/PaymentButtons/PaymentButtonEdges.swift @@ -4,36 +4,36 @@ import UIKit public enum PaymentButtonEdges: Int { /// Hard edges on button with 0 corner radius. - case hardEdges + case sharp /// Soft edges with a corner radius of 4 pts. - case softEdges + case rounded /// Pill shaped corner radius. - case rounded + case pill func cornerRadius(for view: UIView) -> CGFloat { switch self { - case .hardEdges: + case .sharp: return 0.0 - case .softEdges: + case .rounded: return 4.0 - case .rounded: + case .pill: return view.frame.size.height / 2 } } public var description: String { switch self { - case .hardEdges: - return "hardEdges" - - case .softEdges: - return "softEdges" + case .sharp: + return "sharp" case .rounded: return "rounded" + + case .pill: + return "pill" } } } diff --git a/Sources/PaymentButtons/PaymentButtonSize.swift b/Sources/PaymentButtons/PaymentButtonSize.swift index 6cf5203ab..721f3e038 100644 --- a/Sources/PaymentButtons/PaymentButtonSize.swift +++ b/Sources/PaymentButtons/PaymentButtonSize.swift @@ -3,107 +3,61 @@ import UIKit /// The size category which determines how the button is shown. public enum PaymentButtonSize: Int, CustomStringConvertible { - /// Smallest button size that will show the PayPal monogram only. Use this for screens where space is limited. The recommended size when displaying on screens with limited space `.miniWithWordmark` + /// Smallest button size uses the primary mark, vertically stacked. This is the recommended size when displaying on screens with limited space. case mini - /// Smallest button size that will show the primary mark (PayPal monogram and wordmark). This is the recommended size when displaying on screens with limited space. - case miniWithWordmark - - /// Collapsed shows the primary mark (PayPal monogram and wordmark) along with the prefix or suffix. - case collapsed - - /// Expanded shows the primary mark (PayPal monogram and wordmark along with the prefix or suffix - case expanded - - /// Full will show the primary mark (PayPal monogram and wordmark along with the prefix or suffix. - case full + /// Regular size shows the primary mark along with the prefix or suffix + case regular var font: UIFont { switch self { - case .mini, .miniWithWordmark, .collapsed: + case .mini: return PaymentButtonFont.secondaryFont - case .expanded: + case .regular: return PaymentButtonFont.primaryFont - - case .full: - return PaymentButtonFont.systemFont18 } } var elementSpacing: CGFloat { switch self { - case .mini, .miniWithWordmark, .collapsed: + case .mini: return 4.0 - case .expanded: + case .regular: return 4.5 - - case .full: - return 6.0 } } var elementPadding: NSDirectionalEdgeInsets { switch self { - case .mini: - return NSDirectionalEdgeInsets( - top: 14.0, - leading: 14.0, - bottom: 14.0, - trailing: 14.0 - ) - case .miniWithWordmark: - return NSDirectionalEdgeInsets( - top: 14.0, - leading: 14.0, - bottom: 14.0, - trailing: 14.0 - ) - - case .collapsed: + case .mini: return NSDirectionalEdgeInsets( - top: 15.0, + top: 9.0, leading: 20.0, - bottom: 15.0, + bottom: 9.0, trailing: 20.0 ) - case .expanded: - return NSDirectionalEdgeInsets( - top: 13.0, - leading: 24.0, - bottom: 13.0, - trailing: 24.0 - ) - - case .full: + case .regular: return NSDirectionalEdgeInsets( - top: 15.0, - leading: 44.0, - bottom: 15.0, - trailing: 44.0 + top: 10.0, + leading: 80.0, + bottom: 10.0, + trailing: 80.0 ) } } public var description: String { switch self { + case .mini: return "mini" - case .miniWithWordmark: - return "mini with wordmark" - - case .collapsed: - return "collapsed" - - case .expanded: - return "expanded" - - case .full: - return "full" + case .regular: + return "regular" } } } From bbaedd21a3544632ff26e2b17874a09f486be3a7 Mon Sep 17 00:00:00 2001 From: stechiu Date: Thu, 11 Jan 2024 15:14:54 -0800 Subject: [PATCH 02/11] Updated `CHANGELOG` --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dd745964..04af720af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,15 @@ ## unreleased * PaymentButtons - * Add new `PaymentButtonSize` case `.miniWithWordmark` + * Add new `PaymentButtonSize` case `.regular` * Add new `PayPalButton.Labels` cases: `.addMoneyWith`, `.bookWith`, `.buyWith`, `.buyNowWith`, `.checkoutWith`, `.continueWith`, `.contributeWith`, `.orderWith`, `.payLaterWith`, `.payWith`, `.reloadWith`, `.rentWith`, `.reserveWith`, `.subscribeWith`, `.supportWith`, `.tipWith`, `.topUpWith` + * `PayPalButtonSize` `.mini` changed to rectangular button to meet brand guidelines * Breaking Changes * Remove `PayPalButton.Labels` cases: `.checkout`, `.buyNow`, `.payLater` + * Remove `PaymentButtonSize` cases: `.miniWithWordmark`, `.collapsed`, `.expanded`, `.full` ## 1.1.0 (2023-11-16) * PayPalNativePayments From 201fc268ca991c3e81bf6e0d772a90fd14d55db1 Mon Sep 17 00:00:00 2001 From: stechiu Date: Thu, 11 Jan 2024 15:18:28 -0800 Subject: [PATCH 03/11] Reverted `PaymentButtonEdges` changes --- .../PaymentButtonEnums+Extension.swift | 2 +- .../PaymentButtons/PaymentButtonEdges.swift | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift b/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift index aab8b8efa..f892c32aa 100644 --- a/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift +++ b/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift @@ -36,7 +36,7 @@ extension PayPalCreditButton.Color: CaseIterable { extension PaymentButtonEdges: CaseIterable { public static var allCases: [PaymentButtonEdges] { - [.pill, .rounded, .sharp] + [.hardEdges, .softEdges, .rounded] } static func allCasesAsString() -> [String] { diff --git a/Sources/PaymentButtons/PaymentButtonEdges.swift b/Sources/PaymentButtons/PaymentButtonEdges.swift index 0952e73e2..6cc1545b8 100644 --- a/Sources/PaymentButtons/PaymentButtonEdges.swift +++ b/Sources/PaymentButtons/PaymentButtonEdges.swift @@ -4,36 +4,36 @@ import UIKit public enum PaymentButtonEdges: Int { /// Hard edges on button with 0 corner radius. - case sharp + case hardEdges /// Soft edges with a corner radius of 4 pts. - case rounded + case softEdges /// Pill shaped corner radius. - case pill + case rounded func cornerRadius(for view: UIView) -> CGFloat { switch self { - case .sharp: + case .hardEdges: return 0.0 - case .rounded: + case .softEdges: return 4.0 - case .pill: + case .rounded: return view.frame.size.height / 2 } } public var description: String { switch self { - case .sharp: - return "sharp" + case .hardEdges: + return "hardEdges" + + case .softEdges: + return "softEdges" case .rounded: return "rounded" - - case .pill: - return "pill" } } } From 517888a2f6596172b406de9f0a1e02448b737075 Mon Sep 17 00:00:00 2001 From: stechiu Date: Thu, 11 Jan 2024 15:23:49 -0800 Subject: [PATCH 04/11] Fixed lint errors --- .../PayPalWebPayments/PayPalWebButtonsView.swift | 4 ++-- Sources/PaymentButtons/PaymentButton.swift | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift index 4839361ad..569651b8c 100644 --- a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift +++ b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift @@ -16,11 +16,11 @@ struct PayPalWebButtonsView: View { payPalWebViewModel.paymentButtonTapped(funding: .paypal) } .frame(maxWidth: .infinity, maxHeight: 40) - PayPalCreditButton.Representable(color: .black, edges: .pill, size: .regular) { + PayPalCreditButton.Representable(color: .black, edges: .rounded, size: .regular) { payPalWebViewModel.paymentButtonTapped(funding: .paypalCredit) } .frame(maxWidth: .infinity, maxHeight: 40) - PayPalPayLaterButton.Representable(color: .silver, edges: .pill, size: .regular) { + PayPalPayLaterButton.Representable(color: .silver, edges: .rounded, size: .regular) { payPalWebViewModel.paymentButtonTapped(funding: .paylater) } .frame(maxWidth: .infinity, maxHeight: 40) diff --git a/Sources/PaymentButtons/PaymentButton.swift b/Sources/PaymentButtons/PaymentButton.swift index 8928b927c..b3d8f16c4 100644 --- a/Sources/PaymentButtons/PaymentButton.swift +++ b/Sources/PaymentButtons/PaymentButton.swift @@ -120,7 +120,6 @@ public class PaymentButton: UIButton { case .regular: return 20.0 - } } @@ -138,17 +137,12 @@ public class PaymentButton: UIButton { } private var supportsSuffixLabel: Bool { - switch size { case .mini: return false -// case .collapsed: -// return fundingSource == .payLater - case .regular: if let label = label { - fundingSource == .payLater return label.position == .suffix } return false From d0ccfa390cbf81c5a518cff75d72cdcc1a5e53c4 Mon Sep 17 00:00:00 2001 From: stechiu Date: Thu, 11 Jan 2024 15:28:55 -0800 Subject: [PATCH 05/11] Fixed failing tests --- Sources/PaymentButtons/PayPalButton.swift | 4 ++-- Sources/PaymentButtons/PayPalCreditButton.swift | 2 +- Sources/PaymentButtons/PayPalPayLaterButton.swift | 2 +- UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift | 2 +- UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift | 2 +- .../PaymentButtonsTests/PayPalPayLaterButton_Tests.swift | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/PaymentButtons/PayPalButton.swift b/Sources/PaymentButtons/PayPalButton.swift index 71554f6ec..870ee5b38 100644 --- a/Sources/PaymentButtons/PayPalButton.swift +++ b/Sources/PaymentButtons/PayPalButton.swift @@ -99,7 +99,7 @@ public final class PayPalButton: PaymentButton { public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .gold, - edges: PaymentButtonEdges = .rounded, + edges: PaymentButtonEdges = .softEdges, size: PaymentButtonSize = .regular, label: Label? = nil ) { @@ -135,7 +135,7 @@ public extension PayPalButton { public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalButton.Color = .gold, - edges: PaymentButtonEdges = .rounded, + edges: PaymentButtonEdges = .softEdges, size: PaymentButtonSize = .regular, label: PayPalButton.Label? = nil, _ action: @escaping () -> Void = { } diff --git a/Sources/PaymentButtons/PayPalCreditButton.swift b/Sources/PaymentButtons/PayPalCreditButton.swift index adb1b02bd..d2bfae83a 100644 --- a/Sources/PaymentButtons/PayPalCreditButton.swift +++ b/Sources/PaymentButtons/PayPalCreditButton.swift @@ -26,7 +26,7 @@ public final class PayPalCreditButton: PaymentButton { public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .darkBlue, - edges: PaymentButtonEdges = .rounded, + edges: PaymentButtonEdges = .softEdges, size: PaymentButtonSize = .regular ) { self.init( diff --git a/Sources/PaymentButtons/PayPalPayLaterButton.swift b/Sources/PaymentButtons/PayPalPayLaterButton.swift index 686048a94..4236b9e95 100644 --- a/Sources/PaymentButtons/PayPalPayLaterButton.swift +++ b/Sources/PaymentButtons/PayPalPayLaterButton.swift @@ -26,7 +26,7 @@ public final class PayPalPayLaterButton: PaymentButton { public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .gold, - edges: PaymentButtonEdges = .rounded, + edges: PaymentButtonEdges = .softEdges, size: PaymentButtonSize = .regular, _ action: @escaping () -> Void = { } ) { diff --git a/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift b/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift index dd48b2d9e..066eb074e 100644 --- a/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift +++ b/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift @@ -13,7 +13,7 @@ class PayPalButton_Tests: XCTestCase { func testInit_whenPayPalButtonCreated_hasDefaultUIValuess() { let sut = PayPalButton() XCTAssertEqual(sut.edges, PaymentButtonEdges.softEdges) - XCTAssertEqual(sut.size, PaymentButtonSize.collapsed) + XCTAssertEqual(sut.size, PaymentButtonSize.regular) XCTAssertEqual(sut.color, PaymentButtonColor.gold) XCTAssertNil(sut.label) XCTAssertNil(sut.insets) diff --git a/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift b/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift index 75de13323..002fe4e46 100644 --- a/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift +++ b/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift @@ -13,7 +13,7 @@ class PayPalCreditButton_Tests: XCTestCase { func testInit_whenPayPalCreditButtonCreated_hasDefaultUIValues() { let sut = PayPalCreditButton() XCTAssertEqual(sut.edges, PaymentButtonEdges.softEdges) - XCTAssertEqual(sut.size, PaymentButtonSize.collapsed) + XCTAssertEqual(sut.size, PaymentButtonSize.regular) XCTAssertEqual(sut.color, PaymentButtonColor.darkBlue) XCTAssertNil(sut.insets) XCTAssertNil(sut.label) diff --git a/UnitTests/PaymentButtonsTests/PayPalPayLaterButton_Tests.swift b/UnitTests/PaymentButtonsTests/PayPalPayLaterButton_Tests.swift index 82a013b25..3669decf5 100644 --- a/UnitTests/PaymentButtonsTests/PayPalPayLaterButton_Tests.swift +++ b/UnitTests/PaymentButtonsTests/PayPalPayLaterButton_Tests.swift @@ -8,7 +8,7 @@ class PayPalPayLaterButton_Tests: XCTestCase { func testInit_whenPayPalPayLaterButtonCreated_hasDefaultUIValues() { let sut = PayPalPayLaterButton() XCTAssertEqual(sut.edges, PaymentButtonEdges.softEdges) - XCTAssertEqual(sut.size, PaymentButtonSize.collapsed) + XCTAssertEqual(sut.size, PaymentButtonSize.regular) XCTAssertEqual(sut.color, PaymentButtonColor.gold) XCTAssertEqual(sut.label, .payLater) XCTAssertNil(sut.insets) From 13ed24697161f5a1e1474d052e1169dc08dc12aa Mon Sep 17 00:00:00 2001 From: stechiu Date: Tue, 16 Jan 2024 16:50:05 -0800 Subject: [PATCH 06/11] Updated docstrings --- Sources/PaymentButtons/ImageAsset.swift | 2 +- Sources/PaymentButtons/PayPalButton.swift | 4 ++-- Sources/PaymentButtons/PayPalCreditButton.swift | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/PaymentButtons/ImageAsset.swift b/Sources/PaymentButtons/ImageAsset.swift index 03bf9209f..d6acaf327 100644 --- a/Sources/PaymentButtons/ImageAsset.swift +++ b/Sources/PaymentButtons/ImageAsset.swift @@ -6,7 +6,7 @@ enum ImageAsset { switch button.fundingSource { case .payPal: imageAssetString = "paypal" - + case .payLater: imageAssetString = "paypal" diff --git a/Sources/PaymentButtons/PayPalButton.swift b/Sources/PaymentButtons/PayPalButton.swift index 870ee5b38..c66f1276c 100644 --- a/Sources/PaymentButtons/PayPalButton.swift +++ b/Sources/PaymentButtons/PayPalButton.swift @@ -94,7 +94,7 @@ public final class PayPalButton: PaymentButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to collapsed if not provided. + /// - size: Size of the button. Default to regular if not provided. /// - label: Label displayed next to the button's logo. Default to no label. public convenience init( insets: NSDirectionalEdgeInsets? = nil, @@ -130,7 +130,7 @@ public extension PayPalButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to collapsed if not provided. + /// - size: Size of the button. Default to regular if not provided. /// - label: Label displayed next to the button's logo. Default to no label. public init( insets: NSDirectionalEdgeInsets? = nil, diff --git a/Sources/PaymentButtons/PayPalCreditButton.swift b/Sources/PaymentButtons/PayPalCreditButton.swift index d2bfae83a..9cfe11029 100644 --- a/Sources/PaymentButtons/PayPalCreditButton.swift +++ b/Sources/PaymentButtons/PayPalCreditButton.swift @@ -22,7 +22,7 @@ public final class PayPalCreditButton: PaymentButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to dark blue if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to collapsed if not provided. + /// - size: Size of the button. Default to regular if not provided. public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .darkBlue, @@ -55,7 +55,7 @@ public extension PayPalCreditButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to dark blue if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to collapsed if not provided. + /// - size: Size of the button. Default to regular if not provided. public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalCreditButton.Color = .darkBlue, From 1d6a590380579c9cfade930da18cc2f1533c5a2e Mon Sep 17 00:00:00 2001 From: stechiu Date: Sat, 20 Jan 2024 17:48:57 -0800 Subject: [PATCH 07/11] Addressed PR comments --- .../PayPalWebPayments/PayPalWebButtonsView.swift | 2 +- Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift | 2 +- Sources/PaymentButtons/PayPalCreditButton.swift | 2 +- Sources/PaymentButtons/PayPalPayLaterButton.swift | 6 +++--- Sources/PaymentButtons/PaymentButton.swift | 1 - Sources/PaymentButtons/PaymentButtonColor.swift | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift index 61553e16f..8293b88c2 100644 --- a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift +++ b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift @@ -31,7 +31,7 @@ struct PayPalWebButtonsView: View { payPalWebViewModel.paymentButtonTapped(funding: .paypalCredit) } case .paylater: - PayPalPayLaterButton.Representable(color: .silver, edges: .softEdges, size: .full) { + PayPalPayLaterButton.Representable(color: .silver, edges: .softEdges, size: .regular) { payPalWebViewModel.paymentButtonTapped(funding: .paylater) } case .paypal: diff --git a/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift b/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift index 0f3753944..b9458c4d2 100644 --- a/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift +++ b/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift @@ -95,7 +95,7 @@ struct SwiftUIPaymentButtonDemo: View { .pickerStyle(SegmentedPickerStyle()) .onChange(of: edgesIndex) { _ in selectedEdge = PaymentButtonEdges.allCases[edgesIndex] - buttonId += 1 + buttonID += 1 } Picker("label", selection: $labelIndex) { diff --git a/Sources/PaymentButtons/PayPalCreditButton.swift b/Sources/PaymentButtons/PayPalCreditButton.swift index 9d37021b9..1b2127f1b 100644 --- a/Sources/PaymentButtons/PayPalCreditButton.swift +++ b/Sources/PaymentButtons/PayPalCreditButton.swift @@ -60,7 +60,7 @@ public extension PayPalCreditButton { public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalCreditButton.Color = .darkBlue, - edges: PaymentButtonEdges = .rounded, + edges: PaymentButtonEdges = .softEdges, size: PaymentButtonSize = .regular, _ action: @escaping () -> Void = { } ) { diff --git a/Sources/PaymentButtons/PayPalPayLaterButton.swift b/Sources/PaymentButtons/PayPalPayLaterButton.swift index 4236b9e95..bafef8b1f 100644 --- a/Sources/PaymentButtons/PayPalPayLaterButton.swift +++ b/Sources/PaymentButtons/PayPalPayLaterButton.swift @@ -22,7 +22,7 @@ public final class PayPalPayLaterButton: PaymentButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to collapsed if not provided. + /// - size: Size of the button. Default to regular if not provided. public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .gold, @@ -54,11 +54,11 @@ public extension PayPalPayLaterButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to collapsed if not provided. + /// - size: Size of the button. Default to regular if not provided. public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalPayLaterButton.Color = .gold, - edges: PaymentButtonEdges = .rounded, + edges: PaymentButtonEdges = .softEdges, size: PaymentButtonSize = .regular, _ action: @escaping () -> Void = { } ) { diff --git a/Sources/PaymentButtons/PaymentButton.swift b/Sources/PaymentButtons/PaymentButton.swift index 9f10e0f18..e48bbfb7f 100644 --- a/Sources/PaymentButtons/PaymentButton.swift +++ b/Sources/PaymentButtons/PaymentButton.swift @@ -112,7 +112,6 @@ public class PaymentButton: UIButton { public private(set) var label: PaymentButtonLabel? private var imageHeight: CGFloat { - // For pay later or paypal credit return different image height switch size { case .mini: diff --git a/Sources/PaymentButtons/PaymentButtonColor.swift b/Sources/PaymentButtons/PaymentButtonColor.swift index 7bee36401..50a3f26ab 100644 --- a/Sources/PaymentButtons/PaymentButtonColor.swift +++ b/Sources/PaymentButtons/PaymentButtonColor.swift @@ -23,7 +23,7 @@ public enum PaymentButtonColor: String { var color: UIColor { switch self { case .gold: - return UIColor(hexString: "#FFD140") + return UIColor(hexString: "#FFC439") case .white: return UIColor(hexString: "#FFFFFF") From 5c2772d657dd9acae3443abac39b368c9ca2cebc Mon Sep 17 00:00:00 2001 From: stechiu Date: Tue, 23 Jan 2024 17:09:35 -0800 Subject: [PATCH 08/11] Fixed failing test --- UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift b/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift index 002fe4e46..36e62bc9b 100644 --- a/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift +++ b/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift @@ -14,7 +14,7 @@ class PayPalCreditButton_Tests: XCTestCase { let sut = PayPalCreditButton() XCTAssertEqual(sut.edges, PaymentButtonEdges.softEdges) XCTAssertEqual(sut.size, PaymentButtonSize.regular) - XCTAssertEqual(sut.color, PaymentButtonColor.darkBlue) + XCTAssertEqual(sut.color, PaymentButtonColor.gold) XCTAssertNil(sut.insets) XCTAssertNil(sut.label) } From 8048dce3d8b5fd5d9d4ffb21d4d6dbbd4adfbbfc Mon Sep 17 00:00:00 2001 From: stechiu Date: Wed, 24 Jan 2024 10:34:00 -0800 Subject: [PATCH 09/11] Updated color --- .../PayPalWebPayments/PayPalWebButtonsView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift index 8293b88c2..e73ff157e 100644 --- a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift +++ b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift @@ -31,11 +31,11 @@ struct PayPalWebButtonsView: View { payPalWebViewModel.paymentButtonTapped(funding: .paypalCredit) } case .paylater: - PayPalPayLaterButton.Representable(color: .silver, edges: .softEdges, size: .regular) { + PayPalPayLaterButton.Representable(color: .gold, edges: .softEdges, size: .regular) { payPalWebViewModel.paymentButtonTapped(funding: .paylater) } case .paypal: - PayPalButton.Representable(color: .blue, size: .regular) { + PayPalButton.Representable(color: .gold, size: .regular) { payPalWebViewModel.paymentButtonTapped(funding: .paypal) } } From a90c2c211646e75ea07bd176d9222e8497de4aee Mon Sep 17 00:00:00 2001 From: stechiu Date: Fri, 26 Jan 2024 12:22:05 -0800 Subject: [PATCH 10/11] Addressed PR comments --- CHANGELOG.md | 1 - Sources/PaymentButtons/PaymentButtonSize.swift | 2 -- 2 files changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b101d26aa..c461744fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,6 @@ * Remove `PayPalButton.Labels` cases: `.checkout`, `.buyNow`, `.payLater` * Remove `PaymentButtonColor` `.black`, `.silver`, `.blue`, and `.darkBlue` * Add `PaymentButtonColor.gold` for `PayPalCreditButton` - * Remove `PayPalButton.Labels` cases: `.checkout`, `.buyNow`, `.payLater` * Remove `PaymentButtonSize` cases: `.miniWithWordmark`, `.collapsed`, `.expanded`, `.full` ## 1.1.0 (2023-11-16) diff --git a/Sources/PaymentButtons/PaymentButtonSize.swift b/Sources/PaymentButtons/PaymentButtonSize.swift index 721f3e038..5950a1e25 100644 --- a/Sources/PaymentButtons/PaymentButtonSize.swift +++ b/Sources/PaymentButtons/PaymentButtonSize.swift @@ -31,7 +31,6 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { var elementPadding: NSDirectionalEdgeInsets { switch self { - case .mini: return NSDirectionalEdgeInsets( top: 9.0, @@ -52,7 +51,6 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { public var description: String { switch self { - case .mini: return "mini" From 643a4099518ff4413705298d939fc697dc9a5d2c Mon Sep 17 00:00:00 2001 From: stechiu Date: Mon, 29 Jan 2024 09:54:25 -0800 Subject: [PATCH 11/11] * Fixed failing test * Changed from `.regular` to `.standard` --- CHANGELOG.md | 2 +- .../PaymentButtonEnums+Extension.swift | 2 +- .../PayPalWebButtonsView.swift | 6 +++--- .../SwiftUIPaymentButtonDemo.swift | 2 +- Sources/PaymentButtons/PayPalButton.swift | 8 ++++---- .../PaymentButtons/PayPalCreditButton.swift | 8 ++++---- .../PaymentButtons/PayPalPayLaterButton.swift | 8 ++++---- Sources/PaymentButtons/PaymentButton.swift | 6 +++--- .../PaymentButtons/PaymentButtonSize.swift | 20 +++++++------------ .../PayPalButton_Tests.swift | 2 +- .../PayPalCreditButton_Tests.swift | 2 +- .../PayPalPayLaterButton_Tests.swift | 2 +- 12 files changed, 31 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7359e324a..2b0e5bb61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ * Add `PayPalVaultDelegate` to handle results from vault flow * Add `PayPalWebCheckoutClientError.paypalVaultResponseError` for missing or invalid response from vaulting * PaymentButtons - * Add new `PaymentButtonSize` case `.regular` + * Add new `PaymentButtonSize` case `.standard` * Add `custom` case for `PaymentButtonEdges` * Support VoiceOver by adding button accessibility labels * Add new `PaymentButtonSize` case `.miniWithWordmark` diff --git a/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift b/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift index 72717d609..2fb17258d 100644 --- a/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift +++ b/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift @@ -47,7 +47,7 @@ extension PaymentButtonEdges: CaseIterable { extension PaymentButtonSize: CaseIterable { public static var allCases: [PaymentButtonSize] { - [.mini, .regular] + [.mini, .standard] } static func allCasesAsString() -> [String] { diff --git a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift index e73ff157e..adccbb182 100644 --- a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift +++ b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift @@ -27,15 +27,15 @@ struct PayPalWebButtonsView: View { switch selectedFundingSource { case .paypalCredit: - PayPalCreditButton.Representable(color: .gold, size: .regular) { + PayPalCreditButton.Representable(color: .gold, size: .standard) { payPalWebViewModel.paymentButtonTapped(funding: .paypalCredit) } case .paylater: - PayPalPayLaterButton.Representable(color: .gold, edges: .softEdges, size: .regular) { + PayPalPayLaterButton.Representable(color: .gold, edges: .softEdges, size: .standard) { payPalWebViewModel.paymentButtonTapped(funding: .paylater) } case .paypal: - PayPalButton.Representable(color: .gold, size: .regular) { + PayPalButton.Representable(color: .gold, size: .standard) { payPalWebViewModel.paymentButtonTapped(funding: .paypal) } } diff --git a/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift b/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift index b9458c4d2..e1767fd2c 100644 --- a/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift +++ b/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift @@ -86,7 +86,7 @@ struct SwiftUIPaymentButtonDemo: View { switch selectedFunding { case .payPal: - if selectedSize == .regular { + if selectedSize == .standard { Picker("Edges", selection: $edgesIndex) { ForEach(edges.indices, id: \.self) { index in Text(edges[index]) diff --git a/Sources/PaymentButtons/PayPalButton.swift b/Sources/PaymentButtons/PayPalButton.swift index 59ef38df1..5996b8f4c 100644 --- a/Sources/PaymentButtons/PayPalButton.swift +++ b/Sources/PaymentButtons/PayPalButton.swift @@ -91,13 +91,13 @@ public final class PayPalButton: PaymentButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to regular if not provided. + /// - size: Size of the button. Default to standard if not provided. /// - label: Label displayed next to the button's logo. Default to no label. public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .gold, edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .regular, + size: PaymentButtonSize = .standard, label: Label? = nil ) { self.init( @@ -127,13 +127,13 @@ public extension PayPalButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to regular if not provided. + /// - size: Size of the button. Default to standard if not provided. /// - label: Label displayed next to the button's logo. Default to no label. public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalButton.Color = .gold, edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .regular, + size: PaymentButtonSize = .standard, label: PayPalButton.Label? = nil, _ action: @escaping () -> Void = { } ) { diff --git a/Sources/PaymentButtons/PayPalCreditButton.swift b/Sources/PaymentButtons/PayPalCreditButton.swift index 6917695e4..fb3f29dc8 100644 --- a/Sources/PaymentButtons/PayPalCreditButton.swift +++ b/Sources/PaymentButtons/PayPalCreditButton.swift @@ -21,12 +21,12 @@ public final class PayPalCreditButton: PaymentButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to regular if not provided. + /// - size: Size of the button. Default to standard if not provided. public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .gold, edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .regular + size: PaymentButtonSize = .standard ) { self.init( fundingSource: PaymentButtonFundingSource.credit, @@ -54,12 +54,12 @@ public extension PayPalCreditButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to regular if not provided. + /// - size: Size of the button. Default to standard if not provided. public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalCreditButton.Color = .gold, edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .regular, + size: PaymentButtonSize = .standard, _ action: @escaping () -> Void = { } ) { self.button = PayPalCreditButton( diff --git a/Sources/PaymentButtons/PayPalPayLaterButton.swift b/Sources/PaymentButtons/PayPalPayLaterButton.swift index e5901e635..c0c4bc06c 100644 --- a/Sources/PaymentButtons/PayPalPayLaterButton.swift +++ b/Sources/PaymentButtons/PayPalPayLaterButton.swift @@ -19,12 +19,12 @@ public final class PayPalPayLaterButton: PaymentButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to regular if not provided. + /// - size: Size of the button. Default to standard if not provided. public convenience init( insets: NSDirectionalEdgeInsets? = nil, color: Color = .gold, edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .regular, + size: PaymentButtonSize = .standard, _ action: @escaping () -> Void = { } ) { self.init( @@ -51,12 +51,12 @@ public extension PayPalPayLaterButton { /// - insets: Edge insets of the button, defining the spacing of the button's edges relative to its content. /// - color: Color of the button. Default to gold if not provided. /// - edges: Edges of the button. Default to softEdges if not provided. - /// - size: Size of the button. Default to regular if not provided. + /// - size: Size of the button. Default to standard if not provided. public init( insets: NSDirectionalEdgeInsets? = nil, color: PayPalPayLaterButton.Color = .gold, edges: PaymentButtonEdges = .softEdges, - size: PaymentButtonSize = .regular, + size: PaymentButtonSize = .standard, _ action: @escaping () -> Void = { } ) { self.button = PayPalPayLaterButton( diff --git a/Sources/PaymentButtons/PaymentButton.swift b/Sources/PaymentButtons/PaymentButton.swift index 4ce023d81..b1734e315 100644 --- a/Sources/PaymentButtons/PaymentButton.swift +++ b/Sources/PaymentButtons/PaymentButton.swift @@ -117,7 +117,7 @@ public class PaymentButton: UIButton { case .mini: return 24.0 - case .regular: + case .standard: return 20.0 } } @@ -127,7 +127,7 @@ public class PaymentButton: UIButton { case .mini: return false - case .regular: + case .standard: if let label = label { return label.position == .prefix } @@ -140,7 +140,7 @@ public class PaymentButton: UIButton { case .mini: return false - case .regular: + case .standard: if let label = label { return label.position == .suffix } diff --git a/Sources/PaymentButtons/PaymentButtonSize.swift b/Sources/PaymentButtons/PaymentButtonSize.swift index 5950a1e25..6bbac79bb 100644 --- a/Sources/PaymentButtons/PaymentButtonSize.swift +++ b/Sources/PaymentButtons/PaymentButtonSize.swift @@ -6,17 +6,11 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { /// Smallest button size uses the primary mark, vertically stacked. This is the recommended size when displaying on screens with limited space. case mini - /// Regular size shows the primary mark along with the prefix or suffix - case regular + /// Standard size shows the primary mark along with the prefix or suffix + case standard var font: UIFont { - switch self { - case .mini: - return PaymentButtonFont.secondaryFont - - case .regular: - return PaymentButtonFont.primaryFont - } + PaymentButtonFont.paypalPrimaryFont } var elementSpacing: CGFloat { @@ -24,7 +18,7 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { case .mini: return 4.0 - case .regular: + case .standard: return 4.5 } } @@ -39,7 +33,7 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { trailing: 20.0 ) - case .regular: + case .standard: return NSDirectionalEdgeInsets( top: 10.0, leading: 80.0, @@ -54,8 +48,8 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { case .mini: return "mini" - case .regular: - return "regular" + case .standard: + return "standard" } } } diff --git a/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift b/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift index 066eb074e..e146e904d 100644 --- a/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift +++ b/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift @@ -13,7 +13,7 @@ class PayPalButton_Tests: XCTestCase { func testInit_whenPayPalButtonCreated_hasDefaultUIValuess() { let sut = PayPalButton() XCTAssertEqual(sut.edges, PaymentButtonEdges.softEdges) - XCTAssertEqual(sut.size, PaymentButtonSize.regular) + XCTAssertEqual(sut.size, PaymentButtonSize.standard) XCTAssertEqual(sut.color, PaymentButtonColor.gold) XCTAssertNil(sut.label) XCTAssertNil(sut.insets) diff --git a/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift b/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift index 36e62bc9b..327b8c16a 100644 --- a/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift +++ b/UnitTests/PaymentButtonsTests/PayPalCreditButton_Tests.swift @@ -13,7 +13,7 @@ class PayPalCreditButton_Tests: XCTestCase { func testInit_whenPayPalCreditButtonCreated_hasDefaultUIValues() { let sut = PayPalCreditButton() XCTAssertEqual(sut.edges, PaymentButtonEdges.softEdges) - XCTAssertEqual(sut.size, PaymentButtonSize.regular) + XCTAssertEqual(sut.size, PaymentButtonSize.standard) XCTAssertEqual(sut.color, PaymentButtonColor.gold) XCTAssertNil(sut.insets) XCTAssertNil(sut.label) diff --git a/UnitTests/PaymentButtonsTests/PayPalPayLaterButton_Tests.swift b/UnitTests/PaymentButtonsTests/PayPalPayLaterButton_Tests.swift index 3669decf5..553d4dc35 100644 --- a/UnitTests/PaymentButtonsTests/PayPalPayLaterButton_Tests.swift +++ b/UnitTests/PaymentButtonsTests/PayPalPayLaterButton_Tests.swift @@ -8,7 +8,7 @@ class PayPalPayLaterButton_Tests: XCTestCase { func testInit_whenPayPalPayLaterButtonCreated_hasDefaultUIValues() { let sut = PayPalPayLaterButton() XCTAssertEqual(sut.edges, PaymentButtonEdges.softEdges) - XCTAssertEqual(sut.size, PaymentButtonSize.regular) + XCTAssertEqual(sut.size, PaymentButtonSize.standard) XCTAssertEqual(sut.color, PaymentButtonColor.gold) XCTAssertEqual(sut.label, .payLater) XCTAssertNil(sut.insets)