Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix 4593: Crash in Onboarding when accessibility is extremely large
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T authored Dec 14, 2021
1 parent 017a9fe commit f699f2a
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,17 @@ class WelcomeViewCallout: UIView {

detailsLabel.do {
$0.text = details
$0.font = .preferredFont(forTextStyle: .body)
// Calling .preferredFont(forTextStyle: .body) will freeze the app, and crash!
// It creates an Out of Memory exception if the font is not .scaledFont!
// This is an OS bug. Fortunately our extension creates a scaled font properly.
$0.font = .preferredFont(for: .body, weight: .regular)
$0.alpha = 1.0
$0.isHidden = false
}

primaryButton.do {
$0.setTitle(buttonTitle, for: .normal)
$0.titleLabel?.font = .preferredFont(forTextStyle: .body)
$0.titleLabel?.font = .preferredFont(for: .body, weight: .regular)
$0.addAction(UIAction(identifier: .init(rawValue: "primary.action"), handler: { _ in
action()
}), for: .touchUpInside)
Expand Down Expand Up @@ -309,14 +312,14 @@ class WelcomeViewCallout: UIView {

detailsLabel.do {
$0.text = info.details
$0.font = .preferredFont(forTextStyle: .body)
$0.font = .preferredFont(for: .body, weight: .regular)
$0.alpha = 1.0
$0.isHidden = false
}

primaryButton.do {
$0.setTitle(info.primaryButtonTitle, for: .normal)
$0.titleLabel?.font = .preferredFont(forTextStyle: .body)
$0.titleLabel?.font = .preferredFont(for: .body, weight: .regular)
$0.addAction(UIAction(identifier: .init(rawValue: "primary.action"), handler: { _ in
info.primaryAction()
}), for: .touchUpInside)
Expand Down Expand Up @@ -362,14 +365,14 @@ class WelcomeViewCallout: UIView {

detailsLabel.do {
$0.text = info.details
$0.font = .preferredFont(forTextStyle: .body)
$0.font = .preferredFont(for: .body, weight: .regular)
$0.alpha = 1.0
$0.isHidden = false
}

primaryButton.do {
$0.setTitle(info.primaryButtonTitle, for: .normal)
$0.titleLabel?.font = .preferredFont(forTextStyle: .body)
$0.titleLabel?.font = .preferredFont(for: .body, weight: .regular)
$0.addAction(UIAction(identifier: .init(rawValue: "primary.action"), handler: { _ in
info.primaryAction()
}), for: .touchUpInside)
Expand All @@ -380,7 +383,7 @@ class WelcomeViewCallout: UIView {
secondaryLabel.do {
$0.text = Strings.Callout.defaultBrowserCalloutSecondaryButtonDescription
$0.textAlignment = .right
$0.font = .preferredFont(forTextStyle: .body)
$0.font = .preferredFont(for: .body, weight: .regular)
$0.alpha = 1.0
$0.isHidden = false
$0.numberOfLines = 1
Expand Down Expand Up @@ -417,7 +420,7 @@ class WelcomeViewCallout: UIView {

detailsLabel.do {
$0.text = "\(details)\n\(moreDetails)"
$0.font = .preferredFont(forTextStyle: .body)
$0.font = .preferredFont(for: .body, weight: .regular)
$0.alpha = 1.0
$0.isHidden = false
}
Expand Down

0 comments on commit f699f2a

Please sign in to comment.