Skip to content

Commit eb08bc5

Browse files
author
Ignacio Romero Zurbuchen
committed
Merge pull request slackhq#200 from slackhq/misc-fixes
Misc fixes
2 parents c79c314 + 240e5e9 commit eb08bc5

File tree

5 files changed

+8
-132
lines changed

5 files changed

+8
-132
lines changed

Carthage/SlackTextViewController.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
382382
GCC_WARN_UNUSED_FUNCTION = YES;
383383
GCC_WARN_UNUSED_VARIABLE = YES;
384-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
384+
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
385385
MTL_ENABLE_DEBUG_INFO = YES;
386386
ONLY_ACTIVE_ARCH = YES;
387387
SDKROOT = iphoneos;
@@ -422,7 +422,7 @@
422422
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
423423
GCC_WARN_UNUSED_FUNCTION = YES;
424424
GCC_WARN_UNUSED_VARIABLE = YES;
425-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
425+
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
426426
MTL_ENABLE_DEBUG_INFO = NO;
427427
SDKROOT = iphoneos;
428428
TARGETED_DEVICE_FAMILY = "1,2";

Carthage/SlackTextViewController.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 7 deletions
This file was deleted.

Carthage/SlackTextViewController.xcworkspace/xcshareddata/SlackTextViewController.xccheckout

Lines changed: 0 additions & 41 deletions
This file was deleted.

Carthage/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.5</string>
18+
<string>1.5.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Source/Classes/SLKTextViewController.m

Lines changed: 5 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -385,53 +385,13 @@ - (UIModalPresentationStyle)modalPresentationStyle
385385

386386
- (CGFloat)slk_appropriateKeyboardHeight:(NSNotification *)notification
387387
{
388-
CGFloat keyboardHeight = 0.0;
389-
390-
CGRect endFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
391-
392388
self.externalKeyboardDetected = [self slk_detectExternalKeyboardInNotification:notification];
393-
394-
// Always return 0 if an external keyboard has been detected
395389
if (self.externalKeyboardDetected) {
396-
return keyboardHeight;
397-
}
398-
399-
// Convert the main screen bounds into the correct coordinate space but ignore the origin
400-
CGRect bounds = [self.view convertRect:[UIScreen mainScreen].bounds fromView:nil];
401-
bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height);
402-
403-
// Need to correctly convert the endframe kicked out for iOS 7
404-
CGRect endFrameConverted;
405-
406-
if (endFrame.size.width == bounds.size.height || endFrame.size.height == bounds.size.width) {
407-
endFrameConverted = SLKRectInvert(endFrame);
408-
}
409-
else {
410-
endFrameConverted = endFrame;
411-
}
412-
413-
// Sets the minimum height of the keyboard
414-
if (self.isMovingKeyboard) {
415-
keyboardHeight = bounds.size.height;
416-
keyboardHeight -= endFrameConverted.origin.y;
417-
}
418-
else {
419-
if ([notification.name isEqualToString:UIKeyboardWillShowNotification] || [notification.name isEqualToString:UIKeyboardDidShowNotification]) {
420-
keyboardHeight = endFrameConverted.size.height;
421-
}
422-
else {
423-
keyboardHeight = 0.0;
424-
}
425-
}
426-
427-
keyboardHeight -= [self slk_appropriateBottomMarginToWindow];
428-
keyboardHeight -= CGRectGetHeight(self.textView.inputAccessoryView.bounds);
429-
430-
if (keyboardHeight < 0 || endFrameConverted.origin.y < 0) {
431-
keyboardHeight = 0.0;
390+
return 0.0;
432391
}
433392

434-
return keyboardHeight;
393+
CGRect endFrame = [self.view convertRect:[notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil];
394+
return MAX(0.0, CGRectGetHeight(self.view.bounds) - CGRectGetMinY(endFrame) - CGRectGetHeight(self.textView.inputAccessoryView.bounds));
435395
}
436396

437397
- (CGFloat)slk_appropriateScrollViewHeight
@@ -470,42 +430,6 @@ - (CGFloat)slk_topBarsHeight
470430
return height;
471431
}
472432

473-
- (CGFloat)slk_appropriateBottomMarginToWindow
474-
{
475-
// Converts the main screen bounds into the correct coordinate space, but ignore origin
476-
CGRect bounds = [self.view convertRect:[UIScreen mainScreen].bounds fromView:nil];
477-
bounds = CGRectMake(0, 0, bounds.size.width, bounds.size.height);
478-
479-
CGRect viewRect = self.view.frame;
480-
481-
CGFloat bottomWindow = CGRectGetMaxY(bounds);
482-
CGFloat bottomView = CGRectGetMaxY(viewRect);
483-
484-
CGRect statusBarRect = [self.view convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil];
485-
CGFloat statusBarHeight = MIN(statusBarRect.size.height, statusBarRect.size.width);
486-
487-
CGFloat bottomMargin = bottomWindow - bottomView;
488-
489-
if (SLK_IS_IPAD && self.modalPresentationStyle == UIModalPresentationFormSheet) {
490-
491-
// Needs to convert the status bar's frame to the correct coordinate space
492-
bottomMargin -= statusBarHeight;
493-
494-
bottomMargin /= 2.0;
495-
496-
if (SLK_IS_LANDSCAPE) {
497-
bottomMargin += bottomMargin;
498-
}
499-
else if (SLK_IS_IOS8_AND_HIGHER) {
500-
// For some reason in iOS 8 portrait only, we lose half the status bar height somewhere
501-
bottomMargin += statusBarHeight/2.0;
502-
}
503-
}
504-
505-
// Do NOT consider the status bar's max height gap (40 pts while in-call mode)
506-
return (bottomMargin > statusBarHeight) ? bottomMargin : 0.0;
507-
}
508-
509433
- (NSString *)slk_appropriateKeyboardNotificationName:(NSNotification *)notification
510434
{
511435
NSString *name = notification.name;
@@ -1044,7 +968,7 @@ - (void)slk_reloadInputAccessoryViewIfNeeded
1044968
}
1045969
}
1046970
// Reload only if the input views if the frame doesn't match the text input bar's.
1047-
else if (self.textView.inputAccessoryView && CGRectGetHeight(self.textView.inputAccessoryView.frame) != CGRectGetHeight(self.textInputbar.bounds)) {
971+
else if (CGRectGetHeight(self.textView.inputAccessoryView.frame) != CGRectGetHeight(self.textInputbar.bounds)) {
1048972
self.textView.inputAccessoryView = [self emptyInputAccessoryView];
1049973
[self.textView refreshInputViews];
1050974
}
@@ -1217,7 +1141,7 @@ - (void)slk_didShowOrHideKeyboard:(NSNotification *)notification
12171141
// Updates the dismiss mode and input accessory view, if needed.
12181142
[self slk_reloadInputAccessoryViewIfNeeded];
12191143

1220-
// Very important to invalidate this flag after the keyboard is dismissed or presented
1144+
// Very important to invalidate this flag after the keyboard is dismissed or presented, to start with a clean state next time.
12211145
self.movingKeyboard = NO;
12221146
}
12231147

0 commit comments

Comments
 (0)