From bcd487d3118c44f169f9948095927401f5a3e3f2 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 4 Jul 2023 10:25:32 -0700 Subject: [PATCH] Fix favorites count button changing with when (un)faving Closes #406 --- ...ersationMainStatusCollectionViewCell.swift | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift b/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift index 6da79b08..ea0fcbb7 100644 --- a/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift @@ -141,13 +141,23 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status $0.isPointerInteractionEnabled = true } - private lazy var actionsCountHStack = UIStackView(arrangedSubviews: [ - reblogsCountButton, - favoritesCountButton, - ]).configure { - $0.axis = .horizontal - $0.spacing = 8 - $0.distribution = .fillProportionally + // using a UIStackView for this does not layout correctly on the first pass + // (everything is shifted slightly to the right for some reason) + // so do it manually, since there are only two subvviews + private lazy var actionsCountHStack = UIView().configure { + reblogsCountButton.translatesAutoresizingMaskIntoConstraints = false + $0.addSubview(reblogsCountButton) + favoritesCountButton.translatesAutoresizingMaskIntoConstraints = false + $0.addSubview(favoritesCountButton) + NSLayoutConstraint.activate([ + reblogsCountButton.leadingAnchor.constraint(equalTo: $0.leadingAnchor), + reblogsCountButton.topAnchor.constraint(equalTo: $0.topAnchor), + reblogsCountButton.bottomAnchor.constraint(equalTo: $0.bottomAnchor), + favoritesCountButton.leadingAnchor.constraint(equalTo: reblogsCountButton.trailingAnchor, constant: 8), + favoritesCountButton.topAnchor.constraint(equalTo: $0.topAnchor), + favoritesCountButton.bottomAnchor.constraint(equalTo: $0.bottomAnchor), + favoritesCountButton.trailingAnchor.constraint(equalTo: $0.trailingAnchor), + ]) } private let timestampAndClientLabel = UILabel().configure {