Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/paypal/paypal-ios into butt…
Browse files Browse the repository at this point in the history
…on-typeface-update

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
stechiu committed Jan 10, 2024
2 parents 50c58c2 + b39b179 commit 68112af
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 52 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
# PayPal iOS SDK Release Notes

## unreleased
* PaymentButtons
* Deprecate `PaymentButtonColor` `.black`, `.silver`, `.blue`, and `.darkBlue`
* Add `PaymentButtonColor.gold` for `PayPalCreditButton`
* Add `custom` case for `PaymentButtonEdges`
* Support VoiceOver by adding button accessibility labels

* PayPalWebPayments
* Add `vault(url:)` method to `PayPalWebCheckoutClient`
* 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
* PaymentButtons
* Add `custom` case for `PaymentButtonEdges`

* Breaking Changes
* Font typeface changed to "PayPalOpen" to meet brand guidelines
* PaymentButtons
* Font typeface changed to "PayPalOpen" to meet brand guidelines

## 1.1.0 (2023-11-16)
* PayPalNativePayments
Expand Down
2 changes: 1 addition & 1 deletion Demo/Demo/Extensions/PaymentButtonEnums+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension PayPalButton.Color: CaseIterable {
extension PayPalCreditButton.Color: CaseIterable {

public static var allCases: [PayPalCreditButton.Color] {
[.white, .black, .darkBlue]
[.gold, .white, .black, .darkBlue]
}

static func allCasesAsString() -> [String] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ struct PayPalWebButtonsView: View {
.font(.headline)
Picker("Funding Source", selection: $selectedFundingSource) {
Text("PayPal").tag(PayPalWebCheckoutFundingSource.paypal)
Text("PayPal Credit").tag(PayPalWebCheckoutFundingSource.paylater)
Text("Pay Later").tag(PayPalWebCheckoutFundingSource.paypalCredit)
Text("PayPal Credit").tag(PayPalWebCheckoutFundingSource.paypalCredit)
Text("Pay Later").tag(PayPalWebCheckoutFundingSource.paylater)
}
.pickerStyle(SegmentedPickerStyle())

switch selectedFundingSource {
case .paypalCredit:
PayPalCreditButton.Representable(color: .black, size: .full) {
PayPalCreditButton.Representable(color: .gold, size: .full) {
payPalWebViewModel.paymentButtonTapped(funding: .paypalCredit)
}
case .paylater:
Expand Down
8 changes: 4 additions & 4 deletions PayPal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
CB1A47F82820BCE200BD8184 /* PaymentButtonSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB1A47F72820BCE200BD8184 /* PaymentButtonSize.swift */; };
CB1A47FA2820BF6B00BD8184 /* PaymentButtonFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB1A47F92820BF6B00BD8184 /* PaymentButtonFont.swift */; };
CB1A47FE2820C10700BD8184 /* PaymentButtonFundingSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB1A47FD2820C10700BD8184 /* PaymentButtonFundingSource.swift */; };
CB1A48052822BCED00BD8184 /* ImageAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB1A48042822BCED00BD8184 /* ImageAsset.swift */; };
CB1A48052822BCED00BD8184 /* PaymentButton+ImageAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB1A48042822BCED00BD8184 /* PaymentButton+ImageAsset.swift */; };
CB1AC3C22982CDB10081AED6 /* MockNativeCheckoutProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D25238B273979170099E4EB /* MockNativeCheckoutProvider.swift */; };
CB22C018291049500097E592 /* PayPalPayLaterButton_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB22C017291049500097E592 /* PayPalPayLaterButton_Tests.swift */; };
CB4BE27D2847AF6F00EA2DD1 /* SCA.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB4BE27C2847AF6F00EA2DD1 /* SCA.swift */; };
Expand Down Expand Up @@ -336,7 +336,7 @@
CB1A47F72820BCE200BD8184 /* PaymentButtonSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentButtonSize.swift; sourceTree = "<group>"; };
CB1A47F92820BF6B00BD8184 /* PaymentButtonFont.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentButtonFont.swift; sourceTree = "<group>"; };
CB1A47FD2820C10700BD8184 /* PaymentButtonFundingSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentButtonFundingSource.swift; sourceTree = "<group>"; };
CB1A48042822BCED00BD8184 /* ImageAsset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageAsset.swift; sourceTree = "<group>"; };
CB1A48042822BCED00BD8184 /* PaymentButton+ImageAsset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PaymentButton+ImageAsset.swift"; sourceTree = "<group>"; };
CB22C017291049500097E592 /* PayPalPayLaterButton_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayPalPayLaterButton_Tests.swift; sourceTree = "<group>"; };
CB4BE27C2847AF6F00EA2DD1 /* SCA.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SCA.swift; sourceTree = "<group>"; };
CB4BE27F2847F01000EA2DD1 /* CardDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -717,7 +717,7 @@
CB1A47F72820BCE200BD8184 /* PaymentButtonSize.swift */,
CB1A47F92820BF6B00BD8184 /* PaymentButtonFont.swift */,
CB1A47FD2820C10700BD8184 /* PaymentButtonFundingSource.swift */,
CB1A48042822BCED00BD8184 /* ImageAsset.swift */,
CB1A48042822BCED00BD8184 /* PaymentButton+ImageAsset.swift */,
);
name = PaymentButtons;
path = Sources/PaymentButtons;
Expand Down Expand Up @@ -1489,7 +1489,7 @@
BCFAC71E27ED04C500C3AF00 /* PayPalCreditButton.swift in Sources */,
CB1A47FE2820C10700BD8184 /* PaymentButtonFundingSource.swift in Sources */,
CB1A47FA2820BF6B00BD8184 /* PaymentButtonFont.swift in Sources */,
CB1A48052822BCED00BD8184 /* ImageAsset.swift in Sources */,
CB1A48052822BCED00BD8184 /* PaymentButton+ImageAsset.swift in Sources */,
BCFAC71D27ED04C300C3AF00 /* PayPalButton.swift in Sources */,
CB1A47F82820BCE200BD8184 /* PaymentButtonSize.swift in Sources */,
BCFAC71F27ED04C800C3AF00 /* Coordinator.swift in Sources */,
Expand Down
34 changes: 0 additions & 34 deletions Sources/PaymentButtons/ImageAsset.swift

This file was deleted.

3 changes: 2 additions & 1 deletion Sources/PaymentButtons/PayPalCreditButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ public final class PayPalCreditButton: PaymentButton {
Available colors for PayPalCreditButton.
*/
public enum Color: String {
case gold
case white
case black
case darkBlue

var color: PaymentButtonColor {
PaymentButtonColor(rawValue: rawValue) ?? .darkBlue
PaymentButtonColor(rawValue: rawValue) ?? .white
}
}

Expand Down
49 changes: 49 additions & 0 deletions Sources/PaymentButtons/PaymentButton+ImageAsset.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import UIKit

extension PaymentButton {

// MARK: - Internal Properties

var image: UIImage? {
UIImage(named: fileName, in: PaymentButton.bundle, compatibleWith: nil)
}

var imageAccessibilityLabel: String {
// NEXT_MAJOR_VERSION: - To be replaced with translation strings.
fileName.starts(with: "credit") ? "PayPal Credit" : "PayPal"
}

// MARK: - Private Properties

/// Name of the sized `.imageset` assets within `Assets.xcassets` directory
private var fileName: String {
var imageAssetString = ""
switch fundingSource {
case .payPal:
imageAssetString += "paypal_"

if size == .mini {
imageAssetString += "monogram_"
}

case .payLater:
imageAssetString += "paypal_monogram_"

case .credit:
imageAssetString += "credit_"
}

switch color {
case .gold, .white, .silver:
imageAssetString += "color"

case .black, .darkBlue:
imageAssetString += "monochrome"

case .blue:
imageAssetString += "blue"
}

return imageAssetString
}
}
13 changes: 12 additions & 1 deletion Sources/PaymentButtons/PaymentButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public class PaymentButton: UIButton {
configureSuffix()
configureSubviews()
configureConstraints()
configureAccessibilityLabel()
}

private func configureStackView() {
Expand All @@ -181,7 +182,7 @@ public class PaymentButton: UIButton {
}

private func configureLogo() -> UIImageView {
let logo = resize(with: ImageAsset.paymentButtonLogo(for: self))
let logo = resize(with: image)
let logoImageView = UIImageView(image: logo)
sizeToImage(on: logoImageView, with: size)
logoImageView.contentMode = .scaleAspectFit
Expand All @@ -205,6 +206,16 @@ public class PaymentButton: UIButton {
suffixLabel.font = size.font
suffixLabel.isHidden = !supportsSuffixLabel
}

private func configureAccessibilityLabel() {
if let prefixText = prefixLabel.text, supportsPrefixLabel {
accessibilityLabel = "\(prefixText) \(imageAccessibilityLabel)"
} else if let suffixText = suffixLabel.text, supportsSuffixLabel {
accessibilityLabel = "\(imageAccessibilityLabel) \(suffixText)"
} else {
accessibilityLabel = imageAccessibilityLabel
}
}

private func configureSubviews() {
containerView.addSubview(containerStackView)
Expand Down
10 changes: 5 additions & 5 deletions Sources/PaymentButtons/PaymentButtonColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ public enum PaymentButtonColor: String {
/// The gold background and blue wordmark, monogram, and black text.
case gold

/// The white background and blue wordmark, monogram, and black text.
/// The white background and blue wordmark, blue border, monogram, and black text.
case white

/// The black background and monochrome wordmark, monogram, and white text.
@available(*, deprecated, message: "Deprecated color. Replace with `white` button color.")
case black

/// The silver background and blue wordmark, monogram, and black text.
@available(*, deprecated, message: "Deprecated color. Replace with `white` button color.")
case silver

/// The blue background and white wordmark, blue monogram, and white text.
@available(*, deprecated, message: "Deprecated color. Replace with `white` button color.")
case blue

/// The dark blue background with PayPal Credit wordmark and monogram.
@available(*, deprecated, message: "Deprecated color. Replace with `white` button color.")
case darkBlue

var color: UIColor {
Expand Down

0 comments on commit 68112af

Please sign in to comment.