From 781e8335694228d86ea11d4844ba29056dea93c7 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 24 Jun 2012 12:03:13 -0400 Subject: Friend list/selector: created it, styled the view. --- Resources/friendship/ui/ApplicationWindow.js | 5 +- Resources/friendship/ui/FriendSelector.js | 69 ++++++++++++++++++++++++++++ Resources/friendship/ui/ui.js | 3 +- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 Resources/friendship/ui/FriendSelector.js (limited to 'Resources') diff --git a/Resources/friendship/ui/ApplicationWindow.js b/Resources/friendship/ui/ApplicationWindow.js index 8f4835b..b2c174e 100644 --- a/Resources/friendship/ui/ApplicationWindow.js +++ b/Resources/friendship/ui/ApplicationWindow.js @@ -10,12 +10,15 @@ }); refresh_button.addEventListener('click', fs.ui.refreshLikeList); + var friend_selector_button = fs.ui.friendSelectorButton(); + var win = Ti.UI.createWindow({ barColor: fs.ui.styles.navBarColour, title: 'Sphnx', tabBarHidden: true, - leftNavButton: refresh_button + leftNavButton: refresh_button, // rightNavButton: login_button + rightNavButton: friend_selector_button }); var loading = fs.ui.createLoadingView(); win.add(loading); diff --git a/Resources/friendship/ui/FriendSelector.js b/Resources/friendship/ui/FriendSelector.js new file mode 100644 index 0000000..958de5b --- /dev/null +++ b/Resources/friendship/ui/FriendSelector.js @@ -0,0 +1,69 @@ +(function() { + fs.ui.friendSelectorButton = function() { + var button = Ti.UI.createButton({ + title: 'fff' + }); + + button.addEventListener('click', function() { + fs.ui.createFriendSelector().open(); + }); + + return button; + }; + + fs.ui.createFriendSelector = function() { + var done_button = Ti.UI.createButton({ + title: 'Done', + style: Titanium.UI.iPhone.SystemButtonStyle.DONE + }); + + var win = Ti.UI.createWindow({ + title: 'Filter Friends', + barColor: fs.ui.styles.navBarColour, + modal: true, + rightNavButton: done_button + }); + + done_button.addEventListener('click', function() { + // Refresh the like list + + win.close(); + }); + + friend_table = Ti.UI.createTableView(); + + // Sort friends list alphabetically + // + + for (var i = 0; i < fs.data.friends.length; i++) { + var row = Ti.UI.createTableViewRow({ + selectionStyle: 'none' + }); + var name = Ti.UI.createLabel({ + text: fs.data.friends[i].name, + font: {fontSize: 16, fontWeight: 'bold'}, + left: 45 + }); + var avatar = Ti.UI.createImageView({ + image: fs.data.friends[i].pic_square, + height: 35, + width: 35, + left: 5 + }); + var switch_button = Ti.UI.createSwitch({ + right: 5, + value: false + }); + + row.add(avatar); + row.add(name); + row.add(switch_button); + + friend_table.appendRow(row); + } + + win.add(friend_table); + + return win; + }; +})(); diff --git a/Resources/friendship/ui/ui.js b/Resources/friendship/ui/ui.js index bcd5e1a..377051f 100644 --- a/Resources/friendship/ui/ui.js +++ b/Resources/friendship/ui/ui.js @@ -11,5 +11,6 @@ Ti.include( '/friendship/ui/LikeList.js', '/friendship/ui/LoginWindow.js', '/friendship/ui/WebView.js', - '/friendship/ui/ActivityIndicator.js' + '/friendship/ui/ActivityIndicator.js', + '/friendship/ui/FriendSelector.js' ) -- cgit v1.2.3 From 3c1f3dc92d5ffad081afc560f24d0610f64d60bf Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 24 Jun 2012 12:06:03 -0400 Subject: Tried adding a child triangle to the LikeList table rows, but it messed up the layout so commented it out for the moment. --- Resources/friendship/ui/LikeList.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Resources') diff --git a/Resources/friendship/ui/LikeList.js b/Resources/friendship/ui/LikeList.js index 8e9f74c..be81747 100644 --- a/Resources/friendship/ui/LikeList.js +++ b/Resources/friendship/ui/LikeList.js @@ -58,7 +58,9 @@ function create_row( key ) { // Reason for Factory: templating format of the row - var row = Ti.UI.createTableViewRow(); + var row = Ti.UI.createTableViewRow(/*{ + hasChild: true // messes up the layout currently. Try later. + }*/); row.addEventListener('click', function(e) { Ti.UI.currentTabGroup.activeTab.open(fs.ui.createWebViewWin({ -- cgit v1.2.3