Guest User

Untitled

a guest
Aug 18th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. // this sets the background color of the master UIView (when there are no windows/tab groups on it)
  2. Titanium.UI.setBackgroundColor('#fff');
  3.  
  4. // create tab group
  5. var tabGroup;
  6.  
  7. var win = Titanium.UI.createWindow({
  8. title:'TabViewLogin',
  9. tabBarHidden:true,
  10. });
  11.  
  12.  
  13. var username = Titanium.UI.createTextField({
  14. color:'#336699',
  15. top:10,
  16. left:10,
  17. width:300,
  18. height:40,
  19. hintText:'Username',
  20. borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
  21. });
  22. win.add(username);
  23.  
  24. var password = Titanium.UI.createTextField({
  25. color:'#336699',
  26. top:60,
  27. left:10,
  28. width:300,
  29. height:40,
  30. hintText:'Password',
  31. passwordMask:true,
  32. borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
  33. });
  34. win.add(password);
  35.  
  36. var loginBtn = Titanium.UI.createButton({
  37. title:'Login',
  38. top:110,
  39. width:90,
  40. height:35,
  41. borderRadius:1,
  42. font:{fontWeight:'bold',fontSize:14}
  43. });
  44. win.add(loginBtn);
  45. win.open();
  46.  
  47. Titanium.App.addEventListener('logout', function(e) {
  48. win.open();
  49. tabGroup.close();
  50. });
  51.  
  52. loginBtn.addEventListener('click',function(e)
  53. {
  54. if ( tabGroup == undefined ) {
  55. tabGroup = Titanium.UI.createTabGroup();
  56. //
  57. // create base UI tab and root window
  58. //
  59. var win1 = Titanium.UI.createWindow({
  60. title:'Tab 1',
  61. backgroundColor:'#fff'
  62. });
  63. var tab1 = Titanium.UI.createTab({
  64. icon:'KS_nav_views.png',
  65. title:'Tab 1',
  66. window:win1
  67. });
  68.  
  69. var label1 = Titanium.UI.createLabel({
  70. color:'#999',
  71. text:'I am Window 1',
  72. font:{fontSize:20,fontFamily:'Helvetica Neue'},
  73. textAlign:'center',
  74. width:'auto'
  75. });
  76.  
  77. win1.add(label1);
  78.  
  79. //
  80. // create controls tab and root window
  81. //
  82. var win2 = Titanium.UI.createWindow({
  83. title:'Tab 2',
  84. backgroundColor:'#eee'
  85. });
  86. var tab2 = Titanium.UI.createTab({
  87. icon:'KS_nav_ui.png',
  88. title:'Tab 2',
  89. window:win2
  90. });
  91.  
  92. var label2 = Titanium.UI.createLabel({
  93. color:'#999',
  94. text:'I am Window 2',
  95. font:{fontSize:20,fontFamily:'Helvetica Neue'},
  96. textAlign:'center',
  97. width:'auto'
  98. });
  99.  
  100. win2.add(label2);
  101.  
  102. var button = Ti.UI.createButton({
  103. title: "Logout",
  104. style: Ti.UI.iPhone.SystemButtonStyle.DONE
  105.  
  106. });
  107.  
  108. button.addEventListener('click',function(e)
  109. {
  110. Ti.App.fireEvent('logout');
  111. });
  112.  
  113. win1.setRightNavButton(button);
  114. win2.setRightNavButton(button);
  115.  
  116. //
  117. // add tabs
  118. //
  119. tabGroup.addTab(tab1);
  120. tabGroup.addTab(tab2);
  121.  
  122. }
  123.  
  124. // open tab group
  125. win.close();
  126. tabGroup.open();
  127.  
  128. });
Add Comment
Please, Sign In to add comment