Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #794 from matrix-org/element_4159
Browse files Browse the repository at this point in the history
vertical padding is borked on new attachment UI after going into file selector and out again
  • Loading branch information
gileluard authored Apr 8, 2021
2 parents 275a7e3 + a8bbc2a commit 0786b5e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 21 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +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).

⚠️ API Changes
*
Expand Down
5 changes: 5 additions & 0 deletions MatrixKit/Controllers/MXKRoomViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
39 changes: 26 additions & 13 deletions MatrixKit/Controllers/MXKRoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -463,6 +466,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
Expand Down Expand Up @@ -3440,25 +3456,22 @@ - (void)roomInputToolbarView:(MXKRoomInputToolbarView*)toolbarView heightDidChan
_roomInputToolbarContainerHeightConstraint.constant = height;

// Update layout with animation
[UIView animateWithDuration:0.3 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];

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)
Expand Down
11 changes: 4 additions & 7 deletions MatrixKit/Controllers/MXKViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#import "UIViewController+MatrixKit.h"

const CGFloat MXKViewControllerMaxExternalKeyboardHeight = 80;

@interface MXKViewController ()
{
/**
Expand Down Expand Up @@ -636,15 +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
BOOL hasExternalKeyboard = NO;
// Detect if an external keyboard is used
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 <= MXKViewControllerMaxExternalKeyboardHeight;

// Get the animation info
NSNumber *curveValue = [[notif userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey];
Expand Down

0 comments on commit 0786b5e

Please sign in to comment.