Conversation
| /// - Parameters: | ||
| /// - template: The promotional text to be displayed, including a placeholder if needed (e.g. "Buy now or pay later with {partner}") | ||
| /// - substitution: An optional tuple containing the placeholder text from the template to be replaced and the partner logo image to replace it with. | ||
| static func bnplPromoString( |
There was a problem hiding this comment.
Separated this back out into two separate implementations — one for PMME and one for the afterpay header. They do pretty different things at this point, and the afterpay one is about to be removed and replaced with PMME anyways
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| verticalFittingPriority: .fittingSizeLevel | ||
| ) | ||
| label.bounds = CGRect(origin: .zero, size: size) | ||
| STPSnapshotVerifyView(label, identifier: identifier, file: file, line: line) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -0,0 +1,103 @@ | |||
| // | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| // Originally based on https://stackoverflow.com/questions/26105803/center-nstextattachment-image-next-to-single-line-uilabel | ||
| private static func boundsOfImage(font: UIFont, uiImage: UIImage, additionalScale: CGFloat) -> CGRect { | ||
| let scaledSize = uiImage.sizeMatchingFont(font, additionalScale: additionalScale) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -25,7 +25,12 @@ extension PaymentMethodMessagingElement { | |||
| let legalDisclosure = paymentPlan.content.legalDisclosure?.message | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -16,71 +16,71 @@ | |||
| @MainActor | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @MainActor | ||
| class NSAttributedStringStripeSnapshotTests: STPSnapshotTestCase { | ||
|
|
||
| func testBnplPromoString_UILabel_ImageAsset() { | ||
| func testPmmePromoString_UILabel_ImageAsset() { | ||
| let template = "Buy now or pay later with <img/>" | ||
| let image = Image.affirm_copy.makeImage() | ||
| let attributedString = NSMutableAttributedString.bnplPromoString( | ||
| let attributedString = NSMutableAttributedString.pmmePromoString( | ||
| font: .boldSystemFont(ofSize: 20), | ||
| textColor: UIColor(red: 0.2, green: 0.4, blue: 0.8, alpha: 1.0), | ||
| infoIconColor: UIColor.purple, | ||
| template: template, | ||
| substitution: ("<img/>", image) | ||
| substitution: ("<img/>", image), | ||
| infoMessage: "Learn more" | ||
| ) | ||
|
|
||
| let label = UILabel() | ||
| label.attributedText = attributedString | ||
| label.numberOfLines = 0 | ||
|
|
||
| verify(label) | ||
| } | ||
|
|
||
| func testBnplPromoString_UILabel_SystemImage() { | ||
| func testPmmePromoString_UILabel_SystemImage() { | ||
| let template = "4 interest-free payments of $12.50 with {partner}" | ||
| let systemImage = UIImage(systemName: "creditcard.fill")! | ||
| let attributedString = NSMutableAttributedString.bnplPromoString( | ||
| let attributedString = NSMutableAttributedString.pmmePromoString( | ||
| font: .systemFont(ofSize: 14), | ||
| textColor: .darkGray, | ||
| infoIconColor: UIColor.red, | ||
| template: template, | ||
| substitution: ("{partner}", systemImage) | ||
| substitution: ("{partner}", systemImage), | ||
| infoMessage: "Learn more" | ||
| ) | ||
|
|
||
| let label = UILabel() | ||
| label.attributedText = attributedString | ||
| label.numberOfLines = 0 | ||
|
|
||
| verify(label) | ||
| } | ||
|
|
||
| func testBnplPromoString_UILabel_NoSubstitution() { | ||
| func testPmmePromoString_UILabel_NoSubstitution() { | ||
| let template = "Flexible payment options available" | ||
| let attributedString = NSMutableAttributedString.bnplPromoString( | ||
| let attributedString = NSMutableAttributedString.pmmePromoString( | ||
| font: .italicSystemFont(ofSize: 14), | ||
| textColor: UIColor(red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0), | ||
| infoIconColor: UIColor.green, | ||
| template: template, | ||
| substitution: nil | ||
| substitution: nil, | ||
| infoMessage: "Learn more" | ||
| ) | ||
|
|
||
| let label = UILabel() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Summary
Motivation
https://docs.google.com/document/d/1mxe5BEBBm37WL4vPESXAvE5nyKtnafk1mpmyCdR4iwU/edit?tab=t.8fq4xew6ey9y#heading=h.7wfc335i71xh
Testing
Changelog