From 108c6af575ee84c12d5ade94eaaad14a491cb459 Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 11 May 2021 17:07:08 +0800 Subject: [PATCH] fix: notification setting label accessibility layout issue --- .../Scene/Settings/SettingsViewController.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Mastodon/Scene/Settings/SettingsViewController.swift b/Mastodon/Scene/Settings/SettingsViewController.swift index 3d6ebc470..1c69ef6c5 100644 --- a/Mastodon/Scene/Settings/SettingsViewController.swift +++ b/Mastodon/Scene/Settings/SettingsViewController.swift @@ -56,24 +56,22 @@ class SettingsViewController: UIViewController, NeedsDependency { view.translatesAutoresizingMaskIntoConstraints = false view.isLayoutMarginsRelativeArrangement = true view.axis = .horizontal - view.alignment = .fill - view.distribution = .equalSpacing view.spacing = 4 return view }() + let notifyLabel = UILabel() private(set) lazy var notifySectionHeader: UIView = { let view = notifySectionHeaderStackView - - let notifyLabel = UILabel() notifyLabel.translatesAutoresizingMaskIntoConstraints = false + notifyLabel.adjustsFontForContentSizeCategory = true notifyLabel.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: UIFont.systemFont(ofSize: 20, weight: .semibold)) notifyLabel.textColor = Asset.Colors.Label.primary.color notifyLabel.text = L10n.Scene.Settings.Section.Notifications.Trigger.title - // accessibility - notifyLabel.numberOfLines = 0 view.addArrangedSubview(notifyLabel) view.addArrangedSubview(whoButton) + whoButton.setContentHuggingPriority(.defaultHigh + 1, for: .horizontal) + whoButton.setContentHuggingPriority(.defaultHigh + 1, for: .vertical) return view }() @@ -83,6 +81,7 @@ class SettingsViewController: UIViewController, NeedsDependency { whoButton.showsMenuAsPrimaryAction = true whoButton.setBackgroundColor(Asset.Colors.battleshipGrey.color, for: .normal) whoButton.setTitleColor(Asset.Colors.Label.primary.color, for: .normal) + whoButton.titleLabel?.adjustsFontForContentSizeCategory = true whoButton.titleLabel?.font = UIFontMetrics(forTextStyle: .title3).scaledFont(for: UIFont.systemFont(ofSize: 20, weight: .semibold)) whoButton.contentEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5) whoButton.layer.cornerRadius = 10 @@ -113,6 +112,7 @@ class SettingsViewController: UIViewController, NeedsDependency { view.alignment = .center let label = ActiveLabel(style: .default) + label.adjustsFontForContentSizeCategory = true label.textAlignment = .center label.configure(content: "Mastodon is open source software. You can contribute or report issues on GitHub at tootsuite/mastodon (v3.3.0).", emojiDict: [:]) label.delegate = self @@ -153,10 +153,13 @@ class SettingsViewController: UIViewController, NeedsDependency { // MAKR: - Private methods private func updateSectionHeaderStackViewLayout() { + // accessibility if traitCollection.preferredContentSizeCategory < .accessibilityMedium { notifySectionHeaderStackView.axis = .horizontal + notifyLabel.numberOfLines = 1 } else { notifySectionHeaderStackView.axis = .vertical + notifyLabel.numberOfLines = 0 } }