Compare commits

..

No commits in common. "176eb7c011897dba3869bafe0015dce7ecebaf04" and "b470ee6401f01bf31cf157fbcd603019072d59b5" have entirely different histories.

3 changed files with 14 additions and 40 deletions

View File

@ -22,7 +22,7 @@ class SuggestedProfileCardCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var headerImageView: CachedImageView!
@IBOutlet weak var avatarContainerView: UIView!
@IBOutlet weak var avatarImageView: CachedImageView!
@IBOutlet weak var displayNameLabel: AccountDisplayNameLabel!
@IBOutlet weak var displayAndUserNameLabel: AccountDisplayNameLabel!
@IBOutlet weak var usernameLabel: UILabel!
@IBOutlet weak var noteTextView: StatusContentTextView!
@IBOutlet weak var suggestionSourceButton: UIButton!
@ -49,8 +49,8 @@ class SuggestedProfileCardCollectionViewCell: UICollectionViewCell {
avatarImageView.layer.masksToBounds = true
avatarImageView.layer.cornerCurve = .continuous
displayNameLabel.font = UIFontMetrics(forTextStyle: .title1).scaledFont(for: .systemFont(ofSize: 24, weight: .semibold))
displayNameLabel.adjustsFontForContentSizeCategory = true
displayAndUserNameLabel.font = UIFontMetrics(forTextStyle: .title1).scaledFont(for: .systemFont(ofSize: 24, weight: .semibold))
displayAndUserNameLabel.adjustsFontForContentSizeCategory = true
usernameLabel.font = UIFontMetrics.default.scaledFont(for: .systemFont(ofSize: 15, weight: .light))
usernameLabel.adjustsFontForContentSizeCategory = true
@ -96,7 +96,7 @@ class SuggestedProfileCardCollectionViewCell: UICollectionViewCell {
private func updateUIForPreferences(account: AccountMO) {
avatarContainerView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarContainerView)
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)
displayNameLabel.updateForAccountDisplayName(account: account)
displayAndUserNameLabel.updateForAccountDisplayName(account: account)
}
// Unneeded on visionOS since there is no light/dark mode

View File

@ -135,11 +135,12 @@ private struct MockStatusCardView: UIViewRepresentable {
func makeUIView(context: Context) -> StatusCardView {
let view = StatusCardView()
view.isUserInteractionEnabled = false
let card = StatusCardView.CardData(
let card = Card(
url: WebURL("https://vaccor.space/tusker")!,
image: WebURL("https://vaccor.space/tusker/img/icon.png")!,
title: "Tusker",
description: "Tusker is an iOS app for Mastodon"
description: "Tusker is an iOS app for Mastodon",
image: WebURL("https://vaccor.space/tusker/img/icon.png")!,
kind: .link
)
view.updateUI(card: card, sensitive: false)
return view

View File

@ -9,7 +9,6 @@
import UIKit
import Pachyderm
import SafariServices
import WebURL
import WebURLFoundationExtras
import HTMLStreamer
@ -19,7 +18,7 @@ class StatusCardView: UIView {
weak var actionProvider: MenuActionProvider?
private var statusID: String?
private(set) var card: CardData?
private(set) var card: Card?
private static let activeBackgroundColor = UIColor.secondarySystemFill
private static let inactiveBackgroundColor = UIColor.secondarySystemBackground
@ -164,22 +163,20 @@ class StatusCardView: UIView {
}
func updateUI(status: StatusMO) {
let newData = status.card.map { CardData(card: $0) }
guard self.card != newData else {
guard status.id != statusID else {
return
}
self.card = newData
self.card = status.card
self.statusID = status.id
guard let newData else {
guard let card = status.card else {
return
}
updateUI(card: newData, sensitive: status.sensitive)
updateUI(card: card, sensitive: status.sensitive)
}
// This method is internal for use by MockStatusView
func updateUI(card: CardData, sensitive: Bool) {
func updateUI(card: Card, sensitive: Bool) {
if let image = card.image {
if sensitive {
if let blurhash = card.blurhash {
@ -247,30 +244,6 @@ class StatusCardView: UIView {
setNeedsDisplay()
}
struct CardData: Equatable {
let url: WebURL
let image: WebURL?
let title: String
let description: String
let blurhash: String?
init(card: Card) {
self.url = card.url
self.image = card.image
self.title = card.title
self.description = card.description
self.blurhash = card.blurhash
}
init(url: WebURL, image: WebURL? = nil, title: String, description: String, blurhash: String? = nil) {
self.url = url
self.image = image
self.title = title
self.description = description
self.blurhash = blurhash
}
}
}
extension StatusCardView: UIContextMenuInteractionDelegate {