To capture a photo in the Main.js
controller, we need to add a click handler to the Take Photo button. We can do this by adding such a tap handler in the control section:
control: { takePhotoBtn: { tap: 'getPhoto' } }
After that, we define a variable in the controller to store the link to the original image without any applied effect:
originalImageUri: null
When the user taps the Take Photo button, the getPhoto
function will be called. In the function, we take pictures and assign its URL to the originalImageUri
controller's variable to reference later:
getPhoto: function() { var self = this; self.getCameraPicture(function(imageURI) { self.originalImageUri = imageURI; self.showPhotoPopup(imageURI); }); }
You can see that here, we called the self.getCameraPicture
function, where we access the camera plugin:
getCameraPicture: function(callback) { if (Ext.browser.is.PhoneGap) { var onSuccess = function(imageURI) { ...