Skip to content

Add Code to Close imagePicker #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading