From 5aab87e2b3644189a7236a9ccf3305173e0b1c4a Mon Sep 17 00:00:00 2001 From: Axel Martinez Date: Fri, 21 Mar 2025 09:46:11 +0100 Subject: [PATCH] Added animation when updating layout if conversation content insets are updated --- .../ConversationViewController+OWS.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Signal/ConversationView/ConversationViewController+OWS.swift b/Signal/ConversationView/ConversationViewController+OWS.swift index 4c87541c54a..ac211eb7a81 100644 --- a/Signal/ConversationView/ConversationViewController+OWS.swift +++ b/Signal/ConversationView/ConversationViewController+OWS.swift @@ -74,7 +74,7 @@ extension ConversationViewController { updateContentInsetsEvent.requestNotify() } - internal func updateContentInsets() { + internal func updateContentInsets(animationDuration: TimeInterval = UIView.inheritedAnimationDuration) { AssertIsOnMainThread() guard !isMeasuringKeyboardHeight, !isSwitchingKeyboard else { @@ -93,9 +93,13 @@ extension ConversationViewController { return } } - - view.layoutIfNeeded() - + + // Layout changes have to be animated to prevent items that move out of the frame + // to fade out instead of moving with the whole collection. + UIView.animate(withDuration: animationDuration) { + self.view.layoutIfNeeded() + } + let oldInsets = collectionView.contentInset var newInsets = oldInsets