-
Notifications
You must be signed in to change notification settings - Fork 21
fix crash from using legacy UI from cashappafterpay locale #288
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,12 @@ import UIKit | |
| public class CompactBadgeView: AfterpayLogo { | ||
| override public init(colorScheme: ColorScheme = .static(.default)) { | ||
| if Afterpay.isCashAppAfterpayRegion { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for this view |
||
| assertionFailure("Cash App Afterpay compact badge is not supported") | ||
| #if DEBUG | ||
| assertionFailure("Cash App Afterpay compact badge is not supported") | ||
| #endif | ||
| } | ||
| super.init(colorScheme: colorScheme) | ||
| if Afterpay.isCashAppAfterpayRegion { self.isHidden = true } | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,17 +72,15 @@ public class AfterpayLogo: UIView { | |
| deactivateConstraints() | ||
|
|
||
| let color = getImageColor() | ||
| image = AfterpayAssetProvider.image(named: getImageName(brand: brand.details.lowerCaseName, color: color)) | ||
|
|
||
| ratio = image!.size.height / image!.size.width | ||
|
|
||
| imageView.image = image | ||
| imageView.translatesAutoresizingMaskIntoConstraints = false | ||
|
|
||
| addSubview(imageView) | ||
|
|
||
| setImageViewConstraints() | ||
| setupConstraints() | ||
| if let image = AfterpayAssetProvider.image(named: getImageName(brand: brand.details.lowerCaseName, color: color)) { | ||
| self.image = image | ||
| ratio = image.size.height / image.size.width | ||
| imageView.image = image | ||
| imageView.translatesAutoresizingMaskIntoConstraints = false | ||
| addSubview(imageView) | ||
| setImageViewConstraints() | ||
| setupConstraints() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the other constraints added in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, since we use attributes in the image to calculate the constraints (the ratio) we shouldn't setup constraints unless the image exists. Could be changed to use a more modern layout method |
||
| } | ||
| } | ||
|
|
||
| internal func setImageViewConstraints() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may read a little better than running the same
isCashAppAfterpayRegioncheck twice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I agree, but self must first be init'd before we can set it to hidden