Skip to content

Commit 872108a

Browse files
Close imagePicker
1 parent 98d56d9 commit 872108a

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/ios/SOSPicker.h

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import <Cordova/CDVPlugin.h>
10+
#import "GMImagePickerController.h"
1011

1112

1213
@interface SOSPicker : CDVPlugin < UINavigationControllerDelegate, UIScrollViewDelegate>
@@ -16,12 +17,14 @@
1617
- (void) getPictures:(CDVInvokedUrlCommand *)command;
1718
- (void) hasReadPermission:(CDVInvokedUrlCommand *)command;
1819
- (void) requestReadPermission:(CDVInvokedUrlCommand *)command;
20+
- (void) closeImagePicker:(CDVInvokedUrlCommand *)command;
1921

2022
- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize;
2123

2224
@property (nonatomic, assign) NSInteger width;
2325
@property (nonatomic, assign) NSInteger height;
2426
@property (nonatomic, assign) NSInteger quality;
2527
@property (nonatomic, assign) NSInteger outputType;
28+
@property (nonatomic, assign) GMImagePickerController* imagePicker;
2629

2730
@end

src/ios/SOSPicker.m

+9
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ - (void)launchGMImagePicker:(bool)allow_video title:(NSString *)title message:(N
8383
picker.colsInPortrait = 4;
8484
picker.colsInLandscape = 6;
8585
picker.minimumInteritemSpacing = 2.0;
86+
self.imagePicker = picker;
8687

8788
if(!disable_popover) {
8889
picker.modalPresentationStyle = UIModalPresentationPopover;
@@ -280,5 +281,13 @@ -(void)assetsPickerControllerDidCancel:(GMImagePickerController *)picker
280281
NSLog(@"GMImagePicker: User pressed cancel button");
281282
}
282283

284+
- (void) closeImagePicker:(CDVInvokedUrlCommand *)command {
285+
CDVPluginResult* pluginResult = nil;
286+
NSArray* emptyArray = [NSArray array];
287+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:emptyArray];
288+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
289+
[_imagePicker.presentingViewController dismissViewControllerAnimated:YES completion:nil];
290+
}
291+
283292

284293
@end

www/imagepicker.js

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ ImagePicker.prototype.requestReadPermission = function(callback, failureCallback
3232
return cordova.exec(callback, failureCallback, "ImagePicker", "requestReadPermission", []);
3333
};
3434

35+
ImagePicker.prototype.forceClose = function(callback) {
36+
return cordova.exec(callback, null, "ImagePicker", "closeImagePicker", []);
37+
};
38+
3539
/*
3640
* success - success callback
3741
* fail - error callback

0 commit comments

Comments
 (0)