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 26, 2017
1 parent d5caaae commit 3a2c6f7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions client/imports/pages/messages/messages-attachments.ts
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { AlertController, Platform, ModalController, ViewController } from 'ionic-angular';
import { Camera } from 'ionic-native';
import { PictureService } from '../../services/picture';
import { MessageType } from '../../../../imports/models';
import { NewLocationMessageComponent } from './location-message';
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 3a2c6f7

Please sign in to comment.