Compare commits
2 Commits
b470ee6401
...
176eb7c011
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 176eb7c011 | |
Shadowfacts | da9ca78a8b |
|
@ -22,7 +22,7 @@ class SuggestedProfileCardCollectionViewCell: UICollectionViewCell {
|
||||||
@IBOutlet weak var headerImageView: CachedImageView!
|
@IBOutlet weak var headerImageView: CachedImageView!
|
||||||
@IBOutlet weak var avatarContainerView: UIView!
|
@IBOutlet weak var avatarContainerView: UIView!
|
||||||
@IBOutlet weak var avatarImageView: CachedImageView!
|
@IBOutlet weak var avatarImageView: CachedImageView!
|
||||||
@IBOutlet weak var displayAndUserNameLabel: AccountDisplayNameLabel!
|
@IBOutlet weak var displayNameLabel: AccountDisplayNameLabel!
|
||||||
@IBOutlet weak var usernameLabel: UILabel!
|
@IBOutlet weak var usernameLabel: UILabel!
|
||||||
@IBOutlet weak var noteTextView: StatusContentTextView!
|
@IBOutlet weak var noteTextView: StatusContentTextView!
|
||||||
@IBOutlet weak var suggestionSourceButton: UIButton!
|
@IBOutlet weak var suggestionSourceButton: UIButton!
|
||||||
|
@ -49,8 +49,8 @@ class SuggestedProfileCardCollectionViewCell: UICollectionViewCell {
|
||||||
avatarImageView.layer.masksToBounds = true
|
avatarImageView.layer.masksToBounds = true
|
||||||
avatarImageView.layer.cornerCurve = .continuous
|
avatarImageView.layer.cornerCurve = .continuous
|
||||||
|
|
||||||
displayAndUserNameLabel.font = UIFontMetrics(forTextStyle: .title1).scaledFont(for: .systemFont(ofSize: 24, weight: .semibold))
|
displayNameLabel.font = UIFontMetrics(forTextStyle: .title1).scaledFont(for: .systemFont(ofSize: 24, weight: .semibold))
|
||||||
displayAndUserNameLabel.adjustsFontForContentSizeCategory = true
|
displayNameLabel.adjustsFontForContentSizeCategory = true
|
||||||
|
|
||||||
usernameLabel.font = UIFontMetrics.default.scaledFont(for: .systemFont(ofSize: 15, weight: .light))
|
usernameLabel.font = UIFontMetrics.default.scaledFont(for: .systemFont(ofSize: 15, weight: .light))
|
||||||
usernameLabel.adjustsFontForContentSizeCategory = true
|
usernameLabel.adjustsFontForContentSizeCategory = true
|
||||||
|
@ -96,7 +96,7 @@ class SuggestedProfileCardCollectionViewCell: UICollectionViewCell {
|
||||||
private func updateUIForPreferences(account: AccountMO) {
|
private func updateUIForPreferences(account: AccountMO) {
|
||||||
avatarContainerView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarContainerView)
|
avatarContainerView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarContainerView)
|
||||||
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)
|
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)
|
||||||
displayAndUserNameLabel.updateForAccountDisplayName(account: account)
|
displayNameLabel.updateForAccountDisplayName(account: account)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unneeded on visionOS since there is no light/dark mode
|
// Unneeded on visionOS since there is no light/dark mode
|
||||||
|
|
|
@ -135,12 +135,11 @@ private struct MockStatusCardView: UIViewRepresentable {
|
||||||
func makeUIView(context: Context) -> StatusCardView {
|
func makeUIView(context: Context) -> StatusCardView {
|
||||||
let view = StatusCardView()
|
let view = StatusCardView()
|
||||||
view.isUserInteractionEnabled = false
|
view.isUserInteractionEnabled = false
|
||||||
let card = Card(
|
let card = StatusCardView.CardData(
|
||||||
url: WebURL("https://vaccor.space/tusker")!,
|
url: WebURL("https://vaccor.space/tusker")!,
|
||||||
title: "Tusker",
|
|
||||||
description: "Tusker is an iOS app for Mastodon",
|
|
||||||
image: WebURL("https://vaccor.space/tusker/img/icon.png")!,
|
image: WebURL("https://vaccor.space/tusker/img/icon.png")!,
|
||||||
kind: .link
|
title: "Tusker",
|
||||||
|
description: "Tusker is an iOS app for Mastodon"
|
||||||
)
|
)
|
||||||
view.updateUI(card: card, sensitive: false)
|
view.updateUI(card: card, sensitive: false)
|
||||||
return view
|
return view
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
import Pachyderm
|
import Pachyderm
|
||||||
import SafariServices
|
import SafariServices
|
||||||
|
import WebURL
|
||||||
import WebURLFoundationExtras
|
import WebURLFoundationExtras
|
||||||
import HTMLStreamer
|
import HTMLStreamer
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ class StatusCardView: UIView {
|
||||||
weak var actionProvider: MenuActionProvider?
|
weak var actionProvider: MenuActionProvider?
|
||||||
|
|
||||||
private var statusID: String?
|
private var statusID: String?
|
||||||
private(set) var card: Card?
|
private(set) var card: CardData?
|
||||||
|
|
||||||
private static let activeBackgroundColor = UIColor.secondarySystemFill
|
private static let activeBackgroundColor = UIColor.secondarySystemFill
|
||||||
private static let inactiveBackgroundColor = UIColor.secondarySystemBackground
|
private static let inactiveBackgroundColor = UIColor.secondarySystemBackground
|
||||||
|
@ -163,20 +164,22 @@ class StatusCardView: UIView {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUI(status: StatusMO) {
|
func updateUI(status: StatusMO) {
|
||||||
guard status.id != statusID else {
|
let newData = status.card.map { CardData(card: $0) }
|
||||||
|
guard self.card != newData else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.card = status.card
|
self.card = newData
|
||||||
self.statusID = status.id
|
self.statusID = status.id
|
||||||
|
|
||||||
guard let card = status.card else {
|
guard let newData else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUI(card: card, sensitive: status.sensitive)
|
updateUI(card: newData, sensitive: status.sensitive)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUI(card: Card, sensitive: Bool) {
|
// This method is internal for use by MockStatusView
|
||||||
|
func updateUI(card: CardData, sensitive: Bool) {
|
||||||
if let image = card.image {
|
if let image = card.image {
|
||||||
if sensitive {
|
if sensitive {
|
||||||
if let blurhash = card.blurhash {
|
if let blurhash = card.blurhash {
|
||||||
|
@ -243,6 +246,30 @@ class StatusCardView: UIView {
|
||||||
hStack.backgroundColor = StatusCardView.inactiveBackgroundColor
|
hStack.backgroundColor = StatusCardView.inactiveBackgroundColor
|
||||||
setNeedsDisplay()
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue