forked from zelo72/mastodon-ios
fix: set server rules text font and update to center alignment
This commit is contained in:
parent
99af62658f
commit
8ca0b5e447
|
@ -46,13 +46,7 @@ final class MastodonConfirmEmailViewController: UIViewController, NeedsDependenc
|
|||
|
||||
let openEmailButton: UIButton = {
|
||||
let button = UIButton(type: .system)
|
||||
button.titleLabel?.font = .preferredFont(forTextStyle: .headline)
|
||||
button.setBackgroundImage(UIImage.placeholder(color: Asset.Colors.brandBlue.color), for: .normal)
|
||||
button.setTitleColor(.white, for: .normal)
|
||||
button.setTitle(L10n.Scene.ConfirmEmail.Button.openEmailApp, for: .normal)
|
||||
button.layer.masksToBounds = true
|
||||
button.layer.cornerRadius = 8
|
||||
button.layer.cornerCurve = .continuous
|
||||
button.addTarget(self, action: #selector(openEmailButtonPressed(_:)), for: UIControl.Event.touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
|
|
@ -40,7 +40,7 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency
|
|||
|
||||
let rulesLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .preferredFont(forTextStyle: .body)
|
||||
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold))
|
||||
label.textColor = Asset.Colors.Label.primary.color
|
||||
label.text = "Rules"
|
||||
label.numberOfLines = 0
|
||||
|
@ -66,8 +66,6 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency
|
|||
|
||||
let confirmButton: PrimaryActionButton = {
|
||||
let button = PrimaryActionButton()
|
||||
button.titleLabel?.font = .preferredFont(forTextStyle: .headline)
|
||||
button.setTitleColor(.white, for: .normal)
|
||||
button.setTitle(L10n.Scene.ServerRules.Button.confirm, for: .normal)
|
||||
return button
|
||||
}()
|
||||
|
|
|
@ -36,14 +36,19 @@ final class MastodonServerRulesViewModel {
|
|||
var rulesAttributedString: NSAttributedString {
|
||||
let attributedString = NSMutableAttributedString(string: "\n")
|
||||
let configuration = UIImage.SymbolConfiguration(font: .preferredFont(forTextStyle: .title3))
|
||||
let separatorString = Array(repeating: " ", count: 4).joined()
|
||||
for (i, rule) in rules.enumerated() {
|
||||
guard i < 50 else {
|
||||
return NSAttributedString(string: "\(i)" + separatorString + rule.text + "\n\n")
|
||||
}
|
||||
let imageName = String(i + 1) + ".circle.fill"
|
||||
let image = UIImage(systemName: imageName, withConfiguration: configuration)!
|
||||
let attachment = NSTextAttachment()
|
||||
attachment.image = image.withTintColor(Asset.Colors.Label.primary.color)
|
||||
let imageAttribute = NSAttributedString(attachment: attachment)
|
||||
|
||||
let ruleString = NSAttributedString(string: " " + rule.text + "\n\n")
|
||||
let imageAttribute = NSMutableAttributedString(attachment: attachment)
|
||||
imageAttribute.addAttributes([NSAttributedString.Key.baselineOffset : -1.5], range: NSRange(location: 0, length: imageAttribute.length))
|
||||
|
||||
let ruleString = NSAttributedString(string: separatorString + rule.text + "\n\n")
|
||||
attributedString.append(imageAttribute)
|
||||
attributedString.append(ruleString)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ extension PrimaryActionButton {
|
|||
titleLabel?.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold))
|
||||
setTitleColor(.white, for: .normal)
|
||||
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.brandBlue.color), for: .normal)
|
||||
setupButtonBackground()
|
||||
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.brandBlueDarken20.color), for: .highlighted)
|
||||
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.disabled.color), for: .disabled)
|
||||
applyCornerRadius(radius: 10)
|
||||
}
|
||||
|
||||
|
@ -68,20 +69,4 @@ extension PrimaryActionButton {
|
|||
self.setTitle(originalButtonTitle, for: .disabled)
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
setupButtonBackground()
|
||||
}
|
||||
|
||||
func setupButtonBackground() {
|
||||
if UIScreen.main.traitCollection.userInterfaceStyle == .light {
|
||||
setTitleColor(.white, for: .disabled)
|
||||
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.Button.normal.color.withAlphaComponent(0.5)), for: .highlighted)
|
||||
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.Button.disabled.color), for: .disabled)
|
||||
|
||||
} else {
|
||||
setTitleColor(UIColor.white.withAlphaComponent(0.5), for: .disabled)
|
||||
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.brandBlue.color.withAlphaComponent(0.5)), for: .highlighted)
|
||||
setBackgroundImage(UIImage.placeholder(color: Asset.Colors.brandBlue.color.withAlphaComponent(0.5)), for: .disabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue