From 06ad46e639cb98787c3ce9b3114e7fbd86d7e270 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 13 Nov 2022 17:15:06 -0500 Subject: [PATCH] Fix confirm reblog alert not adjusting to Dynamic Type Closes #246 --- Tusker/Screens/Utilities/CustomAlertController.swift | 12 +++++++----- Tusker/Views/ConfirmReblogStatusPreviewView.swift | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Tusker/Screens/Utilities/CustomAlertController.swift b/Tusker/Screens/Utilities/CustomAlertController.swift index 870709de..b5cd14bd 100644 --- a/Tusker/Screens/Utilities/CustomAlertController.swift +++ b/Tusker/Screens/Utilities/CustomAlertController.swift @@ -76,6 +76,7 @@ class CustomAlertController: UIViewController { let titleLabel = UILabel() titleLabel.text = config.title titleLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0) + titleLabel.adjustsFontForContentSizeCategory = true titleLabel.numberOfLines = 0 titleLabel.textAlignment = .center stack.addArrangedSubview(titleLabel) @@ -361,13 +362,14 @@ class CustomAlertActionButton: UIControl { let label = UILabel() label.text = title label.textColor = .tintColor - switch action.style { - case .cancel: + label.adjustsFontForContentSizeCategory = true + if case .cancel = action.style { label.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0) - case .destructive: + } else { + label.font = .preferredFont(forTextStyle: .body) + } + if case .destructive = action.style { label.textColor = .systemRed - default: - break } titleView.addArrangedSubview(label) } diff --git a/Tusker/Views/ConfirmReblogStatusPreviewView.swift b/Tusker/Views/ConfirmReblogStatusPreviewView.swift index 89028ebe..1d68ee6b 100644 --- a/Tusker/Views/ConfirmReblogStatusPreviewView.swift +++ b/Tusker/Views/ConfirmReblogStatusPreviewView.swift @@ -55,6 +55,7 @@ class ConfirmReblogStatusPreviewView: UIView { let displayNameLabel = EmojiLabel() displayNameLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .caption1).addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]), size: 0) displayNameLabel.adjustsFontSizeToFitWidth = true + displayNameLabel.adjustsFontForContentSizeCategory = true displayNameLabel.updateForAccountDisplayName(account: status.account) vStack.addArrangedSubview(displayNameLabel) @@ -64,6 +65,7 @@ class ConfirmReblogStatusPreviewView: UIView { contentView.isScrollEnabled = false contentView.backgroundColor = nil contentView.textContainerInset = .zero + contentView.adjustsFontForContentSizeCategory = true // remove the extra line spacing applied by StatusContentTextView because, since we're using a smaller font, the regular 2pt looks big contentView.paragraphStyle = .default // TODO: line limit