I make a tab based app and would like to show/hide either the login or the user profile tab depending on whether the user is logged in or not. How can I do that? I tried setting the visible property of the tab, but this does not work and both tabs are visible.
If setting two tabs conditionally does not work well, is there a way to dynamically change the loading of the src files? I don't want to put the profile and login/register functions in one file.
index.xml:
<Alloy>
<TabGroup id="root">
<Tab id="profile" visible="false" title="Profile" icon="KS_nav_views.png">
<Require type="view" src="profile" />
</Tab>
<Tab id="login" title="Login" icon="KS_nav_views.png">
<Require type="view" src="modalLogin" />
</TabGroup>
</Alloy>
index.js ()
// open TabGroup
$.root.open();
var userStatus = "loggedin";
showProfile(userStatus);
function showProfile(user){
if (user == "loggedin") {
$.login.visible = false;
$.profile.visible = true;
console.log("user is logged in");
} else {
$.profile.visible = false;
$.login.visible = true;
console.log("user is not logged in");
}
}