-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
544 additions
and
116 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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,51 @@ | ||
var win = Titanium.UI.createWindow({ | ||
title : 'Win 1', | ||
backgroundColor : '#fff' | ||
}); | ||
var tab1 = Titanium.UI.createTab({ | ||
icon:'KS_nav_views.png', | ||
title:'Tab 1', | ||
window: win | ||
}); | ||
|
||
var intContentCount = 0; | ||
|
||
var scrollView = Ti.UI.createScrollView({ | ||
backgroundColor: 'orange', | ||
contentHeight: 'auto', | ||
contentWidth: 'auto', | ||
height: Ti.UI.FILL, | ||
showHorizontalScrollIndicator: true, | ||
showVerticalScrollIndicator: true, | ||
width: Ti.UI.FILL | ||
}); | ||
win.add(scrollView); | ||
|
||
var view = Ti.UI.createView({ | ||
backgroundColor: 'yellow', | ||
bottom: 0, | ||
height: Ti.UI.SIZE, | ||
layout: 'vertical', | ||
width: Ti.UI.FILL | ||
}); | ||
scrollView.add(view); | ||
|
||
var btnTest = Ti.UI.createButton({ | ||
title: 'add another' | ||
}); | ||
btnTest.addEventListener('click', function (e) { | ||
intContentCount = intContentCount + 1; | ||
// just adding a label here but your could add | ||
// a view and put a label and button inside if you wish | ||
var lbl = Ti.UI.createLabel({ | ||
height: Ti.UI.SIZE, | ||
text: 'Example Content: ' + intContentCount, | ||
width: Ti.UI.FILL | ||
}); | ||
view.add(lbl); | ||
scrollView.scrollToBottom(); | ||
}); | ||
win.setRightNavButton(btnTest); | ||
var tabGroup = Titanium.UI.createTabGroup(); | ||
tabGroup.addTab(tab1); | ||
tabGroup.open(); |
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 |
---|---|---|
@@ -1,34 +1,203 @@ | ||
//UI components | ||
var chatTableView, chatView, messageField, messageSendButton = null; | ||
|
||
function buildChatView(){ | ||
var chatView = Ti.UI.createScrollView({ | ||
top:0, | ||
bottom:0 | ||
chatView = Ti.UI.createView({ | ||
//top:0, | ||
//bottom:0 | ||
}); | ||
|
||
var tableView = Ti.UI.createTableView({ | ||
top:10, | ||
bottom:20, | ||
chatTableView = Ti.UI.createTableView({ | ||
top:5, | ||
height:IPHONE5 ? 421 : 324, | ||
width:'95%', | ||
separatorStyle:Ti.UI.iPhone.TableViewSeparatorStyle.NONE, | ||
backgroundColor:'transparent' | ||
selectionStyle:Ti.UI.iPhone.TableViewCellSelectionStyle.NONE, | ||
backgroundColor:'transparent', | ||
minRowHeight:75 | ||
}); | ||
|
||
chatTableView.footerView = Ti.UI.createView({ | ||
height: 1, | ||
backgroundColor: 'transparent' | ||
}); | ||
|
||
var messageField = Ti.UI.createTextField({ | ||
backgroundColor:'#fafafa', | ||
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED, | ||
value:'', | ||
hintText:'Enter your message', | ||
messageField = Ti.UI.createTextField({ | ||
hintText:'Send a message', | ||
paddingLeft:5, | ||
width:252, | ||
height:30, | ||
bottom:1, | ||
left:10, | ||
height:25, | ||
width:'80%', | ||
bottom:15, | ||
font:{fontSize:14, fontWeight:'regular', fontFamily:'Calibri'} | ||
backgroundColor:'white', | ||
borderWidth:1, | ||
borderRadius:3, | ||
borderColor:'c5c5c5', | ||
font:{fontSize:14, fontWeight:'bold', fontFamily:'Calibri'} | ||
}); | ||
|
||
messageField.addEventListener('focus', handleChatFieldFocus); | ||
messageField.addEventListener('blur', handleChatFieldBlur); | ||
|
||
messageSendButton = Ti.UI.createButton({ | ||
title:'Send', | ||
tintColor:COLOR_LIGHT_GREEN, | ||
bottom:1, | ||
right:10 | ||
}); | ||
|
||
chatView.add(tableView); | ||
messageSendButton.addEventListener('click', handleChatMessageSubmition); | ||
|
||
chatView.add(messageSendButton); | ||
chatView.add(chatTableView); | ||
chatView.add(messageField); | ||
|
||
return chatView; | ||
} | ||
|
||
function createMessageRow(msg, time, name){ | ||
function handleChatMessageSubmition(e){ | ||
Ti.App.fireEvent(EVENT_FROM_CHAT, {from:username, message:messageField.value}); | ||
|
||
messageField.value = ''; | ||
messageField.blur(); | ||
|
||
chatView.animate({bottom:0, duration:200}); | ||
chatTableView.animate({height:IPHONE5 ? 421 : 324, duration:200}); | ||
|
||
//used setTimeout because sometimes, it wouldn't respond | ||
var t = setTimeout(function(){ | ||
chatTableView.scrollToIndex(chatTableView.data[0].rows.length - 1); | ||
},50); | ||
} | ||
|
||
function handleChatFieldFocus(){ | ||
chatView.animate({bottom:180, duration:300}); | ||
chatTableView.animate({height:IPHONE5 ? 236 : 140, duration:200}); | ||
|
||
//used setTimeout because sometimes, it wouldn't respond | ||
var t = setTimeout(function(){ | ||
chatTableView.scrollToIndex(chatTableView.data[0].rows.length - 1); | ||
},50); | ||
} | ||
|
||
function handleChatFieldBlur(){ | ||
chatView.animate({bottom:0, duration:200}); | ||
chatTableView.animate({height:IPHONE5 ? 421 : 324, duration:200}); | ||
|
||
//used setTimeout because sometimes, it wouldn't respond | ||
var t = setTimeout(function(){ | ||
chatTableView.scrollToIndex(chatTableView.data[0].rows.length - 1); | ||
},50); | ||
} | ||
|
||
function createMessageRow(msg, time, name, myMessage){ | ||
if(name == username){ | ||
myMessage = true; | ||
} | ||
|
||
var row = Ti.UI.createTableViewRow({ | ||
//height:75, | ||
backgroundColor:'transparent', | ||
width:'90%' | ||
}); | ||
|
||
var photoView, messageView, timeLabel, msgLabel = null; | ||
|
||
if(myMessage){ | ||
photoView = Ti.UI.createView({ | ||
right:2, | ||
top:20, | ||
backgroundColor:'white', | ||
width:40, | ||
height:40 | ||
}); | ||
|
||
timeLabel = Ti.UI.createLabel({ | ||
text:'2m ago', | ||
color:'white', | ||
top:65, | ||
right:5, | ||
textAlign:'center', | ||
font:{fontSize:10, fontWeight:'bold', fontFamily:'Calibri'} | ||
}); | ||
|
||
var msgLabelContainer = Titanium.UI.createView({ | ||
backgroundColor:COLOR_LIGHT_GREEN, | ||
top:20, | ||
bottom:15, | ||
right:53, | ||
width:Titanium.UI.SIZE,//214 | ||
height:Titanium.UI.SIZE, | ||
borderWidth:1, | ||
borderColor:COLOR_LIGHT_GREEN, | ||
borderRadius:5 | ||
}); | ||
|
||
msgLabel = Ti.UI.createLabel({ | ||
text:msg, | ||
color:'white', | ||
top:5, | ||
bottom:5, | ||
left:10, | ||
right:10, | ||
color:'black', | ||
height:'auto', | ||
width:'auto',//184 | ||
textAlign:'left', | ||
opacity:0.7, | ||
font:{fontSize:12, fontWeight:'regular', fontFamily:'Calibri'} | ||
}); | ||
} else { | ||
photoView = Ti.UI.createView({ | ||
left:2, | ||
top:20, | ||
backgroundColor:'white', | ||
width:40, | ||
height:40 | ||
}); | ||
|
||
timeLabel = Ti.UI.createLabel({ | ||
text:'2m ago', | ||
color:'white', | ||
top:65, | ||
left:5, | ||
textAlign:'center', | ||
font:{fontSize:10, fontWeight:'bold', fontFamily:'Calibri'} | ||
}); | ||
|
||
var msgLabelContainer = Titanium.UI.createView({ | ||
backgroundColor:COLOR_LIGHT_RED, | ||
top:20, | ||
bottom:15, | ||
left:53, | ||
width:Titanium.UI.SIZE,//214 | ||
height:Titanium.UI.SIZE, | ||
borderWidth:1, | ||
borderColor:COLOR_LIGHT_RED, | ||
borderRadius:5 | ||
}); | ||
|
||
msgLabel = Ti.UI.createLabel({ | ||
text:msg, | ||
color:'white', | ||
top:5, | ||
bottom:5, | ||
left:10, | ||
right:10, | ||
color:'black', | ||
height:'auto', | ||
width:'auto',//184 | ||
textAlign:'left', | ||
opacity:0.7, | ||
font:{fontSize:12, fontWeight:'regular', fontFamily:'Calibri'} | ||
}); | ||
} | ||
|
||
msgLabelContainer.add(msgLabel); | ||
|
||
row.add(photoView); | ||
row.add(timeLabel); | ||
row.add(msgLabelContainer); | ||
|
||
chatTableView.appendRow(row); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.