forked from shadowfacts/Tusker
Revert "Unseparate out updateStatusState method"
This reverts commit 2157126332
.
This commit is contained in:
parent
ae8191ca0e
commit
76b9496fe6
|
@ -348,24 +348,6 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
||||||
accountDetailAccessibilityElement.navigationDelegate = delegate
|
accountDetailAccessibilityElement.navigationDelegate = delegate
|
||||||
accountDetailAccessibilityElement.accountID = accountID
|
accountDetailAccessibilityElement.accountID = accountID
|
||||||
|
|
||||||
let metaButtonAttributes = AttributeContainer([
|
|
||||||
.font: ConversationMainStatusCollectionViewCell.metaFont
|
|
||||||
])
|
|
||||||
|
|
||||||
let favoritesFormat = NSLocalizedString("favorites count", comment: "conv main status favorites button label")
|
|
||||||
var favoritesConfig = UIButton.Configuration.plain()
|
|
||||||
favoritesConfig.baseForegroundColor = .secondaryLabel
|
|
||||||
favoritesConfig.attributedTitle = AttributedString(String.localizedStringWithFormat(favoritesFormat, status.favouritesCount), attributes: metaButtonAttributes)
|
|
||||||
favoritesConfig.contentInsets = .zero
|
|
||||||
favoritesCountButton.configuration = favoritesConfig
|
|
||||||
|
|
||||||
let reblogsFormat = NSLocalizedString("reblogs count", comment: "conv main status reblogs button label")
|
|
||||||
var reblogsConfig = UIButton.Configuration.plain()
|
|
||||||
reblogsConfig.baseForegroundColor = .secondaryLabel
|
|
||||||
reblogsConfig.attributedTitle = AttributedString(String.localizedStringWithFormat(reblogsFormat, status.reblogsCount), attributes: metaButtonAttributes)
|
|
||||||
reblogsConfig.contentInsets = .zero
|
|
||||||
reblogsCountButton.configuration = reblogsConfig
|
|
||||||
|
|
||||||
var timestampAndClientText = ConversationMainStatusCollectionViewCell.dateFormatter.string(from: status.createdAt)
|
var timestampAndClientText = ConversationMainStatusCollectionViewCell.dateFormatter.string(from: status.createdAt)
|
||||||
if let application = status.applicationName {
|
if let application = status.applicationName {
|
||||||
timestampAndClientText += " • \(application)"
|
timestampAndClientText += " • \(application)"
|
||||||
|
@ -376,7 +358,9 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
||||||
editTimestampButton.isHidden = false
|
editTimestampButton.isHidden = false
|
||||||
var config = UIButton.Configuration.plain()
|
var config = UIButton.Configuration.plain()
|
||||||
config.baseForegroundColor = .secondaryLabel
|
config.baseForegroundColor = .secondaryLabel
|
||||||
config.attributedTitle = AttributedString("Edited on \(ConversationMainStatusCollectionViewCell.dateFormatter.string(from: editedAt))", attributes: metaButtonAttributes)
|
config.attributedTitle = AttributedString("Edited on \(ConversationMainStatusCollectionViewCell.dateFormatter.string(from: editedAt))", attributes: AttributeContainer([
|
||||||
|
.font: ConversationMainStatusCollectionViewCell.metaFont
|
||||||
|
]))
|
||||||
config.contentInsets = .zero
|
config.contentInsets = .zero
|
||||||
editTimestampButton.configuration = config
|
editTimestampButton.configuration = config
|
||||||
} else {
|
} else {
|
||||||
|
@ -392,6 +376,28 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
||||||
baseCreateObservers()
|
baseCreateObservers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateStatusState(status: StatusMO) {
|
||||||
|
baseUpdateStatusState(status: status)
|
||||||
|
|
||||||
|
let attributes = AttributeContainer([
|
||||||
|
.font: ConversationMainStatusCollectionViewCell.metaFont
|
||||||
|
])
|
||||||
|
|
||||||
|
let favoritesFormat = NSLocalizedString("favorites count", comment: "conv main status favorites button label")
|
||||||
|
var favoritesConfig = UIButton.Configuration.plain()
|
||||||
|
favoritesConfig.baseForegroundColor = .secondaryLabel
|
||||||
|
favoritesConfig.attributedTitle = AttributedString(String.localizedStringWithFormat(favoritesFormat, status.favouritesCount), attributes: attributes)
|
||||||
|
favoritesConfig.contentInsets = .zero
|
||||||
|
favoritesCountButton.configuration = favoritesConfig
|
||||||
|
|
||||||
|
let reblogsFormat = NSLocalizedString("reblogs count", comment: "conv main status reblogs button label")
|
||||||
|
var reblogsConfig = UIButton.Configuration.plain()
|
||||||
|
reblogsConfig.baseForegroundColor = .secondaryLabel
|
||||||
|
reblogsConfig.attributedTitle = AttributedString(String.localizedStringWithFormat(reblogsFormat, status.reblogsCount), attributes: attributes)
|
||||||
|
reblogsConfig.contentInsets = .zero
|
||||||
|
reblogsCountButton.configuration = reblogsConfig
|
||||||
|
}
|
||||||
|
|
||||||
func updateUIForPreferences(status: StatusMO) {
|
func updateUIForPreferences(status: StatusMO) {
|
||||||
baseUpdateUIForPreferences(status: status)
|
baseUpdateUIForPreferences(status: status)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ protocol StatusCollectionViewCell: UICollectionViewCell, AttachmentViewDelegate
|
||||||
var cancellables: Set<AnyCancellable> { get set }
|
var cancellables: Set<AnyCancellable> { get set }
|
||||||
|
|
||||||
func updateUIForPreferences(status: StatusMO)
|
func updateUIForPreferences(status: StatusMO)
|
||||||
|
func updateStatusState(status: StatusMO)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: UI Configuration
|
// MARK: UI Configuration
|
||||||
|
@ -98,6 +99,7 @@ extension StatusCollectionViewCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUIForPreferences(status: status)
|
updateUIForPreferences(status: status)
|
||||||
|
updateStatusState(status: status)
|
||||||
|
|
||||||
contentWarningLabel.text = status.spoilerText
|
contentWarningLabel.text = status.spoilerText
|
||||||
contentWarningLabel.isHidden = status.spoilerText.isEmpty
|
contentWarningLabel.isHidden = status.spoilerText.isEmpty
|
||||||
|
@ -105,29 +107,9 @@ extension StatusCollectionViewCell {
|
||||||
contentWarningLabel.setEmojis(status.emojis, identifier: statusID)
|
contentWarningLabel.setEmojis(status.emojis, identifier: statusID)
|
||||||
}
|
}
|
||||||
|
|
||||||
replyButton.isEnabled = mastodonController.loggedIn
|
|
||||||
|
|
||||||
favoriteButton.isEnabled = mastodonController.loggedIn
|
|
||||||
if status.favourited {
|
|
||||||
favoriteButton.tintColor = UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1)
|
|
||||||
favoriteButton.accessibilityLabel = NSLocalizedString("Undo Favorite", comment: "undo favorite button accessibility label")
|
|
||||||
} else {
|
|
||||||
favoriteButton.tintColor = nil
|
|
||||||
favoriteButton.accessibilityLabel = NSLocalizedString("Favorite", comment: "favorite button accessibility label")
|
|
||||||
}
|
|
||||||
|
|
||||||
reblogButton.isEnabled = reblogEnabled(status: status)
|
reblogButton.isEnabled = reblogEnabled(status: status)
|
||||||
if status.reblogged {
|
replyButton.isEnabled = mastodonController.loggedIn
|
||||||
reblogButton.tintColor = UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1)
|
favoriteButton.isEnabled = mastodonController.loggedIn
|
||||||
reblogButton.accessibilityLabel = NSLocalizedString("Undo Reblog", comment: "undo reblog button accessibility label")
|
|
||||||
} else {
|
|
||||||
reblogButton.tintColor = nil
|
|
||||||
reblogButton.accessibilityLabel = NSLocalizedString("Reblog", comment: "reblog button accessibility label")
|
|
||||||
}
|
|
||||||
|
|
||||||
// keep menu in sync with changed states e.g. bookmarked, muted
|
|
||||||
// do not include reply action here, because the cell already contains a button for it
|
|
||||||
moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: delegate?.actionsForStatus(status, source: .view(moreButton), includeStatusButtonActions: false) ?? [])
|
|
||||||
|
|
||||||
let didResolve = statusState.resolveFor(status: status) {
|
let didResolve = statusState.resolveFor(status: status) {
|
||||||
// layout so that we can take the content height into consideration when deciding whether to collapse
|
// layout so that we can take the content height into consideration when deciding whether to collapse
|
||||||
|
@ -212,6 +194,32 @@ extension StatusCollectionViewCell {
|
||||||
displayNameLabel.updateForAccountDisplayName(account: status.account)
|
displayNameLabel.updateForAccountDisplayName(account: status.account)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func baseUpdateStatusState(status: StatusMO) {
|
||||||
|
if status.favourited {
|
||||||
|
favoriteButton.tintColor = UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1)
|
||||||
|
favoriteButton.accessibilityLabel = NSLocalizedString("Undo Favorite", comment: "undo favorite button accessibility label")
|
||||||
|
} else {
|
||||||
|
favoriteButton.tintColor = nil
|
||||||
|
favoriteButton.accessibilityLabel = NSLocalizedString("Favorite", comment: "favorite button accessibility label")
|
||||||
|
}
|
||||||
|
if status.reblogged {
|
||||||
|
reblogButton.tintColor = UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1)
|
||||||
|
reblogButton.accessibilityLabel = NSLocalizedString("Undo Reblog", comment: "undo reblog button accessibility label")
|
||||||
|
} else {
|
||||||
|
reblogButton.tintColor = nil
|
||||||
|
reblogButton.accessibilityLabel = NSLocalizedString("Reblog", comment: "reblog button accessibility label")
|
||||||
|
}
|
||||||
|
|
||||||
|
// keep menu in sync with changed states e.g. bookmarked, muted
|
||||||
|
// do not include reply action here, because the cell already contains a button for it
|
||||||
|
moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: delegate?.actionsForStatus(status, source: .view(moreButton), includeStatusButtonActions: false) ?? [])
|
||||||
|
|
||||||
|
contentContainer.pollView.isHidden = status.poll == nil
|
||||||
|
contentContainer.pollView.mastodonController = mastodonController
|
||||||
|
contentContainer.pollView.delegate = delegate
|
||||||
|
contentContainer.pollView.updateUI(status: status, poll: status.poll)
|
||||||
|
}
|
||||||
|
|
||||||
func setShowThreadLinks(prev: Bool, next: Bool) {
|
func setShowThreadLinks(prev: Bool, next: Bool) {
|
||||||
if prev {
|
if prev {
|
||||||
if let prevThreadLinkView {
|
if let prevThreadLinkView {
|
||||||
|
|
|
@ -625,6 +625,10 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateStatusState(status: StatusMO) {
|
||||||
|
baseUpdateStatusState(status: status)
|
||||||
|
}
|
||||||
|
|
||||||
private func updateTimestamp() {
|
private func updateTimestamp() {
|
||||||
guard let mastodonController,
|
guard let mastodonController,
|
||||||
let status = mastodonController.persistentContainer.status(for: statusID) else {
|
let status = mastodonController.persistentContainer.status(for: statusID) else {
|
||||||
|
|
Loading…
Reference in New Issue