fix crash from using legacy UI from cashappafterpay locale#288
Conversation
kruegermj
left a comment
There was a problem hiding this comment.
What would the state of these views be if the region is not supported?
| @@ -12,9 +12,12 @@ import UIKit | |||
| public class BadgeView: AfterpayLogo { | |||
| override public init(colorScheme: ColorScheme = .static(.default)) { | |||
| if Afterpay.isCashAppAfterpayRegion { | |||
There was a problem hiding this comment.
This may read a little better than running the same isCashAppAfterpayRegion check twice.
| if Afterpay.isCashAppAfterpayRegion { | |
| if Afterpay.isCashAppAfterpayRegion { | |
| self.isHidden = true | |
| #if DEBUG | |
| assertionFailure("Cash App Afterpay compact badge is not supported") | |
| #endif | |
| } | |
| super.init(colorScheme: colorScheme) |
There was a problem hiding this comment.
yes I agree, but self must first be init'd before we can set it to hidden
| @@ -12,9 +12,12 @@ import UIKit | |||
| public class CompactBadgeView: AfterpayLogo { | |||
| override public init(colorScheme: ColorScheme = .static(.default)) { | |||
| if Afterpay.isCashAppAfterpayRegion { | |||
| imageView.translatesAutoresizingMaskIntoConstraints = false | ||
| addSubview(imageView) | ||
| setImageViewConstraints() | ||
| setupConstraints() |
There was a problem hiding this comment.
Should the other constraints added in setupConstraints still be added if there is no image? What does this view render like with no image?
There was a problem hiding this comment.
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
The idea is in debug, it will crash so the implementers will know not to use that UI, but if for some reason they still end up using it we don't want to crash it production albeit less than ideal UI (it's hidden). |
5265192 to
74e255b
Compare
Summary of Changes
Items of Note
Submission Checklist