|
@@ -1,12 +1,12 @@
|
|
|
import { Component } from '@angular/core';
|
|
|
import { NavController, NavParams, ActionSheetController } from 'ionic-angular';
|
|
|
-import { Camera } from 'ionic-native';
|
|
|
import { Product } from '../../models/product'
|
|
|
import { DataProvider } from '../../providers/data-provider'
|
|
|
+import { CameraProvider } from '../../providers/camera-provider';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'page-product-details',
|
|
|
- providers: [DataProvider],
|
|
|
+ providers: [CameraProvider],
|
|
|
templateUrl: 'product-details.html'
|
|
|
})
|
|
|
export class ProductDetailsPage {
|
|
@@ -28,7 +28,8 @@ export class ProductDetailsPage {
|
|
|
public navCtrl: NavController,
|
|
|
public params: NavParams,
|
|
|
public data: DataProvider,
|
|
|
- public actionSheetCtrl: ActionSheetController
|
|
|
+ public actionSheetCtrl: ActionSheetController,
|
|
|
+ private cameraProvider: CameraProvider
|
|
|
) {
|
|
|
this.initialize();
|
|
|
}
|
|
@@ -64,14 +65,14 @@ export class ProductDetailsPage {
|
|
|
text: "Desde la cámara",
|
|
|
icon: "camera",
|
|
|
handler: () => {
|
|
|
- this.takePicture(Camera.PictureSourceType.CAMERA);
|
|
|
+ this.takePicture("camera");
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
text: "Desde la galería",
|
|
|
icon: "images",
|
|
|
handler: () => {
|
|
|
- this.takePicture(Camera.PictureSourceType.SAVEDPHOTOALBUM);
|
|
|
+ this.takePicture("album");
|
|
|
}
|
|
|
},
|
|
|
{
|
|
@@ -85,15 +86,8 @@ export class ProductDetailsPage {
|
|
|
|
|
|
*
|
|
|
*/
|
|
|
- takePicture(sourceType: number) {
|
|
|
- Camera.getPicture({
|
|
|
- sourceType: sourceType,
|
|
|
- destinationType: Camera.DestinationType.DATA_URL,
|
|
|
- correctOrientation: true,
|
|
|
- saveToPhotoAlbum: false,
|
|
|
- targetHeight: 300,
|
|
|
- targetWidth: 300
|
|
|
- }).then(i => {
|
|
|
+ takePicture(source: string): void {
|
|
|
+ this.cameraProvider.getPicture(source).then(i => {
|
|
|
this.product.image = i;
|
|
|
}).catch(e => {
|
|
|
console.log(e);
|