From 54ff3893a6dd98c7632ed6cc2f7535d69ec4cf56 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 17 May 2022 10:19:04 -0400 Subject: [PATCH] Slightly improve ActionNotificationGroupTableViewCell layout --- .../ActionNotificationGroupTableViewCell.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift index b819b36054..04dd06a97d 100644 --- a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift +++ b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift @@ -75,6 +75,9 @@ class ActionNotificationGroupTableViewCell: UITableViewCell { 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) } 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 let avatarViewsWidth = 30 * CGFloat(imageViews.count) 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 if remainingWidth < 34 { break @@ -102,7 +106,6 @@ class ActionNotificationGroupTableViewCell: UITableViewCell { await updateGrayscaleableUI() } - updateTimestamp() actionLabel.setEmojis(pairs: people.map { ($0.displayOrUserName, $0.emojis) }, identifier: group.id) let doc = try! SwiftSoup.parse(status.content)