-
Notifications
You must be signed in to change notification settings - Fork 10
/
ViewIndex.js
66 lines (48 loc) · 1.49 KB
/
ViewIndex.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Creates main menu table view ("index table")
*/
// This method returns a fullwidth view with a table.
// The table contains a row for each demo of titanTricks.
// When a row is clicked, the correspondent demo view is created in a new window
// and destroyed when closed.
App.ui.createViewIndex = {};
(function(){
//Table data is set with App.ui.demos.list array.
//This array is filled by each demo by itself.
//Look at the end of each demo View file to see how it works.
App.ui.createViewIndex = function(){
var view = Ti.UI.createView($$.FULL_SCREEN);
var rows = [];
var list = App.ui.demos.list;
//convert App.ui.demos.list array items in ViewTableRow objects
var oldHeader = '?';
for(var i = 0, j = list.length; i < j; i++) {
rows.push(App.ui.createRowItem(list[i]));
//Set header only if is a new header
if(list[i].header !== oldHeader){
rows[i].header = list[i].header;
oldHeader = list[i].header;
}
}
var tableView = Ti.UI.createTableView({
backgroundColor:'transparent',
top: 0,
bottom: 0,
data: rows
});
//Here is where the demo window is launched.
//e.row must contain a demo property, which is a reference
//to the private demoInfo var defined on each demo.
tableView.addEventListener('click', function(e){
var row = e.row;
var title = e.row.demo.component;
var w = App.ui.createWinDemo({
title: title,
demo: row.demo
});
w.open();
});
view.add(tableView);
return view;
}
})();