Skip to content

Commit fde6a25

Browse files
authored
Merge pull request #4 from brightwheel/Release/1.9.9-bw
Release/1.9.9-bw
2 parents 6aeeab2 + 83fadfb commit fde6a25

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

SlackTextViewController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@version = "1.9.8-bw"
1+
@version = "1.9.9-bw"
22

33
Pod::Spec.new do |s|
44
s.name = "SlackTextViewController"

SlackTextViewController/SlackTextViewController/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.9.8-bw</string>
18+
<string>1.9.9-bw</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Source/SLKTextViewController.m

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ @interface SLKTextViewController ()
2828
{
2929
CGPoint _scrollViewOffsetBeforeDragging;
3030
CGFloat _keyboardHeightBeforeDragging;
31+
CGRect _cachedKeyboardRect;
3132
}
3233

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

159160
self.automaticallyAdjustsScrollViewInsets = YES;
160161
self.extendedLayoutIncludesOpaqueBars = YES;
162+
163+
_cachedKeyboardRect = CGRectNull;
161164
}
162165

163166

@@ -241,7 +244,7 @@ - (void)viewSafeAreaInsetsDidChange
241244
{
242245
[super viewSafeAreaInsetsDidChange];
243246

244-
[self slk_updateViewConstraints];
247+
[self slk_updateViewConstraintsFromCachedKeyboard];
245248
}
246249

247250

@@ -396,10 +399,10 @@ - (CGFloat)slk_appropriateKeyboardHeightFromNotification:(NSNotification *)notif
396399
if ([self ignoreTextInputbarAdjustment]) {
397400
return [self slk_appropriateBottomMargin];
398401
}
399-
400-
CGRect keyboardRect = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
401-
402-
return [self slk_appropriateKeyboardHeightFromRect:keyboardRect];
402+
403+
_cachedKeyboardRect = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
404+
405+
return [self slk_appropriateKeyboardHeightFromRect:_cachedKeyboardRect];
403406
}
404407

405408
- (CGFloat)slk_appropriateKeyboardHeightFromRect:(CGRect)rect
@@ -588,16 +591,18 @@ - (void)setBounces:(BOOL)bounces
588591
}
589592

590593
- (void)slk_updateInsetAdjustmentBehavior
594+
{
591595
{
592-
// Deactivate automatic scrollView adjustment for inverted table view
593-
if (@available(iOS 11.0, *)) {
594-
if (self.isInverted) {
595-
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
596-
} else {
597-
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
598-
}
596+
{
597+
// Deactivate automatic scrollView adjustment for inverted table view
598+
if (@available(iOS 11.0, *)) {
599+
if (self.isInverted) {
600+
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
601+
} else {
602+
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
599603
}
600604
}
605+
}
601606

602607
- (BOOL)slk_updateKeyboardStatus:(SLKKeyboardStatus)status
603608
{
@@ -1345,7 +1350,7 @@ - (void)didPressEscapeKey:(UIKeyCommand *)keyCommand
13451350
else if (_textInputbar.isEditing) {
13461351
[self didCancelTextEditing:keyCommand];
13471352
}
1348-
1353+
13491354
CGFloat bottomMargin = [self slk_appropriateBottomMargin];
13501355

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

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

2298+
- (void)slk_updateViewConstraintsFromCachedKeyboard
2299+
{
2300+
self.textInputbarHC.constant = self.textInputbar.minimumInputbarHeight;
2301+
self.scrollViewHC.constant = [self slk_appropriateScrollViewHeight];
2302+
self.keyboardHC.constant = [self slk_appropriateKeyboardHeightFromRect:_cachedKeyboardRect];
2303+
2304+
if (_textInputbar.isEditing) {
2305+
self.textInputbarHC.constant += self.textInputbar.editorContentViewHeight;
2306+
}
2307+
2308+
[super updateViewConstraints];
2309+
}
22902310

22912311
#pragma mark - Keyboard Command registration
22922312

0 commit comments

Comments
 (0)