Improves error toast view appearance

This commit is contained in:
Riley Testut
2020-03-19 15:02:35 -07:00
parent a2acbcd5b5
commit 63c55b41ec
2 changed files with 5 additions and 5 deletions

View File

@@ -25,14 +25,14 @@ class ToastView: RSTToastView
super.init(text: text, detailText: detailedText) super.init(text: text, detailText: detailedText)
self.layoutMargins = UIEdgeInsets(top: 8, left: 12, bottom: 8, right: 12) self.layoutMargins = UIEdgeInsets(top: 8, left: 16, bottom: 10, right: 16)
self.setNeedsLayout() self.setNeedsLayout()
if let stackView = self.textLabel.superview as? UIStackView if let stackView = self.textLabel.superview as? UIStackView
{ {
// RSTToastView does not expose stack view containing labels, // RSTToastView does not expose stack view containing labels,
// so we access it indirectly as the labels' superview. // so we access it indirectly as the labels' superview.
stackView.spacing = 4.0 stackView.spacing = (detailedText != nil) ? 4.0 : 0.0
} }
} }
@@ -46,7 +46,7 @@ class ToastView: RSTToastView
if let failure = error.localizedFailure if let failure = error.localizedFailure
{ {
text = failure text = failure
detailText = error.localizedFailureReason ?? error.localizedRecoverySuggestion detailText = error.localizedFailureReason ?? error.localizedRecoverySuggestion ?? error.localizedDescription
} }
else if let reason = error.localizedFailureReason else if let reason = error.localizedFailureReason
{ {
@@ -71,7 +71,7 @@ class ToastView: RSTToastView
super.layoutSubviews() super.layoutSubviews()
// Rough calculation to determine height of ToastView with one-line textLabel. // Rough calculation to determine height of ToastView with one-line textLabel.
let minimumHeight = self.textLabel.font.lineHeight.rounded() + 20 let minimumHeight = self.textLabel.font.lineHeight.rounded() + 18
self.layer.cornerRadius = minimumHeight/2 self.layer.cornerRadius = minimumHeight/2
} }

View File

@@ -490,7 +490,7 @@ private extension MyAppsViewController
} }
let error = failures.first?.value as NSError? let error = failures.first?.value as NSError?
let detailText = error?.localizedFailureReason ?? error?.localizedDescription let detailText = error?.localizedFailure ?? error?.localizedFailureReason ?? error?.localizedDescription
toastView = ToastView(text: localizedText, detailText: detailText) toastView = ToastView(text: localizedText, detailText: detailText)
toastView.preferredDuration = 4.0 toastView.preferredDuration = 4.0