-
-
Save rborn/3216431 to your computer and use it in GitHub Desktop.
Tweetie like TiUITableView cells
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
var data = []; | |
var t1; | |
var win = Ti.UI.createWindow({ | |
width: Ti.UI.FILL, | |
height: Ti.UI.FILL, | |
backgroundColor: '#ffffff' | |
}); | |
var tableView = Ti.UI.createTableView({ | |
width: Ti.UI.FILL, | |
height: Ti.UI.FILL, | |
minRowHeight: 72, | |
selectionStyle:Ti.UI.iPhone.TableViewCellSelectionStyle.NONE, | |
}); | |
for(i=0; i<10; i++) { | |
var row = Ti.UI.createTableViewRow({ | |
width: 420, | |
height: Ti.UI.FILL, | |
backgroundColor: '#ffffff', | |
className: 'row' | |
}); | |
row.add(Ti.UI.createView({ | |
width: 160, | |
height: 72, | |
backgroundColor: '#333', | |
left: 160 | |
})); | |
var rowView = Ti.UI.createView({ | |
width: 320, | |
height: 72, | |
backgroundColor: '#ececec' | |
}); | |
rowView.add(Ti.UI.createLabel({ | |
width: 'auto', | |
height: Ti.UI.FILL, | |
text: (i+1) + " times 20", | |
color: '#000000', | |
left: 20 | |
})); | |
row.add(rowView); | |
row.addEventListener('swipe', function(e) { | |
if(e.direction == 'left' && this == '[object TiUIView]') { | |
t1 = Ti.UI.create2DMatrix(); | |
t1 = t1.translate(-160,0); | |
this.animate({ | |
transform: t1, | |
duration: 200 | |
}); | |
} | |
if(e.direction == 'right' && this == '[object TiUIView]') { | |
t1 = Ti.UI.create2DMatrix(); | |
t1 = t1.translate(0,0); | |
this.animate({ | |
transform: t1, | |
duration: 200 | |
}); | |
} | |
}); | |
data.push(row); | |
//Setting the variables we created to null improves performance of drawing reusable cells | |
row = null; rowView = null; | |
} | |
tableView.setData(data); | |
win.add(tableView); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment