Skip to content

Instantly share code, notes, and snippets.

@dezinezync
Created July 31, 2012 11:41
Show Gist options
  • Save dezinezync/3216387 to your computer and use it in GitHub Desktop.
Save dezinezync/3216387 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();
@Lukic
Copy link

Lukic commented Jul 31, 2012

Here is a demo of it, with some small changes.

DEMO : http://bit.ly/MYVaMi

@dezinezync
Copy link
Author

@Lukic: Good job.

Here's a video of this on the iPhone 4: http://www.youtube.com/watch?v=nesNEcdVJJU

@dezinezync
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment