Skip to content

Commit

Permalink
Update bottom margin to accommodate iPhone X home indicator (slackhq#619
Browse files Browse the repository at this point in the history
)

* Update bottom margin to accommodate iPhone X home indicator

* Skips the bottom safe area when the textinputbar is hidden

* Reverting slackhq#624 to be using UIToolbar again, specially for iPhone X compatibility so the bottom edge of the input bar expands to the bottom of the screen
Fixes slackhq#619

* [skip-ci] updating changelog
  • Loading branch information
hipwelljo authored and Vincent Chau committed Nov 8, 2017
1 parent 76ac59c commit 94eca29
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Change Log

<<<<<<< HEAD
=======
## Version 1.9.6 (unreleased)

This release includes many iOS 11 and iPhone X hot fixes.

##### Features:
- Allowing color customization in typing indicator. By @dskatz22 (#613)
- Adding support for an optional view to host outlets under the text view. By @dzenbot (#562)
- Exposing auto-completion variables. By @dzenbot (#561)

##### Hot Fixes & Enhancements:
- Fixed the text input not being interactive on iOS 11. By @dzenbot (#624)
- Fixed iPhone X issue where the text input bar wouldn't expand to the bottom of the screen, below the home indicator. (#619)
- Fixed scroll view content inset adjustments on iOS 11. By @gim- (#643)
- Fixed compiler error in example app. By @BasThomas (#629)
- Fixed content offset for keyboard when uninverted. By @ZAndyL (#542)

##### Deprecation:
- Deprecated `-shouldProcessTextForAutoCompletion:` in favor of `-shouldProcessTextForAutoCompletion`

##### CI:
- Building the SlackTextViewController framework and running basic tests using BuddyBuild CI, against all PRs. By @dzenbot (#640)

>>>>>>> 37f91f2... Update bottom margin to accommodate iPhone X home indicator (#619)
## [Version 1.9.5](https://github.com/slackhq/SlackTextViewController/releases/tag/v1.9.5)

##### Features:
Expand Down
8 changes: 6 additions & 2 deletions Source/SLKTextInputbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,18 @@ - (void)slk_commonInit
self.autoHideRightButton = YES;
self.editorContentViewHeight = 38.0;
self.contentInset = UIEdgeInsetsMake(5.0, 8.0, 5.0, 8.0);


// Since iOS 11, it is required to call -layoutSubviews before adding custom subviews
// so private UIToolbar subviews don't interfere on the touch hierarchy
[self layoutSubviews];

[self addSubview:self.editorContentView];
[self addSubview:self.leftButton];
[self addSubview:self.rightButton];
[self addSubview:self.textView];
[self addSubview:self.charCountLabel];
[self addSubview:self.contentView];

[self slk_setupViewConstraints];
[self slk_updateConstraintConstants];

Expand Down
22 changes: 20 additions & 2 deletions Source/SLKTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ - (void)viewDidLayoutSubviews
[super viewDidLayoutSubviews];
}

- (void)viewSafeAreaInsetsDidChange
{
[super viewSafeAreaInsetsDidChange];

[self slk_updateViewConstraints];
}


#pragma mark - Getters

Expand Down Expand Up @@ -414,7 +421,7 @@ - (CGFloat)slk_appropriateKeyboardHeightFromRect:(CGRect)rect

- (CGFloat)slk_appropriateBottomMargin
{
// A bottom margin is required only if the view is extended out of it bounds
// A bottom margin is required if the view is extended out of it bounds
if ((self.edgesForExtendedLayout & UIRectEdgeBottom) > 0) {

UITabBar *tabBar = self.tabBarController.tabBar;
Expand All @@ -425,6 +432,13 @@ - (CGFloat)slk_appropriateBottomMargin
}
}

// A bottom margin is required for iPhone X
if (@available(iOS 11.0, *)) {
if (!self.textInputbar.isHidden) {
return self.view.safeAreaInsets.bottom;
}
}

return 0.0;
}

Expand Down Expand Up @@ -876,6 +890,10 @@ - (void)setTextInputbarHidden:(BOOL)hidden animated:(BOOL)animated
}

_textInputbar.hidden = hidden;

if (@available(iOS 11.0, *)) {
[self viewSafeAreaInsetsDidChange];
}

__weak typeof(self) weakSelf = self;

Expand Down Expand Up @@ -2226,7 +2244,7 @@ - (void)slk_setupViewConstraints
NSDictionary *views = @{@"scrollView": self.scrollViewProxy,
@"autoCompletionView": self.autoCompletionView,
@"typingIndicatorView": self.typingIndicatorProxyView,
@"textInputbar": self.textInputbar,
@"textInputbar": self.textInputbar
};

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[scrollView(0@750)][typingIndicatorView(0)]-0@999-[textInputbar(0)]|" options:0 metrics:nil views:views]];
Expand Down

0 comments on commit 94eca29

Please sign in to comment.