fix: date meta may be trunked in thread scene issue. resolve #285
This commit is contained in:
parent
7667d9ad3f
commit
143c6a0a99
|
@ -603,24 +603,33 @@ extension StatusSection {
|
||||||
status: Status
|
status: Status
|
||||||
) {
|
) {
|
||||||
cell.selectionStyle = .none
|
cell.selectionStyle = .none
|
||||||
cell.threadMetaView.dateLabel.text = {
|
|
||||||
let formatter = DateFormatter()
|
// set reblog count
|
||||||
formatter.dateStyle = .medium
|
|
||||||
formatter.timeStyle = .short
|
|
||||||
return formatter.string(from: status.createdAt)
|
|
||||||
}()
|
|
||||||
cell.threadMetaView.dateLabel.accessibilityLabel = DateFormatter.localizedString(from: status.createdAt, dateStyle: .medium, timeStyle: .short)
|
|
||||||
let reblogCountTitle: String = {
|
let reblogCountTitle: String = {
|
||||||
let count = status.reblogsCount.intValue
|
let count = status.reblogsCount.intValue
|
||||||
return L10n.Plural.Count.reblog(count)
|
return L10n.Plural.Count.reblog(count)
|
||||||
}()
|
}()
|
||||||
cell.threadMetaView.reblogButton.setTitle(reblogCountTitle, for: .normal)
|
cell.threadMetaView.reblogButton.setTitle(reblogCountTitle, for: .normal)
|
||||||
|
// set favorite count
|
||||||
let favoriteCountTitle: String = {
|
let favoriteCountTitle: String = {
|
||||||
let count = status.favouritesCount.intValue
|
let count = status.favouritesCount.intValue
|
||||||
return L10n.Plural.Count.favorite(count)
|
return L10n.Plural.Count.favorite(count)
|
||||||
}()
|
}()
|
||||||
cell.threadMetaView.favoriteButton.setTitle(favoriteCountTitle, for: .normal)
|
cell.threadMetaView.favoriteButton.setTitle(favoriteCountTitle, for: .normal)
|
||||||
|
// set date
|
||||||
|
cell.threadMetaView.dateLabel.text = {
|
||||||
|
let formatter = DateFormatter()
|
||||||
|
// make adaptive UI
|
||||||
|
if UIView.isZoomedMode || (reblogCountTitle.count + favoriteCountTitle.count > 20) {
|
||||||
|
formatter.dateStyle = .short
|
||||||
|
formatter.timeStyle = .short
|
||||||
|
} else {
|
||||||
|
formatter.dateStyle = .medium
|
||||||
|
formatter.timeStyle = .short
|
||||||
|
}
|
||||||
|
return formatter.string(from: status.createdAt)
|
||||||
|
}()
|
||||||
|
cell.threadMetaView.dateLabel.accessibilityLabel = DateFormatter.localizedString(from: status.createdAt, dateStyle: .medium, timeStyle: .short)
|
||||||
|
|
||||||
cell.threadMetaView.isHidden = false
|
cell.threadMetaView.isHidden = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ final class ThreadMetaView: UIView {
|
||||||
label.text = "Date"
|
label.text = "Date"
|
||||||
label.adjustsFontSizeToFitWidth = true
|
label.adjustsFontSizeToFitWidth = true
|
||||||
label.minimumScaleFactor = 0.5
|
label.minimumScaleFactor = 0.5
|
||||||
|
label.numberOfLines = 2
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ final class ThreadMetaView: UIView {
|
||||||
let containerStackView: UIStackView = {
|
let containerStackView: UIStackView = {
|
||||||
let stackView = UIStackView()
|
let stackView = UIStackView()
|
||||||
stackView.axis = .horizontal
|
stackView.axis = .horizontal
|
||||||
stackView.spacing = 20
|
stackView.spacing = 4
|
||||||
return stackView
|
return stackView
|
||||||
}()
|
}()
|
||||||
let actionButtonStackView = UIStackView()
|
let actionButtonStackView = UIStackView()
|
||||||
|
@ -77,9 +78,9 @@ extension ThreadMetaView {
|
||||||
actionButtonStackView.addArrangedSubview(favoriteButton)
|
actionButtonStackView.addArrangedSubview(favoriteButton)
|
||||||
|
|
||||||
dateLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
dateLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
||||||
reblogButton.titleLabel?.setContentHuggingPriority(.required - 2, for: .horizontal)
|
reblogButton.setContentHuggingPriority(.required - 2, for: .horizontal)
|
||||||
favoriteButton.titleLabel?.setContentHuggingPriority(.required - 1, for: .horizontal)
|
|
||||||
reblogButton.setContentCompressionResistancePriority(.required - 2, for: .horizontal)
|
reblogButton.setContentCompressionResistancePriority(.required - 2, for: .horizontal)
|
||||||
|
favoriteButton.setContentHuggingPriority(.required - 1, for: .horizontal)
|
||||||
favoriteButton.setContentCompressionResistancePriority(.required - 1, for: .horizontal)
|
favoriteButton.setContentCompressionResistancePriority(.required - 1, for: .horizontal)
|
||||||
|
|
||||||
updateContainerLayout()
|
updateContainerLayout()
|
||||||
|
@ -98,12 +99,15 @@ extension ThreadMetaView {
|
||||||
private func updateContainerLayout() {
|
private func updateContainerLayout() {
|
||||||
if traitCollection.preferredContentSizeCategory < .accessibilityMedium {
|
if traitCollection.preferredContentSizeCategory < .accessibilityMedium {
|
||||||
containerStackView.axis = .horizontal
|
containerStackView.axis = .horizontal
|
||||||
containerStackView.spacing = 20
|
|
||||||
dateLabel.numberOfLines = 1
|
if bounds.size.width < 400 || UIView.isZoomedMode {
|
||||||
|
actionButtonStackView.spacing = 10
|
||||||
|
} else {
|
||||||
|
actionButtonStackView.spacing = 20
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
containerStackView.axis = .vertical
|
containerStackView.axis = .vertical
|
||||||
containerStackView.spacing = 4
|
actionButtonStackView.spacing = 20
|
||||||
dateLabel.numberOfLines = 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue