|
|
@@ -442,6 +442,8 @@ private final class PaywallProductsErrorView: NSView, AppearanceRefreshable {
|
|
|
|
|
|
private let messageLabel = NSTextField(wrappingLabelWithString: "")
|
|
|
private let retryButton = PaywallFooterLink(title: "")
|
|
|
+ private var retryTopConstraint: NSLayoutConstraint!
|
|
|
+ private var retryBottomConstraint: NSLayoutConstraint!
|
|
|
|
|
|
init() {
|
|
|
super.init(frame: .zero)
|
|
|
@@ -462,14 +464,17 @@ private final class PaywallProductsErrorView: NSView, AppearanceRefreshable {
|
|
|
addSubview(messageLabel)
|
|
|
addSubview(retryButton)
|
|
|
|
|
|
+ retryTopConstraint = retryButton.topAnchor.constraint(equalTo: messageLabel.bottomAnchor, constant: 8)
|
|
|
+ retryBottomConstraint = retryButton.bottomAnchor.constraint(equalTo: bottomAnchor)
|
|
|
+
|
|
|
NSLayoutConstraint.activate([
|
|
|
messageLabel.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
|
messageLabel.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
|
messageLabel.topAnchor.constraint(equalTo: topAnchor),
|
|
|
|
|
|
retryButton.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
|
- retryButton.topAnchor.constraint(equalTo: messageLabel.bottomAnchor, constant: 8),
|
|
|
- retryButton.bottomAnchor.constraint(equalTo: bottomAnchor),
|
|
|
+ retryTopConstraint,
|
|
|
+ retryBottomConstraint,
|
|
|
])
|
|
|
}
|
|
|
|
|
|
@@ -480,10 +485,22 @@ private final class PaywallProductsErrorView: NSView, AppearanceRefreshable {
|
|
|
let messages = PaywallConfigService.shared.config.messages
|
|
|
messageLabel.stringValue = message
|
|
|
retryButton.isHidden = false
|
|
|
+ setCollapsed(false)
|
|
|
retryButton.isEnabled = !isRetrying
|
|
|
retryButton.updateTitle(isRetrying ? messages.retrying : messages.retry)
|
|
|
}
|
|
|
|
|
|
+ func setCollapsed(_ collapsed: Bool) {
|
|
|
+ if collapsed {
|
|
|
+ NSLayoutConstraint.deactivate([retryTopConstraint, retryBottomConstraint])
|
|
|
+ retryButton.isHidden = true
|
|
|
+ messageLabel.stringValue = ""
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ NSLayoutConstraint.activate([retryTopConstraint, retryBottomConstraint])
|
|
|
+ }
|
|
|
+
|
|
|
func refreshAppearance() {
|
|
|
messageLabel.textColor = AppTheme.textSecondary
|
|
|
retryButton.refreshAppearance()
|
|
|
@@ -867,6 +884,7 @@ final class PaywallView: NSView, AppearanceRefreshable {
|
|
|
let isRetrying = hasLoadFailure && store.isLoadingProducts
|
|
|
|
|
|
productsErrorView.isHidden = !hasLoadFailure
|
|
|
+ productsErrorView.setCollapsed(!hasLoadFailure)
|
|
|
plansStack.isHidden = hasLoadFailure || store.availablePlans.isEmpty
|
|
|
let visiblePlanCount = hasLoadFailure ? 0 : store.availablePlans.count
|
|
|
refreshPlansLayout(planCount: visiblePlanCount)
|