@@ -18,6 +18,7 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
18
18
private _height : number ;
19
19
private _keepAspectRatio : boolean ;
20
20
private _saveToGallery : boolean ;
21
+ private _allowsEditing : boolean ;
21
22
22
23
public initWithCallback ( callback : ( result ?) => void , errorCallback : ( result ?) => void ) : UIImagePickerControllerDelegateImpl {
23
24
this . _callback = callback ;
@@ -32,6 +33,7 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
32
33
this . _width = options . width ;
33
34
this . _height = options . height ;
34
35
this . _saveToGallery = options . saveToGallery ;
36
+ this . _allowsEditing = options . allowsEditing ;
35
37
this . _keepAspectRatio = types . isNullOrUndefined ( options . keepAspectRatio ) ? true : options . keepAspectRatio ;
36
38
}
37
39
return this ;
@@ -41,6 +43,9 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
41
43
if ( info ) {
42
44
let currentDate : Date = new Date ( ) ;
43
45
let source = info . valueForKey ( UIImagePickerControllerOriginalImage ) ;
46
+ if ( this . _allowsEditing ) {
47
+ source = info . valueForKey ( UIImagePickerControllerEditedImage ) ;
48
+ }
44
49
if ( source ) {
45
50
let imageSource : typeof imageSourceModule = require ( "image-source" ) ;
46
51
let imageSourceResult = imageSource . fromNativeSource ( source ) ;
@@ -129,11 +134,13 @@ export let takePicture = function (options): Promise<any> {
129
134
let reqHeight = 0 ;
130
135
let keepAspectRatio = true ;
131
136
let saveToGallery = true ;
137
+ let allowsEditing = false ;
132
138
if ( options ) {
133
139
reqWidth = options . width || 0 ;
134
140
reqHeight = options . height || reqWidth ;
135
141
keepAspectRatio = types . isNullOrUndefined ( options . keepAspectRatio ) ? keepAspectRatio : options . keepAspectRatio ;
136
142
saveToGallery = types . isNullOrUndefined ( options . saveToGallery ) ? saveToGallery : options . saveToGallery ;
143
+ allowsEditing = types . isNullOrUndefined ( options . allowsEditing ) ? allowsEditing : options . allowsEditing ;
137
144
}
138
145
139
146
let authStatus = PHPhotoLibrary . authorizationStatus ( ) ;
@@ -143,10 +150,10 @@ export let takePicture = function (options): Promise<any> {
143
150
144
151
if ( reqWidth && reqHeight ) {
145
152
listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallbackAndOptions (
146
- resolve , reject , { width : reqWidth , height : reqHeight , keepAspectRatio : keepAspectRatio , saveToGallery : saveToGallery } ) ;
153
+ resolve , reject , { width : reqWidth , height : reqHeight , keepAspectRatio : keepAspectRatio , saveToGallery : saveToGallery , allowsEditing : allowsEditing } ) ;
147
154
} else if ( saveToGallery ) {
148
155
listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallbackAndOptions (
149
- resolve , reject , { saveToGallery : saveToGallery , keepAspectRatio : keepAspectRatio } ) ;
156
+ resolve , reject , { saveToGallery : saveToGallery , keepAspectRatio : keepAspectRatio , allowsEditing : allowsEditing } ) ;
150
157
} else {
151
158
listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallback ( resolve , reject ) ;
152
159
}
@@ -162,6 +169,7 @@ export let takePicture = function (options): Promise<any> {
162
169
imagePickerController . sourceType = sourceType ;
163
170
imagePickerController . cameraDevice = options && options . cameraFacing === "front" ?
164
171
UIImagePickerControllerCameraDevice . Front : UIImagePickerControllerCameraDevice . Rear ;
172
+ imagePickerController . allowsEditing = allowsEditing ;
165
173
}
166
174
167
175
imagePickerController . modalPresentationStyle = UIModalPresentationStyle . CurrentContext ;
0 commit comments