protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || this.Element == null)
            {
                return;
            }

            loginButton = new LoginButton()
            {
                LoginBehavior = LoginBehavior.Native,
            };

            loginButton.Completed += (sender, args) => {
                FacebookButton    facebookButton = (FacebookButton)e.NewElement;
                FacebookEventArgs fbArgs         = new FacebookEventArgs();

                if (args.Result.Token != null)
                {
                    fbArgs.UserId          = args.Result.Token.UserID;
                    fbArgs.AccessToken     = args.Result.Token.TokenString;
                    fbArgs.TokenExpiration = args.Result.Token.ExpirationDate.ToDateTime();
                }

                facebookButton.Login(facebookButton, fbArgs);
            };

            SetNativeControl(loginButton);
        }
Esempio n. 2
0
        private void InitBindings()
        {
            ViewModel.PropertyChanged += (object sender, PropertyChangedEventArgs e) =>
            {
                if (e.PropertyName.Equals("CharacterCount"))
                {
                    CountLabel.Text = ViewModel.CharacterCount;
                }
            };

            this.SetBinding(
                () => TextView.Text,
                () => ViewModel.Message,
                BindingMode.TwoWay
                ).UpdateSourceTrigger("Changed");

            this.SetBinding(
                () => FacebookButton.Selected,
                () => ViewModel.IsFacebookSelected,
                BindingMode.TwoWay
                ).UpdateSourceTrigger("TouchUpInside");

            this.SetBinding(
                () => TwitterButton.Selected,
                () => ViewModel.IsTwitterSelected,
                BindingMode.TwoWay
                ).UpdateSourceTrigger("TouchUpInside");

            ViewModel.CanExecute         = OnCanExecute;
            ViewModel.RequestDismissPage = OnRequestDismissPage;

            PostButton.SetCommand("TouchUpInside", ViewModel.PostCommand);
            TwitterButton.SetCommand("TouchUpInside", ViewModel.TwitterCommand);
            FacebookButton.SetCommand("TouchUpInside", ViewModel.FacebookCommand);
        }
Esempio n. 3
0
        protected override void OnElementChanged(ElementChangedEventArgs <Button> button)
        {
            //base.OnElementChanged(button);
            if (base.Control == null)
            {
                var loginButton = new LoginButton()
                {
                    LoginBehavior   = LoginBehavior.Native,
                    ReadPermissions = readPermissions.ToArray(),
                };
                SetNativeControl(loginButton);

                FacebookButton el = (FacebookButton)this.Element;
                loginButton.Completed += (sender, e) =>
                {
                    var response = new SignInResponse()
                    {
                        SignInResult = new SignInResponse.Result()
                        {
                            Token = new Token()
                            {
                                AppID          = e.Result.Token.AppID,
                                ExpirationDate = (System.DateTime)e.Result.Token.ExpirationDate,
                                TokenString    = e.Result.Token.TokenString,
                                UserId         = e.Result.Token.UserID,
                                RefreshDate    = (System.DateTime)e.Result.Token.RefreshDate
                            }
                        }
                    };

                    el.OnFacebookLoginCompleted(sender, response);
                };
            }
        }
Esempio n. 4
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            // Facebook login button has its own look and feel, so the layout properties
            // are the only important properties to check
            if (e.PropertyName == VisualElement.XProperty.PropertyName)
            {
                FacebookButton button = (FacebookButton)sender;
                CGRect         frame  = loginButton.Frame;
                frame.X           = (nfloat)button.X;
                loginButton.Frame = frame;
            }
            else if (e.PropertyName == VisualElement.YProperty.PropertyName)
            {
                FacebookButton button = (FacebookButton)sender;
                CGRect         frame  = loginButton.Frame;
                frame.Y           = (nfloat)button.Y;
                loginButton.Frame = frame;
            }
            else if (e.PropertyName == VisualElement.WidthProperty.PropertyName)
            {
                FacebookButton button = (FacebookButton)sender;
                CGRect         frame  = loginButton.Frame;
                frame.Width       = (nfloat)button.Width;
                loginButton.Frame = frame;
            }
            else if (e.PropertyName == VisualElement.HeightProperty.PropertyName)
            {
                FacebookButton button = (FacebookButton)sender;
                CGRect         frame  = loginButton.Frame;
                frame.Height      = (nfloat)button.Height;
                loginButton.Frame = frame;
            }
        }
 /// <summary>
 ///     Login in Souq.com using Facebook Account
 /// </summary>
 /// <param name="email"> Facebook email address or telephone number</param>
 /// <param name="password">Facebook password</param>
 public void LoginUsingFacebook(string email, string password)
 {
     FacebookButton.Click();
     DriverWait.Until(ExpectedConditions.UrlContains("facebook.com"));
     FacebookEmailTextBox.SendKeys(email);
     FacebookPasswordTextBox.SendKeys(password);
     FacebookLoginButton.Click();
 }
Esempio n. 6
0
        private async void OnFacebookAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            this.DismissViewController(true, null);

            var facebookService = new FacebookService();
            var email           = await facebookService.GetEmailAsync(e.Account.Properties["access_token"]);

            FacebookButton.SetTitle(email, UIControlState.Normal);
        }
Esempio n. 7
0
        void ReleaseDesignerOutlets()
        {
            if (FacebookButton != null)
            {
                FacebookButton.Dispose();
                FacebookButton = null;
            }

            if (GithubButton != null)
            {
                GithubButton.Dispose();
                GithubButton = null;
            }

            if (GoogleButton != null)
            {
                GoogleButton.Dispose();
                GoogleButton = null;
            }

            if (LinkedinButton != null)
            {
                LinkedinButton.Dispose();
                LinkedinButton = null;
            }

            if (PinterestButton != null)
            {
                PinterestButton.Dispose();
                PinterestButton = null;
            }

            if (TwitterButton != null)
            {
                TwitterButton.Dispose();
                TwitterButton = null;
            }

            if (WatsappButton != null)
            {
                WatsappButton.Dispose();
                WatsappButton = null;
            }

            if (Image != null)
            {
                Image.Dispose();
                Image = null;
            }

            if (Label != null)
            {
                Label.Dispose();
                Label = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (XamLogoImageView != null)
            {
                XamLogoImageView.Dispose();
                XamLogoImageView = null;
            }

            if (AboutTextView != null)
            {
                AboutTextView.Dispose();
                AboutTextView = null;
            }

            if (StackOverflowButton != null)
            {
                StackOverflowButton.Dispose();
                StackOverflowButton = null;
            }

            if (LinkedInButton != null)
            {
                LinkedInButton.Dispose();
                LinkedInButton = null;
            }

            if (TwitterButton != null)
            {
                TwitterButton.Dispose();
                TwitterButton = null;
            }

            if (YouTubeButton != null)
            {
                YouTubeButton.Dispose();
                YouTubeButton = null;
            }

            if (FacebookButton != null)
            {
                FacebookButton.Dispose();
                FacebookButton = null;
            }

            if (BlogRssButton != null)
            {
                BlogRssButton.Dispose();
                BlogRssButton = null;
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null || this.Element == null)
            {
                return;
            }
            loginButton = new LoginButton(Forms.Context);
            loginButton.LoginBehavior = LoginBehavior.NativeWithFallback;
            //Implement FacebookCallback with LoginResult type to handle Callback's result
            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    /*
                     *  If login success, We can now retrieve our needed data and build our
                     *  FacebookEventArgs parameters
                     */
                    FacebookButton    facebookButton = (FacebookButton)e.NewElement;
                    FacebookEventArgs fbArgs         = new FacebookEventArgs();
                    if (loginResult.AccessToken != null)
                    {
                        fbArgs.UserId      = loginResult.AccessToken.UserId;
                        fbArgs.AccessToken = loginResult.AccessToken.Token;
                        var expires = loginResult.AccessToken.Expires;
                        //TODO better way to retrive Java.Util.Date and cast it to System.DateTime type
                        fbArgs.TokenExpiration = new DateTime(expires.Year, expires.Month, expires.Day, expires.Hours, expires.Minutes, expires.Seconds);
                    }

                    /*
                     *  Pass the parameters into Login method in the FacebookButton
                     *  object and handle it on Xamarin.Forms side
                     */
                    facebookButton.Login(facebookButton, fbArgs);
                },
                HandleCancel = () =>
                {
                    //Handle any cancel the user has perform
                    Console.WriteLine("User cancel de login operation");
                },
                HandleError = loginError =>
                {
                    //Handle any error happends here
                    Console.WriteLine("Operation throws an error: " + loginError.Cause.Message);
                }
            };

            LoginManager.Instance.RegisterCallback(MainActivity.CallbackManager, loginCallback);
            //Set the LoginButton as NativeControl
            SetNativeControl(loginButton);
        }
Esempio n. 10
0
        void ReleaseDesignerOutlets()
        {
            if (FacebookButton != null)
            {
                FacebookButton.Dispose();
                FacebookButton = null;
            }

            if (GoogleButton != null)
            {
                GoogleButton.Dispose();
                GoogleButton = null;
            }
        }
Esempio n. 11
0
        void ReleaseDesignerOutlets()
        {
            if (EmailTxt != null)
            {
                EmailTxt.Dispose();
                EmailTxt = null;
            }

            if (FacebookButton != null)
            {
                FacebookButton.Dispose();
                FacebookButton = null;
            }

            if (GirisButton != null)
            {
                GirisButton.Dispose();
                GirisButton = null;
            }

            if (GoogleButton != null)
            {
                GoogleButton.Dispose();
                GoogleButton = null;
            }

            if (SifrenimiUnuttunButton != null)
            {
                SifrenimiUnuttunButton.Dispose();
                SifrenimiUnuttunButton = null;
            }

            if (SifreTxt != null)
            {
                SifreTxt.Dispose();
                SifreTxt = null;
            }

            if (Sozlesmelabel != null)
            {
                Sozlesmelabel.Dispose();
                Sozlesmelabel = null;
            }

            if (UyeOlButton != null)
            {
                UyeOlButton.Dispose();
                UyeOlButton = null;
            }
        }
Esempio n. 12
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null || this.Element == null)
            {
                return;
            }

            //Native Button
            loginButton = new LoginButton(_context);
            loginButton.TextAlignment = Android.Views.TextAlignment.TextEnd;
            loginButton.LoginBehavior = LoginBehavior.NativeWithFallback;

            //Implement FacebookCallback with LoginResult type to handle Callback's result
            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    //If login success, We can now retrieve our needed data and build our FacebookEventArgs parameters

                    FacebookButton    facebookButton = (FacebookButton)e.NewElement;
                    FacebookEventArgs fbArgs         = new FacebookEventArgs();
                    if (loginResult.AccessToken != null)
                    {
                        fbArgs.UserId      = loginResult.AccessToken.UserId;
                        fbArgs.AccessToken = loginResult.AccessToken.Token;
                        //Hack from Java.Util.Date to DateTime
                        fbArgs.TokenExpiration = FromUnixTime(loginResult.AccessToken.Expires.Time);
                    }

                    //Pass the parameters into Login method in the FacebookButton
                    //object and handle it on Xamarin.Forms side
                    facebookButton.Login(facebookButton, fbArgs);
                },
                HandleCancel = () =>
                {
                    //Handle any cancel the user has perform
                    Console.WriteLine("User deleted the login operation");
                },
                HandleError = loginError =>
                {
                    //Handle any error happends here
                    //TODO: we have to decide what to do here
                }
            };

            LoginManager.Instance.RegisterCallback(MainActivity.CallbackManager, loginCallback);
            //Set the LoginButton as NativeControl
            SetNativeControl(loginButton);
        }
Esempio n. 13
0
        private void InitUI()
        {
            // Setup UI elements
            InitSocialButton(FacebookButton);
            InitSocialButton(TwitterButton);

            var bubbleCenterYConstraint = 0;

            GoButton.Layer.CornerRadius = 6;
            GoButton.Layer.BorderColor  = ThemeManager.Instance.CurrentTheme.Disabled.ToUIColor().CGColor;
            GoButton.Layer.BorderWidth  = 1;

            // Animations
            View.SetNeedsLayout();

            TitleImageViewTopConstraint.Constant = 46;

            FacebookButton.Alpha = 0;
            TwitterButton.Alpha  = 0;
            GoButton.Alpha       = 0;
            SubtitleLabel.Alpha  = 0;

            UIView.AnimateNotify(0.75, () => {
                View.LayoutIfNeeded();
                SubtitleLabel.Alpha = 1;
            }, (ic) => {
                FacebookButton.SetNeedsLayout();
                FacebookButtonCenterYConstraint.Constant = bubbleCenterYConstraint;

                UIView.AnimateNotify(1, 0, 0.4f, 1, 0, () => {
                    FacebookButton.LayoutIfNeeded();
                    FacebookButton.Alpha = 1;
                }, (ic1) => {
                    TwitterButton.SetNeedsLayout();
                    TwitterButtonCenterYConstraint.Constant = bubbleCenterYConstraint;
                    UIView.AnimateNotify(1, 0, 0.4f, 1, 0, () => {
                        TwitterButton.LayoutIfNeeded();
                        TwitterButton.Alpha = 1;
                    }, (ic2) => {
                        UIView.AnimateNotify(0.5, () => {
                            GoButtonBottomConstraint.Constant = 26;
                            GoButton.Alpha = 1;
                        }, null);
                    });
                });
            });
        }
        void ReleaseDesignerOutlets()
        {
            if (FacebookButton != null)
            {
                FacebookButton.Dispose();
                FacebookButton = null;
            }

            if (InstagramButton != null)
            {
                InstagramButton.Dispose();
                InstagramButton = null;
            }

            if (LinkedinButton != null)
            {
                LinkedinButton.Dispose();
                LinkedinButton = null;
            }

            if (PrivacyPolicyButton != null)
            {
                PrivacyPolicyButton.Dispose();
                PrivacyPolicyButton = null;
            }

            if (SeekiosButton != null)
            {
                SeekiosButton.Dispose();
                SeekiosButton = null;
            }

            if (TwitterButton != null)
            {
                TwitterButton.Dispose();
                TwitterButton = null;
            }

            if (VersionLabel != null)
            {
                VersionLabel.Dispose();
                VersionLabel = null;
            }
        }
Esempio n. 15
0
        private void InitBindings()
        {
            ViewModel.PropertyChanged += (object sender, PropertyChangedEventArgs e) => {
                if (e.PropertyName.Equals("IsFacebookSelected"))
                {
                    OnSocialButtonSelected(FacebookButton, ViewModel.IsFacebookSelected);
                }
                else if (e.PropertyName.Equals("IsTwitterSelected"))
                {
                    OnSocialButtonSelected(TwitterButton, ViewModel.IsTwitterSelected);
                }
            };

            FacebookButton.SetCommand("TouchUpInside", ViewModel.FacebookCommand);
            TwitterButton.SetCommand("TouchUpInside", ViewModel.TwitterCommand);

            ViewModel.RequestHomePage = OnRequestHomePage;
            ViewModel.CanExecute      = OnCanExecute;
        }
Esempio n. 16
0
        public LoginPage()
        {
            Title           = "Login";
            BackgroundColor = Color.White;
            StackLayout layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding         = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0)
            };
            Label lblTitle = new Label
            {
                Text            = "Facebook LoginButton Example",
                FontAttributes  = FontAttributes.Bold,
                FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                VerticalOptions = LayoutOptions.StartAndExpand,
                XAlign          = TextAlignment.Center,
                TextColor       = Color.Black
            };
            Label lblExplanation = new Label
            {
                Text            = "This will show you how the Facebook LoginButton look like using Xamarin Forms CustomRenderer",
                FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                XAlign          = TextAlignment.Center,
                TextColor       = Color.Black
            };
            FacebookButton fbButton = new FacebookButton();

            fbButton.HeightRequest   = 60;
            fbButton.VerticalOptions = LayoutOptions.End;
            //Add your event handler for the OnLogin to operate with the Facebook credentials comming from SDK
            fbButton.OnLogin += LoginWithFacebook;

            //Adding views to layout
            layout.Children.Add(lblTitle);
            layout.Children.Add(lblExplanation);
            layout.Children.Add(fbButton);
            this.Content = layout;
        }
Esempio n. 17
0
        void ReleaseDesignerOutlets()
        {
            if (EnterYourEmail != null)
            {
                EnterYourEmail.Dispose();
                EnterYourEmail = null;
            }

            if (EnterYourPasswordForLogin != null)
            {
                EnterYourPasswordForLogin.Dispose();
                EnterYourPasswordForLogin = null;
            }

            if (FacebookButton != null)
            {
                FacebookButton.Dispose();
                FacebookButton = null;
            }

            if (GoogleButton != null)
            {
                GoogleButton.Dispose();
                GoogleButton = null;
            }

            if (LoginButton != null)
            {
                LoginButton.Dispose();
                LoginButton = null;
            }

            if (RegistrationButton != null)
            {
                RegistrationButton.Dispose();
                RegistrationButton = null;
            }
        }
Esempio n. 18
0
        void ReleaseDesignerOutlets()
        {
            if (BackgroundImageView != null)
            {
                BackgroundImageView.Dispose();
                BackgroundImageView = null;
            }

            if (CountLabel != null)
            {
                CountLabel.Dispose();
                CountLabel = null;
            }

            if (FacebookButton != null)
            {
                FacebookButton.Dispose();
                FacebookButton = null;
            }

            if (FacebookTrailingConstraint != null)
            {
                FacebookTrailingConstraint.Dispose();
                FacebookTrailingConstraint = null;
            }

            if (FooterView != null)
            {
                FooterView.Dispose();
                FooterView = null;
            }

            if (FooterViewBottomConstraint != null)
            {
                FooterViewBottomConstraint.Dispose();
                FooterViewBottomConstraint = null;
            }

            if (PostButton != null)
            {
                PostButton.Dispose();
                PostButton = null;
            }

            if (TextView != null)
            {
                TextView.Dispose();
                TextView = null;
            }

            if (TwitterButton != null)
            {
                TwitterButton.Dispose();
                TwitterButton = null;
            }

            if (TwitterTrailingConstraint != null)
            {
                TwitterTrailingConstraint.Dispose();
                TwitterTrailingConstraint = null;
            }

            if (AccountsView != null)
            {
                AccountsView.Dispose();
                AccountsView = null;
            }
        }
Esempio n. 19
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || this.Element == null)
            {
                return;
            }

            loginButton = new LoginButton(Forms.Context);
            loginButton.LoginBehavior = LoginBehavior.NativeWithFallback;

            //Implement FacebookCallback with LoginResult type to handle Callback's result
            var loginCallback = new FacebookCallback <LoginResult>
            {
                HandleSuccess = loginResult =>
                {
                    /*
                     * If login success, We can now retrieve our needed data and build our
                     * FacebookEventArgs parameters
                     */

                    FacebookButton    facebookButton = (FacebookButton)e.NewElement;
                    FacebookEventArgs fbArgs         = new FacebookEventArgs();

                    if (loginResult.AccessToken != null)
                    {
                        fbArgs.UserId      = loginResult.AccessToken.UserId;
                        fbArgs.AccessToken = loginResult.AccessToken.Token;
                        var expires = loginResult.AccessToken.Expires;

                        //TODO better way to retrive Java.Util.Date and cast it to System.DateTime type
                        fbArgs.TokenExpiration = new DateTime(expires.Year, expires.Month, expires.Day, expires.Hours, expires.Minutes, expires.Seconds);

                        Bundle param = new Bundle();
                        param.PutString("fields", "first_name,last_name,email,birthday,picture");

                        var request = new GraphRequest(loginResult.AccessToken, "/me/acounts", param, HttpMethod.Get);
                        request.ExecuteAsync();

                        /*((connection, result, error) =>
                         * {
                         *      var userInfo = result as NSDictionary;
                         *      nameLabel.Text = userInfo["first_name"].ToString();
                         *
                         *      ((App)App.Current).settings.AccessToken = fbArgs.AccessToken;
                         *      ((App)App.Current).settings.BirthDay = DateTime.Parse(userInfo["birthday"].ToString());
                         *      ((App)App.Current).settings.Email = userInfo["email"].ToString();
                         *      ((App)App.Current).settings.ExpirinDate = fbArgs.TokenExpiration;
                         *      ((App)App.Current).settings.Name = userInfo["first_name"].ToString() + " " + userInfo["last_name"].ToString();
                         *      ((App)App.Current).settings.Imagem = userInfo["picture"].ToString();
                         *
                         *      var picture = userInfo["picture"] as NSDictionary;
                         *      picture = picture["data"] as NSDictionary;
                         *
                         *      ((App)App.Current).settings.Imagem = picture["url"].ToString();
                         *      ((App)App.Current).settingsViewModel.Gravar();
                         *      ((App)App.Current).NavigateToHome();
                         * });*/
                    }

                    /*
                     * Pass the parameters into Login method in the FacebookButton
                     * object and handle it on Xamarin.Forms side
                     */
                    facebookButton.Login(facebookButton, fbArgs);
                },
                HandleCancel = () =>
                {
                    //Handle any cancel the user has perform
                    Console.WriteLine("User cancel de login operation");
                },
                HandleError = loginError =>
                {
                    //Handle any error happends here
                    Console.WriteLine("Operation throws an error: " + loginError.Cause.Message);
                }
            };

            LoginManager.Instance.RegisterCallback(MainActivity.CallbackManager, loginCallback);
            //Set the LoginButton as NativeControl
            SetNativeControl(loginButton);
        }
Esempio n. 20
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || this.Element == null)
            {
                return;
            }

            loginButton = new LoginButton(new CGRect(48, 0, 218, 46))
            {
                LoginBehavior   = LoginBehavior.Native,
                ReadPermissions = readPermissions.ToArray()
            };

            var facebookLoginButtonText = new NSAttributedString("Entrar com Facebook",
                                                                 new UIStringAttributes()
            {
                ForegroundColor = UIColor.White
            });

            loginButton.SetAttributedTitle(facebookLoginButtonText, UIControlState.Normal);

            loginButton.Completed += (sender, args) =>
            {
                FacebookButton    facebookButton = (FacebookButton)e.NewElement;
                FacebookEventArgs fbArgs         = new FacebookEventArgs();


                if (args.Result.Token != null)
                {
                    fbArgs.UserId          = args.Result.Token.UserID;
                    fbArgs.AccessToken     = args.Result.Token.TokenString;
                    fbArgs.TokenExpiration = args.Result.Token.ExpirationDate.ToDateTime();

                    var request = new GraphRequest("/" + args.Result.Token.UserID, new NSDictionary("fields", "first_name,last_name,email,birthday,picture"), AccessToken.CurrentAccessToken.TokenString, null, "GET");
                    request.Start((connection, result, error) =>
                    {
                        var userInfo   = result as NSDictionary;
                        nameLabel.Text = userInfo["first_name"].ToString();

                        ((App)App.Current).settings.AccessToken = fbArgs.AccessToken;

                        try
                        {
                            //((App)App.Current).settings.BirthDay = DateTime.Parse(userInfo["birthday"].ToString() + " 00:00:00");
                            ((App)App.Current).settings.Email = userInfo["email"].ToString();
                        }
                        catch (Exception erro)
                        {
                            Console.WriteLine(erro.Message);
                        }

                        ((App)App.Current).settings.ExpirinDate = fbArgs.TokenExpiration;
                        ((App)App.Current).settings.Name        = userInfo["first_name"].ToString() + " " + userInfo["last_name"].ToString();
                        ((App)App.Current).settings.Imagem      = userInfo["picture"].ToString();

                        var picture = userInfo["picture"] as NSDictionary;
                        picture     = picture["data"] as NSDictionary;

                        ((App)App.Current).settings.Imagem = picture["url"].ToString();
                        ((App)App.Current).settingsViewModel.Gravar();
                        ((App)App.Current).NavigateToHome();
                    });
                }


                facebookButton.Login(facebookButton, fbArgs);
                // The user image profile is set automatically once is logged in

                //pictureView = new ProfilePictureView(new CGRect(80, -500, 220, 220));
                //this.AddSubview(pictureView);

                nameLabel = new UILabel(new RectangleF(80, -200, 280, 280))
                {
                    TextAlignment   = UITextAlignment.Center,
                    BackgroundColor = UIColor.Clear
                };
                this.AddSubview(nameLabel);
            };

            SetNativeControl(loginButton);
        }
Esempio n. 21
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "About Xamarin";

            StackOverflowButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_stackoverflow.png"), UIControlState.Normal);
            LinkedInButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_linkedin.png"), UIControlState.Normal);
            TwitterButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_twitter.png"), UIControlState.Normal);
            YouTubeButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_youtube.png"), UIControlState.Normal);
            FacebookButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_facebook.png"), UIControlState.Normal);
            BlogRssButton.SetBackgroundImage(UIImage.FromFile("Images/Logos/logo_rss.png"), UIControlState.Normal);


            StackOverflowButton.TouchUpInside += (sender, e) => { OpenUrl(Constants.AboutUrlStackOverflow); };
            LinkedInButton.TouchUpInside      += (sender, e) => { OpenUrl(Constants.AboutUrlLinkedIn); };
            TwitterButton.TouchUpInside       += (sender, e) => { OpenUrl(Constants.AboutUrlTwitter); };
            YouTubeButton.TouchUpInside       += (sender, e) => { OpenUrl(Constants.AboutUrlYouTube); };
            FacebookButton.TouchUpInside      += (sender, e) => { OpenUrl(Constants.AboutUrlFacebook); };
            BlogRssButton.TouchUpInside       += (sender, e) => { OpenUrl(Constants.AboutUrlBlogRss); };


            if (AppDelegate.IsPhone)
            {
                ScrollView.Frame       = new CGRect(0, 43, 320, 367);
                ScrollView.ContentSize = new CGSize(320, 610);

                XamLogoImageView.Image = UIImage.FromBundle("/Images/About");

                AboutTextView.Frame = new CGRect(
                    AboutTextView.Frame.X,
                    AboutTextView.Frame.Y,
                    320,
                    240);

                var Y = AboutTextView.Frame.Y + 240;

                StackOverflowButton.Frame = new CGRect(StackOverflowButton.Frame.X, Y, StackOverflowButton.Frame.Width, StackOverflowButton.Frame.Height);
                LinkedInButton.Frame      = new CGRect(LinkedInButton.Frame.X, Y, LinkedInButton.Frame.Width, LinkedInButton.Frame.Height);
                TwitterButton.Frame       = new CGRect(TwitterButton.Frame.X, Y, TwitterButton.Frame.Width, TwitterButton.Frame.Height);
                YouTubeButton.Frame       = new CGRect(YouTubeButton.Frame.X, Y, YouTubeButton.Frame.Width, YouTubeButton.Frame.Height);
                FacebookButton.Frame      = new CGRect(FacebookButton.Frame.X, Y, FacebookButton.Frame.Width, FacebookButton.Frame.Height);
                BlogRssButton.Frame       = new CGRect(BlogRssButton.Frame.X, Y, BlogRssButton.Frame.Width, BlogRssButton.Frame.Height);
            }
            else
            {
                // IsPad
                ScrollView.Frame       = new CGRect(0, 0, 768, 1004);
                ScrollView.ContentSize = new CGSize(768, 1024);

                XamLogoImageView.Image = UIImage.FromBundle("/Images/About-Portrait~iPad");
                XamLogoImageView.Frame = ScrollView.Frame;

                CGSize size = UIStringDrawing.StringSize(AboutTextView.Text
                                                         , AboutTextView.Font
                                                         , new SizeF(738, 500)
                                                         , UILineBreakMode.WordWrap);

                AboutTextView.Frame = new CGRect(
                    15,
                    650,
                    size.Width,
                    size.Height + 30);
                //AboutTextView.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth;

                var Y = AboutTextView.Frame.Y + size.Height + 40;

                StackOverflowButton.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                LinkedInButton.AutoresizingMask      = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                TwitterButton.AutoresizingMask       = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                YouTubeButton.AutoresizingMask       = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                BlogRssButton.AutoresizingMask       = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                FacebookButton.AutoresizingMask      = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;

                LayoutButtons(Y);
            }
            AboutTextView.Text = Constants.AboutText;             // @"Xamarin was founded in 2011 with the mission to make it fast, easy and fun to build great mobile apps. Xamarin’s products are used by individual developers and companies, including VMware, Target, Rdio, Medtronic and Unity Technologies, to simplify creation and operation of high-performance, cross-platform mobile consumer and corporate applications, targeting phones and tablets running iOS, Android and Windows. For more information, visit http://xamarin.com.";
        }
 private void Logout(object sender, RoutedEventArgs e)
 {
     FacebookButton.Logout();
 }
Esempio n. 23
0
        public LandingPage(LoginViewModel vm)
        {
            this.Appearing += LandingPage_Appearing;
            _viewModel      = vm;

            layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Fill
            };

            backgroundImage = new Image
            {
                Source = Device.RuntimePlatform == Device.iOS ? "*****@*****.**" : "login_background.png",
                Margin = new Thickness(0, Device.OnPlatform(100, 0, 0), 0, 0)
            };
            BackgroundColor = Color.White;

            if (Device.RuntimePlatform == Device.iOS)
            {
                backgroundImage.WidthRequest = 180;
            }

            title = new Label()
            {
                Text      = "Travlendar+",
                FontSize  = 32,
                TextColor = Color.White
            };

            StackLayout buttons = new StackLayout {
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            fbButton = new FacebookButton();
            fbButton.HorizontalOptions = LayoutOptions.Center;
            fbButton.HeightRequest     = 50;
            fbButton.VerticalOptions   = LayoutOptions.Center;

            buttons.Children.Add(fbButton);
            layout.Children.Add(backgroundImage);

            //Future AWS Cognito Identity Authentication Implementation

            //registerButton = new Button
            //{
            //    Text = "Create Account",
            //    TextColor = Constants.TravlendarAquaGreen,
            //    BackgroundColor = Color.White,
            //    BorderColor = Constants.TravlendarAquaGreen,
            //    BorderRadius = 4,
            //    BorderWidth = 1,
            //    HorizontalOptions = LayoutOptions.Center,
            //    WidthRequest = 155
            //};

            //loginButton = new Button
            //{
            //    Text = "Login",
            //    TextColor = Constants.TravlendarAquaGreen,
            //    BackgroundColor = Color.White,
            //    BorderColor = Constants.TravlendarAquaGreen,
            //    BorderRadius = 4,
            //    BorderWidth = 1,
            //    HorizontalOptions = LayoutOptions.Center,
            //    WidthRequest = 155
            //};

            //relativeLayout.Children.Add (backgroundImage, Constraint.Constant (0), Constraint.Constant (0));
            //relativeLayout.Children.Add (title, Constraint.RelativeToParent (parent => (parent.Width / 2) - 75), Constraint.RelativeToParent (parent => parent.Height / 2));
            //buttons.Children.Add (registerButton);
            //buttons.Children.Add (loginButton);

            RegisterEvents();
            buttons.Children.Add(fbButton);
            layout.Children.Add(buttons);

            this.Content = layout;
        }
Esempio n. 24
0
        void ReleaseDesignerOutlets()
        {
            if (ActivityIndicator != null)
            {
                ActivityIndicator.Dispose();
                ActivityIndicator = null;
            }

            if (BackgroundImageView != null)
            {
                BackgroundImageView.Dispose();
                BackgroundImageView = null;
            }

            if (FacebookButton != null)
            {
                FacebookButton.Dispose();
                FacebookButton = null;
            }

            if (GoButton != null)
            {
                GoButton.Dispose();
                GoButton = null;
            }

            if (GoButtonBottomConstraint != null)
            {
                GoButtonBottomConstraint.Dispose();
                GoButtonBottomConstraint = null;
            }

            if (SubtitleLabel != null)
            {
                SubtitleLabel.Dispose();
                SubtitleLabel = null;
            }

            if (TitleImageView != null)
            {
                TitleImageView.Dispose();
                TitleImageView = null;
            }

            if (TitleImageViewTopConstraint != null)
            {
                TitleImageViewTopConstraint.Dispose();
                TitleImageViewTopConstraint = null;
            }

            if (TwitterButton != null)
            {
                TwitterButton.Dispose();
                TwitterButton = null;
            }

            if (FacebookButtonCenterYConstraint != null)
            {
                FacebookButtonCenterYConstraint.Dispose();
                FacebookButtonCenterYConstraint = null;
            }

            if (TwitterButtonCenterYConstraint != null)
            {
                TwitterButtonCenterYConstraint.Dispose();
                TwitterButtonCenterYConstraint = null;
            }
        }