Skip to content

Commit 0395f5b

Browse files
committed
fix(): Fix error on get image page
1 parent c3ba6db commit 0395f5b

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

src/pages/ionic-native/get-image/get-image.ts

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,62 @@ export class GetImagePage {
1616
}
1717

1818
changePicture() {
19-
let loading = this.loadingCtrl.create();
2019

21-
let actionSheet = this.actionsheetCtrl.create({
22-
title: 'Upload picture',
23-
cssClass: 'action-sheets-basic-page',
20+
let actionsheet = this.actionsheetCtrl.create({
21+
title: 'upload picture',
2422
buttons: [
2523
{
26-
text: 'Camera',
24+
text: 'camera',
2725
icon: !this.platform.is('ios') ? 'camera' : null,
2826
handler: () => {
29-
loading.present();
30-
return this.cameraProvider.getPictureFromCamera().then(picture => {
31-
if (picture) {
32-
this.chosenPicture = picture;
33-
}
34-
loading.dismiss();
35-
}, error => {
36-
alert(error);
37-
});
27+
this.takePicture();
3828
}
3929
},
4030
{
41-
text: !this.platform.is('ios') ? 'Gallery' : 'Camera Roll',
31+
text: !this.platform.is('ios') ? 'gallery' : 'camera roll',
4232
icon: !this.platform.is('ios') ? 'image' : null,
4333
handler: () => {
44-
loading.present();
45-
return this.cameraProvider.getPictureFromPhotoLibrary().then(picture => {
46-
if (picture) {
47-
this.chosenPicture = picture;
48-
}
49-
loading.dismiss();
50-
}, error => {
51-
alert(error);
52-
});
34+
this.getPicture();
5335
}
5436
},
5537
{
56-
text: 'Cancel',
38+
text: 'cancel',
5739
icon: !this.platform.is('ios') ? 'close' : null,
5840
role: 'destructive',
5941
handler: () => {
60-
console.log('The user has cancelled the interaction.');
42+
console.log('the user has cancelled the interaction.');
6143
}
6244
}
6345
]
6446
});
65-
return actionSheet.present();
47+
return actionsheet.present();
48+
}
49+
50+
takePicture() {
51+
let loading = this.loadingCtrl.create();
52+
53+
loading.present();
54+
return this.cameraProvider.getPictureFromCamera().then(picture => {
55+
if (picture) {
56+
this.chosenPicture = picture;
57+
}
58+
loading.dismiss();
59+
}, error => {
60+
alert(error);
61+
});
62+
}
63+
64+
getPicture() {
65+
let loading = this.loadingCtrl.create();
66+
67+
loading.present();
68+
return this.cameraProvider.getPictureFromPhotoLibrary().then(picture => {
69+
if (picture) {
70+
this.chosenPicture = picture;
71+
}
72+
loading.dismiss();
73+
}, error => {
74+
alert(error);
75+
});
6676
}
6777
}

src/pages/ionic-native/ionic-native.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { GetImagePage } from './get-image/get-image';
33
import { CreditCardScanPage } from './credit-card-scan/credit-card-scan';
44
import { BarcodescannerPage } from './barcodescanner/barcodescanner';
55
import { Component } from '@angular/core';
6-
import { IonicPage, NavController, NavParams } from 'ionic-angular';
6+
import { IonicPage, NavController } from 'ionic-angular';
77

88
@IonicPage()
99
@Component({

0 commit comments

Comments
 (0)