Skip to content

Instantly share code, notes, and snippets.

@rborn
Forked from dezinezync/app.js
Created July 31, 2012 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rborn/3216431 to your computer and use it in GitHub Desktop.
Save rborn/3216431 to your computer and use it in GitHub Desktop.
Tweetie like TiUITableView cells
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