Fix confirm reblog alert not adjusting to Dynamic Type

Closes #246
This commit is contained in:
Shadowfacts 2022-11-13 17:15:06 -05:00
parent 71f97d41c4
commit 06ad46e639
2 changed files with 9 additions and 5 deletions

View File

@ -76,6 +76,7 @@ class CustomAlertController: UIViewController {
let titleLabel = UILabel() let titleLabel = UILabel()
titleLabel.text = config.title titleLabel.text = config.title
titleLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0) titleLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0)
titleLabel.adjustsFontForContentSizeCategory = true
titleLabel.numberOfLines = 0 titleLabel.numberOfLines = 0
titleLabel.textAlignment = .center titleLabel.textAlignment = .center
stack.addArrangedSubview(titleLabel) stack.addArrangedSubview(titleLabel)
@ -361,13 +362,14 @@ class CustomAlertActionButton: UIControl {
let label = UILabel() let label = UILabel()
label.text = title label.text = title
label.textColor = .tintColor label.textColor = .tintColor
switch action.style { label.adjustsFontForContentSizeCategory = true
case .cancel: if case .cancel = action.style {
label.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .body).withSymbolicTraits(.traitBold)!, size: 0) 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 label.textColor = .systemRed
default:
break
} }
titleView.addArrangedSubview(label) titleView.addArrangedSubview(label)
} }

View File

@ -55,6 +55,7 @@ class ConfirmReblogStatusPreviewView: UIView {
let displayNameLabel = EmojiLabel() let displayNameLabel = EmojiLabel()
displayNameLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .caption1).addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]), size: 0) displayNameLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .caption1).addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]), size: 0)
displayNameLabel.adjustsFontSizeToFitWidth = true displayNameLabel.adjustsFontSizeToFitWidth = true
displayNameLabel.adjustsFontForContentSizeCategory = true
displayNameLabel.updateForAccountDisplayName(account: status.account) displayNameLabel.updateForAccountDisplayName(account: status.account)
vStack.addArrangedSubview(displayNameLabel) vStack.addArrangedSubview(displayNameLabel)
@ -64,6 +65,7 @@ class ConfirmReblogStatusPreviewView: UIView {
contentView.isScrollEnabled = false contentView.isScrollEnabled = false
contentView.backgroundColor = nil contentView.backgroundColor = nil
contentView.textContainerInset = .zero 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 // remove the extra line spacing applied by StatusContentTextView because, since we're using a smaller font, the regular 2pt looks big
contentView.paragraphStyle = .default contentView.paragraphStyle = .default
// TODO: line limit // TODO: line limit