diff --git a/CHANGELOG.md b/CHANGELOG.md index f1613128d..2b0e5bb61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,8 @@ * Add `PayPalVaultResult` type to return vault result * Add `PayPalVaultDelegate` to handle results from vault flow * Add `PayPalWebCheckoutClientError.paypalVaultResponseError` for missing or invalid response from vaulting -<<<<<<< HEAD * PaymentButtons + * Add new `PaymentButtonSize` case `.standard` * Add `custom` case for `PaymentButtonEdges` * Support VoiceOver by adding button accessibility labels * Add new `PaymentButtonSize` case `.miniWithWordmark` @@ -21,12 +21,14 @@ `.checkoutWith`, `.continueWith`, `.contributeWith`, `.orderWith`, `.payLaterWith`, `.payWith`, `.reloadWith`, `.rentWith`, `.reserveWith`, `.subscribeWith`, `.supportWith`, `.tipWith`, `.topUpWith` + * `PayPalButtonSize` `.mini` changed to rectangular button to meet brand guidelines * Font typeface changed to "PayPalOpen" to meet brand guidelines * Breaking Changes * PaymentButtons * Remove `PayPalButton.Labels` cases: `.checkout`, `.buyNow`, `.payLater` * Remove `PaymentButtonColor` `.black`, `.silver`, `.blue`, and `.darkBlue` * Add `PaymentButtonColor.gold` for `PayPalCreditButton` + * Remove `PaymentButtonSize` cases: `.miniWithWordmark`, `.collapsed`, `.expanded`, `.full` ## 1.1.0 (2023-11-16) * PayPalNativePayments diff --git a/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift b/Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift index 29a29a6dc..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, .miniWithWordmark, .collapsed, .expanded, .full] + [.mini, .standard] } static func allCasesAsString() -> [String] { diff --git a/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift b/Demo/Demo/SwiftUIComponents/PayPalWebPayments/PayPalWebButtonsView.swift index 7ddd32030..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: .full) { + PayPalCreditButton.Representable(color: .gold, size: .standard) { payPalWebViewModel.paymentButtonTapped(funding: .paypalCredit) } case .paylater: - PayPalPayLaterButton.Representable(color: .silver, edges: .softEdges, size: .full) { + PayPalPayLaterButton.Representable(color: .gold, edges: .softEdges, size: .standard) { payPalWebViewModel.paymentButtonTapped(funding: .paylater) } case .paypal: - PayPalButton.Representable(color: .blue, size: .full) { + 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 d2e58e7db..e1767fd2c 100644 --- a/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift +++ b/Demo/Demo/SwiftUIComponents/SwiftUIPaymentButtonDemo.swift @@ -86,7 +86,18 @@ struct SwiftUIPaymentButtonDemo: View { switch selectedFunding { case .payPal: - if selectedSize == .expanded || selectedSize == .full { + if selectedSize == .standard { + 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..d6acaf327 100644 --- a/Sources/PaymentButtons/ImageAsset.swift +++ b/Sources/PaymentButtons/ImageAsset.swift @@ -9,24 +9,15 @@ enum ImageAsset { 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 0049f70ca..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 collapsed 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 = .collapsed, + 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 collapsed 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 = .collapsed, + size: PaymentButtonSize = .standard, label: PayPalButton.Label? = nil, _ action: @escaping () -> Void = { } ) { diff --git a/Sources/PaymentButtons/PayPalCreditButton.swift b/Sources/PaymentButtons/PayPalCreditButton.swift index d2127bb12..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 collapsed 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 = .collapsed + 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 collapsed 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 = .collapsed, + size: PaymentButtonSize = .standard, _ action: @escaping () -> Void = { } ) { self.button = PayPalCreditButton( diff --git a/Sources/PaymentButtons/PayPalPayLaterButton.swift b/Sources/PaymentButtons/PayPalPayLaterButton.swift index d64e03f23..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 collapsed 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 = .collapsed, + 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 collapsed 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 = .collapsed, + size: PaymentButtonSize = .standard, _ action: @escaping () -> Void = { } ) { self.button = PayPalPayLaterButton( diff --git a/Sources/PaymentButtons/PaymentButton.swift b/Sources/PaymentButtons/PaymentButton.swift index 316b5b86b..b1734e315 100644 --- a/Sources/PaymentButtons/PaymentButton.swift +++ b/Sources/PaymentButtons/PaymentButton.swift @@ -112,31 +112,22 @@ 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: - return 20.0 - case .miniWithWordmark: + case .mini: return 24.0 - case .collapsed: - return 15.0 - - case .expanded: + case .standard: 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 .standard: if let label = label { return label.position == .prefix } @@ -145,15 +136,11 @@ public class PaymentButton: UIButton { } private var supportsSuffixLabel: Bool { - switch size { - case .mini, .miniWithWordmark: + case .mini: return false - case .collapsed: - return fundingSource == .payLater - - case .expanded, .full: + case .standard: if let label = label { return label.position == .suffix } @@ -251,9 +238,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) } @@ -267,7 +253,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/PaymentButtonSize.swift b/Sources/PaymentButtons/PaymentButtonSize.swift index 0b5b0ace2..6bbac79bb 100644 --- a/Sources/PaymentButtons/PaymentButtonSize.swift +++ b/Sources/PaymentButtons/PaymentButtonSize.swift @@ -3,17 +3,11 @@ import UIKit /// The size category which determines how the button is shown. public enum PaymentButtonSize: Int, CustomStringConvertible { - /// Circle shaped button similar to a floating action button will show the monogram, if `.venmo` then will show `Venmo` logo. + /// Smallest button size uses the primary mark, vertically stacked. This is the recommended size when displaying on screens with limited space. case mini - /// Collapsed will only show the wordmark. - case collapsed - - /// Expanded shows the wordmark along with the suffix. - case expanded - - /// Full will show the wordmark along with the prefix and suffix. - case full + /// Standard size shows the primary mark along with the prefix or suffix + case standard var font: UIFont { PaymentButtonFont.paypalPrimaryFont @@ -21,14 +15,11 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { var elementSpacing: CGFloat { switch self { - case .mini, .collapsed: + case .mini: return 4.0 - case .expanded: + case .standard: return 4.5 - - case .full: - return 6.0 } } @@ -36,34 +27,18 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { switch self { case .mini: return NSDirectionalEdgeInsets( - top: 14.0, - leading: 14.0, - bottom: 14.0, - trailing: 14.0 - ) - - case .collapsed: - 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 .standard: 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 ) } } @@ -73,14 +48,8 @@ public enum PaymentButtonSize: Int, CustomStringConvertible { case .mini: return "mini" - case .collapsed: - return "collapsed" - - case .expanded: - return "expanded" - - case .full: - return "full" + case .standard: + return "standard" } } } diff --git a/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift b/UnitTests/PaymentButtonsTests/PayPalButton_Tests.swift index dd48b2d9e..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.collapsed) + 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 06ba9e572..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.collapsed) + 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 82a013b25..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.collapsed) + XCTAssertEqual(sut.size, PaymentButtonSize.standard) XCTAssertEqual(sut.color, PaymentButtonColor.gold) XCTAssertEqual(sut.label, .payLater) XCTAssertNil(sut.insets)