Last active
May 7, 2018 23:31
-
-
Save ponnex/9531106feb1e547dfbf2c1b158946d36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DISCLAIMER: Did not test this code HAHAHA ask lang if ever naay error ;) | |
// Camera Service | |
onTakePhoto() { | |
return new Promise((resolve, reject) => { | |
requestPermissions().then( | |
() => { | |
// Other Codes Here | |
takePicture(options) | |
.then((imageAsset: any) => { | |
let source = new ImageSource(); | |
source.fromAsset(imageAsset).then((source) => { | |
return resolve(source); | |
}); | |
}); | |
}).catch(err => { | |
return reject(err); | |
}); | |
}, | |
() => return reject(err); | |
); | |
}); | |
} | |
// Component | |
this.priceListImage = imageSource; | |
this._cameraService.onTakePhoto().then((imageSource: ImageSource) => { | |
this.priceListImage = imageSource; // <- the ImageAsset from Service ;) | |
console.dir(this.priceListImage); | |
//Research on how to use the ImageSource for e.g. Image src for displaying the image, get the path of the file, etc | |
}).catch(err => { | |
// Do something here when there's an error | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment