Skip to content

Commit 1016734

Browse files
on iPhone X the keyboard will not hide on NativeKeyboard.hideMessenger #97
1 parent 43fc6f6 commit 1016734

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-native-keyboard",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "This plugin aims to solve common keyboard problems encountered with Cordova / PhoneGap apps. The messenger component (see screenshots) is ready for production, but this plugin will have more tricks up its sleeve. I'll document those once they're ready for primetime as well.",
55
"cordova": {
66
"id": "cordova-plugin-native-keyboard",

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
id="cordova-plugin-native-keyboard"
5-
version="2.0.0">
5+
version="2.0.1">
66

77
<name>Native Keyboard</name>
88

src/ios/CDVNativeKeyboard.m

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ @implementation CDVNativeKeyboard
55

66
BOOL DEBUG_KEYBOARD = NO;
77

8+
// a little hack for when the messenger keyboard has been shown and hidden, then a regular textfield is shown - this prevents the messenger bar from being shown
9+
int CDVNativeKeyboardHideKeyboardOffscreenOffset = 0;
10+
811
// TODO move as much as possible to the helper, and move this to the framwework and wire the Cordova-SLK stuff via the NKHelper class
912
NKSLKTextViewController * tvc;
1013

@@ -123,10 +126,13 @@ - (void)showMessenger:(CDVInvokedUrlCommand*)command {
123126

124127
if (tvc == nil) {
125128
tvc = [[NKSLKTextViewController alloc] initWithScrollView:self.webView.scrollView];
129+
} else if (CDVNativeKeyboardHideKeyboardOffscreenOffset != 0) {
130+
tvc.view.frame = CGRectMake(tvc.view.frame.origin.x, tvc.view.frame.origin.y, tvc.view.frame.size.width, tvc.view.frame.size.height - CDVNativeKeyboardHideKeyboardOffscreenOffset);
131+
CDVNativeKeyboardHideKeyboardOffscreenOffset = 0;
126132
}
127133

128134
[tvc configureMessengerWithCommand:command andCommandDelegate:self.commandDelegate];
129-
135+
130136
NSArray * ors = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];
131137
NSArray * suppOrientations = [((CDVViewController*)self.viewController) parseInterfaceOrientations:ors];
132138
[tvc setSupportedInterfaceOrientations:suppOrientations];
@@ -170,8 +176,11 @@ - (void)showMessenger:(CDVInvokedUrlCommand*)command {
170176
- (void)hideMessenger:(CDVInvokedUrlCommand*)command {
171177
if (tvc != nil) {
172178
NSDictionary* options = [command argumentAtIndex:0];
173-
[tvc setTextInputbarHidden:YES animated:[options[@"animated"] boolValue]];
174-
// tvc = nil;
179+
[tvc setTextInputbarHidden:YES animated:[options[@"animated"] boolValue]];
180+
if (CDVNativeKeyboardHideKeyboardOffscreenOffset == 0) {
181+
CDVNativeKeyboardHideKeyboardOffscreenOffset = 500; // at least the height of the keyboard + messenger bar (this is ok)
182+
tvc.view.frame = CGRectMake(tvc.view.frame.origin.x, tvc.view.frame.origin.y, tvc.view.frame.size.width, tvc.view.frame.size.height + CDVNativeKeyboardHideKeyboardOffscreenOffset);
183+
}
175184
}
176185
}
177186

0 commit comments

Comments
 (0)