feat: make dynamic type font adapt accessibility level font size
This commit is contained in:
parent
4901b50d3b
commit
55943db9bc
|
@ -47,7 +47,7 @@ final class AttachmentContainerView: UIView {
|
||||||
textView.showsVerticalScrollIndicator = false
|
textView.showsVerticalScrollIndicator = false
|
||||||
textView.backgroundColor = .clear
|
textView.backgroundColor = .clear
|
||||||
textView.textColor = .white
|
textView.textColor = .white
|
||||||
textView.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15))
|
textView.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15), maximumPointSize: 20)
|
||||||
textView.placeholder = L10n.Scene.Compose.Attachment.descriptionPhoto
|
textView.placeholder = L10n.Scene.Compose.Attachment.descriptionPhoto
|
||||||
textView.placeholderColor = UIColor.white.withAlphaComponent(0.6) // force white with alpha for Light/Dark mode
|
textView.placeholderColor = UIColor.white.withAlphaComponent(0.6) // force white with alpha for Light/Dark mode
|
||||||
textView.returnKeyType = .done
|
textView.returnKeyType = .done
|
||||||
|
|
|
@ -50,7 +50,7 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
|
||||||
let actionLabel: UILabel = {
|
let actionLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.secondary.color
|
label.textColor = Asset.Colors.Label.secondary.color
|
||||||
label.font = UIFont.preferredFont(forTextStyle: .body)
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular), maximumPointSize: 20)
|
||||||
label.lineBreakMode = .byTruncatingTail
|
label.lineBreakMode = .byTruncatingTail
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
@ -58,7 +58,7 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
|
||||||
let nameLabel: UILabel = {
|
let nameLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.brandBlue.color
|
label.textColor = Asset.Colors.brandBlue.color
|
||||||
label.font = .systemFont(ofSize: 15, weight: .semibold)
|
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold), maximumPointSize: 20)
|
||||||
label.lineBreakMode = .byTruncatingTail
|
label.lineBreakMode = .byTruncatingTail
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -67,7 +67,7 @@ final class NotificationTableViewCell: UITableViewCell {
|
||||||
let actionLabel: UILabel = {
|
let actionLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.secondary.color
|
label.textColor = Asset.Colors.Label.secondary.color
|
||||||
label.font = UIFont.preferredFont(forTextStyle: .body)
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular), maximumPointSize: 20)
|
||||||
label.lineBreakMode = .byTruncatingTail
|
label.lineBreakMode = .byTruncatingTail
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
@ -75,7 +75,7 @@ final class NotificationTableViewCell: UITableViewCell {
|
||||||
let nameLabel: UILabel = {
|
let nameLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.brandBlue.color
|
label.textColor = Asset.Colors.brandBlue.color
|
||||||
label.font = .systemFont(ofSize: 15, weight: .semibold)
|
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold), maximumPointSize: 20)
|
||||||
label.lineBreakMode = .byTruncatingTail
|
label.lineBreakMode = .byTruncatingTail
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -34,7 +34,7 @@ class PickServerCell: UITableViewCell {
|
||||||
|
|
||||||
let domainLabel: UILabel = {
|
let domainLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.font = .preferredFont(forTextStyle: .headline)
|
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22)
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.adjustsFontForContentSizeCategory = true
|
label.adjustsFontForContentSizeCategory = true
|
||||||
label.translatesAutoresizingMaskIntoConstraints = false
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -52,7 +52,7 @@ class PickServerCell: UITableViewCell {
|
||||||
|
|
||||||
let descriptionLabel: UILabel = {
|
let descriptionLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.font = .preferredFont(forTextStyle: .subheadline)
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15, weight: .regular))
|
||||||
label.numberOfLines = 0
|
label.numberOfLines = 0
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.adjustsFontForContentSizeCategory = true
|
label.adjustsFontForContentSizeCategory = true
|
||||||
|
@ -106,7 +106,7 @@ class PickServerCell: UITableViewCell {
|
||||||
let langValueLabel: UILabel = {
|
let langValueLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.font = UIFontMetrics(forTextStyle: .title2).scaledFont(for: UIFont.systemFont(ofSize: 22, weight: .semibold))
|
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 22, weight: .semibold), maximumPointSize: 27)
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
label.adjustsFontForContentSizeCategory = true
|
label.adjustsFontForContentSizeCategory = true
|
||||||
label.translatesAutoresizingMaskIntoConstraints = false
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -116,7 +116,7 @@ class PickServerCell: UITableViewCell {
|
||||||
let usersValueLabel: UILabel = {
|
let usersValueLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.font = UIFontMetrics(forTextStyle: .title2).scaledFont(for: UIFont.systemFont(ofSize: 22, weight: .semibold))
|
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 22, weight: .semibold), maximumPointSize: 27)
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
label.adjustsFontForContentSizeCategory = true
|
label.adjustsFontForContentSizeCategory = true
|
||||||
label.translatesAutoresizingMaskIntoConstraints = false
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -126,7 +126,7 @@ class PickServerCell: UITableViewCell {
|
||||||
let categoryValueLabel: UILabel = {
|
let categoryValueLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.font = UIFontMetrics(forTextStyle: .title2).scaledFont(for: UIFont.systemFont(ofSize: 22, weight: .semibold))
|
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 22, weight: .semibold), maximumPointSize: 27)
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
label.adjustsFontForContentSizeCategory = true
|
label.adjustsFontForContentSizeCategory = true
|
||||||
label.translatesAutoresizingMaskIntoConstraints = false
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -136,7 +136,7 @@ class PickServerCell: UITableViewCell {
|
||||||
let langTitleLabel: UILabel = {
|
let langTitleLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.font = .preferredFont(forTextStyle: .caption2)
|
label.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 11, weight: .regular), maximumPointSize: 16)
|
||||||
label.text = L10n.Scene.ServerPicker.Label.language
|
label.text = L10n.Scene.ServerPicker.Label.language
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
label.adjustsFontForContentSizeCategory = true
|
label.adjustsFontForContentSizeCategory = true
|
||||||
|
@ -147,7 +147,7 @@ class PickServerCell: UITableViewCell {
|
||||||
let usersTitleLabel: UILabel = {
|
let usersTitleLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.font = .preferredFont(forTextStyle: .caption2)
|
label.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 11, weight: .regular), maximumPointSize: 16)
|
||||||
label.text = L10n.Scene.ServerPicker.Label.users
|
label.text = L10n.Scene.ServerPicker.Label.users
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
label.adjustsFontForContentSizeCategory = true
|
label.adjustsFontForContentSizeCategory = true
|
||||||
|
@ -158,7 +158,7 @@ class PickServerCell: UITableViewCell {
|
||||||
let categoryTitleLabel: UILabel = {
|
let categoryTitleLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.font = .preferredFont(forTextStyle: .caption2)
|
label.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 11, weight: .regular), maximumPointSize: 16)
|
||||||
label.text = L10n.Scene.ServerPicker.Label.category
|
label.text = L10n.Scene.ServerPicker.Label.category
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
label.adjustsFontForContentSizeCategory = true
|
label.adjustsFontForContentSizeCategory = true
|
||||||
|
|
|
@ -63,6 +63,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: UIFont.boldSystemFont(ofSize: 34))
|
label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: UIFont.boldSystemFont(ofSize: 34))
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.text = L10n.Scene.Register.title
|
label.text = L10n.Scene.Register.title
|
||||||
|
label.numberOfLines = 0
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
|
|
||||||
let domainLabel: UILabel = {
|
let domainLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.font = .preferredFont(forTextStyle: .headline)
|
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22)
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
@ -113,7 +114,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
textField.textColor = Asset.Colors.Label.primary.color
|
textField.textColor = Asset.Colors.Label.primary.color
|
||||||
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Username.placeholder,
|
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Username.placeholder,
|
||||||
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
||||||
NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .headline)])
|
NSAttributedString.Key.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22)])
|
||||||
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
||||||
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
||||||
textField.leftView = paddingView
|
textField.leftView = paddingView
|
||||||
|
@ -136,7 +137,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
textField.textColor = Asset.Colors.Label.primary.color
|
textField.textColor = Asset.Colors.Label.primary.color
|
||||||
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.DisplayName.placeholder,
|
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.DisplayName.placeholder,
|
||||||
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
||||||
NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .headline)])
|
NSAttributedString.Key.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22)])
|
||||||
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
||||||
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
||||||
textField.leftView = paddingView
|
textField.leftView = paddingView
|
||||||
|
@ -153,7 +154,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
textField.textColor = Asset.Colors.Label.primary.color
|
textField.textColor = Asset.Colors.Label.primary.color
|
||||||
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Email.placeholder,
|
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Email.placeholder,
|
||||||
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
||||||
NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .headline)])
|
NSAttributedString.Key.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22)])
|
||||||
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
||||||
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
||||||
textField.leftView = paddingView
|
textField.leftView = paddingView
|
||||||
|
@ -178,7 +179,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
textField.textColor = Asset.Colors.Label.primary.color
|
textField.textColor = Asset.Colors.Label.primary.color
|
||||||
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Password.placeholder,
|
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Password.placeholder,
|
||||||
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
||||||
NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .headline)])
|
NSAttributedString.Key.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22)])
|
||||||
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
||||||
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
||||||
textField.leftView = paddingView
|
textField.leftView = paddingView
|
||||||
|
@ -208,7 +209,7 @@ final class MastodonRegisterViewController: UIViewController, NeedsDependency, O
|
||||||
textField.textColor = Asset.Colors.Label.primary.color
|
textField.textColor = Asset.Colors.Label.primary.color
|
||||||
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Invite.registrationUserInviteRequest,
|
textField.attributedPlaceholder = NSAttributedString(string: L10n.Scene.Register.Input.Invite.registrationUserInviteRequest,
|
||||||
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
attributes: [NSAttributedString.Key.foregroundColor: Asset.Colors.Label.secondary.color,
|
||||||
NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .headline)])
|
NSAttributedString.Key.font: UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 22)])
|
||||||
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
textField.borderStyle = UITextField.BorderStyle.roundedRect
|
||||||
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 5, height: textField.frame.height))
|
||||||
textField.leftView = paddingView
|
textField.leftView = paddingView
|
||||||
|
|
|
@ -223,7 +223,7 @@ extension MastodonRegisterViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
static func attributeStringForPassword(validateState: ValidateState) -> NSAttributedString {
|
static func attributeStringForPassword(validateState: ValidateState) -> NSAttributedString {
|
||||||
let font = UIFont.preferredFont(forTextStyle: .caption1)
|
let font = UIFontMetrics(forTextStyle: .caption1).scaledFont(for: .systemFont(ofSize: 13, weight: .regular), maximumPointSize: 18)
|
||||||
let attributeString = NSMutableAttributedString()
|
let attributeString = NSMutableAttributedString()
|
||||||
|
|
||||||
let image = MastodonRegisterViewModel.checkmarkImage(font: font)
|
let image = MastodonRegisterViewModel.checkmarkImage(font: font)
|
||||||
|
@ -236,7 +236,7 @@ extension MastodonRegisterViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
static func errorPromptAttributedString(for prompt: String) -> NSAttributedString {
|
static func errorPromptAttributedString(for prompt: String) -> NSAttributedString {
|
||||||
let font = UIFont.preferredFont(forTextStyle: .caption1)
|
let font = UIFontMetrics(forTextStyle: .caption1).scaledFont(for: .systemFont(ofSize: 13, weight: .regular), maximumPointSize: 18)
|
||||||
let attributeString = NSMutableAttributedString()
|
let attributeString = NSMutableAttributedString()
|
||||||
|
|
||||||
let image = MastodonRegisterViewModel.xmarkImage(font: font)
|
let image = MastodonRegisterViewModel.xmarkImage(font: font)
|
||||||
|
|
|
@ -25,6 +25,7 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency
|
||||||
label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 34, weight: .bold))
|
label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 34, weight: .bold))
|
||||||
label.textColor = .label
|
label.textColor = .label
|
||||||
label.text = L10n.Scene.ServerRules.title
|
label.text = L10n.Scene.ServerRules.title
|
||||||
|
label.numberOfLines = 0
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency
|
||||||
|
|
||||||
private(set) lazy var bottomPromptTextView: UITextView = {
|
private(set) lazy var bottomPromptTextView: UITextView = {
|
||||||
let textView = UITextView()
|
let textView = UITextView()
|
||||||
textView.font = .preferredFont(forTextStyle: .body)
|
textView.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .regular), maximumPointSize: 22)
|
||||||
textView.textColor = .label
|
textView.textColor = .label
|
||||||
textView.isSelectable = true
|
textView.isSelectable = true
|
||||||
textView.isEditable = false
|
textView.isEditable = false
|
||||||
|
@ -181,7 +182,7 @@ extension MastodonServerRulesViewController {
|
||||||
let str = NSString(string: L10n.Scene.ServerRules.prompt(viewModel.domain))
|
let str = NSString(string: L10n.Scene.ServerRules.prompt(viewModel.domain))
|
||||||
let termsOfServiceRange = str.range(of: L10n.Scene.ServerRules.termsOfService)
|
let termsOfServiceRange = str.range(of: L10n.Scene.ServerRules.termsOfService)
|
||||||
let privacyRange = str.range(of: L10n.Scene.ServerRules.privacyPolicy)
|
let privacyRange = str.range(of: L10n.Scene.ServerRules.privacyPolicy)
|
||||||
let attributeString = NSMutableAttributedString(string: L10n.Scene.ServerRules.prompt(viewModel.domain), attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body), NSAttributedString.Key.foregroundColor: UIColor.label])
|
let attributeString = NSMutableAttributedString(string: L10n.Scene.ServerRules.prompt(viewModel.domain), attributes: [NSAttributedString.Key.font: UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .regular), maximumPointSize: 22), NSAttributedString.Key.foregroundColor: UIColor.label])
|
||||||
attributeString.addAttribute(.link, value: Mastodon.API.serverRulesURL(domain: viewModel.domain), range: termsOfServiceRange)
|
attributeString.addAttribute(.link, value: Mastodon.API.serverRulesURL(domain: viewModel.domain), range: termsOfServiceRange)
|
||||||
attributeString.addAttribute(.link, value: Mastodon.API.privacyURL(domain: viewModel.domain), range: privacyRange)
|
attributeString.addAttribute(.link, value: Mastodon.API.privacyURL(domain: viewModel.domain), range: privacyRange)
|
||||||
let linkAttributes = [NSAttributedString.Key.foregroundColor:linkColor]
|
let linkAttributes = [NSAttributedString.Key.foregroundColor:linkColor]
|
||||||
|
|
|
@ -100,7 +100,7 @@ final class ProfileHeaderView: UIView {
|
||||||
|
|
||||||
let nameTextField: UITextField = {
|
let nameTextField: UITextField = {
|
||||||
let textField = UITextField()
|
let textField = UITextField()
|
||||||
textField.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 20, weight: .semibold))
|
textField.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 20, weight: .semibold), maximumPointSize: 28)
|
||||||
textField.textColor = .white
|
textField.textColor = .white
|
||||||
textField.text = "Alice"
|
textField.text = "Alice"
|
||||||
textField.autocorrectionType = .no
|
textField.autocorrectionType = .no
|
||||||
|
@ -111,7 +111,7 @@ final class ProfileHeaderView: UIView {
|
||||||
|
|
||||||
let usernameLabel: UILabel = {
|
let usernameLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 15, weight: .regular))
|
label.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 15, weight: .regular), maximumPointSize: 20)
|
||||||
label.adjustsFontSizeToFitWidth = true
|
label.adjustsFontSizeToFitWidth = true
|
||||||
label.minimumScaleFactor = 0.5
|
label.minimumScaleFactor = 0.5
|
||||||
label.textColor = Asset.Scene.Profile.Banner.usernameGray.color
|
label.textColor = Asset.Scene.Profile.Banner.usernameGray.color
|
||||||
|
|
|
@ -51,21 +51,27 @@ class SettingsViewController: UIViewController, NeedsDependency {
|
||||||
return menu
|
return menu
|
||||||
}
|
}
|
||||||
|
|
||||||
private(set) lazy var notifySectionHeader: UIView = {
|
private let notifySectionHeaderStackView: UIStackView = {
|
||||||
let view = UIStackView()
|
let view = UIStackView()
|
||||||
view.translatesAutoresizingMaskIntoConstraints = false
|
view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
view.isLayoutMarginsRelativeArrangement = true
|
view.isLayoutMarginsRelativeArrangement = true
|
||||||
//view.layoutMargins = UIEdgeInsets(top: 15, left: 4, bottom: 5, right: 4)
|
|
||||||
view.axis = .horizontal
|
view.axis = .horizontal
|
||||||
view.alignment = .fill
|
view.alignment = .fill
|
||||||
view.distribution = .equalSpacing
|
view.distribution = .equalSpacing
|
||||||
view.spacing = 4
|
view.spacing = 4
|
||||||
|
return view
|
||||||
|
}()
|
||||||
|
|
||||||
|
private(set) lazy var notifySectionHeader: UIView = {
|
||||||
|
let view = notifySectionHeaderStackView
|
||||||
|
|
||||||
let notifyLabel = UILabel()
|
let notifyLabel = UILabel()
|
||||||
notifyLabel.translatesAutoresizingMaskIntoConstraints = false
|
notifyLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||||
notifyLabel.font = UIFontMetrics(forTextStyle: .title3).scaledFont(for: UIFont.systemFont(ofSize: 20, weight: .semibold))
|
notifyLabel.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: UIFont.systemFont(ofSize: 20, weight: .semibold))
|
||||||
notifyLabel.textColor = Asset.Colors.Label.primary.color
|
notifyLabel.textColor = Asset.Colors.Label.primary.color
|
||||||
notifyLabel.text = L10n.Scene.Settings.Section.Notifications.Trigger.title
|
notifyLabel.text = L10n.Scene.Settings.Section.Notifications.Trigger.title
|
||||||
|
// accessibility
|
||||||
|
notifyLabel.numberOfLines = 0
|
||||||
view.addArrangedSubview(notifyLabel)
|
view.addArrangedSubview(notifyLabel)
|
||||||
view.addArrangedSubview(whoButton)
|
view.addArrangedSubview(whoButton)
|
||||||
return view
|
return view
|
||||||
|
@ -138,7 +144,22 @@ class SettingsViewController: UIViewController, NeedsDependency {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
|
super.traitCollectionDidChange(previousTraitCollection)
|
||||||
|
|
||||||
|
updateSectionHeaderStackViewLayout()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// MAKR: - Private methods
|
// MAKR: - Private methods
|
||||||
|
private func updateSectionHeaderStackViewLayout() {
|
||||||
|
if traitCollection.preferredContentSizeCategory < .accessibilityMedium {
|
||||||
|
notifySectionHeaderStackView.axis = .horizontal
|
||||||
|
} else {
|
||||||
|
notifySectionHeaderStackView.axis = .vertical
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func bindViewModel() {
|
private func bindViewModel() {
|
||||||
self.whoButton.setTitle(viewModel.setting.value.activeSubscription?.policy.title, for: .normal)
|
self.whoButton.setTitle(viewModel.setting.value.activeSubscription?.policy.title, for: .normal)
|
||||||
viewModel.setting
|
viewModel.setting
|
||||||
|
@ -173,6 +194,8 @@ class SettingsViewController: UIViewController, NeedsDependency {
|
||||||
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||||
])
|
])
|
||||||
setupTableView()
|
setupTableView()
|
||||||
|
|
||||||
|
updateSectionHeaderStackViewLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupNavigation() {
|
private func setupNavigation() {
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ContentWarningOverlayView: UIView {
|
||||||
}()
|
}()
|
||||||
let blurContentWarningTitleLabel: UILabel = {
|
let blurContentWarningTitleLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17))
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17), maximumPointSize: 23)
|
||||||
label.text = L10n.Common.Controls.Status.mediaContentWarning
|
label.text = L10n.Common.Controls.Status.mediaContentWarning
|
||||||
label.textColor = Asset.Colors.Label.primary.color
|
label.textColor = Asset.Colors.Label.primary.color
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
|
@ -44,7 +44,7 @@ class ContentWarningOverlayView: UIView {
|
||||||
}()
|
}()
|
||||||
let blurContentWarningLabel: UILabel = {
|
let blurContentWarningLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15))
|
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 15), maximumPointSize: 20)
|
||||||
label.text = L10n.Common.Controls.Status.mediaContentWarning
|
label.text = L10n.Common.Controls.Status.mediaContentWarning
|
||||||
label.textColor = Asset.Colors.Label.secondary.color
|
label.textColor = Asset.Colors.Label.secondary.color
|
||||||
label.textAlignment = .center
|
label.textAlignment = .center
|
||||||
|
|
|
@ -71,7 +71,7 @@ final class StatusView: UIView {
|
||||||
|
|
||||||
let headerInfoLabel: UILabel = {
|
let headerInfoLabel: UILabel = {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
label.font = UIFontMetrics(forTextStyle: .footnote).scaledFont(for: .systemFont(ofSize: 13, weight: .medium))
|
label.font = UIFontMetrics(forTextStyle: .footnote).scaledFont(for: .systemFont(ofSize: 13, weight: .medium), maximumPointSize: 17)
|
||||||
label.textColor = Asset.Colors.Label.secondary.color
|
label.textColor = Asset.Colors.Label.secondary.color
|
||||||
label.text = "Bob reblogged"
|
label.text = "Bob reblogged"
|
||||||
return label
|
return label
|
||||||
|
|
|
@ -34,6 +34,14 @@ final class ThreadMetaView: UIView {
|
||||||
return button
|
return button
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
let containerStackView: UIStackView = {
|
||||||
|
let stackView = UIStackView()
|
||||||
|
stackView.axis = .horizontal
|
||||||
|
stackView.spacing = 20
|
||||||
|
return stackView
|
||||||
|
}()
|
||||||
|
let actionButtonStackView = UIStackView()
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
_init()
|
_init()
|
||||||
|
@ -48,27 +56,48 @@ final class ThreadMetaView: UIView {
|
||||||
|
|
||||||
extension ThreadMetaView {
|
extension ThreadMetaView {
|
||||||
private func _init() {
|
private func _init() {
|
||||||
let stackView = UIStackView()
|
|
||||||
stackView.axis = .horizontal
|
|
||||||
stackView.spacing = 20
|
|
||||||
|
|
||||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
containerStackView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
addSubview(stackView)
|
addSubview(containerStackView)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
stackView.topAnchor.constraint(equalTo: topAnchor, constant: 8),
|
containerStackView.topAnchor.constraint(equalTo: topAnchor, constant: 8),
|
||||||
stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
containerStackView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||||
stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
containerStackView.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||||
bottomAnchor.constraint(equalTo: stackView.bottomAnchor, constant: 12),
|
bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor, constant: 12),
|
||||||
])
|
])
|
||||||
|
|
||||||
stackView.addArrangedSubview(dateLabel)
|
containerStackView.addArrangedSubview(dateLabel)
|
||||||
stackView.addArrangedSubview(reblogButton)
|
containerStackView.addArrangedSubview(actionButtonStackView)
|
||||||
stackView.addArrangedSubview(favoriteButton)
|
|
||||||
|
actionButtonStackView.axis = .horizontal
|
||||||
|
actionButtonStackView.addArrangedSubview(reblogButton)
|
||||||
|
actionButtonStackView.addArrangedSubview(favoriteButton)
|
||||||
|
|
||||||
dateLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
dateLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
||||||
reblogButton.setContentHuggingPriority(.required - 2, for: .horizontal)
|
reblogButton.setContentHuggingPriority(.required - 2, for: .horizontal)
|
||||||
favoriteButton.setContentHuggingPriority(.required - 1, for: .horizontal)
|
favoriteButton.setContentHuggingPriority(.required - 1, for: .horizontal)
|
||||||
|
|
||||||
|
updateContainerLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
|
super.traitCollectionDidChange(previousTraitCollection)
|
||||||
|
|
||||||
|
updateContainerLayout()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateContainerLayout() {
|
||||||
|
if traitCollection.preferredContentSizeCategory < .accessibilityMedium {
|
||||||
|
containerStackView.axis = .horizontal
|
||||||
|
containerStackView.spacing = 20
|
||||||
|
dateLabel.numberOfLines = 1
|
||||||
|
} else {
|
||||||
|
containerStackView.axis = .vertical
|
||||||
|
containerStackView.spacing = 4
|
||||||
|
dateLabel.numberOfLines = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if canImport(SwiftUI) && DEBUG
|
#if canImport(SwiftUI) && DEBUG
|
||||||
|
|
Loading…
Reference in New Issue