Compare commits

..

3 Commits

Author SHA1 Message Date
Shadowfacts 88cfbfb1f3 Improve reblog indicator on statuses
Closes #225
2022-11-22 11:48:59 -05:00
Shadowfacts 49f1d6339f Fix crash when toggling collapse in Trending Posts
Closes #262
2022-11-22 11:47:57 -05:00
Shadowfacts 3e7cb443fa Correct post content type warning
Hometown does not support formatting
2022-11-22 11:39:47 -05:00
4 changed files with 45 additions and 14 deletions

View File

@ -8,7 +8,7 @@
import Foundation
public class StatusState: Equatable, Hashable {
public class StatusState: Equatable {
public var collapsible: Bool?
public var collapsed: Bool?

View File

@ -122,6 +122,27 @@ extension TrendingStatusesViewController {
case status(id: String, state: StatusState)
case loadingIndicator
static func ==(lhs: Item, rhs: Item) -> Bool {
switch (lhs, rhs) {
case (.status(id: let a, state: _), .status(id: let b, state: _)):
return a == b
case (.loadingIndicator, .loadingIndicator):
return true
default:
return false
}
}
func hash(into hasher: inout Hasher) {
switch self {
case .status(id: let id, state: _):
hasher.combine(0)
hasher.combine(id)
case .loadingIndicator:
hasher.combine(1)
}
}
var hideSeparators: Bool {
if case .loadingIndicator = self {
return true

View File

@ -23,7 +23,7 @@ struct AdvancedPrefsView : View {
}
var formattingFooter: some View {
var s: AttributedString = "This option is only supported with Pleroma and some compatible Mastodon instances (such as Glitch or Hometown).\n"
var s: AttributedString = "This option is only supported with Pleroma and some compatible Mastodon instances (such as Glitch).\n"
if let account = LocalData.shared.getMostRecentAccount() {
let mastodonController = MastodonController.getForAccount(account)
// shouldn't need to load the instance here, because loading it is kicked off my the scene delegate

View File

@ -16,10 +16,20 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
// MARK: Subviews
private lazy var reblogLabel = EmojiLabel().configure {
private lazy var rebloggerLabel = EmojiLabel().configure {
$0.textColor = .secondaryLabel
$0.font = .preferredFont(forTextStyle: .body)
$0.adjustsFontForContentSizeCategory = true
}
private let reblogIcon = UIImageView(image: UIImage(systemName: "repeat")).configure {
$0.tintColor = .secondaryLabel
}
private lazy var reblogHStack = UIStackView(arrangedSubviews: [
reblogIcon,
rebloggerLabel,
]).configure {
$0.axis = .horizontal
$0.spacing = 8
// this needs to have a higher priorty than the content container's zero height constraint
$0.setContentHuggingPriority(.defaultHigh, for: .vertical)
$0.isUserInteractionEnabled = true
@ -265,12 +275,12 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
override init(frame: CGRect) {
super.init(frame: frame)
for subview in [reblogLabel, mainContainer, actionsContainer] {
for subview in [reblogHStack, mainContainer, actionsContainer] {
subview.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(subview)
}
mainContainerTopToReblogLabelConstraint = mainContainer.topAnchor.constraint(equalTo: reblogLabel.bottomAnchor, constant: 4)
mainContainerTopToReblogLabelConstraint = mainContainer.topAnchor.constraint(equalTo: reblogHStack.bottomAnchor, constant: 4)
mainContainerTopToSelfConstraint = mainContainer.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8)
mainContainerBottomToActionsConstraint = mainContainer.bottomAnchor.constraint(equalTo: actionsContainer.topAnchor, constant: -4)
mainContainerBottomToSelfConstraint = mainContainer.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -6)
@ -281,9 +291,9 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
NSLayoutConstraint.activate([
// why is this 4 but the mainContainerTopSelfConstraint constant 8? because this looks more balanced
reblogLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 4),
reblogLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
reblogLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16),
reblogHStack.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 4),
rebloggerLabel.leadingAnchor.constraint(equalTo: contentVStack.leadingAnchor),
reblogHStack.trailingAnchor.constraint(lessThanOrEqualTo: contentView.trailingAnchor, constant: -16),
mainContainer.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
mainContainer.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16),
@ -399,7 +409,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
if let rebloggedStatus = status.reblog {
reblogStatusID = statusID
rebloggerID = status.account.id
reblogLabel.isHidden = false
reblogHStack.isHidden = false
mainContainerTopToReblogLabelConstraint.isActive = true
mainContainerTopToSelfConstraint.isActive = false
updateRebloggerLabel(reblogger: status.account)
@ -408,7 +418,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
} else {
reblogStatusID = nil
rebloggerID = nil
reblogLabel.isHidden = true
reblogHStack.isHidden = true
mainContainerTopToReblogLabelConstraint.isActive = false
mainContainerTopToSelfConstraint.isActive = true
}
@ -492,11 +502,11 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
private func updateRebloggerLabel(reblogger: AccountMO) {
if Preferences.shared.hideCustomEmojiInUsernames {
reblogLabel.text = "Reblogged by \(reblogger.displayNameWithoutCustomEmoji)"
reblogLabel.removeEmojis()
rebloggerLabel.text = "\(reblogger.displayNameWithoutCustomEmoji) reblogged"
rebloggerLabel.removeEmojis()
} else {
reblogLabel.text = "Reblogged by \(reblogger.displayOrUserName)"
reblogLabel.setEmojis(reblogger.emojis, identifier: reblogger.id)
rebloggerLabel.text = "\(reblogger.displayOrUserName) reblogged"
rebloggerLabel.setEmojis(reblogger.emojis, identifier: reblogger.id)
}
}