Skip to content

Commit

Permalink
Merge pull request #20 from spoonconsulting/close-image-picker
Browse files Browse the repository at this point in the history
Add Code to Close imagePicker
  • Loading branch information
parveshneedhoo authored May 22, 2024
2 parents 98d56d9 + 31de103 commit 9238acc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.1.1](https://github.com/spoonconsulting/cordova-plugin-telerik-imagepicker/compare/2.0.5...2.1.1) (2024-05-21)

* **ios:** Added a method `closeImagePicker` to close the image picker on ios devices.

## [2.1.0](https://github.com/spoonconsulting/cordova-plugin-telerik-imagepicker/compare/2.0.5...2.1.0) (2023-11-23)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spoonconsulting/cordova-plugin-telerik-imagepicker",
"version": "2.1.0",
"version": "2.1.1",
"cordova_name": "ImagePicker",
"description": "This plugin allows selection of multiple images from the camera roll / gallery in a phonegap app",
"license": "MIT",
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://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="@spoonconsulting/cordova-plugin-telerik-imagepicker"
version="2.1.0">
version="2.1.1">

<name>ImagePicker</name>

Expand Down
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
10 changes: 10 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,14 @@ -(void)assetsPickerControllerDidCancel:(GMImagePickerController *)picker
NSLog(@"GMImagePicker: User pressed cancel button");
}

- (void) closeImagePicker:(CDVInvokedUrlCommand *)command {
bool boolMessage = FALSE;
if (self.imagePicker && self.imagePicker.presentingViewController) {
[self.imagePicker.presentingViewController dismissViewControllerAnimated:YES completion:nil];
boolMessage = TRUE;
}
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:boolMessage];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

@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.closeImagePicker = function(callback) {
return cordova.exec(callback, null, "ImagePicker", "closeImagePicker", []);
};

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

0 comments on commit 9238acc

Please sign in to comment.