Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SlackTextViewController.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@version = "1.9.8-bw"
@version = "1.9.9-bw"

Pod::Spec.new do |s|
s.name = "SlackTextViewController"
Expand Down
2 changes: 1 addition & 1 deletion SlackTextViewController/SlackTextViewController/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.9.8-bw</string>
<string>1.9.9-bw</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
46 changes: 33 additions & 13 deletions Source/SLKTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ @interface SLKTextViewController ()
{
CGPoint _scrollViewOffsetBeforeDragging;
CGFloat _keyboardHeightBeforeDragging;
CGRect _cachedKeyboardRect;
}

// The shared scrollView pointer, either a tableView or collectionView
Expand Down Expand Up @@ -158,6 +159,8 @@ - (void)slk_commonInit

self.automaticallyAdjustsScrollViewInsets = YES;
self.extendedLayoutIncludesOpaqueBars = YES;

_cachedKeyboardRect = CGRectNull;
}


Expand Down Expand Up @@ -241,7 +244,7 @@ - (void)viewSafeAreaInsetsDidChange
{
[super viewSafeAreaInsetsDidChange];

[self slk_updateViewConstraints];
[self slk_updateViewConstraintsFromCachedKeyboard];
}


Expand Down Expand Up @@ -396,10 +399,10 @@ - (CGFloat)slk_appropriateKeyboardHeightFromNotification:(NSNotification *)notif
if ([self ignoreTextInputbarAdjustment]) {
return [self slk_appropriateBottomMargin];
}
CGRect keyboardRect = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
return [self slk_appropriateKeyboardHeightFromRect:keyboardRect];

_cachedKeyboardRect = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

return [self slk_appropriateKeyboardHeightFromRect:_cachedKeyboardRect];
}

- (CGFloat)slk_appropriateKeyboardHeightFromRect:(CGRect)rect
Expand Down Expand Up @@ -588,16 +591,18 @@ - (void)setBounces:(BOOL)bounces
}

- (void)slk_updateInsetAdjustmentBehavior
{
{
// Deactivate automatic scrollView adjustment for inverted table view
if (@available(iOS 11.0, *)) {
if (self.isInverted) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
}
{
// Deactivate automatic scrollView adjustment for inverted table view
if (@available(iOS 11.0, *)) {
if (self.isInverted) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
}
}
}

- (BOOL)slk_updateKeyboardStatus:(SLKKeyboardStatus)status
{
Expand Down Expand Up @@ -1345,7 +1350,7 @@ - (void)didPressEscapeKey:(UIKeyCommand *)keyCommand
else if (_textInputbar.isEditing) {
[self didCancelTextEditing:keyCommand];
}

CGFloat bottomMargin = [self slk_appropriateBottomMargin];

if ([self ignoreTextInputbarAdjustment] || ([self.textView isFirstResponder] && self.keyboardHC.constant == bottomMargin)) {
Expand Down Expand Up @@ -1399,6 +1404,8 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
// Programatically stops scrolling before updating the view constraints (to avoid scrolling glitch).
if (status == SLKKeyboardStatusWillShow) {
[self.scrollViewProxy slk_stopScrolling];
} else if (status == SLKKeyboardStatusWillHide) {
_cachedKeyboardRect = CGRectNull;
}

// Stores the previous keyboard height
Expand Down Expand Up @@ -1478,6 +1485,7 @@ - (void)slk_didShowOrHideKeyboard:(NSNotification *)notification
if (!self.isViewVisible) {
if (status == SLKKeyboardStatusDidHide && self.keyboardStatus == SLKKeyboardStatusWillHide) {
// Even if the view isn't visible anymore, let's still continue to update all states.
_cachedKeyboardRect = CGRectNull;
}
else {
return;
Expand Down Expand Up @@ -2287,6 +2295,18 @@ - (void)slk_updateViewConstraints
[super updateViewConstraints];
}

- (void)slk_updateViewConstraintsFromCachedKeyboard
{
self.textInputbarHC.constant = self.textInputbar.minimumInputbarHeight;
self.scrollViewHC.constant = [self slk_appropriateScrollViewHeight];
self.keyboardHC.constant = [self slk_appropriateKeyboardHeightFromRect:_cachedKeyboardRect];

if (_textInputbar.isEditing) {
self.textInputbarHC.constant += self.textInputbar.editorContentViewHeight;
}

[super updateViewConstraints];
}

#pragma mark - Keyboard Command registration

Expand Down