Created
June 25, 2012 03:09
-
-
Save ryugoo/2986255 to your computer and use it in GitHub Desktop.
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
var APP = {}; | |
(function () { | |
var StatusLogin, StatusLogout; | |
StatusLogin = require("status_login"); | |
StatusLogout = require("status_logout"); | |
APP.init = function () { | |
APP.flag = Ti.App.Properties.getBool("status"); | |
if (APP.TabGroup) { | |
APP.TabGroup.close(); | |
APP.TabGroup = null; | |
} | |
if (APP.flag) { | |
APP.TabGroup = new StatusLogin(); | |
} else { | |
APP.TabGroup = new StatusLogout(); | |
} | |
return APP.TabGroup.open(); | |
}; | |
return APP.init(); | |
})(); |
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
var StatusLogin = (function () { | |
function StatusLogin() { | |
var btn, tab, tabGroup, view, win; | |
Ti.API.info("Your login"); | |
win = Ti.UI.createWindow({ | |
title: "Status: Login" | |
}); | |
view = Ti.UI.createView({ | |
backgroundColor: "#FFFFFF", | |
width: Ti.UI.FILL, | |
height: Ti.UI.FILL | |
}); | |
btn = Ti.UI.createButton({ | |
title: "Logout" | |
}); | |
btn.addEventListener("singletap", function (e) { | |
Ti.App.Properties.setBool("status", false); | |
APP.init(); | |
}); | |
view.add(btn); | |
win.add(view); | |
tab = Ti.UI.createTab({ | |
title: "Status: Login", | |
window: win | |
}); | |
tabGroup = Ti.UI.createTabGroup(); | |
tabGroup.addTab(tab); | |
tabGroup.setActiveTab(tab); | |
tabGroup.addEventListener("focus", function (e) { | |
APP.currentTab = e.tab; | |
}); | |
return tabGroup; | |
} | |
return StatusLogin; | |
})(); | |
module.exports = StatusLogin; |
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
var StatusLogout = (function () { | |
function StatusLogout() { | |
var btn, tab, tabGroup, view, win; | |
Ti.API.info("Your not login"); | |
win = Ti.UI.createWindow({ | |
title: "Login", | |
tabBarHidden: true | |
}); | |
view = Ti.UI.createView({ | |
backgroundColor: "#FFFFFF", | |
width: Ti.UI.FILL, | |
height: Ti.UI.FILL | |
}); | |
btn = Ti.UI.createButton({ | |
title: "Login" | |
}); | |
btn.addEventListener("singletap", function (e) { | |
Ti.App.Properties.setBool("status", true); | |
APP.init(); | |
}); | |
view.add(btn); | |
win.add(view); | |
tab = Ti.UI.createTab({ | |
title: "Login", | |
window: win | |
}); | |
tabGroup = Ti.UI.createTabGroup(); | |
tabGroup.addTab(tab); | |
tabGroup.setActiveTab(tab); | |
tabGroup.addEventListener("focus", function (e) { | |
APP.currentTab = e.tab; | |
}); | |
return tabGroup; | |
} | |
return StatusLogout; | |
})(); | |
module.exports = StatusLogout; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment