Skip to content

Commit

Permalink
on iPhone X the keyboard will not hide on NativeKeyboard.hideMessenger
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Mar 3, 2019
1 parent 43fc6f6 commit 1016734
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-native-keyboard"
version="2.0.0">
version="2.0.1">

<name>Native Keyboard</name>

Expand Down
15 changes: 12 additions & 3 deletions src/ios/CDVNativeKeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 1016734

Please sign in to comment.