Created
August 15, 2012 01:51
-
-
Save setou/3354735 to your computer and use it in GitHub Desktop.
Titanium Mobile Facebook Menu UI
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
if (Ti.version < 1.8 ) { | |
alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later'); | |
} | |
(function() { | |
var Window = require('ui/handheld/ApplicationWindow'); | |
new Window().open(); | |
})(); |
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
function ApplicationWindow() { | |
var MainView = require('ui/common/MainView') | |
MenuTableView = require('ui/common/MenuTableView'); | |
var self = Ti.UI.createWindow(); | |
var mainView = new MainView(), | |
menuTable = new MenuTableView(); | |
self.add(mainView); | |
self.add(menuTable); | |
menuTable.addEventListener('click', function(e) { | |
switch(e.index) { | |
case Ti.App.MenuRowIndex.ONE: | |
mainView.fireEvent('ChangeText', {value:e.index}); | |
break; | |
case Ti.App.MenuRowIndex.TWO: | |
mainView.fireEvent('ChangeText', {value:e.index}); | |
break; | |
case Ti.App.MenuRowIndex.FOUR: | |
mainView.fireEvent('ChangeText', {value:e.index}); | |
break; | |
case Ti.App.MenuRowIndex.FIVE: | |
mainView.fireEvent('ChangeText', {value:e.index}); | |
break; | |
case Ti.App.MenuRowIndex.SEVEN: | |
mainView.fireEvent('ChangeText', {value:e.index}); | |
break; | |
case Ti.App.MenuRowIndex.EIGHT: | |
mainView.fireEvent('ChangeText', {value:e.index}); | |
break; | |
case Ti.App.MenuRowIndex.TEN: | |
mainView.fireEvent('ChangeText', {value:e.index}); | |
break; | |
default : | |
break; | |
} | |
}); | |
return self; | |
} | |
module.exports = ApplicationWindow; |
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
function MainView() { | |
var self = Ti.UI.createView({ | |
backgroundColor : 'white', | |
zIndex : 10, | |
}); | |
var label = Ti.UI.createLabel({ | |
left : 85, | |
height : Ti.UI.SIZE, | |
width : 150, | |
color : 'black', | |
text : 'value: none', | |
textAlign : 'center', | |
}); | |
self.add(label); | |
var NavbarView = require('ui/common/NavbarView'); | |
var navbar = new NavbarView(); | |
self.add(navbar); | |
var menuOpened = false; | |
var menuOpen = function() { | |
self.animate({ | |
left : 260, | |
curve : Ti.UI.ANIMATION_CURVE_EASE_IN_OUT, | |
duration : 300, | |
}, function() { | |
menuOpened = true; | |
}); | |
}; | |
var menuClose = function() { | |
self.animate({ | |
left : 0, | |
curve : Ti.UI.ANIMATION_CURVE_EASE_IN_OUT, | |
duration : 300, | |
}, function() { | |
menuOpened = false; | |
}); | |
}; | |
navbar.addEventListener('BtnSubmenuToggle', function() { | |
if (menuOpened) { | |
menuClose(); | |
} | |
else { | |
menuOpen(); | |
} | |
}); | |
self.addEventListener('ChangeText', function(e) { | |
label.text = 'value: ' + e.value; | |
menuClose(); | |
}); | |
return self; | |
} | |
module.exports = MainView; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment