From 3109aafd20c7aa5a39c174fff90d20c628a59304 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 18 Jul 2023 21:14:43 -0700 Subject: [PATCH] Workaround for status collapse button overlapping other views in the cell --- Tusker/Views/Status/StatusCollectionViewCell.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index 5c2dae8d..61c93b9a 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -125,7 +125,19 @@ extension StatusCollectionViewCell { statusState.collapsed = false } } - collapseButton.isHidden = !statusState.collapsible! + let expected = !statusState.collapsible! + // Very very rarely, setting isHidden to false only seems to partially take effect: + // the button will be rendered, but isHidden will still return true, and the + // containing stack view won't have updated constraints for it and so the cell + // layout will be wrong and the button will overlap other views in the stack. + // So, as a truly cursed workaround, just try a few times in a row until reading + // back isHidden returns the correct value. + for _ in 0..<5 { + collapseButton.isHidden = expected + if collapseButton.isHidden == expected { + break + } + } contentContainer.setCollapsed(statusState.collapsed!) if statusState.collapsed! { contentContainer.alpha = 0