Skip to content

Instantly share code, notes, and snippets.

@minhnc
Created February 14, 2012 23:42
Show Gist options
  • Save minhnc/1831704 to your computer and use it in GitHub Desktop.
Save minhnc/1831704 to your computer and use it in GitHub Desktop.
ui.js
/*
* POSSIBLE SOLUTION for the user session integration?
*/
// This sets the status bar style and background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.iPhone.statusBarStyle = Titanium.UI.iPhone.StatusBar.TRANSLUCENT_BLACK;
Titanium.UI.setBackgroundColor('#000');
(function(){
studiospace.ui = {};
studiospace.ui.createApplicationContainer = function() {
/*
* CHECK FOR ACCOUNT LOGIN TOKEN
*/
function need2Login(){
// var lastLogin = Ti.App.Properties.getString('user_password');---
var lastLogin = Ti.App.Properties.getString('user_password', '');
/*
if (lastLogin.length==0){
return true;
}
*/
return lastLogin.length == 0;
}
var tabGroup = Titanium.UI.createTabGroup({
barColor:'#414753'
});
// MIC CABINET code (micCabinetTab is contained)
// Ti.include('includes/mic_cabinet.js');---
var micCabinetTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_diagrams.png',
title:'Diagrams',
// window:diagramsWin---
window: Ti.UI.createWindow({backgroundColor:'pink'})
});
/**
* The following snippet will ask the user to rate your app the second time they launch it.
* It lets the user rate it now, "Remind Me Later" or never rate the app.
*/
// Ti.include('includes/rate_app.js');---
// DIAGRAMS code
// Ti.include('includes/diagrams.js');---
var diagramsTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_diagrams.png',
title:'Diagrams',
// window:diagramsWin---
window: Ti.UI.createWindow({backgroundColor:'red'})
});
// GLOSSARY code
// Ti.include('includes/glossary.js');---
var glossaryTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_glossary.png',
title:'Glossary',
// window:glossaryWin---
window: Ti.UI.createWindow({backgroundColor:'green'})
});
// ABOUT code
// Ti.include('includes/about.js');---
var aboutTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_about.png',
title:'About',
// window:aboutWin---
window: Ti.UI.createWindow({backgroundColor:'blue'})
});
// SHOWCASE code
// Ti.include('includes/showcase.js');---
var showcaseTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_showcase.png',
title:'Showcase',
// window:showcaseWin---
window: Ti.UI.createWindow({backgroundColor:'yellow'})
});
// STUDIO CALENDAR code
// Ti.include('includes/studio_calendar.js');---
var studioCalendarTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_calendar.png',
title:'Studio Calendar',
// window:studioCalendarWin---
window: Ti.UI.createWindow({backgroundColor:'white'})
});
// STUDIO RESERVATION code
// Ti.include('includes/studio_reservation.js');---
var studioReservationTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_reserve.png',
title:'Studio Reservation',
// window:studioReservationWin---
window: Ti.UI.createWindow({backgroundColor:'black'})
});
// SETTINGS code
// Ti.include('includes/settings.js');---
var settingsTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_settings.png',
title:'Settings',
// window:settingsWin---
window: Ti.UI.createWindow({backgroundColor:'white'})
});
// LOGIN code
// Ti.include('includes/user_authentication.js');---
var userAuthenticationTab = Titanium.UI.createTab({
icon:'images/tab_icons/KS_nav_settings.png',
title:'User Authentication',
// window:userAuthenticationWin---
window: Ti.UI.createWindow({backgroundColor:'black'})
});
// add tabs
tabGroup.addTab(micCabinetTab);
tabGroup.addTab(diagramsTab);
tabGroup.addTab(glossaryTab);
tabGroup.addTab(aboutTab);
tabGroup.addTab(settingsTab);
tabGroup.addTab(userAuthenticationTab);
/*
* Do this IF user is logged in
*/
return {
manageLogin: function(){
if (need2Login()){
// if user needs to log in, redirect them to the login window
// userAuthenticationWin.open();---
tabGroup.setActiveTab(5);
} else {
//TODO - MINHNC: Should move below tabs initialization code here
// if user IS logged in, add these tabs to the tabGroup
tabGroup.addTab(showcaseTab);
tabGroup.addTab(studioCalendarTab);
tabGroup.addTab(studioReservationTab);
}
},
tabGroup: tabGroup
}
// return tabGroup;---
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment