@nativescript/camera
Advanced tools
Comparing version 5.0.5 to 5.0.6
import { Utils, ImageSource, ImageAsset, Trace, Frame } from '@nativescript/core'; | ||
let UIImagePickerControllerDelegateImpl = class UIImagePickerControllerDelegateImpl extends NSObject { | ||
static new() { | ||
return super.new(); | ||
var UIImagePickerControllerDelegateImpl = /** @class */ (function (_super) { | ||
__extends(UIImagePickerControllerDelegateImpl, _super); | ||
function UIImagePickerControllerDelegateImpl() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
initWithCallback(callback, errorCallback) { | ||
UIImagePickerControllerDelegateImpl.new = function () { | ||
return _super.new.call(this); | ||
}; | ||
UIImagePickerControllerDelegateImpl.prototype.initWithCallback = function (callback, errorCallback) { | ||
this._callback = callback; | ||
this._errorCallback = errorCallback; | ||
return this; | ||
} | ||
initWithCallbackAndOptions(callback, errorCallback, options) { | ||
}; | ||
UIImagePickerControllerDelegateImpl.prototype.initWithCallbackAndOptions = function (callback, errorCallback, options) { | ||
this._callback = callback; | ||
@@ -22,7 +26,8 @@ this._errorCallback = errorCallback; | ||
return this; | ||
} | ||
imagePickerControllerDidFinishPickingMediaWithInfo(picker, info) { | ||
}; | ||
UIImagePickerControllerDelegateImpl.prototype.imagePickerControllerDidFinishPickingMediaWithInfo = function (picker, info) { | ||
var _this = this; | ||
if (info) { | ||
let currentDate = new Date(); | ||
let source = info.valueForKey(UIImagePickerControllerOriginalImage); | ||
var currentDate_1 = new Date(); | ||
var source = info.valueForKey(UIImagePickerControllerOriginalImage); | ||
if (this._allowsEditing) { | ||
@@ -32,19 +37,19 @@ source = info.valueForKey(UIImagePickerControllerEditedImage); | ||
if (source) { | ||
let imageSourceResult = new ImageSource(source); | ||
var imageSourceResult_1 = new ImageSource(source); | ||
if (this._callback) { | ||
let imageAsset; | ||
var imageAsset_1; | ||
if (this._saveToGallery) { | ||
PHPhotoLibrary.sharedPhotoLibrary().performChangesCompletionHandler(() => { | ||
PHAssetChangeRequest.creationRequestForAssetFromImage(imageSourceResult.ios); | ||
}, (success, err) => { | ||
PHPhotoLibrary.sharedPhotoLibrary().performChangesCompletionHandler(function () { | ||
PHAssetChangeRequest.creationRequestForAssetFromImage(imageSourceResult_1.ios); | ||
}, function (success, err) { | ||
if (success) { | ||
let fetchOptions = PHFetchOptions.alloc().init(); | ||
let sortDescriptors = NSArray.arrayWithObject(NSSortDescriptor.sortDescriptorWithKeyAscending('creationDate', false)); | ||
var fetchOptions = PHFetchOptions.alloc().init(); | ||
var sortDescriptors = NSArray.arrayWithObject(NSSortDescriptor.sortDescriptorWithKeyAscending('creationDate', false)); | ||
fetchOptions.sortDescriptors = sortDescriptors; | ||
fetchOptions.predicate = NSPredicate.predicateWithFormatArgumentArray('mediaType = %d', NSArray.arrayWithObject(1 /* Image */)); | ||
let fetchResult = PHAsset.fetchAssetsWithOptions(fetchOptions); | ||
fetchOptions.predicate = NSPredicate.predicateWithFormatArgumentArray('mediaType = %d', NSArray.arrayWithObject(PHAssetMediaType.Image)); | ||
var fetchResult = PHAsset.fetchAssetsWithOptions(fetchOptions); | ||
if (fetchResult.count > 0) { | ||
// Take last picture | ||
let asset = fetchResult.objectAtIndex(0); | ||
const dateDiff = asset.creationDate.valueOf() - currentDate.valueOf(); | ||
var asset = fetchResult.objectAtIndex(0); | ||
var dateDiff = asset.creationDate.valueOf() - currentDate_1.valueOf(); | ||
if (Math.abs(dateDiff) > 1000) { | ||
@@ -55,4 +60,4 @@ // Image assets create date is rounded when asset is created. | ||
} | ||
imageAsset = new ImageAsset(asset); | ||
this.setImageAssetAndCallCallback(imageAsset); | ||
imageAsset_1 = new ImageAsset(asset); | ||
_this.setImageAssetAndCallCallback(imageAsset_1); | ||
} | ||
@@ -66,4 +71,4 @@ } | ||
else { | ||
imageAsset = new ImageAsset(imageSourceResult.ios); | ||
this.setImageAssetAndCallCallback(imageAsset); | ||
imageAsset_1 = new ImageAsset(imageSourceResult_1.ios); | ||
this.setImageAssetAndCallCallback(imageAsset_1); | ||
} | ||
@@ -75,11 +80,11 @@ } | ||
listener = null; | ||
} | ||
setImageAssetAndCallCallback(imageAsset) { | ||
}; | ||
UIImagePickerControllerDelegateImpl.prototype.setImageAssetAndCallCallback = function (imageAsset) { | ||
if (this._keepAspectRatio) { | ||
let pictureWidth = imageAsset.nativeImage ? imageAsset.nativeImage.size.width : imageAsset.ios.pixelWidth; | ||
let pictureHeight = imageAsset.nativeImage ? imageAsset.nativeImage.size.height : imageAsset.ios.pixelHeight; | ||
let isPictureLandscape = pictureWidth > pictureHeight; | ||
let areOptionsLandscape = this._width > this._height; | ||
var pictureWidth = imageAsset.nativeImage ? imageAsset.nativeImage.size.width : imageAsset.ios.pixelWidth; | ||
var pictureHeight = imageAsset.nativeImage ? imageAsset.nativeImage.size.height : imageAsset.ios.pixelHeight; | ||
var isPictureLandscape = pictureWidth > pictureHeight; | ||
var areOptionsLandscape = this._width > this._height; | ||
if (isPictureLandscape !== areOptionsLandscape) { | ||
let oldWidth = this._width; | ||
var oldWidth = this._width; | ||
this._width = this._height; | ||
@@ -95,13 +100,11 @@ this._height = oldWidth; | ||
this._callback(imageAsset); | ||
} | ||
imagePickerControllerDidCancel(picker) { | ||
}; | ||
UIImagePickerControllerDelegateImpl.prototype.imagePickerControllerDidCancel = function (picker) { | ||
picker.presentingViewController.dismissViewControllerAnimatedCompletion(true, null); | ||
listener = null; | ||
this._errorCallback(new Error('cancelled')); | ||
} | ||
}; | ||
UIImagePickerControllerDelegateImpl.ObjCProtocols = [UIImagePickerControllerDelegate]; | ||
UIImagePickerControllerDelegateImpl = __decorate([ | ||
NativeClass() | ||
], UIImagePickerControllerDelegateImpl); | ||
}; | ||
UIImagePickerControllerDelegateImpl.ObjCProtocols = [UIImagePickerControllerDelegate]; | ||
return UIImagePickerControllerDelegateImpl; | ||
}(NSObject)); | ||
let listener; | ||
@@ -108,0 +111,0 @@ export let takePicture = function (options) { |
{ | ||
"name": "@nativescript/camera", | ||
"version": "5.0.5", | ||
"version": "5.0.6", | ||
"description": "Provides API for using device camera", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
509
54072
17