2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Fix vertical clipping of author name in status card

Remove Mastodon logo and update color and font of author name text, moving towards the planned new layout design.

Fixes IOS-353
This commit is contained in:
shannon 2025-01-07 09:34:40 -05:00
parent 2a2a002f2e
commit 1e6ae1796e
2 changed files with 12 additions and 22 deletions

View File

@ -10,7 +10,8 @@ class StatusCardAuthorControl: UIControl {
public override init(frame: CGRect) {
authorLabel = UILabel()
authorLabel.textAlignment = .center
authorLabel.font = UIFontMetrics(forTextStyle: .footnote).scaledFont(for: .systemFont(ofSize: 16, weight: .bold))
authorLabel.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 15, weight: .semibold))
authorLabel.textColor = .systemIndigo
authorLabel.isUserInteractionEnabled = false
avatarImage = AvatarImageView()
@ -30,20 +31,22 @@ class StatusCardAuthorControl: UIControl {
addSubview(contentStackView)
setupConstraints()
backgroundColor = Asset.Colors.Button.userFollowing.color
layer.cornerRadius = 10
layer.cornerRadius = 6
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
private let verticalPadding: CGFloat = 4
private let horizontalPadding: CGFloat = 6
private func setupConstraints() {
let constraints = [
contentStackView.topAnchor.constraint(equalTo: topAnchor, constant: 6),
contentStackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 6),
trailingAnchor.constraint(equalTo: contentStackView.trailingAnchor, constant: 6),
bottomAnchor.constraint(equalTo: contentStackView.bottomAnchor, constant: 6),
contentStackView.topAnchor.constraint(equalTo: topAnchor, constant: verticalPadding),
contentStackView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: horizontalPadding),
trailingAnchor.constraint(equalTo: contentStackView.trailingAnchor, constant: horizontalPadding),
bottomAnchor.constraint(equalTo: contentStackView.bottomAnchor, constant: verticalPadding),
avatarImage.widthAnchor.constraint(equalToConstant: 16),
avatarImage.widthAnchor.constraint(equalTo: avatarImage.heightAnchor).priority(.defaultHigh),
avatarImage.widthAnchor.constraint(equalToConstant: 20),
avatarImage.widthAnchor.constraint(equalTo: avatarImage.heightAnchor).priority(.required),
]
NSLayoutConstraint.activate(constraints)

View File

@ -73,7 +73,6 @@ public final class StatusCardControl: UIControl {
private let authorDivider: UIView
private let mastodonLogoImageView: UIImageView
private let byLabel: UILabel
private let authorLabel: UILabel
private let authorAccountButton: StatusCardAuthorControl
@ -108,11 +107,6 @@ public final class StatusCardControl: UIControl {
// mainContentStackView - vertical in .large, horizontal in .compact, holds imageView and labelStackView
// authorStackView - always vertical, has an avatar button if the author has an account, otherwise shows author information as text
let mastodonLogo = Asset.Scene.Sidebar.logo.image.withRenderingMode(.alwaysTemplate)
mastodonLogoImageView = UIImageView(image: mastodonLogo)
mastodonLogoImageView.tintColor = .gray
mastodonLogoImageView.translatesAutoresizingMaskIntoConstraints = false
byLabel = UILabel()
byLabel.text = L10n.Common.Controls.Status.Card.by
byLabel.numberOfLines = 1
@ -148,7 +142,7 @@ public final class StatusCardControl: UIControl {
authorAccountButton = StatusCardAuthorControl()
authorStackView = UIStackView(arrangedSubviews: [mastodonLogoImageView, byLabel, authorLabel, authorAccountButton, UIView()])
authorStackView = UIStackView(arrangedSubviews: [byLabel, authorLabel, authorAccountButton, UIView()])
authorStackView.alignment = .fill//.center
authorStackView.layoutMargins = .init(top: 10, left: 16, bottom: 10, right: 16)
authorStackView.isLayoutMarginsRelativeArrangement = true
@ -269,7 +263,6 @@ public final class StatusCardControl: UIControl {
authorAccountButton.isHidden = false
authorLabel.isHidden = true
byLabel.isHidden = false
mastodonLogoImageView.isHidden = false
self.author = account
authorAccountButton.addTarget(self, action: #selector(StatusCardControl.profileTapped(_:)), for: .touchUpInside)
@ -287,7 +280,6 @@ public final class StatusCardControl: UIControl {
author = nil
authorLabel.isHidden = false
byLabel.isHidden = true
mastodonLogoImageView.isHidden = true
authorAccountButton.isHidden = true
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(StatusCardControl.contentTapped(_:)))
@ -398,11 +390,6 @@ public final class StatusCardControl: UIControl {
imageDividerView.isHidden = layout == .noPreviewImage
}
layoutConstraints.append(contentsOf: [
mastodonLogoImageView.widthAnchor.constraint(equalToConstant: 20),
mastodonLogoImageView.heightAnchor.constraint(equalTo: mastodonLogoImageView.widthAnchor),
])
NSLayoutConstraint.activate(layoutConstraints)
invalidateIntrinsicContentSize()
}