Skip to content

Commit

Permalink
Step 13.6: Implement takePicture
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 13, 2017
1 parent 3d909a4 commit 72409d5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/pages/messages/messages-attachments.ts
Expand Up @@ -3,6 +3,7 @@ import { AlertController, Platform, ModalController, ViewController } from 'ioni
import { NewLocationMessageComponent } from './location-message';
import { MessageType } from 'api/models';
import { PictureService } from '../../services/picture';
import { Camera } from 'ionic-native';

@Component({
selector: 'messages-attachments',
Expand All @@ -26,6 +27,21 @@ export class MessagesAttachmentsComponent {
});
}

takePicture(): void {
if (!this.platform.is('cordova')) {
return console.warn('Device must run cordova in order to take pictures');
}

Camera.getPicture().then((dataURI) => {
const blob = this.pictureService.convertDataURIToBlob(dataURI);

this.viewCtrl.dismiss({
messageType: MessageType.PICTURE,
selectedPicture: blob
});
});
}

sendLocation(): void {
const locationModal = this.modelCtrl.create(NewLocationMessageComponent);
locationModal.onDidDismiss((location) => {
Expand Down

0 comments on commit 72409d5

Please sign in to comment.