Fix context menu presentation animation getting clipped in new status cells

This commit is contained in:
Shadowfacts 2022-10-08 15:31:08 -04:00
parent fd6a4ba41c
commit bcb3c24027
4 changed files with 11 additions and 9 deletions

View File

@ -357,11 +357,11 @@ extension TimelineViewController: MenuActionProvider {
}
extension TimelineViewController: StatusCollectionViewCellDelegate {
func statusCellNeedsReconfigure(_ cell: StatusCollectionViewCell, animated: Bool) {
func statusCellNeedsReconfigure(_ cell: StatusCollectionViewCell, animated: Bool, completion: (() -> Void)?) {
if let indexPath = collectionView.indexPath(for: cell) {
var snapshot = dataSource.snapshot()
snapshot.reconfigureItems([dataSource.itemIdentifier(for: indexPath)!])
dataSource.apply(snapshot, animatingDifferences: animated)
dataSource.apply(snapshot, animatingDifferences: animated, completion: completion)
}
}
}

View File

@ -12,7 +12,7 @@ import Combine
@MainActor
protocol StatusCollectionViewCellDelegate: AnyObject, TuskerNavigationDelegate, MenuActionProvider {
func statusCellNeedsReconfigure(_ cell: StatusCollectionViewCell, animated: Bool)
func statusCellNeedsReconfigure(_ cell: StatusCollectionViewCell, animated: Bool, completion: (() -> Void)?)
}
@MainActor
@ -196,8 +196,13 @@ extension StatusCollectionViewCell {
extension StatusCollectionViewCell {
func toggleCollapse() {
statusState.collapsed!.toggle()
// mask so that the content appears to expand with the container during the animation
// but only while the animation is taking place, otherwise the mask interferes with context menu presentation animation
contentContainer.layer.masksToBounds = true
// this delegate call causes the collection view to reconfigure this cell, at which point (and inside of the collection view's animation handling) we'll update the contentContainer
delegate?.statusCellNeedsReconfigure(self, animated: true)
delegate?.statusCellNeedsReconfigure(self, animated: true) {
self.contentContainer.layer.masksToBounds = false
}
}
func toggleFavorite() {

View File

@ -60,10 +60,7 @@ class StatusContentContainer: UIView {
zeroHeightConstraint.priority = .defaultLow
setNeedsUpdateConstraints()
// mask to bounds so that the during the expand/collapse animation, subviews are clipped
layer.masksToBounds = true
isHiddenObservations = arrangedSubviews.map {
$0.observe(\.isHidden) { [unowned self] _, _ in
self.setNeedsUpdateConstraints()

View File

@ -474,7 +474,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
let oldState = actionsContainer.isHidden
if oldState != Preferences.shared.hideActionsInTimeline {
updateActionsVisibility()
delegate?.statusCellNeedsReconfigure(self, animated: true)
delegate?.statusCellNeedsReconfigure(self, animated: true, completion: nil)
}
}