Advertisement
Guest User

app.js

a guest
Apr 2nd, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // this sets the background color of the master UIView (when there are no windows/tab groups on it)
  2. Titanium.UI.setBackgroundColor('#000');
  3.  
  4. // create tab group
  5. var tabGroup = Titanium.UI.createTabGroup();
  6. var vp = require('videoplayer');
  7. function getOrientation(o) {
  8.     switch (o) {
  9.         case Titanium.UI.PORTRAIT:
  10.             return 'portrait';
  11.         case Titanium.UI.UPSIDE_PORTRAIT:
  12.             return 'portrait';
  13.         case Titanium.UI.LANDSCAPE_LEFT:
  14.             return 'landscape';
  15.         case Titanium.UI.LANDSCAPE_RIGHT:
  16.             return 'landscape';
  17.         default:
  18.             return 'portrait';
  19.  
  20.     }
  21.  
  22. }
  23. vp.top=0;
  24. var previousOrientation=null;
  25. Titanium.Gesture.addEventListener('orientationchange', function(e) {
  26.     sOrientation = getOrientation(Titanium.Gesture.orientation);
  27.     if(sOrientation !== previousOrientation) {
  28.         previousOrientation = sOrientation;
  29.         if(sOrientation == 'portrait') {
  30.             vp.setfullscreen(false);
  31.            
  32.         }
  33.         else
  34.         {
  35.             vp.setfullscreen(true);
  36.         }
  37.     }
  38.  
  39. });
  40.  
  41. //
  42. // create base UI tab and root window
  43. //
  44. var win1 = Titanium.UI.createWindow({  
  45.     title:'Tab 1',
  46.     backgroundColor:'#fff'
  47. });
  48. win1.add(vp.player);
  49. var tab1 = Titanium.UI.createTab({  
  50.     icon:'KS_nav_views.png',
  51.     title:'Tab 1',
  52.     window:win1
  53. });
  54.  
  55. var label1 = Titanium.UI.createLabel({
  56.     color:'#999',
  57.     text:'I am Window 1',
  58.     font:{fontSize:20,fontFamily:'Helvetica Neue'},
  59.     textAlign:'center',
  60.     width:'auto'
  61. });
  62.  
  63. win1.add(label1);
  64.  
  65. //
  66. // create controls tab and root window
  67. //
  68. var win2 = Titanium.UI.createWindow({  
  69.     title:'Tab 2',
  70.     backgroundColor:'#fff'
  71. });
  72. var tab2 = Titanium.UI.createTab({  
  73.     icon:'KS_nav_ui.png',
  74.     title:'Tab 2',
  75.     window:win2
  76. });
  77.  
  78. var label2 = Titanium.UI.createLabel({
  79.     color:'#999',
  80.     text:'I am Window 2',
  81.     font:{fontSize:20,fontFamily:'Helvetica Neue'},
  82.     textAlign:'center',
  83.     width:'auto'
  84. });
  85.  
  86. win2.add(label2);
  87.  
  88.  
  89.  
  90. //
  91. //  add tabs
  92. //
  93. tabGroup.addTab(tab1);  
  94. tabGroup.addTab(tab2);  
  95.  
  96.  
  97. // open tab group
  98. tabGroup.open();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement