Created
April 29, 2011 16:32
-
-
Save benbahrenburg/948579 to your computer and use it in GitHub Desktop.
Login Example
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
// create tab group | |
demo.tabMainGroup = Ti.UI.createTabGroup({isOpen:false}); | |
demo.tabLoginGroup = Ti.UI.createTabGroup({isOpen:false}); | |
demo.wLogin = Ti.UI.createWindow({ | |
id:'wLogin' | |
}); | |
demo.tbLogin = Ti.UI.createTab({window:demo.wLogin}); | |
demo.wMain = Ti.UI.createWindow({ | |
id:'wMain' | |
}); | |
demo.tbMain = Ti.UI.createTab({ | |
visible:false, | |
window:demo.wMain | |
}); | |
demo.showMain = function(){ | |
if(demo.tabLoginGroup.isOpen){ | |
demo.tabLoginGroup.close(); | |
} | |
demo.tabLoginGroup.isopen=false; | |
if((demo.tabMainGroup.isOpen==undefined)|| | |
(demo.tabMainGroup.isOpen==false)){ | |
demo.tabMainGroup.open({}); | |
} | |
demo.tabMainGroup.isOpen=true; | |
}; | |
demo.showLogin = function(){ | |
if(demo.tabMainGroup.isOpen){ | |
demo.tabMainGroup.close(); | |
} | |
demo.tabMainGroup.isOpen=false; | |
if((demo.tabLoginGroup.isOpen==undefined)|| | |
(demo.tabLoginGroup.isOpen==false)){ | |
demo.tabLoginGroup.open({ | |
transition:Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT | |
}); | |
} | |
demo.tabLoginGroup.isOpen=true; | |
}; | |
demo.need2Login=function(){ | |
var lastLogin = Ti.App.Properties.getString('last_login'); | |
if(lastLogin.length==0){ | |
return true; | |
} | |
//add some date validation to expire any tokens | |
// return a value based on the validation rules | |
}; | |
demo.manageLogin=function(){ | |
if(demo.need2Login()){ | |
demo.showLogin(); //Open Login window | |
}else{ | |
demo.showMain; //Open Main window | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment