Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convergence asset update #282

Merged
merged 2 commits into from
Feb 27, 2025
Merged

Convergence asset update #282

merged 2 commits into from
Feb 27, 2025

Conversation

squarepaul
Copy link
Collaborator

@squarepaul squarepaul commented Feb 26, 2025

Summary of Changes

  • Introduces the concept of a migrated Brand to CashAppAfterpay using isCashAppAfterpayRegion
  • Creates a new set of ColorPalettes and maps the existing and new color configurations to them
  • Creates a new set of assets for both Mono and Poly chrome to match for a new enCashAppAfterpay locale
  • Logic to fail if a merchant in a migrated regions tries to use a badge or compact-badge (lockups only)
  • Logic to use the right color scheme and asset dependent on if in the migrated region or not
  • Default everything to "default" scheme
    https://docs.google.com/document/d/1SZYkcTyi5Y5NyclJJu6wHWEZAT6oHFyGZVgX5MhhTI8/edit?tab=t.0

Items of Note

Submission Checklist

  • Tests are included.
  • Documentation is changed or added.

@squarepaul
Copy link
Collaborator Author

Legacy Views:
Simulator Screenshot - iPhone 16 Pro Max - 2025-02-26 at 11 07 51
Simulator Screenshot - iPhone 16 Pro Max - 2025-02-26 at 11 07 25

@squarepaul
Copy link
Collaborator Author

CashAppAfterpay Branding:
Screenshot 2025-02-25 at 4 56 29 PM

Copy link
Collaborator

@mmroz mmroz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of thoughts:

  1. If we go with this approach to silently swap views then we will need to communicate these changes to avoid merchant confusion

  2. This changes public API so it will be a breaking change. Have we considered a non-breaking approach and deprecating then removing no longer supported views?

Comment on lines 36 to -40
public enum ColorPalette {
case blackOnMint
case mintOnBlack
case whiteOnBlack
case blackOnWhite
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a breaking change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but that was intentional to get the US merchants to update the UI since it is new. Also we're not marketing non-US partners to update but we should have good documentation on how the new values map to the old ones just in case they do end up updating for some reason

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every other asset is a PNG, is there a reason we are moving to SVG?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SVG is better for static images like logos since it scales better, but tbh I didn't think it would make a difference and wanted to use the same assets as Android, was there a reason why PNG or PDF was used before?

foregroundImageView.tintColor = color.foreground
}

private func resolveColorScheme(palette: ColorPalette?) -> (foreground: UIColor?, background: UIColor?) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does palette need to be optional here?

Comment on lines 26 to 32
if Afterpay.isCashAppAfterpayRegion {
var color = colorScheme.lightPalette.foregroundCashAppAfterpay
if traitCollection.userInterfaceStyle == .dark {
color = colorScheme.darkPalette.foregroundCashAppAfterpay
}
return color
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can be cleaned up with a guard?

@@ -416,6 +416,10 @@ internal var brand: Brand {
Brand.forLocale(locale: getLocale())
}

public var isCashAppAfterpayRegion: Bool {
Brand.forLocale(locale: getLocale()).isCashAppAfterpayRegion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not completely sure but you might want to double check that getLocale() works with getV3Configuration

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok? it looks like the v3 endpoint ends up calling setConfiguration which is required to have a locale.

Also that same exact code is used in several other places:

https://github.com/afterpay/sdk-ios/blob/master/Sources/Afterpay/Views/LogoView.swift#L68

https://github.com/afterpay/sdk-ios/blob/master/Sources/Afterpay/Afterpay.swift#L416

I've updated to just use the brand computed property

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok here - correct me if I'm wrong @mmroz, but my understanding is that for any of the assets to work anyway the Brand needs to be set which is done by having a locale set through via setConfiguration. Configuration also contains things like min/max amounts for SDK consumers so that they can show the Pay with ${brand} messaging.

So I believe if consumers of the SDK want to use v3 + the assets, they need to set Configuration and CheckoutV3Configuration.

@squarepaul squarepaul force-pushed the convergence-asset-update branch from 59030fa to 7663874 Compare February 27, 2025 20:09
@squarepaul squarepaul requested a review from mmroz February 27, 2025 20:22
@squarepaul squarepaul force-pushed the convergence-asset-update branch from 7663874 to dfe6f3b Compare February 27, 2025 20:34
@squarepaul
Copy link
Collaborator Author

Couple of thoughts:

  1. If we go with this approach to silently swap views then we will need to communicate these changes to avoid merchant confusion
    If the merchant updates it wouldn't silently swap but the API would break and it would force them to select the UI assets that make sense for them, which is the behavior that we want since the assets are markedly different from the legacy ones. There is one scenario where a non-US user updates and they would need documentation to see how the new values map to the old ones which we're working on.
  1. This changes public API so it will be a breaking change. Have we considered a non-breaking approach and deprecating then removing no longer supported views?
    We can't deprecate the old ones since they are still being used in certain regions. I do think we need to think about how to re-structure the selection and treatment of UI since now there are many dimensions that go into that decisioning

@squarepaul squarepaul merged commit 7c26aca into master Feb 27, 2025
3 checks passed
@squarepaul squarepaul deleted the convergence-asset-update branch February 27, 2025 21:43
@@ -70,7 +70,7 @@ final class CartViewController: UIViewController, UITableViewDataSource {

if Afterpay.enabled {
let payButton: UIButton = PaymentButton(
colorScheme: .dynamic(lightPalette: .blackOnMint, darkPalette: .mintOnBlack),
colorScheme: .dynamic(lightPalette: .default, darkPalette: .lightMono),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean to change the colors here? i thought the updated mappings were:
.blackOnMint.alt
.mintOnBlack.default

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea that's true, I'm actually going to overhaul this entire view to include more permutations and ability to select region

@@ -12,7 +12,7 @@ private let localeLanguages: [Locale: Drawables] = [
Locales.enAU: .enAfterpay,
Locales.enGB: .enClearpay,
Locales.enNZ: .enAfterpay,
Locales.enUS: .enAfterpay,
Locales.enUS: .enCashAppAfterpay,
Locales.enUSposix: .enAfterpay,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should Locales.enUSposix be changed to .enCashAppAfterpay too, since it's now a Cash App Afterpay locale according to Brand.swift?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you for the catch!

override public init(colorScheme: ColorScheme = .static(.blackOnMint)) {
override public init(colorScheme: ColorScheme = .static(.default)) {
if Afterpay.isCashAppAfterpayRegion {
assertionFailure("Cash App Afterpay badge is not supported")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the context behind not supporting BadgeView and CompactBadgeView? what happens if a merchant was previously using them in a Cash App Afterpay region?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would crash, which is what we would want since there are no assets associated with them in the CashAppAfterpay branding. We should include in the documentation to use the Lockup assets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants