-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1) feat(camera plugin): enabled camera functionality saving pic into firebase storage 2) Bug fixes, minor enhancements and clean up
- Loading branch information
1 parent
d8720f8
commit d21a9f5
Showing
16 changed files
with
141 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/pages/myinfo/personalprofilephoto/personalprofilephoto.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ion-header> | ||
<ion-navbar mlnavbar> | ||
<button menuToggle> | ||
<ion-icon name="menu" mllightblue></ion-icon> | ||
</button> | ||
<ion-title>Profile Photo</ion-title> | ||
<ion-buttons end> | ||
<button (click)="savePicture()" mllightblue>Save</button> | ||
</ion-buttons> | ||
</ion-navbar> | ||
</ion-header> | ||
<ion-content class='picturebg'> | ||
<img src="{{userPicture}}" width="100%" /> | ||
</ion-content> |
3 changes: 3 additions & 0 deletions
3
app/pages/myinfo/personalprofilephoto/personalprofilephoto.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.picturebg { | ||
background-color: #000; | ||
} |
72 changes: 72 additions & 0 deletions
72
app/pages/myinfo/personalprofilephoto/personalprofilephoto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import {Component} from '@angular/core'; | ||
import {NavController, Alert, AlertController, ActionSheet, Modal, ModalController, Loading, LoadingController, NavParams} from 'ionic-angular'; | ||
import {Camera} from 'ionic-native'; | ||
|
||
// Services | ||
import {PersonalProfilePhotoData} from '../../../providers/personalprofilephoto-data'; | ||
|
||
@Component({ | ||
templateUrl: 'build/pages/myinfo/personalprofilephoto/personalprofilephoto.html', | ||
providers: [PersonalProfilePhotoData] | ||
}) | ||
|
||
export class PersonalProfilePhotoPage { | ||
|
||
public userSettings: any; | ||
public userPicture: any; | ||
public userPictureblob: any; | ||
|
||
constructor( | ||
public nav: NavController, | ||
public modalController: ModalController, | ||
public alertController: AlertController, | ||
public loadingController: LoadingController, | ||
public personalprofilephotoData: PersonalProfilePhotoData) { | ||
|
||
// Initialize camera on load | ||
this.takePicture(); | ||
} | ||
|
||
dismiss() { | ||
this.nav.pop(); | ||
} | ||
|
||
savePicture() { | ||
this.personalprofilephotoData.savePicture(this.userPictureblob); | ||
this.dismiss(); | ||
} | ||
|
||
takePicture(){ | ||
Camera.getPicture({ | ||
quality : 95, | ||
destinationType : Camera.DestinationType.DATA_URL, | ||
sourceType : Camera.PictureSourceType.CAMERA, | ||
allowEdit : true, | ||
encodingType: Camera.EncodingType.PNG, | ||
targetWidth: 800, | ||
targetHeight: 800, | ||
saveToPhotoAlbum: false | ||
}).then(imageData => { | ||
const b64toBlob = (b64Data, contentType='', sliceSize=512) => { | ||
const byteCharacters = atob(b64Data); | ||
const byteArrays = []; | ||
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) { | ||
const slice = byteCharacters.slice(offset, offset + sliceSize); | ||
const byteNumbers = new Array(slice.length); | ||
for (let i = 0; i < slice.length; i++) { | ||
byteNumbers[i] = slice.charCodeAt(i); | ||
} | ||
const byteArray = new Uint8Array(byteNumbers); | ||
byteArrays.push(byteArray); | ||
} | ||
const blob = new Blob(byteArrays, {type: contentType}); | ||
return blob; | ||
} | ||
this.userPictureblob = b64toBlob(imageData, 'image/png'); | ||
this.userPicture = "data:image/jpeg;base64," + imageData; | ||
}, error => { | ||
console.log("ERROR -> " + JSON.stringify(error)); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {Injectable} from '@angular/core'; | ||
|
||
@Injectable() | ||
export class PersonalProfilePhotoData { | ||
|
||
public user: any; | ||
public userdata: any; | ||
public profilepicdata: any; | ||
|
||
constructor() { | ||
this.user = firebase.auth().currentUser; | ||
this.userdata = firebase.database().ref('/users/'); | ||
this.profilepicdata = firebase.storage().ref('/profilepics/'); | ||
} | ||
|
||
savePicture(pic): any { | ||
this.profilepicdata.child(this.user.uid).child('profilepicture.png') | ||
.put(pic).then((savedpicture) => { | ||
this.userdata.child(this.user.uid).update({'profilepic' : savedpicture.downloadURL}); | ||
}); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters