Created
October 30, 2010 04:22
-
-
Save rblalock/654942 to your computer and use it in GitHub Desktop.
A quick layout I did to see how close I could become to the Windows phone interface... Here's a video of it working: http://www.screencast.com/users/XiDScreencasts/folders/Jing/media/370b66e1-d960-40e6-8aa3-42b9a7e4759d
This file contains hidden or 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 win = Ti.UI.currentWindow; | |
win.hideNavBar(); | |
// The main background image | |
var wrapper = Ti.UI.createImageView({ | |
url: 'images/building.png', | |
left: -40 | |
}); | |
win.add(wrapper); | |
// The scrollview where all our elements will be placed | |
var scrollView = Titanium.UI.createScrollView({ | |
contentWidth: 'auto', | |
contentHeight: 'auto', | |
top: 0, | |
showVerticalScrollIndicator: false, | |
showHorizontalScrollIndicator: false, | |
}); | |
win.add(scrollView); | |
// a background view to add some opaque layer on top | |
var view = Ti.UI.createView({ | |
backgroundColor: '#000', | |
width: 500, | |
opacity: 0.3 | |
}); | |
scrollView.add(view); | |
// The main title at the top | |
var titleLabel = Ti.UI.createLabel({ | |
text: 'MARKETPLACE', | |
font: { fontSize: 52 }, | |
color: '#fff', | |
opacity: 0.0, | |
top: 5, | |
left: 95, | |
height: 50 | |
}); | |
scrollView.add(titleLabel); | |
// Some sample data to fill in the tableview | |
var data = [ | |
{ | |
title : 'news', | |
height : 50, | |
color : '#fff' | |
}, | |
{ | |
title : 'media', | |
height : 50, | |
color : '#fff' | |
}, | |
{ | |
title : 'events', | |
height : 50, | |
color : '#fff' | |
} | |
]; | |
// Tableview that represents a navigational area | |
var tableview = Titanium.UI.createTableView({ | |
data: data, | |
layout: 'vertical', | |
height: '70%', | |
bottom: 0, | |
left: 290, | |
backgroundColor : 'transparent', | |
separatorColor : '#transparent', | |
width : 100, | |
opacity : 0.0 | |
}); | |
scrollView.add(tableview); | |
// First transform group | |
var t1 = Ti.UI.create3DMatrix(); | |
t1.m34 = 5.0/-1500; | |
t1 = t1.scale(2.0,2.0,2.0); | |
t1 = t1.rotate(10,0,1,1); | |
// Second transformation group (this will be the transformation everything animates too) | |
var t2 = Ti.UI.create3DMatrix(); | |
t2 = t2.rotate(0,0,0,0); | |
// First animation | |
var a1 = Titanium.UI.createAnimation(); | |
a1.left = 10; | |
a1.opacity = 0.5; | |
a1.duration = 1500; | |
// Second animation | |
var a2 = Titanium.UI.createAnimation(); | |
a2.left = 10; | |
a2.transform = t2; | |
a2.opacity = 0.7; | |
a2.duration = 1000; | |
// Third animation | |
var a3 = Titanium.UI.createAnimation(); | |
a3.left = 30; | |
a3.transform = t2; | |
a3.duration = 3000; | |
// Fourth animation and transformation style. Used for the click bounce effect | |
var t3 = Ti.UI.create3DMatrix(); | |
t3.m34 = 5.0/-1500; | |
t3 = t3.scale(1.0,1.0,1.0); | |
t3 = t3.rotate(10,1,1,1); | |
var a4 = Titanium.UI.createAnimation(); | |
a4.transform = t3; | |
a4.autoreverse = true; | |
a4.duration = 150; | |
var a5 = Titanium.UI.createAnimation(); | |
a5.opacity = 0.9; | |
a5.left = 100; | |
a5.duration = 1000; | |
// Handle the click event on the table | |
tableview.addEventListener('click', function() { | |
tableview.animate(a4); | |
}); | |
// Create a few items on the right hand side of the scrollView | |
var itemView = Ti.UI.createView({ | |
height: 75, | |
width: 280, | |
left: 600, | |
top: 150, | |
opacity: 0.0 | |
}); | |
var pic1 = Ti.UI.createImageView({ | |
url: 'images/placeholder.gif', | |
width: 75, | |
height: 75, | |
opacity: 0.9, | |
left: 100 | |
}); | |
var pic2 = Ti.UI.createImageView({ | |
url: 'images/placeholder.gif', | |
width: 75, | |
height: 75, | |
opacity: 0.9, | |
left: 200 | |
}); | |
var pic3 = Ti.UI.createImageView({ | |
url: 'images/placeholder.gif', | |
width: 75, | |
height: 75, | |
opacity: 0.9, | |
left: 300 | |
}); | |
itemView.add(pic1); | |
itemView.add(pic2); | |
itemView.add(pic3); | |
scrollView.add(itemView); | |
pic1.addEventListener('click', function() { | |
pic1.animate(a4); | |
}); | |
pic2.addEventListener('click', function() { | |
pic2.animate(a4); | |
}); | |
pic3.addEventListener('click', function() { | |
pic3.animate(a4); | |
}); | |
// Apply the animations to the window elements | |
tableview.transform = t1; | |
titleLabel.animate(a1); | |
tableview.animate(a2); | |
wrapper.animate(a3); | |
itemView.animate(a5); |
This is some butt ugly code. Tidy up when I can a chance or please fork it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a video of it working: http://www.screencast.com/users/XiDScreencasts/folders/Jing/media/370b66e1-d960-40e6-8aa3-42b9a7e4759d