@@ -16,52 +16,62 @@ export class GetImagePage {
16
16
}
17
17
18
18
changePicture ( ) {
19
- let loading = this . loadingCtrl . create ( ) ;
20
19
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' ,
24
22
buttons : [
25
23
{
26
- text : 'Camera ' ,
24
+ text : 'camera ' ,
27
25
icon : ! this . platform . is ( 'ios' ) ? 'camera' : null ,
28
26
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 ( ) ;
38
28
}
39
29
} ,
40
30
{
41
- text : ! this . platform . is ( 'ios' ) ? 'Gallery ' : 'Camera Roll ' ,
31
+ text : ! this . platform . is ( 'ios' ) ? 'gallery ' : 'camera roll ' ,
42
32
icon : ! this . platform . is ( 'ios' ) ? 'image' : null ,
43
33
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 ( ) ;
53
35
}
54
36
} ,
55
37
{
56
- text : 'Cancel ' ,
38
+ text : 'cancel ' ,
57
39
icon : ! this . platform . is ( 'ios' ) ? 'close' : null ,
58
40
role : 'destructive' ,
59
41
handler : ( ) => {
60
- console . log ( 'The user has cancelled the interaction.' ) ;
42
+ console . log ( 'the user has cancelled the interaction.' ) ;
61
43
}
62
44
}
63
45
]
64
46
} ) ;
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
+ } ) ;
66
76
}
67
77
}
0 commit comments