Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Sources/PayPalMessages/Enums/ImageAsset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ enum ImageAsset: String {

let renderFormat = UIGraphicsImageRendererFormat.default()
renderFormat.opaque = false

let renderer = UIGraphicsImageRenderer(size: sized, format: renderFormat)

let newImage = renderer.image { _ in
Expand Down
2 changes: 1 addition & 1 deletion Sources/PayPalMessages/Extensions/UIColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit

extension UIColor {

static let colorBlue600 = UIColor(red: 0.00, green: 0.44, blue: 0.73, alpha: 1)
static let colorBlue600 = UIColor(hexString: "#0065F2")
static let colorGrey700 = UIColor(red: 0.17, green: 0.18, blue: 0.18, alpha: 1)

convenience init(hexString: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,17 @@ final class PayPalMessageAttributedStringBuilder {
includesMonogram: Bool,
icon: UIImage
) -> CGRect {
// Use the cap height of the displayed raw text as the basis for calculations.
// The cap height is the distance from the baseline to the highest point of a capital letter.
// The height of 'P' would be the cap height.
let capHeight = getDynamicTypeFont(for: .systemFont(ofSize: fontSize)).capHeight
// The descender is the lowest part of the text that goes below the baseline.
// The difference in height between 'a' and 'y' would be the descender, where the
// descender is just the bottom part of 'y'. We calculate it ourselves instead of pulling it
// from the font because the PayPal logo has a slightly different descender ratio.
let font = getDynamicTypeFont(for: .systemFont(ofSize: fontSize))
let capHeight = font.capHeight
let descender = capHeight * Constants.capHeightToDescenderRatio + Constants.descenderOffset
// Used to scale up the calculations when the image includes a monogram since the
// "PayPal" portion is smaller than the "PP" monogram
let monogramMultiplier = includesMonogram ? Constants.monogramToPayPalRatio : 1
// Ratio which is used to calculate the correctly scaled width of the boundary
let iconRatio = icon.size.width / icon.size.height
// The height consists of the cap height ('P') and descender (bottom of 'y') and an optional
// monogram ratio upscale when present
let iconHeight = (capHeight + descender) * monogramMultiplier
// Veritical shift down so that the descender (bottom of 'y') falls below the baseline
let iconYOffset = -1 * descender
// Leading badge: center vertically on the text line's midpoint
// Inline logo: shift down so the logo's descender falls below the baseline
let iconYOffset = includesMonogram
? (font.ascender + font.descender) / 2 - iconHeight / 2
: -1 * descender

return CGRect(
x: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct PayPalMessageViewParametersBuilder {
asset = isPayLater ? ImageAsset.logoPrimaryMonochrome : ImageAsset.logoPrimaryMonochromeCredit

case .grayscale:
asset = isPayLater ? ImageAsset.logoPrimaryGrayscale : ImageAsset.logoPrimaryGrayscaleCredit
asset = isPayLater ? ImageAsset.logoPrimaryMonochrome : ImageAsset.logoPrimaryMonochromeCredit
}

return ImageAsset.image(asset)
Expand All @@ -115,7 +115,7 @@ struct PayPalMessageViewParametersBuilder {
asset = isPayLater ? ImageAsset.logoAlternativeMonochrome : ImageAsset.logoAlternativeMonochromeCredit

case .grayscale:
asset = isPayLater ? ImageAsset.logoAlternativeGrayscale : ImageAsset.logoAlternativeGrayscaleCredit
asset = isPayLater ? ImageAsset.logoAlternativeMonochrome : ImageAsset.logoAlternativeMonochromeCredit
}

return ImageAsset.image(asset)
Expand All @@ -138,7 +138,7 @@ struct PayPalMessageViewParametersBuilder {
asset = isPayLater ? ImageAsset.logoInlineMonochrome : ImageAsset.logoInlineMonochromeCredit

case .grayscale:
asset = isPayLater ? ImageAsset.logoInlineGrayscale : ImageAsset.logoInlineGrayscaleCredit
asset = isPayLater ? ImageAsset.logoInlineMonochrome : ImageAsset.logoInlineMonochromeCredit
}

return ImageAsset.image(asset)
Expand Down
12 changes: 6 additions & 6 deletions Tests/PayPalMessagesTests/PayPalMessageLogoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ final class PayPalMessageLogoTests: XCTestCase {
logoType: .primary,
color: .grayscale,
productGroup: .payLater,
expectedAsset: .logoPrimaryGrayscale
expectedAsset: .logoPrimaryMonochrome
)
}

Expand All @@ -101,7 +101,7 @@ final class PayPalMessageLogoTests: XCTestCase {
logoType: .primary,
color: .grayscale,
productGroup: .paypalCredit,
expectedAsset: .logoPrimaryGrayscaleCredit
expectedAsset: .logoPrimaryMonochromeCredit
)
}

Expand Down Expand Up @@ -166,7 +166,7 @@ final class PayPalMessageLogoTests: XCTestCase {
logoType: .alternative,
color: .grayscale,
productGroup: .payLater,
expectedAsset: .logoAlternativeGrayscale
expectedAsset: .logoAlternativeMonochrome
)
}

Expand All @@ -175,7 +175,7 @@ final class PayPalMessageLogoTests: XCTestCase {
logoType: .alternative,
color: .grayscale,
productGroup: .paypalCredit,
expectedAsset: .logoAlternativeGrayscaleCredit
expectedAsset: .logoAlternativeMonochromeCredit
)
}

Expand Down Expand Up @@ -240,7 +240,7 @@ final class PayPalMessageLogoTests: XCTestCase {
logoType: .inline,
color: .grayscale,
productGroup: .payLater,
expectedAsset: .logoInlineGrayscale
expectedAsset: .logoInlineMonochrome
)
}

Expand All @@ -249,7 +249,7 @@ final class PayPalMessageLogoTests: XCTestCase {
logoType: .inline,
color: .grayscale,
productGroup: .paypalCredit,
expectedAsset: .logoInlineGrayscaleCredit
expectedAsset: .logoInlineMonochromeCredit
)
}

Expand Down
Loading