Skip to content

Commit

Permalink
Close imagePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
parveshneedhoo committed May 3, 2024
1 parent 98d56d9 commit 872108a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ios/SOSPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <Cordova/CDVPlugin.h>
#import "GMImagePickerController.h"


@interface SOSPicker : CDVPlugin < UINavigationControllerDelegate, UIScrollViewDelegate>
Expand All @@ -16,12 +17,14 @@
- (void) getPictures:(CDVInvokedUrlCommand *)command;
- (void) hasReadPermission:(CDVInvokedUrlCommand *)command;
- (void) requestReadPermission:(CDVInvokedUrlCommand *)command;
- (void) closeImagePicker:(CDVInvokedUrlCommand *)command;

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

@property (nonatomic, assign) NSInteger width;
@property (nonatomic, assign) NSInteger height;
@property (nonatomic, assign) NSInteger quality;
@property (nonatomic, assign) NSInteger outputType;
@property (nonatomic, assign) GMImagePickerController* imagePicker;

@end
9 changes: 9 additions & 0 deletions src/ios/SOSPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ - (void)launchGMImagePicker:(bool)allow_video title:(NSString *)title message:(N
picker.colsInPortrait = 4;
picker.colsInLandscape = 6;
picker.minimumInteritemSpacing = 2.0;
self.imagePicker = picker;

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

- (void) closeImagePicker:(CDVInvokedUrlCommand *)command {
CDVPluginResult* pluginResult = nil;
NSArray* emptyArray = [NSArray array];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:emptyArray];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
[_imagePicker.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}


@end
4 changes: 4 additions & 0 deletions www/imagepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ ImagePicker.prototype.requestReadPermission = function(callback, failureCallback
return cordova.exec(callback, failureCallback, "ImagePicker", "requestReadPermission", []);
};

ImagePicker.prototype.forceClose = function(callback) {
return cordova.exec(callback, null, "ImagePicker", "closeImagePicker", []);
};

/*
* success - success callback
* fail - error callback
Expand Down

0 comments on commit 872108a

Please sign in to comment.