<file_sep>import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser'

/**
 * Generated class for the VideoTuitionPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-video-tuition',
  templateUrl: 'video-tuition.html',
})
export class VideoTuitionPage {

  constructor(public navCtrl: NavController, public navParams: NavParams, public platform: Platform, private iab: InAppBrowser) {
	  
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad VideoTuitionPage');
  }
 openUrl(){
	 //this. platform.ready().then(() => {
		 const browser = this. iab.create('https://www.numberprep.com/online-tutoring/', '_self', 'location= yes');
		 browser.show();
	// });
 }
}
<file_sep>import { Injectable } from '@angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import 'rxjs/add/operator/map';
import * as firebase from 'firebase/app';
import { Storage } from '@ionic/storage';



@Injectable()
export class AuthServiceProvider {
	public fireAuth: any;
	userData= firebase.database().ref('/userProfile');
	userCredit:number=0;
	acredit:any;

  constructor(public af: AngularFireAuth, public storage:Storage) {
		this.fireAuth = firebase.auth();
		console.log('Hello AuthServiceProvider Provider');
  }
   doLogin(email: string, password: string): firebase.Promise<any> {
    return this.fireAuth.signInWithEmailAndPassword(email, password);
  }

  register(email: string, password: string, fullname: string, age: number, year: string, schoolname: string): firebase.Promise<any> {
    return this.fireAuth.createUserWithEmailAndPassword(email, password)
     .then((newUser) => {this.userData.child(this.fireAuth.currentUser.uid).set({
		 email:email,
		 fullname:fullname,
		 age:age,
		 year:year,
		 schoolname:schoolname,
		 usercredit:this.userCredit,
		 photoUrl:'https://firebasestorage.googleapis.com/v0/b/numberapp-dbbb6.appspot.com/o/marguerite-daisy-beautiful-beauty.jpg?alt=media&token=<PASSWORD>'});
       this.storage.set('userInfo', JSON.stringify(newUser));
	   // firebase.database().ref('userProfile').child(newUser.uid).set({email: email});
      });
  }
  
   updateimage(imageurl) {
      var promise = new Promise((resolve, reject) => {
          this.fireAuth.currentUser.updateProfile({
              displayName: this.fireAuth.currentUser.fullname,
              photoURL: imageurl      
          }).then(() => {
              this.userData.child(this.fireAuth.currentUser.uid).update({
              fullname: this.fireAuth.currentUser.fullname,
              photoURL: imageurl,
              uid: firebase.auth().currentUser.uid
              }).then(() => {
                  resolve({ success: true });
                  }).catch((err) => {
                      reject(err);
                  })
          }).catch((err) => {
                reject(err);
             })  
      })
      return promise;
  }
  onfetchdata(){
	  var promise= new Promise((resolve,reject)=> {
		  this.userData.child(this.fireAuth.currentUser.uid).once('value',(snapshot) => {
			  resolve(snapshot.val());
		  }).catch ((err) => {
			  reject(err);
		  })
	  })
	  return promise;
  }
  
  resetPassword(email: string): any {
    return this.fireAuth.sendPasswordResetEmail(email);
  }

  doLogout(): any {
    return this.fireAuth.signOut();
  }

}
<file_sep>import { Component } from '@angular/core';

/**
 * Generated class for the ChatBubbleComponent component.
 *
 * See https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html
 * for more info on Angular Components.
 */
@Component({
  selector: 'chat-bubble',
  inputs: ['msg: message'],
  templateUrl: 'chat-bubble.html'
})
export class ChatBubbleComponent {

 /** text: string;

  constructor() {
    console.log('Hello ChatBubbleComponent Component');
    this.text = 'Hello World';
  }
*/
 public msg: any;
    constructor() {
        this.msg = {
            content: 'Welcome, How may i help you?',
            isMe: true,
            time: '14/07/2017',
			type:'text',
            senderName: 'NumberPrep'
        }
    }

}
<file_sep>import { Component,  NgZone  } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { ImghandlerProvider } from '../../providers/imghandler/imghandler';
import { AuthServiceProvider } from '../../providers/auth-service/auth-service';

/**
 * Generated class for the ProfilePage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-profile',
  templateUrl: 'profile.html',
})
export class ProfilePage {
	avatar: string;
	fullname: string;
  constructor(public navCtrl: NavController, public navParams: NavParams,
  public uprovider:AuthServiceProvider, public zone: NgZone, public alertCtrl: AlertController,
    public imghandler: ImghandlerProvider) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad ProfilePage');
	this.loaduserdetails();
  }
  
loaduserdetails(){
	this.uprovider.onfetchdata().then((res: any) => {
      this.fullname = res.fullname;
      this.zone.run(() => {
        this.avatar = res.photoURL;
      })
    })
}

editimage() {
    let statusalert = this.alertCtrl.create({
      buttons: ['okay']
    });
    this.imghandler.uploadimage().then((url: any) => {
      this.uprovider.updateimage(url).then((res: any) => {
        if (res.success) {
          statusalert.setTitle('Updated');
          statusalert.setSubTitle('Your profile pic has been changed successfully!!');
          statusalert.present();
          this.zone.run(() => {
          this.avatar = url;
        })  
        }  
      }).catch((err) => {
          statusalert.setTitle('Failed');
          statusalert.setSubTitle('Your profile pic was not changed');
          statusalert.present();
      })
      })
  }

}
<file_sep>import { Component } from '@angular/core';
import { IonicPage, NavController, AlertController, NavParams, LoadingController } from 'ionic-angular';
import { FormBuilder, Validators } from '@angular/forms';
import { AuthServiceProvider} from '../../providers/auth-service/auth-service';
import { HomePage } from '../home/home';
import { RegisterPage } from '../register/register';
import { TutorLoginPage } from '../tutor-login/tutor-login';

@IonicPage({
  name: 'login'
})

@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {
	
  public loginForm;
  emailChanged: boolean = false;
  passwordChanged: boolean = false;
  submitAttempt: boolean = false;
  loading: any;

  constructor(public navCtrl: NavController, public authService: AuthServiceProvider, public navParams: NavParams, 
			public formBuilder: FormBuilder, public alertCtrl: AlertController, public loadingCtrl: LoadingController) {
				let EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
				this.loginForm = formBuilder.group({
					email: ['', Validators.compose([Validators.required, Validators.pattern(EMAIL_REGEXP)])],
					password: ['', Validators.compose([Validators.minLength(6), Validators.required])]
    });
  }

    ionViewDidLoad() {
    console.log('ionViewDidLoad LoginPage');
  }
  
  loginUser(){
    this.submitAttempt = true;

    if (!this.loginForm.valid){
      console.log(this.loginForm.value);
    } else {
      this.authService.doLogin(this.loginForm.value.email, this.loginForm.value.password).then( authService => {
        this.navCtrl.setRoot(HomePage);
      }, error => {
        this.loading.dismiss().then( () => {
          let alert = this.alertCtrl.create({
            message: error.message,
            buttons: [
              {
                text: "Ok",
                role: 'cancel'
              }
            ]
          });
          alert.present();
        });
      });

      this.loading = this.loadingCtrl.create({
        dismissOnPageChange: true,
      });
      this.loading.present();
    }
  }
  
 goToRegister(): void { this.navCtrl.push(RegisterPage);}
 
 gotoTutorlogin(): void{this.navCtrl.push(TutorLoginPage);}
 
 
 
 
}
<file_sep>import { Injectable } from '@angular/core';
import { AngularFireDatabase} from 'angularfire2/database';
import { Storage } from '@ionic/storage';
import { Camera } from '@ionic-native/camera';
import { Http } from '@angular/http';
import * as firebase from 'firebase/app';
import 'rxjs/add/operator/map';


/*
  Generated class for the UserProvider provider.

  See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  for more info on providers and Angular DI.
*/
@Injectable()
export class UserProvider {
	m:any;
	
constructor(public http: Http, public angFire:AngularFireDatabase, 
  private camera:Camera, public local:Storage) {
	  
    console.log('Hello UserProvider Provider');
  }
  
  //get Current User's UID
  getUid(){
	  return this.local.get('userInfo').then(value => {
		  let newValue=JSON.parse(value);
		  return newValue.uid;
	  });
  }
  getCurrentUser(){
	  var uId=firebase.auth().currentUser.uid;
	  return uId;
  }
  
  /*getTutorId(tutor:string){
	  var query= firebase.database().ref('tutors').orderByChild('email').equalTo(tutor);
	     query.once("value",(snapshot) => {
				snapshot.forEach((childSnapshot)=>{
					console.log(childSnapshot.key);
					//return tvalue;
				});
			});
  }*/
   
  
}
<file_sep>import { Component, ViewChild, Renderer } from '@angular/core';
import { IonicPage, NavController, NavParams, Content, Platform} from 'ionic-angular';
import { Keyboard } from '@ionic-native/keyboard';
import { ImagePicker } from '@ionic-native/image-picker';
import { Camera} from '@ionic-native/camera';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { UserProvider } from '../../providers/user/user-provider';
import {ChatProvider} from '../../providers/chat/chat-provider';
//import { AngularFireAuth } from 'angularfire2/auth';
//import * as firebase from 'firebase/app';

/**
 * Generated class for the ChatViewPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-chat-view',
  templateUrl: 'chat-view.html',
})
export class ChatViewPage {
	//message:string;
	uid:string;
	interlocutor:string;
	username:string;
	chats:FirebaseListObservable<any>;
	@ViewChild(Content)content:Content;
  private inputElement;
  private millis = 200;
  private scrollTimeout = this.millis + 50;
  private textareaHeight;
  private scrollContentElelment: any;
  private footerElement: any;
  private initialTextAreaHeight;
  private keyboardHideSub;
  private keybaordShowSub;
  user:boolean;
  userid:string;
  private message = "";

  constructor(private camera: Camera, private keyboard: Keyboard, private imagePicker: ImagePicker, 
			public platform: Platform, public renderer: Renderer, 
			public navCtrl: NavController, public navParams: NavParams, 
				public angFire:AngularFireDatabase, public chatprov:ChatProvider, 
				public userprov:UserProvider) 
	{		
		this.uid = navParams.get('uid');
		this.interlocutor = navParams.get('interlocutor');
		this.username = navParams.get('name');
		
		chatprov.getChatRef(this.uid,this.interlocutor).then((chatRef:any)=>
		{
			this.chats =this.angFire.list(chatRef);
		});
	 
	}
ionViewDidLoad() {
	
	this.updateScroll('load', 500)
  if (this.platform.is('ios')) {
     this.addKeyboardListeners()
  }

    this.scrollContentElelment = this.content.getScrollElement();

    this.footerElement = document.getElementsByTagName('page-chat-view')[0].getElementsByTagName('ion-footer')[0];
    this.inputElement = document.getElementsByTagName('page-chat-view')[0].getElementsByTagName('textarea')[0];

    this.footerElement.style.cssText = this.footerElement.style.cssText + "transition: all " + this.millis + "ms; -webkit-transition: all " +
      this.millis + "ms; -webkit-transition-timing-function: ease-out; transition-timing-function: ease-out;"

    this.scrollContentElelment.style.cssText = this.scrollContentElelment.style.cssText + "transition: all " + this.millis + "ms; -webkit-transition: all " +
      this.millis + "ms; -webkit-transition-timing-function: ease-out; transition-timing-function: ease-out;"

    this.textareaHeight = Number(this.inputElement.style.height.replace('px', ''));
    this.initialTextAreaHeight = this.textareaHeight;

    

  
}
addKeyboardListeners() {

    this.keyboardHideSub = this.keyboard.onKeyboardHide().subscribe(() => {
      let newHeight = this.textareaHeight - this.initialTextAreaHeight + 44;
      let marginBottom = newHeight + 'px';
      console.log('marginBottom', marginBottom)
      this.renderer.setElementStyle(this.scrollContentElelment, 'marginBottom', marginBottom);
      this.renderer.setElementStyle(this.footerElement, 'marginBottom', '0px')
    });

    this.keybaordShowSub = this.keyboard.onKeyboardShow().subscribe((e) => {

      let newHeight = (e['keyboardHeight']) + this.textareaHeight - this.initialTextAreaHeight;
      let marginBottom = newHeight + 44 + 'px';
      console.log('marginBottom', marginBottom)
      this.renderer.setElementStyle(this.scrollContentElelment, 'marginBottom', marginBottom);
      this.renderer.setElementStyle(this.footerElement, 'marginBottom', e['keyboardHeight'] + 'px');
      this.updateScroll('keybaord show', this.scrollTimeout);
    });
  }
  
   footerTouchStart(event) {
    //console.log('footerTouchStart: ', event.type, event.target.localName, '...')
    if (event.target.localName !== "textarea") {
      event.preventDefault();
      // console.log('preventing')
    }
  }

contentMouseDown(event) {
    //console.log('blurring input element :- > event type:', event.type);
    this.inputElement.blur();
  }
  
textAreaChange() {

    let newHeight = Number(this.inputElement.style.height.replace('px', ''));
    if (newHeight !== this.textareaHeight) {

      let diffHeight = newHeight - this.textareaHeight;
      this.textareaHeight = newHeight;
      let newNumber = Number(this.scrollContentElelment.style.marginBottom.replace('px', '')) + diffHeight;

      let marginBottom = newNumber + 'px';
      this.renderer.setElementStyle(this.scrollContentElelment, 'marginBottom', marginBottom);
      this.updateScroll('textAreaChange', this.scrollTimeout);
    }
  }
  
  updateScroll(from, timeout) {
    setTimeout(() => {
      //console.log('updating scroll -->', from)
      this.content.scrollToBottom();
    }, timeout);
  }
  
  
  ionViewDidEnter() {
    this.content.scrollToBottom(300);
  }
  
 /** sendMessage(){
	  if(this.message){
		  let chat={
			  from:this.uid,
			  message:this.message,
			  type:'message',
			  timestamp: new Date()
		  };
		  this.chats.push(chat);
		  this.message = "";
	  }
	  
  };**/ 
  
  sendMessage() {
	this.user = this.uid === this.userprov.getCurrentUser();
    this.addMessage(this.user, this.message);
    this.message = "";
	//this.user=false;
    let currentHeight = this.scrollContentElelment.style.marginBottom.replace('px', '');
    let newHeight = currentHeight - this.textareaHeight + this.initialTextAreaHeight;
    let top = newHeight + 'px';
    this.renderer.setElementStyle(this.scrollContentElelment, 'marginBottom', top);
    this.updateScroll('sendMessage', this.scrollTimeout);
    this.textareaHeight = this.initialTextAreaHeight;

    setTimeout(() => {
         this.content.scrollToBottom(300);
  });
  
  }
  
  addMessage(id, msg) {
    
    this.chats.push({
	  from: this.uid,
      isMe:id,
      body: msg,
	  timestamp: new Date().toISOString(),
	  type:'message'
      
    });

  }
  
  
   /*sendPicture(){
	  let chat = {
		  from:this.uid,
		  type:'picture', 
		  picture:null};
	   }*/

  
  sendImage(){
  let camerOptions = {
      quality: 50,
      destinationType: this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE,
      sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
	  allowEdit: true,
      saveToPhotoAlbum: true,
      targetWidth: 1000,
      targetHeight: 1000,
	  correctOrientation: true  //Corrects Android orientation quirks
    }

    this.camera.getPicture(camerOptions).then((imageData) => {
      // imageData is either a base64 encoded string or a file URI
      // If it's base64:
      let base64Image = 'data:image/jpeg;base64,' + imageData;
	
	  this.user = this.uid === this.userprov.getCurrentUser();
      this.addImage(this.user, base64Image);
      console.log(base64Image);
      this.updateScroll('image add', this.millis)
    }, (err) => {
      // Handle error
    });

  }
  
  captureImage(){
  let camerOptions = {
      quality: 50,
      destinationType: this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE,
      sourceType: this.camera.PictureSourceType.CAMERA,
	  allowEdit: true,
      saveToPhotoAlbum: true,
      targetWidth: 1000,
      targetHeight: 1000,
	  correctOrientation: true  //Corrects Android orientation quirks
    }

    this.camera.getPicture(camerOptions).then((imageData) => {
      // imageData is either a base64 encoded string or a file URI
      // If it's base64:
      let base64Image = 'data:image/jpeg;base64,' + imageData;
	
	  this.user = this.uid === this.userprov.getCurrentUser();
      this.addImage(this.user, base64Image);
      console.log(base64Image);
      this.updateScroll('image add', this.millis)
    }, (err) => {
      // Handle error
    });

  }

  addImage(id, imgData) {
     this.chats.push({
	  from:this.uid,
      isMe:id,
      img: imgData,
	  type:'picture',
      timestamp: new Date()
    });
  }

    
}
<file_sep>import { Component } from '@angular/core';
import { App, IonicPage, NavController, NavParams } from 'ionic-angular';
import { AuthServiceProvider} from '../../providers/auth-service/auth-service';
import { LoginPage } from '../login/login';

/**
 * Generated class for the LogOutPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-log-out',
  templateUrl: 'log-out.html',
})
export class LogOutPage {

  constructor(public app:App, public navCtrl: NavController, public navParams: NavParams,  public authprovider:AuthServiceProvider ) {
  }

  ionViewDidLoad() {
    this.authprovider.doLogout().then(authprovider => {
		let nav = this.app.getRootNav();
	nav.setRoot(LoginPage);});
  }

}
<file_sep><!--
  Generated template for the VideoTuitionPage page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.
-->
<ion-header>

  <ion-navbar>
  <button ion-button menuToggle>
      <ion-icon name="menu"></ion-icon>
   </button>
    <ion-title>VideoTuition</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>
<p> Please, click on the button below to have access to get access to our video tuition. </p>

<button ion-button="" large="" color="primary" (click)="openUrl()" >Video Tuition</button>
</ion-content>
<file_sep>import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { VideoTuitionPage } from './video-tuition';

@NgModule({
  declarations: [
    VideoTuitionPage,
  ],
  imports: [
    IonicPageModule.forChild(VideoTuitionPage),
  ],
  exports: [
    VideoTuitionPage
  ]
})
export class VideoTuitionPageModule {}
<file_sep>import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import firebase from 'firebase';
import { AngularFireAuth } from 'angularfire2/auth';
import { UserProvider } from '../../providers/user/user-provider';
import { AuthServiceProvider} from '../../providers/auth-service/auth-service';

/**
 * Generated class for the BuycreditPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-buycredit',
  templateUrl: 'buycredit.html',
})
export class BuycreditPage {
	public fireAuth: any;
	credit:any;
	userId:any;
	userData= firebase.database().ref('/userProfile');
public newvalue: number;

  constructor(public navCtrl: NavController, public navParams: NavParams, 
			   public af: AngularFireAuth, public authService: AuthServiceProvider, public user:UserProvider) {
					this.fireAuth = firebase.auth();  
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad BuycreditPage');
	this.loadusercredit();
	 
  }
  loadusercredit(){
	   this.authService.onfetchdata().then((res:any)=>{
		   this.newvalue = res.usercredit;
	   })
  }
   
 add5(){
	 this.credit=this.newvalue + 50;
	 this.userData.child(this.fireAuth.currentUser.uid).update({usercredit:this.credit});
	}
	
 add10(){
	 this.credit=this.newvalue + 100;
	 this.userData.child(this.fireAuth.currentUser.uid).update({usercredit:this.credit});
	}
	
 add15(){
	 this.credit=this.newvalue + 150;
	 this.userData.child(this.fireAuth.currentUser.uid).update({usercredit:this.credit});
	 }
	 
 add20(){
	 this.credit=this.newvalue + 200;
	 this.userData.child(this.fireAuth.currentUser.uid).update({usercredit:this.credit});
	}
}
<file_sep>import { Component } from '@angular/core';
import { IonicPage, NavParams } from 'ionic-angular';

//import {ChatViewPage} from '../../pages/chat-view/chat-view';
import {ChatsPage} from '../../pages/chats/chats';
import {LogOutPage} from '../../pages/log-out/log-out';

@IonicPage()
@Component({
  selector: 'page-tutor-tabs',
  templateUrl: 'tutor-tabs.html',
})
export class TutorTabsPage {
	myTutor:any;
	//tab1Root:any = ChatViewPage;
	tab1Root:any = ChatsPage;
	tab2Root:any = LogOutPage;
	tab2Params:any;
	

  constructor(public navParams:NavParams) {
	  
	  this.myTutor=navParams.get('tutormail')
	  this.tab2Params={id:this.myTutor};
  }

 
}
<file_sep>import { Injectable } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import {UserProvider} from '../../providers/user/user-provider';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

/*
  Generated class for the ChatProvider provider.

  See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  for more info on providers and Angular DI.
*/
@Injectable()
export class ChatProvider {

  constructor(public http: Http, public angfire:AngularFireDatabase, public userprovider:UserProvider) 
  {
    console.log('Hello ChatProvider Provider');
  }
  
 //get list of chat of a logged in user
	getChats(){
	  return this. userprovider.getUid().then(uid => {
		let chats = this.angfire.list(`/userProfile/${uid}/chats`);
		return chats;
	});
}

//add chat reference to both users
	addChats(uid,interlocutor){
	// First User   
      //let otherUid = interlocutor; 
	  let endpoint = 
		this.angfire.object(`userProfile/${uid}/chats/${interlocutor}`);
       endpoint.set(true); 
	   
	   // Second User   
      
	  let endpoint2 = 
		this.angfire.object(`tutors/${interlocutor}/chats/${uid}`);
       endpoint2.set(true); 
}

 getChatRef(uid, interlocutor) { 
	let firstRef = 
		this.angfire.object(`userProfile/${uid}/chats/${interlocutor}`,{preserveSnapshot:true});
		let promise = new Promise((resolve, reject) => {
			  firstRef.subscribe(snapshot => {
				  let a = snapshot.exists();
				  if(a) {
					  resolve(`/chats/${interlocutor},${uid}`); 
					  } 
					else { 
						let secondRef = this.angfire.object(`tutors/${uid}/chats/${interlocutor}`, {preserveSnapshot:true});
						secondRef.subscribe(snapshot => {   
							let b = snapshot.exists();  
							if(b) {
								resolve(`/chats/${uid},${interlocutor}`);
								}
								else{
									this.addChats(uid,interlocutor);
									resolve(`/chats/${interlocutor},${uid}`);
								}
							});
						}
				}); 
			});     
		return promise; 
	} 

}
<file_sep>import { Component } from '@angular/core';
import { IonicPage, NavController, AlertController, NavParams, LoadingController } from 'ionic-angular';
import { FormBuilder, Validators } from '@angular/forms';
import { AuthServiceProvider} from '../../providers/auth-service/auth-service';
import {TutorTabsPage} from '../tutor-tabs/tutor-tabs';


/**
 * Generated class for the TutorLoginPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
@IonicPage()
@Component({
  selector: 'page-tutor-login',
  templateUrl: 'tutor-login.html',
})
export class TutorLoginPage {
	 public tutorForm;
	 submitAttempt: boolean = false;
	  loading: any;

  constructor(public navCtrl: NavController, public authService: AuthServiceProvider, public navParams: NavParams, 
			public formBuilder: FormBuilder, public alertCtrl: AlertController, public loadingCtrl: LoadingController) {
				let EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
				this.tutorForm = formBuilder.group({
					email: ['', Validators.compose([Validators.required, Validators.pattern(EMAIL_REGEXP)])],
					password: ['', Validators.compose([Validators.minLength(6), Validators.required])]
    });
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad TutorLoginPage');
  }
loginTutor(){
    this.submitAttempt = true;

    if (!this.tutorForm.valid){
      console.log(this.tutorForm.value);
    } else {
      this.authService.doLogin(this.tutorForm.value.email, this.tutorForm.value.password).then( authService => {
        this.navCtrl.push(TutorTabsPage,{tutormail:this.tutorForm.value.email});
      }, error => {
        this.loading.dismiss().then( () => {
          let alert = this.alertCtrl.create({
            message: error.message,
            buttons: [
              {
                text: "Ok",
                role: 'cancel'
              }
            ]
          });
          alert.present();
        });
      });

      this.loading = this.loadingCtrl.create({
        dismissOnPageChange: true,
      });
      this.loading.present();
    }
  }
}
<file_sep>import { Component } from '@angular/core';
import { NavController, ModalController, Platform } from 'ionic-angular';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import 'rxjs/add/operator/map';
import { TutorsPage } from '../tutors/tutors';


@Component({
  selector: 'page-ask-question',
  templateUrl: 'ask-question.html',
})
export class AskQuestionPage {
	public topics    : FirebaseListObservable<any[]>;
	
	selectedItem: any;
	icons: string[];
	items: Array<{title: string, note: string, icon: string}>;

  constructor(public navCtrl    : NavController,
               private angFire   : AngularFireDatabase,
               private modalCtrl : ModalController,
               private platform  : Platform)
   {
   }
  
  ionViewDidLoad() 
  {
    this.platform.ready()
      .then(() =>
      {
         this.topics = this.angFire.list('/topics');
      });
  }
  
  listtutors(topic){
	  this.navCtrl.push(TutorsPage, {topic : topic});
	  
	  //let params = { topic: topic },
          //tutormodal  = this.modalCtrl.create( TutorsPage, params);
			//tutormodal.present();
	  
    }
  
 }
<file_sep>import { Component, NgZone } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {Observable} from 'rxjs/Rx';
import { UserProvider } from '../../providers/user/user-provider';
import { AngularFireDatabase } from 'angularfire2/database';
import {ChatViewPage} from '../../pages/chat-view/chat-view';
import * as firebase from 'firebase/app';

/**
 * Generated class for the ChatsPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */
 
 export interface Detail {
    // Property (public by default)
	key:string;
    username: string;
	email: string;
    
}
@IonicPage()
@Component({
  selector: 'page-chats',
  templateUrl: 'chats.html',
})

 
export class ChatsPage {
	tutorID:any;
    myTutor:any;
	query:any;
	query1: any;
	query2:any;
	interlocutor:string;
	chats:Observable<any[]>;
	studentdetail: Detail[]=[];
	
  constructor(public navCtrl: NavController, public navParams: NavParams, public user:UserProvider, 
				public angfire:AngularFireDatabase, public zone: NgZone) {
			this.myTutor=navParams.get('id');
			this.query= firebase.database().ref('tutors').orderByChild('email').equalTo(this.myTutor);
			
			//this.getChats().then(chats => {
				/*this.chats=this.getChats().map(users =>{
					return users.map(user =>{
						user.info = this.angfire.object(`/userProfile/${user.$key}`);
						return user;
					});
				});*/
			//});
			
		
  }
  
  ngOnInit(){
	  //gets tutor's ID
	  		this.query.once("value",(snapshot) => {
				snapshot.forEach((childSnapshot)=>{
					var tvalue= childSnapshot.key;
					//console.log("first",tvalue);
					this.tutorID = tvalue;
					//console.log('second', this.tutorID);
					this.getChats(this.tutorID);
					
				});
			});
  }
  
  //get Tutor's chats list
  getChats(ttutor){
	var userRef=firebase.database().ref('userProfile/')
	this.query2=firebase.database().ref('tutors/' + ttutor + '/chats');
	this.query2.on('value',(snapshot)=> {
		this.zone.run(()=> {
		snapshot.forEach((childSnapshot)=>{
		//var childKey = childSnapshot.key;
		//var childData = childSnapshot.val();
		//console.log("The " + childKey + " student " + childData);
			userRef.child(childSnapshot.key).on('value',(data)=>{
			//var stkey= data.key;
			//var stdata = data.val();
			//console.log(data.key, 'name', data.val().fullname);
			this.getDetails(data.key, data.val().fullname, data.val().email);
			});
		});
	});
  });
	
}

//get student details
getDetails(data1, data2, data3){
		this.studentdetail.push({
		key:data1,
		username:data2,
		email:data3
	});
}


	openChat(key, username){
		this. navCtrl.push(ChatViewPage, {uid:this.tutorID, interlocutor:key, name: username});
}
 
  

 }
<file_sep>import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { AngularFireDatabase} from 'angularfire2/database';
import { UserProvider } from '../../providers/user/user-provider';
import {ChatViewPage} from '../../pages/chat-view/chat-view';


@IonicPage()
@Component({
  selector: 'page-tutors',
  templateUrl: 'tutors.html',
})
export class TutorsPage {
	
	//public topics      : FirebaseListObservable<any[]>;
	public topictitle  : any = '';
	public topictutors : any = [];
	uid:string;
	public tutorID: any;
	
		
  constructor(public navCtrl: NavController, private angFire:AngularFireDatabase, 
	public params: NavParams, public user:UserProvider)
  {
	  
	  //this.topics = this.angFire.list('/topics');
	  let topic = params.get('topic');
	  let k;
	  
	  for(k in topic.tutors)
	  {
		this.topictitle = topic.title;
		this.topictutors.push(topic.tutors[k].name); 
	  }
	   
	 this.uid= user.getCurrentUser();
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad TutorsPage');
  }

 
openChat(key){
	
	this. navCtrl.push(ChatViewPage, {uid:this.uid, interlocutor:key, name:key});
	
}

}
<file_sep>import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { AngularFireModule } from 'angularfire2';
import { AngularFireAuthModule} from 'angularfire2/auth';

import { AngularFireDatabaseModule} from 'angularfire2/database';
import { HttpModule } from '@angular/http';
import { Camera} from '@ionic-native/camera';
import { Keyboard } from '@ionic-native/keyboard';
import { ImagePicker } from '@ionic-native/image-picker';
 import {IonicStorageModule} from '@ionic/storage';
 import {FileChooser} from '@ionic-native/file-chooser';
import { InAppBrowser } from '@ionic-native/in-app-browser'




import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { AskQuestionPage } from '../pages/ask-question/ask-question';
import {LoginPage} from '../pages/login/login';
import { RegisterPage } from '../pages/register/register';
import {BuycreditPage} from '../pages/buycredit/buycredit';
import {TutorsPage} from '../pages/tutors/tutors';
import {ChatViewPage} from '../pages/chat-view/chat-view';
import {LogOutPage} from '../pages/log-out/log-out';
import {ChatsPage} from '../pages/chats/chats';
import {TutorLoginPage} from '../pages/tutor-login/tutor-login';
import {TutorTabsPage} from '../pages/tutor-tabs/tutor-tabs';
import {ProfilePage} from '../pages/profile/profile';
import {VideoTuitionPage} from '../pages/video-tuition/video-tuition';


import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { AuthServiceProvider } from '../providers/auth-service/auth-service';
import { UserProvider } from '../providers/user/user-provider';
import { ChatProvider } from '../providers/chat/chat-provider';
import { ChatBubbleComponent } from '../components/chat-bubble/chat-bubble';
import { ImghandlerProvider } from '../providers/imghandler/imghandler';
import * as firebase from 'firebase/app';

 // Initialize Firebase
  export const firebaseConfig = {
    apiKey: "<KEY>",
    authDomain: "numberapp-dbbb6.firebaseapp.com",
    databaseURL: "https://numberapp-dbbb6.firebaseio.com",
    projectId: "numberapp-dbbb6",
    storageBucket: "numberapp-dbbb6.appspot.com",
    messagingSenderId: "616363762415"
  };
 
firebase.initializeApp(firebaseConfig);
 
@NgModule({
  declarations: [
    MyApp,
    HomePage,
   	AskQuestionPage,
	LoginPage,
	BuycreditPage,
	RegisterPage,
	TutorsPage,
	ChatViewPage,
	LogOutPage,
	ChatsPage,
	TutorLoginPage,
	TutorTabsPage,
	ProfilePage,
	VideoTuitionPage,
    ChatBubbleComponent
	
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
	AngularFireModule.initializeApp(firebaseConfig),
	AngularFireAuthModule,
	AngularFireDatabaseModule,
	HttpModule,
	IonicStorageModule.forRoot()
	],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    AskQuestionPage,
	LoginPage,
	BuycreditPage,
	RegisterPage,
	TutorsPage,
	ChatViewPage,
	LogOutPage,
	ChatsPage,
	TutorLoginPage,
	TutorTabsPage,
	ProfilePage,
	VideoTuitionPage
	
  ],
  providers: [
    StatusBar,
    SplashScreen,
	Camera,
	Keyboard,
	ImagePicker,
	FileChooser,
	InAppBrowser,
	//Storage,
	{provide: ErrorHandler, useClass: IonicErrorHandler},
    AuthServiceProvider,
    UserProvider,
    ChatProvider,
    ImghandlerProvider
  ]
})
export class AppModule {}
