aboutsummaryrefslogtreecommitdiffstats
path: root/Resources
diff options
context:
space:
mode:
authorAnqi Xu2012-06-24 12:45:05 -0400
committerAnqi Xu2012-06-24 12:45:05 -0400
commit1a9c58f10c98565124141840a61a34494f4d4579 (patch)
treee826e48c78367f0fe3678075516c5ecae57a403f /Resources
parente06955279665f5ead6414c2f23485997e77dbad9 (diff)
parent3c1f3dc92d5ffad081afc560f24d0610f64d60bf (diff)
downloadLikeFeed-1a9c58f10c98565124141840a61a34494f4d4579.tar.bz2
Merge branch 'master' of github.com:teddywing/LikeFeed
Conflicts: tiapp.xml
Diffstat (limited to 'Resources')
-rw-r--r--Resources/friendship/ui/ApplicationWindow.js8
-rw-r--r--Resources/friendship/ui/FriendSelector.js89
-rw-r--r--Resources/friendship/ui/LikeList.js22
-rw-r--r--Resources/friendship/ui/ui.js3
4 files changed, 109 insertions, 13 deletions
diff --git a/Resources/friendship/ui/ApplicationWindow.js b/Resources/friendship/ui/ApplicationWindow.js
index 8f4835b..067969a 100644
--- a/Resources/friendship/ui/ApplicationWindow.js
+++ b/Resources/friendship/ui/ApplicationWindow.js
@@ -8,14 +8,16 @@
image: 'images/refresh.png',
height: 5
});
- refresh_button.addEventListener('click', fs.ui.refreshLikeList);
+ refresh_button.addEventListener('click', fs.ui.refreshAllFriendsLikeList);
+
+ var friend_selector_button = fs.ui.friendSelectorButton();
var win = Ti.UI.createWindow({
barColor: fs.ui.styles.navBarColour,
title: 'Sphnx',
tabBarHidden: true,
- leftNavButton: refresh_button
-// rightNavButton: login_button
+ leftNavButton: refresh_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..ad85c4a
--- /dev/null
+++ b/Resources/friendship/ui/FriendSelector.js
@@ -0,0 +1,89 @@
+(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() {
+ var friend_ids = Array();
+ for (key in fs.data.friends) {
+ if (fs.data.friends[key].selected) {
+ friend_ids.push(fs.data.friends[key].uid);
+ }
+ }
+ if (friend_ids.length > 0) {
+ fs.ui.refreshLikeList(friend_ids);
+ }
+
+ win.close();
+ });
+
+ friend_table = Ti.UI.createTableView();
+
+ var friends = [];
+
+ for (var key in fs.data.friends) {
+ friends.push(fs.data.friends[key]);
+ }
+ friends.sort(function(a, b) {
+ a = a.name;
+ b = b.name;
+ return a > b ? 1 : (a < b ? -1 : 0);
+ });
+
+ for (var i = 0; i < friends.length; i++) {
+ var row = Ti.UI.createTableViewRow({
+ selectionStyle: 'none'
+ });
+ var name = Ti.UI.createLabel({
+ text: friends[i].name,
+ font: {fontSize: 16, fontWeight: 'bold'},
+ left: 45
+ });
+ var avatar = Ti.UI.createImageView({
+ image: friends[i].pic,
+ height: 35,
+ width: 35,
+ left: 5
+ });
+ var switch_button = Ti.UI.createSwitch({
+ right: 5,
+ value: fs.data.friends[friends[i].uid.toString()].selected,
+ SP_uidString: friends[i].uid.toString(),
+ });
+ switch_button.addEventListener("change", function(e) {
+ fs.data.friends[this.SP_uidString].selected = e.value;
+ });
+
+ 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/LikeList.js b/Resources/friendship/ui/LikeList.js
index d70af54..f46ba55 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({
@@ -205,14 +207,9 @@
//Ti.App.fireEvent('app:show.loader');
Ti.API.addEventListener("processFriendIDs", function(e) {
- Ti.API.info(e.data);
fs.data.friends = Array();
for (var i = 0; i < e.data.length; i++) {
- fs.data.friends[e.data[i].uid.toString()] = {uid: e.data[i].uid, pic: e.data[i].pic_square, name: e.data[i].name};
- }
-
- for (key in fs.data.friends) {
- Ti.API.info(key + ": " + fs.data.friends[key].name);
+ fs.data.friends[e.data[i].uid.toString()] = {uid: e.data[i].uid, pic: e.data[i].pic_square, name: e.data[i].name, selected: true};
}
fs.core.queryAllFriendLikeIDsFQL();
@@ -300,10 +297,17 @@
return ll_view;
};
- fs.ui.refreshLikeList = function(e) {
+ fs.ui.refreshAllFriendsLikeList = function(e) {
+ if (Ti.Facebook.loggedIn) {
+ Ti.App.fireEvent('app:show.loader');
+ fs.core.queryFriendIDsFQL();
+ }
+ };
+
+ fs.ui.refreshLikeList = function(friend_ids) {
if (Ti.Facebook.loggedIn) {
Ti.App.fireEvent('app:show.loader');
- fs.core.queryAllFriendLikeIDsFQL(); // TODO: switch to friend_ids version of query
+ fs.core.queryLikeIDsFQL(friend_ids);
}
};
})();
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'
)