Skip to content

Commit

Permalink
Return current values of shrinkView, disableScroll and hideFormAccess…
Browse files Browse the repository at this point in the history
…oryBar in a success callback
  • Loading branch information
cjpearson committed Jul 25, 2017
1 parent 50c922c commit 5bf06a5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 25 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ From github latest (may not be stable)

Shrink the WebView when the keyboard comes up.

Keyboard.shrinkView(true);
Keyboard.shrinkView(value, successCallback);

#### Description

Expand All @@ -57,12 +57,13 @@ Set to true to shrink the WebView when the keyboard comes up. The WebView shrink

Keyboard.shrinkView(true);
Keyboard.shrinkView(false);
Keyboard.shrinkView(null, function (currentValue) { console.log(currentValue); });

## Keyboard.hideFormAccessoryBar

Hide the keyboard toolbar.

Keyboard.hideFormAccessoryBar(true);
Keyboard.hideFormAccessoryBar(value, successCallback);

#### Description

Expand All @@ -77,13 +78,13 @@ Set to true to hide the additional toolbar that is on top of the keyboard. This

Keyboard.hideFormAccessoryBar(true);
Keyboard.hideFormAccessoryBar(false);

Keyboard.hideFormAccessoryBar(null, function (currentValue) { console.log(currentValue); });

## Keyboard.disableScrollingInShrinkView

Disable scrolling when the the WebView is shrunk.

Keyboard.disableScrollingInShrinkView(true);
Keyboard.disableScrollingInShrinkView(value, successCallback);

#### Description

Expand All @@ -98,6 +99,7 @@ Set to true to disable scrolling when the WebView is shrunk.

Keyboard.disableScrollingInShrinkView(true);
Keyboard.disableScrollingInShrinkView(false);
Keyboard.disableScrollingInShrinkView(null, function (currentValue) { console.log(currentValue); });

## Keyboard.hide

Expand Down
45 changes: 30 additions & 15 deletions src/ios/CDVKeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,32 +221,47 @@ - (void)scrollViewDidScroll:(UIScrollView*)scrollView

- (void)shrinkView:(CDVInvokedUrlCommand*)command
{
id value = [command.arguments objectAtIndex:0];
if (!([value isKindOfClass:[NSNumber class]])) {
value = [NSNumber numberWithBool:NO];
}
if (command.arguments.count > 0) {
id value = [command.arguments objectAtIndex:0];
if (!([value isKindOfClass:[NSNumber class]])) {
value = [NSNumber numberWithBool:NO];
}

self.shrinkView = [value boolValue];
self.shrinkView = [value boolValue];
}

[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.shrinkView]
callbackId:command.callbackId];
}

- (void)disableScrollingInShrinkView:(CDVInvokedUrlCommand*)command
{
id value = [command.arguments objectAtIndex:0];
if (!([value isKindOfClass:[NSNumber class]])) {
value = [NSNumber numberWithBool:NO];
}
if (command.arguments.count > 0) {
id value = [command.arguments objectAtIndex:0];
if (!([value isKindOfClass:[NSNumber class]])) {
value = [NSNumber numberWithBool:NO];
}

self.disableScrollingInShrinkView = [value boolValue];
self.disableScrollingInShrinkView = [value boolValue];
}

[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.disableScrollingInShrinkView]
callbackId:command.callbackId];
}

- (void)hideFormAccessoryBar:(CDVInvokedUrlCommand*)command
{
id value = [command.arguments objectAtIndex:0];
if (!([value isKindOfClass:[NSNumber class]])) {
value = [NSNumber numberWithBool:NO];
if (command.arguments.count > 0) {
id value = [command.arguments objectAtIndex:0];
if (!([value isKindOfClass:[NSNumber class]])) {
value = [NSNumber numberWithBool:NO];
}

self.hideFormAccessoryBar = [value boolValue];
}

self.hideFormAccessoryBar = [value boolValue];

[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.hideFormAccessoryBar]
callbackId:command.callbackId];
}

- (void)hide:(CDVInvokedUrlCommand*)command
Expand Down
24 changes: 18 additions & 6 deletions www/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,28 @@ var argscheck = require('cordova/argscheck'),
var Keyboard = function() {
};

Keyboard.shrinkView = function(shrink) {
exec(null, null, "Keyboard", "shrinkView", [shrink]);
Keyboard.shrinkView = function(shrink, success) {
if (shrink !== null && shrink !== undefined) {
exec(success, null, "Keyboard", "shrinkView", [shrink]);
} else {
exec(success, null, "Keyboard", "shrinkView", []);
}
};

Keyboard.hideFormAccessoryBar = function(hide) {
exec(null, null, "Keyboard", "hideFormAccessoryBar", [hide]);
Keyboard.hideFormAccessoryBar = function(hide, success) {
if (hide !== null && hide !== undefined){
exec(success, null, "Keyboard", "hideFormAccessoryBar", [hide]);
} else {
exec(success, null, "Keyboard", "hideFormAccessoryBar", []);
}
};

Keyboard.disableScrollingInShrinkView = function(disable) {
exec(null, null, "Keyboard", "disableScrollingInShrinkView", [disable]);
Keyboard.disableScrollingInShrinkView = function(disable, success) {
if (disable !== null && disable !== undefined) {
exec(success, null, "Keyboard", "disableScrollingInShrinkView", [disable]);
} else {
exec(success, null, "Keyboard", "disableScrollingInShrinkView", []);
}
};

Keyboard.fireOnShow = function() {
Expand Down

0 comments on commit 5bf06a5

Please sign in to comment.