From 0e87d2e5b31dfe326031df1eb1eaa92d5a7126b5 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 9 Apr 2019 11:50:39 -0400 Subject: [PATCH 1/4] Simplify the scroll down button layout. --- .../ConversationView/ConversationViewController.m | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index a5f9b69e1..5c09f4e3e 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2595,7 +2595,7 @@ typedef enum : NSUInteger { { CGFloat inset = -(self.collectionView.contentInset.bottom + self.bottomLayoutGuide.length); self.scrollDownButtonButtomConstraint.constant = inset; - [self.view setNeedsLayout]; + [self.scrollDownButton setNeedsLayout]; } - (void)setHasUnreadMessages:(BOOL)hasUnreadMessages @@ -3886,16 +3886,14 @@ typedef enum : NSUInteger { // RADAR: #36297652 [self updateScrollDownButtonLayout]; - [self.scrollDownButton setNeedsLayout]; - [self.scrollDownButton layoutIfNeeded]; // HACK: I've made the assumption that we are already in the context of an animation, in which case the // above should be sufficient to smoothly move the scrollDown button in step with the keyboard presentation // animation. Yet, setting the constraint doesn't animate the movement of the button - it "jumps" to it's final // position. So here we manually lay out the scroll down button frame (seemingly redundantly), which allows it // to be smoothly animated. CGRect newButtonFrame = self.scrollDownButton.frame; - newButtonFrame.origin.y - = self.scrollDownButton.superview.height - (newInsets.bottom + self.scrollDownButton.height); + newButtonFrame.origin.y = self.scrollDownButton.superview.height + - (newInsets.bottom + self.scrollDownButton.height + self.bottomLayoutGuide.length); self.scrollDownButton.frame = newButtonFrame; // Adjust content offset to prevent the presented keyboard from obscuring content. From 42871bb6a60f65c33fe6fab53d1bcd8709bf9c42 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 9 Apr 2019 14:48:01 -0400 Subject: [PATCH 2/4] Simplify the scroll down button layout. --- .../ConversationView/ConversationViewController.m | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 5c09f4e3e..5e305ae7b 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2595,7 +2595,6 @@ typedef enum : NSUInteger { { CGFloat inset = -(self.collectionView.contentInset.bottom + self.bottomLayoutGuide.length); self.scrollDownButtonButtomConstraint.constant = inset; - [self.scrollDownButton setNeedsLayout]; } - (void)setHasUnreadMessages:(BOOL)hasUnreadMessages @@ -3886,15 +3885,7 @@ typedef enum : NSUInteger { // RADAR: #36297652 [self updateScrollDownButtonLayout]; - // HACK: I've made the assumption that we are already in the context of an animation, in which case the - // above should be sufficient to smoothly move the scrollDown button in step with the keyboard presentation - // animation. Yet, setting the constraint doesn't animate the movement of the button - it "jumps" to it's final - // position. So here we manually lay out the scroll down button frame (seemingly redundantly), which allows it - // to be smoothly animated. - CGRect newButtonFrame = self.scrollDownButton.frame; - newButtonFrame.origin.y = self.scrollDownButton.superview.height - - (newInsets.bottom + self.scrollDownButton.height + self.bottomLayoutGuide.length); - self.scrollDownButton.frame = newButtonFrame; + [self.view layoutSubviews]; // Adjust content offset to prevent the presented keyboard from obscuring content. if (!self.viewHasEverAppeared) { @@ -5164,6 +5155,7 @@ typedef enum : NSUInteger { // Scroll button layout depends on input toolbar size. [self updateScrollDownButtonLayout]; + [self.view setNeedsLayout]; } @end From 40bd2b06d2bfeb26447db419f653e301048475c3 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 9 Apr 2019 14:55:49 -0400 Subject: [PATCH 3/4] Simplify the scroll down button layout. --- .../ConversationView/ConversationViewController.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 5e305ae7b..fa095f6df 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3885,6 +3885,8 @@ typedef enum : NSUInteger { // RADAR: #36297652 [self updateScrollDownButtonLayout]; + // Update the layout of the scroll down button immediately. + // This change might be animated by the keyboard notification. [self.view layoutSubviews]; // Adjust content offset to prevent the presented keyboard from obscuring content. From 6c1d6cc20126dc7574f8540577e615b5b68c345e Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 9 Apr 2019 15:46:42 -0400 Subject: [PATCH 4/4] Simplify the scroll down button layout. --- .../ConversationView/ConversationViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index fa095f6df..202bd46ec 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2595,6 +2595,7 @@ typedef enum : NSUInteger { { CGFloat inset = -(self.collectionView.contentInset.bottom + self.bottomLayoutGuide.length); self.scrollDownButtonButtomConstraint.constant = inset; + [self.scrollDownButton.superview setNeedsLayout]; } - (void)setHasUnreadMessages:(BOOL)hasUnreadMessages @@ -3887,7 +3888,7 @@ typedef enum : NSUInteger { // Update the layout of the scroll down button immediately. // This change might be animated by the keyboard notification. - [self.view layoutSubviews]; + [self.scrollDownButton.superview layoutIfNeeded]; // Adjust content offset to prevent the presented keyboard from obscuring content. if (!self.viewHasEverAppeared) { @@ -5157,7 +5158,6 @@ typedef enum : NSUInteger { // Scroll button layout depends on input toolbar size. [self updateScrollDownButtonLayout]; - [self.view setNeedsLayout]; } @end