I am using the ActionSheet component to get the user to select an image either from the camera or the gallery.
What I would like to do is call a service function getPicture that will show the ActionSheet and depending on the user selection will resolve with the photo either from camera or gallery.
public getPicture() {
let actionSheet = ActionSheet.create({
title: 'Select Source',
buttons: [
{
text: 'Take Picture',
icon: this._platform.is('android') ? 'camera' : null,
handler: () => {
this.UseCamera(Camera.PictureSourceType.CAMERA)
.then(WHAT NOW?);
}
}, {
text: 'Import From Library',
icon: this._platform.is('android') ? 'camera' : null,
handler: () => {
this.UseCamera(Camera.PictureSourceType.PHOTOLIBRARY)
.then(WHAT NOW?);
}
}, {
text: 'Cancel',
role: 'cancel',
icon: this._platform.is('android') ? 'close' : null,
handler: () => {
}
}
]
});
this._nav.present(actionSheet);
}
//Note this.UseCamera(Camera.PictureSourceType.CAMERA) returns a promise that resolved with the Base64 photo string
How can I resolve the string to the caller of getPicture?
One option would be to use an eventEmitter to emit an event on the handler with the given data, but I am not sure it will work, and not crazy about it. Is there a clean way to go about this?