From 606d3b95e941f48c8963d3996920472145da1200 Mon Sep 17 00:00:00 2001 From: PliablePixels Date: Tue, 15 Sep 2015 09:32:35 -0400 Subject: Added pindialog plugin --- .../src/ios/CDVPinDialog.h | 19 +++++++ .../src/ios/CDVPinDialog.m | 61 ++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.h create mode 100644 plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.m (limited to 'plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios') diff --git a/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.h b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.h new file mode 100644 index 00000000..415195d5 --- /dev/null +++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.h @@ -0,0 +1,19 @@ +// +// CDVPinDialog.h +// HelloWorld +// +// +// + +#import +#import +#import + + +@interface CDVPinDialog : CDVPlugin {} +@property (nonatomic, copy) NSString* callbackId; + +- (void)prompt:(CDVInvokedUrlCommand*)command; + +@end + diff --git a/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.m b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.m new file mode 100644 index 00000000..bd33a205 --- /dev/null +++ b/plugins/hu.dpal.phonegap.plugins.PinDialog/src/ios/CDVPinDialog.m @@ -0,0 +1,61 @@ +// +// CDVPinDialog.m +// HelloWorld +// +// +// + +#import "CDVPinDialog.h" + +@implementation CDVPinDialog + +- (void)prompt:(CDVInvokedUrlCommand*)command +{ + self.callbackId = command.callbackId; + NSString* message = [command argumentAtIndex:0]; + NSString* title = [command argumentAtIndex:1]; + NSArray* buttons = [command argumentAtIndex:2]; + + UIAlertView* alertView = [[UIAlertView alloc] + initWithTitle:title + message:message + delegate:self + cancelButtonTitle:nil + otherButtonTitles:nil]; + + //alertView.callbackId = callbackId; + + int count = [buttons count]; + + for (int n = 0; n < count; n++) { + [alertView addButtonWithTitle:[buttons objectAtIndex:n]]; + } + + alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; + UITextField* textField = [alertView textFieldAtIndex:0]; + + [alertView show]; + + [textField resignFirstResponder]; + [textField setKeyboardType:UIKeyboardTypeNumberPad]; + [textField becomeFirstResponder]; + +} + + +- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + CDVPluginResult* result; + + NSString* value0 = [[alertView textFieldAtIndex:0] text]; + NSDictionary* info = @{ + @"buttonIndex":@(buttonIndex + 1), + @"input1":(value0 ? value0 : [NSNull null]) + }; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info]; + + [self.commandDelegate sendPluginResult:result callbackId:self.callbackId]; +} + + +@end -- cgit v1.2.3