Login and Tabgroup
Hi ,
I want to have an app to login first (in fullscreen), after login, it goes to tabview..
I know I should declare the tabgroup inside app.js first, but after load the full screen login, it can never go back to the tabgroup view.
may I know what should I do to linked up after fullscreen login? should I not to declare the tabgroup in app.js?
and how should I call back the app.js again? is it possible?
2 Answers
-
Accepted Answer
here is an iphone solution
// this sets the background color of the master // UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#fff'); // create tab group var tabGroup; var win = Titanium.UI.createWindow({ title:'TabViewLogin', tabBarHidden:true, }); var username = Titanium.UI.createTextField({ color:'#336699', top:10, left:10, width:300, height:40, hintText:'Username', borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED }); win.add(username); var password = Titanium.UI.createTextField({ color:'#336699', top:60, left:10, width:300, height:40, hintText:'Password', passwordMask:true, borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED }); win.add(password); var loginBtn = Titanium.UI.createButton({ title:'Login', top:110, width:90, height:35, borderRadius:1, font:{fontWeight:'bold',fontSize:14} }); win.add(loginBtn); win.open(); Titanium.App.addEventListener('logout', function(e) { win.open(); tabGroup.close(); }); loginBtn.addEventListener('click',function(e) { if ( tabGroup == undefined ) { tabGroup = Titanium.UI.createTabGroup(); // // create base UI tab and root window // var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var tab1 = Titanium.UI.createTab({ icon:'KS_nav_views.png', title:'Tab 1', window:win1 }); var label1 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 1', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win1.add(label1); // // create controls tab and root window // var win2 = Titanium.UI.createWindow({ title:'Tab 2', backgroundColor:'#eee' }); var tab2 = Titanium.UI.createTab({ icon:'KS_nav_ui.png', title:'Tab 2', window:win2 }); var label2 = Titanium.UI.createLabel({ color:'#999', text:'I am Window 2', font:{fontSize:20,fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto' }); win2.add(label2); var button = Ti.UI.createButton({ title: "Logout", style: Ti.UI.iPhone.SystemButtonStyle.DONE }); button.addEventListener('click',function(e) { Ti.App.fireEvent('logout'); }); win1.setRightNavButton(button); win2.setRightNavButton(button); // // add tabs // tabGroup.addTab(tab1); tabGroup.addTab(tab2); } // open tab group win.close(); tabGroup.open(); });
-
What if…else… statements would you add to make this Android compatible?