aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Resources/app.js10
-rw-r--r--Resources/friendship/ui/LoginWindow.js24
2 files changed, 32 insertions, 2 deletions
diff --git a/Resources/app.js b/Resources/app.js
index bf28cac..3835b41 100644
--- a/Resources/app.js
+++ b/Resources/app.js
@@ -1,4 +1,12 @@
Ti.include('/friendship/friendship.js');
fs.app.mainTabGroup = fs.ui.createApplicationTabGroup();
-fs.app.mainTabGroup.open();
+
+// Login switch
+if (Ti.Facebook.loggedIn) {
+ fs.app.mainTabGroup.open();
+}
+else {
+ fs.ui.loginWindow = fs.ui.createLoginWindow();
+ fs.ui.loginWindow.open();
+}
diff --git a/Resources/friendship/ui/LoginWindow.js b/Resources/friendship/ui/LoginWindow.js
index cbb803b..1d9befc 100644
--- a/Resources/friendship/ui/LoginWindow.js
+++ b/Resources/friendship/ui/LoginWindow.js
@@ -5,7 +5,7 @@
Titanium.Facebook.addEventListener('login', function(e) {
if (e.success) {
- alert('Logged in');
+ fs.app.mainTabGroup.open();
}
});
Titanium.Facebook.addEventListener('logout', function(e) {
@@ -18,4 +18,26 @@
style: 'wide'
});
};
+
+ fs.ui.createLoginWindow = function() {
+ var tab_group = Ti.UI.createTabGroup();
+ var win = Ti.UI.createWindow({
+ title: 'FriendShip',
+ tabBarHidden: true
+ });
+ var view = Ti.UI.createView({
+ backgroundColor: '#fff'
+ });
+
+ var tab = Ti.UI.createTab({
+ window: win
+ });
+ tab_group.addTab(tab);
+
+ view.add(createFBLoginButton());
+ win.add(view);
+
+ return tab_group;
+ }
+
})();