예제 #1
0
        public DVCLogIn()
            : base(UITableViewStyle.Grouped, null, true)
        {
            loginView = new FBLoginView (ExtendedPermissions);

            if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0)) {
                loginView.Frame = new RectangleF (51, 0, 218, 46);
            } else {
                loginView.Frame = new RectangleF (40, 0, 218, 46);
            }

            loginView.FetchedUserInfo += (sender, e) => {
                if (Root.Count < 3) {
                    user = e.User;
                    pictureView.ProfileID = user.Id;

                    Root.Add (new Section ("Hello " + user.Name) {
                        new StringElement ("Actions Menu", () => {
                            var dvc = new DVCActions (user);
                            NavigationController.PushViewController (dvc, true);
                        }) {
                            Alignment = UITextAlignment.Center
                        }
                    });
                }
            };
            loginView.ShowingLoggedOutUser += (sender, e) => {
                pictureView.ProfileID = null;
                if (Root.Count >= 3) {
                    InvokeOnMainThread (() => {
                        var section = Root [2];
                        section.Remove (0);
                        Root.Remove (section);
                        ReloadData ();
                    });
                }
            };

            pictureView = new FBProfilePictureView () ;

            if (UIDevice.CurrentDevice.CheckSystemVersion (7,0)) {
                pictureView.Frame = new RectangleF (50, 0, 220, 220);
            }
            else {
                pictureView.Frame = new RectangleF (40, 0, 220, 220);
            }

            Root = new RootElement ("Facebook Sample") {
                new Section () {
                    new UIViewElement ("", loginView, true) {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    }
                },
                new Section () {
                    new UIViewElement ("", pictureView, true) {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    },
                }
            };
        }
 public override void LoginViewFetchedUserInfo(FBLoginView loginView, FBGraphUser user)
 {
     Console.WriteLine("LoginViewFetchedUserInfo");
     // here we use helper properties of FBGraphUser to dot-through to first_name and
     // id properties of the json response from the server; alternatively we could use
     // NSDictionary methods such as objectForKey to get values from the my json object
     parentViewController.labelFirstName.Text = String.Format(@"Hello {0}!", user.ObjectForKey(new NSString(@"first_name")).ToString());
     // setting the profileID property of the FBProfilePictureView instance
     // causes the control to fetch and display the profile picture for the user
     parentViewController.profilePic.ProfileID = user.ObjectForKey(new NSString(@"id")).ToString();
     parentViewController.loggedInUser = user;
 }
예제 #3
0
        public DVCActions(FBGraphUser facebookUser)
            : base(UITableViewStyle.Grouped, null, true)
        {
            this.user = facebookUser;

            pictureView = new FBProfilePictureView () {
                ProfileID = user.Id
            };

            if (UIDevice.CurrentDevice.CheckSystemVersion (7,0)) {
                pictureView.Frame = new RectangleF (120, 0, 80, 80);
            }
            else {
                pictureView.Frame = new RectangleF (110, 0, 80, 80);
            }

            Root = new RootElement ("Menu") {
                new Section (){
                    new UIViewElement ("", pictureView, true) {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    }
                },
                new Section () {
                    new StringElement (user.Name) {
                        Alignment = UITextAlignment.Center
                    }
                },
                new Section ("Actions") {
                    new StringElement ("Share Xamarin.com", ShareUrl) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("FQL Sample - Show 25 friends", FQLSample) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Graph API Sample - Post \"Hello\"", GraphApiPost) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Graph API Sample - Delete \"Hello\"", GraphApiDeletePost) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Select Some Friends", FriendPicker) {
                        Alignment = UITextAlignment.Center
                    },
                    new StringElement ("Select a Place", PlacePicker) {
                        Alignment = UITextAlignment.Center
                    }
                }
            };
        }
 void PopulateUserDetails()
 {
     if (FBSession.ActiveSession.IsOpen)
     {
         FBRequest.GetRequestForMe.Start( (connection, result, error) =>
         {
             if (error == null)
             {
                 FBGraphUser user = new FBGraphUser(result);
                 userNameLabel.Text = user.Name;
                 userProfileImage.ProfileID = user.Id;
             }
         });
     }
 }