Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Commit 02963a8

Browse files
author
Ignacio Romero Zurbuchen
authored
Merge pull request #494 from slackhq/keyboard-status-fix
Fixes the keyboard state updates. Fixes #487
2 parents 5c4fa70 + a1e3482 commit 02963a8

4 files changed

Lines changed: 63 additions & 12 deletions

File tree

Examples/Messenger-Shared/MessageViewController.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ - (BOOL)forceTextInputbarAdjustmentForResponder:(UIResponder *)responder
376376
- (void)didChangeKeyboardStatus:(SLKKeyboardStatus)status
377377
{
378378
// Notifies the view controller that the keyboard changed status.
379+
380+
switch (status) {
381+
case SLKKeyboardStatusWillShow: return NSLog(@"Will Show");
382+
case SLKKeyboardStatusDidShow: return NSLog(@"Did Show");
383+
case SLKKeyboardStatusWillHide: return NSLog(@"Will Hide");
384+
case SLKKeyboardStatusDidHide: return NSLog(@"Did Hide");
385+
}
379386
}
380387

381388
- (void)textWillUpdate
@@ -397,6 +404,12 @@ - (void)didPressLeftButton:(id)sender
397404
// Notifies the view controller when the left button's action has been triggered, manually.
398405

399406
[super didPressLeftButton:sender];
407+
408+
UIViewController *vc = [UIViewController new];
409+
vc.view.backgroundColor = [UIColor whiteColor];
410+
vc.title = @"Details";
411+
412+
[self.navigationController pushViewController:vc animated:YES];
400413
}
401414

402415
- (void)didPressRightButton:(id)sender

Examples/Messenger-Swift/Base.lproj/Main.storyboard

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="jPN-Ft-lgW">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="jPN-Ft-lgW">
33
<dependencies>
44
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
66
</dependencies>
77
<scenes>
8-
<!--Message View Controller-->
8+
<!--Message Thread-->
99
<scene sceneID="tne-QT-ifu">
1010
<objects>
11-
<viewController id="BYZ-38-t0r" customClass="MessageViewController" customModule="Messenger_Swift" customModuleProvider="target" sceneMemberID="viewController">
11+
<viewController title="Message Thread" id="BYZ-38-t0r" customClass="MessageViewController" customModule="Messenger_Swift" customModuleProvider="target" sceneMemberID="viewController">
1212
<layoutGuides>
1313
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
1414
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
@@ -19,11 +19,32 @@
1919
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
2020
</view>
2121
<navigationItem key="navigationItem" id="Kuo-HA-7nc"/>
22+
<connections>
23+
<segue destination="kwe-Wv-66Y" kind="show" identifier="Push" id="rAO-Fs-P9l"/>
24+
</connections>
2225
</viewController>
2326
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2427
</objects>
2528
<point key="canvasLocation" x="1213" y="478"/>
2629
</scene>
30+
<!--Message Detail-->
31+
<scene sceneID="EBE-UJ-9Eg">
32+
<objects>
33+
<viewController title="Message Detail" id="kwe-Wv-66Y" sceneMemberID="viewController">
34+
<layoutGuides>
35+
<viewControllerLayoutGuide type="top" id="08R-wf-6EQ"/>
36+
<viewControllerLayoutGuide type="bottom" id="9ks-NF-Vcp"/>
37+
</layoutGuides>
38+
<view key="view" contentMode="scaleToFill" id="KMe-76-E1y">
39+
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
40+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
41+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
42+
</view>
43+
</viewController>
44+
<placeholder placeholderIdentifier="IBFirstResponder" id="Qla-sV-EqK" userLabel="First Responder" sceneMemberID="firstResponder"/>
45+
</objects>
46+
<point key="canvasLocation" x="1977" y="478"/>
47+
</scene>
2748
<!--Navigation Controller-->
2849
<scene sceneID="Tsc-df-QmC">
2950
<objects>

Examples/Messenger-Swift/MessageViewController.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,16 @@ extension MessageViewController {
354354

355355
// Notifies the view controller that the keyboard changed status.
356356
override func didChangeKeyboardStatus(status: SLKKeyboardStatus) {
357-
// So something
357+
switch status {
358+
case .WillShow:
359+
print("Will Show")
360+
case .DidShow:
361+
print("Did Show")
362+
case .WillHide:
363+
print("Will Hide")
364+
case .DidHide:
365+
print("Did Hide")
366+
}
358367
}
359368

360369
// Notifies the view controller that the text will update.
@@ -370,6 +379,9 @@ extension MessageViewController {
370379
// Notifies the view controller when the left button's action has been triggered, manually.
371380
override func didPressLeftButton(sender: AnyObject!) {
372381
super.didPressLeftButton(sender)
382+
383+
self.dismissKeyboard(true)
384+
self.performSegueWithIdentifier("Push", sender: nil)
373385
}
374386

375387
// Notifies the view controller when the right button's action has been triggered, manually or by using the keyboard return key.

Source/SLKTextViewController.m

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,8 +1312,10 @@ - (void)didPressArrowKey:(UIKeyCommand *)keyCommand
13121312

13131313
- (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
13141314
{
1315+
SLKKeyboardStatus status = [self slk_keyboardStatusForNotification:notification];
1316+
13151317
// Skips if the view isn't visible.
1316-
if (!self.view.window) {
1318+
if (!self.isViewVisible) {
13171319
return;
13181320
}
13191321

@@ -1336,8 +1338,6 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
13361338
return;
13371339
}
13381340

1339-
SLKKeyboardStatus status = [self slk_keyboardStatusForNotification:notification];
1340-
13411341
// Skips if it's the current status
13421342
if (self.keyboardStatus == status) {
13431343
return;
@@ -1404,9 +1404,16 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
14041404

14051405
- (void)slk_didShowOrHideKeyboard:(NSNotification *)notification
14061406
{
1407+
SLKKeyboardStatus status = [self slk_keyboardStatusForNotification:notification];
1408+
14071409
// Skips if the view isn't visible
1408-
if (!self.view.window) {
1409-
return;
1410+
if (!self.isViewVisible) {
1411+
if (status == SLKKeyboardStatusDidHide && self.keyboardStatus == SLKKeyboardStatusWillHide) {
1412+
// Even if the view isn't visible anymore, let's still continue to update all states.
1413+
}
1414+
else {
1415+
return;
1416+
}
14101417
}
14111418

14121419
// Skips if it is presented inside of a popover
@@ -1419,8 +1426,6 @@ - (void)slk_didShowOrHideKeyboard:(NSNotification *)notification
14191426
return;
14201427
}
14211428

1422-
SLKKeyboardStatus status = [self slk_keyboardStatusForNotification:notification];
1423-
14241429
// Skips if it's the current status
14251430
if (self.keyboardStatus == status) {
14261431
return;

0 commit comments

Comments
 (0)