Skip to content

Commit

Permalink
Fix vertical clipping of author name in status card
Browse files Browse the repository at this point in the history
Remove Mastodon logo and update color and font of author name text, moving towards the planned new layout design.

Fixes IOS-353
  • Loading branch information
whattherestimefor committed Jan 7, 2025
1 parent 2a2a002 commit 1e6ae17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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(_:)))
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit 1e6ae17

Please sign in to comment.