Permalink
Browse files

Updating home screen UI to image grid

  • Loading branch information...
1 parent 45a00c7 commit 1a61c81f9b1554af73f1dac6288610a056443940 @n8fr8 n8fr8 committed Mar 30, 2011
View
@@ -0,0 +1,145 @@
+Ti.include("globals.js");
+// this sets the background color of the master UIView (when there are no windows/tab groups on it)
+Titanium.UI.setBackgroundColor(DEFAULT_BAR_COLOR);
+
+//
+// create base UI tab and root window
+//
+var winHome;
+
+winHome = Titanium.UI.createWindow({
+ title:'New York State Senate',
+ barColor:DEFAULT_BAR_COLOR,
+ backgroundImage:'img/bg/bglight.jpg',
+ orientationModes:[Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT,Titanium.UI.PORTRAIT]
+});
+
+
+// create table view data object
+var data = [
+ {title:'Senators', summary:'', hasDetail:true, ilink:'tabs.js', icon:'img/tabs/man.png'},
+ {title:'Newsroom', summary:'', hasDetail:true,ilink:'tabs.js', icon:'img/tabs/newspaper.png'},
+ {title:'Legislation', summary:'', hasDetail:true, ilink:'tabs.js', icon:'img/tabs/database.png'},
+ {title:'Latest Videos', summary:'', hasDetail:true, ilink:'tabs.js', icon:'img/tabs/star.png'},
+ {title:'More Information', summary:'', hasDetail:true, ilink:'tabs.js', icon:'img/tabs/bank.png'},
+ {title:'Visit NYSenate.gov', summary:'', hasDetail:true, elink:'http://nysenate.gov', icon:'img/tabs/world.png'},
+];
+
+var tableview = Titanium.UI.createTableView(
+{
+backgroundColor:"#ffffff",
+opacity:.8
+});
+
+for (var c = 0; c < data.length; c++)
+{
+
+
+ row = Ti.UI.createTableViewRow({height:60});
+ row.className = 'morerow';
+ row.color = '#333333';
+ row.pageTitle = data[c].title;
+ row.link = data[c].link;
+ row.rss = data[c].rss;
+ row.ilink = data[c].ilink;
+ row.oltype = data[c].oltype;
+ row.hasDetail = data[c].hasDetail;
+ row.leftImage = data[c].icon;
+
+ row.title = data[c].title;
+
+ tableview.appendRow(row);
+
+
+}
+
+
+var subWin;
+
+// create table view event listener
+tableview.addEventListener('click', function(e)
+{
+ if (e.rowData.tab)
+ {
+ //Titanium.UI.currentTab.setActiveTab(e.rowData.tab);
+ }
+ else if (e.rowData.ilink)
+ {
+ subWin = Titanium.UI.createWindow({
+ url:e.rowData.ilink,
+ title:e.rowData.pageTitle
+
+ });
+
+ subWin.channel = e.rowData.channel;
+
+ subWin.barColor = DEFAULT_BAR_COLOR;
+ subWin.open({animated:true});
+ }
+ if (e.rowData.elink)
+ {
+ showWebModal(e.rowData.pageTitle,e.rowData.elink);
+ }
+ else if (e.rowData.link)
+ {
+ showNYSenateContent(e.rowData.pageTitle,e.rowData.link);
+ }
+ else if (e.rowData.rss)
+ {
+ subWin = Titanium.UI.createWindow({
+ url:'views/rss.js',
+ title:e.rowData.pageTitle
+ });
+
+ subWin.barColor = DEFAULT_BAR_COLOR;
+ subWin.rss = e.rowData.rss;
+
+ subWin.open({animated:true});
+ }
+});
+
+// add table view to the window
+winHome.add(tableview);
+Titanium.UI.currentWindow = winHome;
+winHome.open({});
+
+
+var hadWelcome = Titanium.App.Properties.getString("welcome");
+
+
+if (!hadWelcome)
+{
+ //
+ // BASIC OPTIONS DIALOG
+ //
+ var dialog = Titanium.UI.createOptionDialog({
+ options:['Lookup My Senator', 'No thanks'],
+ title:'Would you like to find your Senator?'
+ });
+
+ // add event listener
+ dialog.addEventListener('click',function(e)
+ {
+ if (e.index == 0)
+ {
+ // tabGroup.setActiveTab(2);
+ var winSearch = Titanium.UI.createWindow({
+ url:'views/findsenator.js',
+ title:'Senator Search',
+ barColor:DEFAULT_BAR_COLOR,
+ backgroundImage:'img/bg/Default.png'
+
+ });
+ winHome.open(winSearch,{animated:true});
+
+ }
+
+ Titanium.App.Properties.setString("welcome","done");
+
+ });
+
+ dialog.show();
+
+
+}
+
View
@@ -0,0 +1,158 @@
+Ti.include("globals.js");
+
+function showTabs (tabIdx)
+{
+
+ // create tab group
+ var tabGroup = Titanium.UI.createTabGroup({});
+
+ //
+ // create base UI tab and root window
+ //
+ var winHome;
+
+ winHome = Titanium.UI.createWindow({
+ title:'New York State Senate',
+ url:'views/newsroom.js',
+ orientationModes:[Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT,Titanium.UI.PORTRAIT]
+ });
+
+ var tabHome = Titanium.UI.createTab({
+ icon:'img/tabs/bank.png',
+ title:'Newsroom',
+ window:winHome,
+ background:DEFAULT_BAR_COLOR
+ });
+
+ tabGroup.addTab(tabHome);
+
+
+ //
+ // create controls tab and root window
+ //
+ var winToday = Titanium.UI.createWindow({
+ title:'Calendar',
+ url:'views/today.js',
+
+ backgroundImage:"img/bg/Default.png",
+ orientationModes:[Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT,Titanium.UI.PORTRAIT]
+
+ });
+ var tabToday = Titanium.UI.createTab({
+ icon:'img/tabs/newspaper.png',
+ title:'Calendar',
+ window:winToday,
+ });
+
+ tabGroup.addTab(tabToday);
+
+
+ //third tab
+ var winSenators;
+
+
+ winSenators = Titanium.UI.createWindow({
+ title:'Senators',
+ url:'views/senators.js',
+ barColor:DEFAULT_BAR_COLOR,
+ backgroundImage:'img/bg/Default.png',
+ orientationModes:[Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT,Titanium.UI.PORTRAIT]
+ });
+
+
+ var tabSenators = Titanium.UI.createTab({
+ icon:'img/tabs/man.png',
+ title:'Senators',
+ window:winSenators
+ });
+
+
+ tabGroup.addTab(tabSenators);
+
+ //fourth tab
+ var winOpenLeg = Titanium.UI.createWindow({
+ title:'Legislation',
+ url:'views/legislation.js',
+ barColor:DEFAULT_BAR_COLOR,
+ backgroundImage:"img/bg/Default.png",
+ orientationModes:[Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT,Titanium.UI.PORTRAIT]
+ });
+ var tabOpenLeg = Titanium.UI.createTab({
+ icon:'img/tabs/database.png',
+ title:'Legislation',
+ window:winOpenLeg
+ });
+
+ tabGroup.addTab(tabOpenLeg);
+
+ //fifth tab
+ var winMore = Titanium.UI.createWindow({
+ title:'More',
+ url:'views/more.js',
+ barColor:DEFAULT_BAR_COLOR,
+ backgroundImage:"img/bg/Default.png",
+ orientationModes:[Titanium.UI.LANDSCAPE_LEFT,Titanium.UI.LANDSCAPE_RIGHT,Titanium.UI.PORTRAIT]
+ });
+ var tabMore = Titanium.UI.createTab({
+ icon:'img/tabs/preferences.png',
+ title:'More',
+ window:winMore
+ });
+
+ tabGroup.addTab(tabMore);
+
+ tabGroup.addEventListener('blur', function(e)
+ {
+ Titanium.API.info("got tab win blur key event!");
+
+ });
+
+ tabGroup.addEventListener('close',function(e)
+ {
+ Titanium.API.info("got tab win close key event!");
+
+ });
+
+ tabGroup.close();
+ // open tab group with a transition animation
+ tabGroup.open();
+
+ tabGroup.setActiveTab(tabIdx);
+
+}
+
+var focusCount = 0;
+
+Ti.UI.currentWindow.addEventListener('focus', function(e)
+ {
+ focusCount++;
+
+ Titanium.API.info("TAB PARENT - got focus; count=" + focusCount);
+
+ if (focusCount > 1)
+ {
+ Ti.API.info("closing curr window");
+ Ti.UI.currentWindow.close();
+ }
+
+ });
+
+Ti.UI.currentWindow.addEventListener('blur', function(e)
+ {
+ Titanium.API.info("TAB PARENT - got blur");
+
+ });
+
+Ti.UI.currentWindow.addEventListener('close', function(e)
+ {
+ Titanium.API.info("TAB PARENT - got close");
+
+ });
+
+Ti.UI.currentWindow.addEventListener('android:back', function(e)
+ {
+ Titanium.API.info("TAB PARENT - got android:back!");
+
+ });
+
+showTabs(0);
Oops, something went wrong.

0 comments on commit 1a61c81

Please sign in to comment.