Skip to content

Instantly share code, notes, and snippets.

@manumaticx
Created January 31, 2013 14:39
Show Gist options
  • Save manumaticx/4683264 to your computer and use it in GitHub Desktop.
Save manumaticx/4683264 to your computer and use it in GitHub Desktop.
function TestView() {
var self = Ti.UI.createWindow({
backgroundColor:'white',
title: 'Test'
});
var cards = [];
for( var i=0; i<=10; i++){
var backView = Ti.UI.createView({
backgroundColor: 'blue',
width: Ti.UI.FILL,
height: Ti.UI.FILL
});
var backLabel = Ti.UI.createLabel({
text: i+'\nback',
color: 'white',
font: {
fontSize: 32,
fontWeight: 'bold'
}
});
backView.add(backLabel);
var frontView = Ti.UI.createView({
backgroundColor: 'green',
width: Ti.UI.FILL,
height: Ti.UI.FILL,
backView: backView,
isFlipped: false,
index: i
});
var frontLabel = Ti.UI.createLabel({
text: i,
font: {
fontSize: 32,
fontWeight: 'bold'
}
});
frontView.add(frontLabel);
cards.push(frontView);
}
var scrollableView = Ti.UI.createScrollableView({
width: Ti.UI.FILL,
height: Ti.UI.FILL,
views:cards,
showPagingControl:true
});
scrollableView.addEventListener('singletap', function(e){
if (!e.source.isFlipped){
e.source.animate({view:e.source.backView,transition:Ti.UI.iPhone.AnimationStyle.FLIP_FROM_RIGHT});
e.source.isFlipped = true;
}
});
self.add(scrollableView);
return self;
};
module.exports = TestView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment