From 086a9af80e965d2ff4aa6e58b5f8357e783ca70c Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Thu, 1 Apr 2021 07:29:47 +0200 Subject: [PATCH 1/8] vertical layout of typing notifs can go wonky --- MatrixKit/Controllers/MXKViewController.m | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/MatrixKit/Controllers/MXKViewController.m b/MatrixKit/Controllers/MXKViewController.m index 54b642c60..d300b8d27 100644 --- a/MatrixKit/Controllers/MXKViewController.m +++ b/MatrixKit/Controllers/MXKViewController.m @@ -638,13 +638,9 @@ - (void)onKeyboardWillShow:(NSNotification *)notif // Detect if an external keyboard is used by checking that // the bottom of the provided keyboard frame is outside of the screen - BOOL hasExternalKeyboard = NO; CGRect keyboard = [self.view convertRect:endRect fromView:self.view.window]; CGFloat height = self.view.frame.size.height; - if ((keyboard.origin.y + keyboard.size.height) > height) - { - hasExternalKeyboard = YES; - } + BOOL hasExternalKeyboard = keyboard.size.height <= 80; // Get the animation info NSNumber *curveValue = [[notif userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey]; From 41695cc96f3d731934b8188a57ea87e80c356703 Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Thu, 1 Apr 2021 07:35:44 +0200 Subject: [PATCH 2/8] Updated CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5a150dd66..b98d8441b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,7 +8,7 @@ Changes to be released in next version * 🐛 Bugfix - * + * vertical layout of typing notifs can go wonky (vector-im/element-ios/issues/4159). ⚠️ API Changes * From 14b5118d2c932dd804d7f5c7f5b1401772bd2f59 Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Thu, 1 Apr 2021 09:39:34 +0200 Subject: [PATCH 3/8] Updated CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index b98d8441b..04d79ea52 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,7 +8,7 @@ Changes to be released in next version * 🐛 Bugfix - * vertical layout of typing notifs can go wonky (vector-im/element-ios/issues/4159). + * vertical padding is borked on new attachment UI after going into file selector and out again (vector-im/element-ios/issues/4156). ⚠️ API Changes * From d60855a64885f4c8e75340b2ce6232be48dfa146 Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Tue, 6 Apr 2021 16:57:18 +0200 Subject: [PATCH 4/8] vertical layout of typing notifs can go wonky - fixed default padding between last message and composer - increased animation speed --- MatrixKit/Controllers/MXKRoomViewController.m | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/MatrixKit/Controllers/MXKRoomViewController.m b/MatrixKit/Controllers/MXKRoomViewController.m index a8d64c8e0..b19777db7 100644 --- a/MatrixKit/Controllers/MXKRoomViewController.m +++ b/MatrixKit/Controllers/MXKRoomViewController.m @@ -463,6 +463,19 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO }); } +- (void)viewDidLayoutSubviews +{ + [super viewDidLayoutSubviews]; + + CGFloat bubblesTableViewBottomConst = self.roomInputToolbarContainerBottomConstraint.constant + self.roomInputToolbarContainerHeightConstraint.constant + self.roomActivitiesContainerHeightConstraint.constant; + + if (self.bubblesTableViewBottomConstraint.constant != bubblesTableViewBottomConst) + { + self.bubblesTableViewBottomConstraint.constant = bubblesTableViewBottomConst; + } + +} + #pragma mark - Override MXKViewController - (void)onMatrixSessionChange @@ -3440,25 +3453,22 @@ - (void)roomInputToolbarView:(MXKRoomInputToolbarView*)toolbarView heightDidChan _roomInputToolbarContainerHeightConstraint.constant = height; // Update layout with animation - [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseIn + [UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseIn animations:^{ // We will scroll to bottom if the bottom of the table is currently visible BOOL shouldScrollToBottom = [self isBubblesTableScrollViewAtTheBottom]; CGFloat bubblesTableViewBottomConst = self->_roomInputToolbarContainerBottomConstraint.constant + self->_roomInputToolbarContainerHeightConstraint.constant + self->_roomActivitiesContainerHeightConstraint.constant; - if (self->_bubblesTableViewBottomConstraint.constant != bubblesTableViewBottomConst) - { - self->_bubblesTableViewBottomConstraint.constant = bubblesTableViewBottomConst; - - // Force to render the view - [self.view layoutIfNeeded]; - - if (shouldScrollToBottom) - { - [self scrollBubblesTableViewToBottomAnimated:NO]; - } - } + self->_bubblesTableViewBottomConstraint.constant = bubblesTableViewBottomConst; + + // Force to render the view + [self.view layoutIfNeeded]; + + if (shouldScrollToBottom) + { + [self scrollBubblesTableViewToBottomAnimated:NO]; + } } completion:^(BOOL finished){ if (completion) From bdd8577d56e29f545c869b3e154acf4ef02aa2a2 Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Tue, 6 Apr 2021 17:02:01 +0200 Subject: [PATCH 5/8] Updated CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 04d79ea52..07e349ca4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,7 @@ Changes to be released in next version 🐛 Bugfix * vertical padding is borked on new attachment UI after going into file selector and out again (vector-im/element-ios/issues/4156). + * vertical layout of typing notifs can go wonky (vector-im/element-ios/issues/4159). ⚠️ API Changes * From bac646660e4f5623c6318fc12cea4fdf1b65d502 Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Wed, 7 Apr 2021 09:21:11 +0200 Subject: [PATCH 6/8] vertical layout of typing notifs can go wonky - made animation speed configurable --- MatrixKit/Controllers/MXKRoomViewController.h | 5 +++++ MatrixKit/Controllers/MXKRoomViewController.m | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/MatrixKit/Controllers/MXKRoomViewController.h b/MatrixKit/Controllers/MXKRoomViewController.h index 0fe590175..cc1fb60b6 100644 --- a/MatrixKit/Controllers/MXKRoomViewController.h +++ b/MatrixKit/Controllers/MXKRoomViewController.h @@ -181,6 +181,11 @@ */ @property BOOL allowActionsInDocumentPreview; +/** + Duration of the animation in case of the composer needs to be resized (default 0.3s) + */ +@property NSTimeInterval resizeComposerAnimationDuration; + /** This object is defined when the displayed room is left. It is added into the bubbles table header. This label is used to display the reason why the room has been left. diff --git a/MatrixKit/Controllers/MXKRoomViewController.m b/MatrixKit/Controllers/MXKRoomViewController.m index b19777db7..c893405ee 100644 --- a/MatrixKit/Controllers/MXKRoomViewController.m +++ b/MatrixKit/Controllers/MXKRoomViewController.m @@ -218,6 +218,9 @@ - (void)finalizeInit // By default actions button is shown in document preview _allowActionsInDocumentPreview = YES; + + // By default the duration of the composer resizing is 0.3s + _resizeComposerAnimationDuration = 0.3; } - (void)viewDidLoad @@ -3453,7 +3456,7 @@ - (void)roomInputToolbarView:(MXKRoomInputToolbarView*)toolbarView heightDidChan _roomInputToolbarContainerHeightConstraint.constant = height; // Update layout with animation - [UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseIn + [UIView animateWithDuration:self.resizeComposerAnimationDuration delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseIn animations:^{ // We will scroll to bottom if the bottom of the table is currently visible BOOL shouldScrollToBottom = [self isBubblesTableScrollViewAtTheBottom]; From c65b7132edd2badac5ebb3597642c1c2336f4831 Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Thu, 8 Apr 2021 09:22:32 +0200 Subject: [PATCH 7/8] Update CHANGES.rst Co-authored-by: ismailgulek --- CHANGES.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 07e349ca4..b02f31d45 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,8 +8,8 @@ Changes to be released in next version * 🐛 Bugfix - * vertical padding is borked on new attachment UI after going into file selector and out again (vector-im/element-ios/issues/4156). - * vertical layout of typing notifs can go wonky (vector-im/element-ios/issues/4159). + * Vertical padding is borked on new attachment UI after going into file selector and out again (vector-im/element-ios/issues/4156). + * Vertical layout of typing notifs can go wonky (vector-im/element-ios/issues/4159). ⚠️ API Changes * From a8bbc2a209909ca93168823683d0592f671b326c Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Thu, 8 Apr 2021 09:27:17 +0200 Subject: [PATCH 8/8] Update after review --- MatrixKit/Controllers/MXKViewController.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MatrixKit/Controllers/MXKViewController.m b/MatrixKit/Controllers/MXKViewController.m index d300b8d27..243802e30 100644 --- a/MatrixKit/Controllers/MXKViewController.m +++ b/MatrixKit/Controllers/MXKViewController.m @@ -19,6 +19,8 @@ #import "UIViewController+MatrixKit.h" +const CGFloat MXKViewControllerMaxExternalKeyboardHeight = 80; + @interface MXKViewController () { /** @@ -636,11 +638,10 @@ - (void)onKeyboardWillShow:(NSNotification *)notif return; } - // Detect if an external keyboard is used by checking that - // the bottom of the provided keyboard frame is outside of the screen + // Detect if an external keyboard is used CGRect keyboard = [self.view convertRect:endRect fromView:self.view.window]; CGFloat height = self.view.frame.size.height; - BOOL hasExternalKeyboard = keyboard.size.height <= 80; + BOOL hasExternalKeyboard = keyboard.size.height <= MXKViewControllerMaxExternalKeyboardHeight; // Get the animation info NSNumber *curveValue = [[notif userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey];