diff --git a/Ionic/app/pages/chatPage/chatPage.html b/Ionic/app/pages/chatPage/chatPage.html index d7f67a8..e63ed1e 100644 --- a/Ionic/app/pages/chatPage/chatPage.html +++ b/Ionic/app/pages/chatPage/chatPage.html @@ -5,7 +5,7 @@ - + @@ -21,12 +21,12 @@
- +
- diff --git a/Ionic/app/pages/chatPage/chatPage.js b/Ionic/app/pages/chatPage/chatPage.js index 6b7a8ed..7c95ce2 100644 --- a/Ionic/app/pages/chatPage/chatPage.js +++ b/Ionic/app/pages/chatPage/chatPage.js @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {Component, ViewChild} from '@angular/core'; import {NavController, NavParams} from 'ionic-angular'; import {ChatBubble} from '../components/chatBubble/chatBubble'; @@ -6,7 +6,11 @@ import {ElasticTextarea} from '../components/elasticTextarea'; @Component({ templateUrl: 'build/pages/chatPage/chatPage.html', - directives: [ChatBubble, ElasticTextarea] + directives: [ChatBubble, ElasticTextarea], + queries: { + txtChat: new ViewChild('txtChat'), + content: new ViewChild('content') + } }) export class ChatPage { static get parameters() { @@ -44,4 +48,24 @@ export class ChatPage { ]; } + sendMessage(){ + this.messages.push({ + img: 'build/img/hugh.png', + position: 'right', + content: this.txtChat.content, + senderName: 'Me', + time: new Date().toLocaleTimeString() + }); + + console.log(this.txtChat.content); + this.txtChat.clearInput(); + + //without this timout the list scrolls + //to the second to last element. + //It's some kind of race condition + setTimeout(() => { + this.content.scrollToBottom(300);//300ms animation speed + }); + } + } diff --git a/Ionic/app/pages/components/chatBubble/chatBubble.scss b/Ionic/app/pages/components/chatBubble/chatBubble.scss index 87fc365..a2862a2 100644 --- a/Ionic/app/pages/components/chatBubble/chatBubble.scss +++ b/Ionic/app/pages/components/chatBubble/chatBubble.scss @@ -25,7 +25,7 @@ .message { font-size: medium; word-wrap: break-word; - white-space: normal; + white-space: pre-wrap; } .message-detail { diff --git a/Ionic/app/pages/components/elasticTextarea.js b/Ionic/app/pages/components/elasticTextarea.js index dc14e0d..657f3ad 100644 --- a/Ionic/app/pages/components/elasticTextarea.js +++ b/Ionic/app/pages/components/elasticTextarea.js @@ -29,4 +29,9 @@ export class ElasticTextarea { this.txtArea.style.height = this.lineHeight + "px"; this.txtArea.style.height = this.txtArea.scrollHeight + "px"; } + + clearInput(){ + this.content = ""; + this.txtArea.style.height = this.lineHeight + "px"; + } } diff --git a/Ionic/app/pages/loginPage/loginPage.js b/Ionic/app/pages/loginPage/loginPage.js index 563d3ef..ea82672 100644 --- a/Ionic/app/pages/loginPage/loginPage.js +++ b/Ionic/app/pages/loginPage/loginPage.js @@ -1,7 +1,6 @@ import {Component} from '@angular/core'; import {NavController} from 'ionic-angular'; import {ProfilePage} from '../profilePage/profilePage'; -import {ContactPage} from '../contactPage/contactPage'; @Component({ @@ -19,7 +18,6 @@ export class LoginPage { } login(){ - //TODO just for testing - this.nav.setRoot(ContactPage);//ProfilePage); + this.nav.setRoot(ProfilePage); } }