From 101673464c4da1ddd786e31477475496e2a94b51 Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Sun, 3 Mar 2019 14:46:52 +0100 Subject: [PATCH] on iPhone X the keyboard will not hide on NativeKeyboard.hideMessenger #97 --- package.json | 2 +- plugin.xml | 2 +- src/ios/CDVNativeKeyboard.m | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 18edbfc..ebede0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-native-keyboard", - "version": "2.0.0", + "version": "2.0.1", "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.", "cordova": { "id": "cordova-plugin-native-keyboard", diff --git a/plugin.xml b/plugin.xml index 5529e75..5eb01c4 100755 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="2.0.1"> Native Keyboard diff --git a/src/ios/CDVNativeKeyboard.m b/src/ios/CDVNativeKeyboard.m index 69499a5..7dd41de 100644 --- a/src/ios/CDVNativeKeyboard.m +++ b/src/ios/CDVNativeKeyboard.m @@ -5,6 +5,9 @@ @implementation CDVNativeKeyboard BOOL DEBUG_KEYBOARD = NO; +// 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 +int CDVNativeKeyboardHideKeyboardOffscreenOffset = 0; + // 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 NKSLKTextViewController * tvc; @@ -123,10 +126,13 @@ - (void)showMessenger:(CDVInvokedUrlCommand*)command { if (tvc == nil) { tvc = [[NKSLKTextViewController alloc] initWithScrollView:self.webView.scrollView]; + } else if (CDVNativeKeyboardHideKeyboardOffscreenOffset != 0) { + 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); + CDVNativeKeyboardHideKeyboardOffscreenOffset = 0; } [tvc configureMessengerWithCommand:command andCommandDelegate:self.commandDelegate]; - + NSArray * ors = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"]; NSArray * suppOrientations = [((CDVViewController*)self.viewController) parseInterfaceOrientations:ors]; [tvc setSupportedInterfaceOrientations:suppOrientations]; @@ -170,8 +176,11 @@ - (void)showMessenger:(CDVInvokedUrlCommand*)command { - (void)hideMessenger:(CDVInvokedUrlCommand*)command { if (tvc != nil) { NSDictionary* options = [command argumentAtIndex:0]; - [tvc setTextInputbarHidden:YES animated:[options[@"animated"] boolValue]]; -// tvc = nil; + [tvc setTextInputbarHidden:YES animated:[options[@"animated"] boolValue]]; + if (CDVNativeKeyboardHideKeyboardOffscreenOffset == 0) { + CDVNativeKeyboardHideKeyboardOffscreenOffset = 500; // at least the height of the keyboard + messenger bar (this is ok) + 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); + } } }