Slightly improve ActionNotificationGroupTableViewCell layout

This commit is contained in:
Shadowfacts 2022-05-17 10:19:04 -04:00
parent 0168c05259
commit 54ff3893a6
1 changed files with 5 additions and 2 deletions

View File

@ -75,6 +75,9 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
isGrayscale = Preferences.shared.grayscaleImages isGrayscale = Preferences.shared.grayscaleImages
updateTimestamp()
let timestampLabelSize = timestampLabel.sizeThatFits(CGSize(width: .greatestFiniteMagnitude, height: timestampLabel.bounds.height))
let people = group.notifications.compactMap { mastodonController.persistentContainer.account(for: $0.account.id) } let people = group.notifications.compactMap { mastodonController.persistentContainer.account(for: $0.account.id) }
actionAvatarStackView.arrangedSubviews.forEach { $0.removeFromSuperview() } actionAvatarStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
@ -90,7 +93,8 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
// don't add more avatars if they would overflow or squeeze the timestamp label // don't add more avatars if they would overflow or squeeze the timestamp label
let avatarViewsWidth = 30 * CGFloat(imageViews.count) let avatarViewsWidth = 30 * CGFloat(imageViews.count)
let avatarMarginsWidth = 4 * CGFloat(max(0, imageViews.count - 1)) let avatarMarginsWidth = 4 * CGFloat(max(0, imageViews.count - 1))
let maxAvatarStackWidth = verticalStackView.bounds.width - timestampLabel.bounds.width - 8 // todo: when the cell is first created, verticalStackView.bounds.width is not correct
let maxAvatarStackWidth = verticalStackView.bounds.width - timestampLabelSize.width - 8
let remainingWidth = maxAvatarStackWidth - avatarViewsWidth - avatarMarginsWidth let remainingWidth = maxAvatarStackWidth - avatarViewsWidth - avatarMarginsWidth
if remainingWidth < 34 { if remainingWidth < 34 {
break break
@ -102,7 +106,6 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
await updateGrayscaleableUI() await updateGrayscaleableUI()
} }
updateTimestamp()
actionLabel.setEmojis(pairs: people.map { ($0.displayOrUserName, $0.emojis) }, identifier: group.id) actionLabel.setEmojis(pairs: people.map { ($0.displayOrUserName, $0.emojis) }, identifier: group.id)
let doc = try! SwiftSoup.parse(status.content) let doc = try! SwiftSoup.parse(status.content)