public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var scopes = string.Join(", ", OctokitClientFactory.Scopes);

            DescriptionLabel.Text      = string.Format("The provided Personal Access Token must allow access to the following scopes: {0}", scopes);
            DescriptionLabel.TextColor = ComponentTextColor;

            TokenText.AttributedPlaceholder = new Foundation.NSAttributedString("Token", foregroundColor: ComponentPlaceholderColor);
            TokenText.BackgroundColor       = ComponentBackgroundColor;
            TokenText.TextColor             = ComponentTextColor;

            DomainText.AttributedPlaceholder = new Foundation.NSAttributedString("Domain", foregroundColor: ComponentPlaceholderColor);
            DomainText.BackgroundColor       = ComponentBackgroundColor;
            DomainText.TextColor             = ComponentTextColor;

            View.BackgroundColor = BackgroundColor;
            LogoImageView.Image  = Images.Logos.Enterprise;

            LoginButton.SetTitleColor(ComponentTextColor, UIControlState.Normal);
            LoginButton.SetBackgroundImage(Images.Buttons.BlackButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);

            //Set some generic shadowing
            LoginButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            LoginButton.Layer.ShadowOffset  = new CGSize(0, 1);
            LoginButton.Layer.ShadowOpacity = 0.2f;

            this.ViewportObservable().Subscribe(x => ScrollView.Frame = x);

            ImageHeight.Constant = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 192 : 86;

            OnActivation(d => {
                d(TokenText.GetChangedObservable().Subscribe(x => ViewModel.Token    = x));
                d(ViewModel.WhenAnyValue(x => x.Token).Subscribe(x => TokenText.Text = x));

                d(DomainText.GetChangedObservable().Subscribe(x => ViewModel.Domain    = x));
                d(ViewModel.WhenAnyValue(x => x.Domain).Subscribe(x => DomainText.Text = x));

                d(LoginButton.GetClickedObservable().InvokeCommand(ViewModel.LoginCommand));
                d(ViewModel.LoginCommand.CanExecuteObservable.Subscribe(x => LoginButton.Enabled = x));

                DomainText.ShouldReturn = delegate {
                    TokenText.BecomeFirstResponder();
                    return(true);
                };

                TokenText.ShouldReturn = delegate {
                    TokenText.ResignFirstResponder();
                    LoginButton.SendActionForControlEvents(UIControlEvent.TouchUpInside);
                    return(true);
                };

                d(Disposable.Create(() => {
                    DomainText.ShouldReturn = null;
                    TokenText.ShouldReturn  = null;
                }));
            });
        }
Exemple #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Login";


            View.BackgroundColor = EnterpriseBackgroundColor;
            Logo.Image           = Images.Logos.EnterpriseMascot;

            LoginButton.SetBackgroundImage(Images.Buttons.BlackButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);
            LoginButton.Enabled = true;

            //Set some generic shadowing
            LoginButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            LoginButton.Layer.ShadowOffset  = new CGSize(0, 1);
            LoginButton.Layer.ShadowOpacity = 0.3f;

            var attributes = new UIStringAttributes {
                ForegroundColor = UIColor.LightGray,
            };

            Domain.AttributedPlaceholder   = new NSAttributedString("Domain", attributes);
            User.AttributedPlaceholder     = new NSAttributedString("Username", attributes);
            Password.AttributedPlaceholder = new NSAttributedString("Password", attributes);

            foreach (var i in new [] { Domain, User, Password })
            {
                i.Layer.BorderColor  = UIColor.Black.CGColor;
                i.Layer.BorderWidth  = 1;
                i.Layer.CornerRadius = 4;
            }

            Domain.ShouldReturn = delegate {
                User.BecomeFirstResponder();
                return(true);
            };

            User.ShouldReturn = delegate {
                Password.BecomeFirstResponder();
                return(true);
            };
            Password.ShouldReturn = delegate {
                Password.ResignFirstResponder();
                LoginButton.SendActionForControlEvents(UIControlEvent.TouchUpInside);
                return(true);
            };

            OnActivation(d =>
            {
                d(User.GetChangedObservable().Subscribe(x => ViewModel.Username     = x));
                d(Password.GetChangedObservable().Subscribe(x => ViewModel.Password = x));
                d(Domain.GetChangedObservable().Subscribe(x => ViewModel.Domain     = x));
                d(LoginButton.GetClickedObservable().BindCommand(ViewModel.LoginCommand));
                d(ViewModel.Bind(x => x.IsLoggingIn).SubscribeStatus("Logging in..."));
                d(ViewModel.LoginCommand.ThrownExceptions.Subscribe(HandleLoginException));
            });
        }
Exemple #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Username.BackgroundColor       = ComponentBackgroundColor;
            Username.AttributedPlaceholder = new Foundation.NSAttributedString("Username", foregroundColor: ComponentPlaceholderColor);
            Username.TextColor             = ComponentTextColor;

            Password.BackgroundColor       = ComponentBackgroundColor;
            Password.AttributedPlaceholder = new Foundation.NSAttributedString("Password", foregroundColor: ComponentPlaceholderColor);
            Password.TextColor             = ComponentTextColor;

            Domain.BackgroundColor       = ComponentBackgroundColor;
            Domain.AttributedPlaceholder = new Foundation.NSAttributedString("Domain", foregroundColor: ComponentPlaceholderColor);
            Domain.TextColor             = ComponentTextColor;

            View.BackgroundColor = BackgroundColor;
            LogoImageView.Image  = Images.Logos.Enterprise;

            LoginButton.SetTitleColor(ComponentTextColor, UIControlState.Normal);
            LoginButton.SetBackgroundImage(Images.Buttons.BlackButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);

            //Set some generic shadowing
            LoginButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            LoginButton.Layer.ShadowOffset  = new CGSize(0, 1);
            LoginButton.Layer.ShadowOpacity = 0.2f;

            this.ViewportObservable().Subscribe(x => ScrollView.Frame = x);

            ImageHeight.Constant = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 192 : 86;

            OnActivation(d => {
                d(Username.GetChangedObservable().Subscribe(x => ViewModel.Username         = x));
                d(this.WhenAnyValue(x => x.ViewModel.Username).Subscribe(x => Username.Text = x));
                d(Password.GetChangedObservable().Subscribe(x => ViewModel.Password         = x));
                d(this.WhenAnyValue(x => x.ViewModel.Password).Subscribe(x => Password.Text = x));
                d(Domain.GetChangedObservable().Subscribe(x => ViewModel.Domain             = x));
                d(this.WhenAnyValue(x => x.ViewModel.Domain).Subscribe(x => Domain.Text     = x));
                d(LoginButton.GetClickedObservable().InvokeCommand(ViewModel.LoginCommand));
                d(ViewModel.LoginCommand.CanExecuteObservable.Subscribe(x => LoginButton.Enabled = x));

                d(this.WhenAnyValue(x => x.ViewModel.ShowLoginOptionsCommand)
                  .ToBarButtonItem(UIBarButtonSystemItem.Action, x => NavigationItem.RightBarButtonItem = x));

                Domain.ShouldReturn = delegate {
                    Username.BecomeFirstResponder();
                    return(true);
                };

                Username.ShouldReturn = delegate {
                    Password.BecomeFirstResponder();
                    return(true);
                };

                Password.ShouldReturn = delegate {
                    Password.ResignFirstResponder();
                    LoginButton.SendActionForControlEvents(UIControlEvent.TouchUpInside);
                    return(true);
                };

                d(Disposable.Create(() => {
                    Domain.ShouldReturn   = null;
                    Username.ShouldReturn = null;
                    Password.ShouldReturn = null;
                }));
            });
        }
Exemple #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var scopes = string.Join(", ", OctokitClientFactory.Scopes);

            DescriptionLabel.Text      = string.Format("The provided Personal Access Token must allow access to the following scopes: {0}", scopes);
            DescriptionLabel.TextColor = ComponentTextColor;

            AuthenticationSelector.TintColor = ComponentTextColor.ColorWithAlpha(0.9f);

            View.BackgroundColor = EnterpriseBackgroundColor;
            Logo.Image           = Images.Logos.EnterpriseMascot;

            LoginButton.SetBackgroundImage(Images.Buttons.BlackButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);
            LoginButton.Enabled = true;

            //Set some generic shadowing
            LoginButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            LoginButton.Layer.ShadowOffset  = new CGSize(0, 1);
            LoginButton.Layer.ShadowOpacity = 0.2f;

            var attributes = new UIStringAttributes {
                ForegroundColor = UIColor.LightGray,
            };

            Domain.AttributedPlaceholder         = new NSAttributedString("Domain", attributes);
            User.AttributedPlaceholder           = new NSAttributedString("Username", attributes);
            Password.AttributedPlaceholder       = new NSAttributedString("Password", attributes);
            TokenTextField.AttributedPlaceholder = new NSAttributedString("Token", attributes);

            foreach (var i in new [] { Domain, User, Password, TokenTextField })
            {
                i.Layer.BorderColor  = UIColor.Black.CGColor;
                i.Layer.BorderWidth  = 1;
                i.Layer.CornerRadius = 4;
            }

            SelectAuthenticationScheme(0);

            Domain.ShouldReturn = delegate {
                User.BecomeFirstResponder();
                return(true);
            };

            User.ShouldReturn = delegate {
                Password.BecomeFirstResponder();
                return(true);
            };

            Password.ShouldReturn = delegate {
                Password.ResignFirstResponder();
                LoginButton.SendActionForControlEvents(UIControlEvent.TouchUpInside);
                return(true);
            };

            OnActivation(d =>
            {
                d(User.GetChangedObservable()
                  .Subscribe(x => ViewModel.Username = x));

                d(Password.GetChangedObservable()
                  .Subscribe(x => ViewModel.Password = x));

                d(Domain.GetChangedObservable()
                  .Subscribe(x => ViewModel.Domain = x));

                d(TokenTextField.GetChangedObservable()
                  .Subscribe(x => ViewModel.Token = x));

                d(LoginButton.GetClickedObservable()
                  .InvokeReactiveCommand(ViewModel.LoginCommand));

                d(AuthenticationSelector.GetChangedObservable()
                  .Do(x => ViewModel.TokenAuthentication = x == 1)
                  .Subscribe(SelectAuthenticationScheme));

                d(this.WhenAnyObservable(x => x.ViewModel.LoginCommand.CanExecute)
                  .Subscribe(x => LoginButton.Enabled = x));

                d(this.WhenAnyValue(x => x.ViewModel.TokenAuthentication)
                  .Subscribe(x => AuthenticationSelector.SelectedSegment = x ? 1 : 0));
            });
        }
Exemple #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Login";

            View.BackgroundColor = EnterpriseBackgroundColor;
            Logo.Image           = Images.StashLogo.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
            Logo.TintColor       = UIColor.FromRGB(239, 239, 244);

            LoginButton.BackgroundColor = UIColor.FromRGB(0x10, 0x40, 0x71);
            LoginButton.Enabled         = true;

            LoginButton.Layer.BorderColor  = UIColor.Black.CGColor;
            LoginButton.Layer.BorderWidth  = 1;
            LoginButton.Layer.CornerRadius = 4;

            var attributes = new UIStringAttributes
            {
                ForegroundColor = UIColor.LightGray
            };

            Domain.AttributedPlaceholder   = new NSAttributedString("Domain", attributes);
            User.AttributedPlaceholder     = new NSAttributedString("Username", attributes);
            Password.AttributedPlaceholder = new NSAttributedString("Password", attributes);

            foreach (var i in new[] { Domain, User, Password })
            {
                i.BackgroundColor    = UIColor.FromRGB(0x10, 0x40, 0x71);
                i.Layer.BorderColor  = UIColor.Black.CGColor;
                i.Layer.BorderWidth  = 1;
                i.Layer.CornerRadius = 4;
            }

            Domain.ShouldReturn = delegate
            {
                User.BecomeFirstResponder();
                return(true);
            };

            User.ShouldReturn = delegate
            {
                Password.BecomeFirstResponder();
                return(true);
            };
            Password.ShouldReturn = delegate
            {
                Password.ResignFirstResponder();
                LoginButton.SendActionForControlEvents(UIControlEvent.TouchUpInside);
                return(true);
            };

            OnActivation(d =>
            {
                User.GetChangedObservable().Subscribe(x => ViewModel.Username     = x).AddTo(d);
                Password.GetChangedObservable().Subscribe(x => ViewModel.Password = x).AddTo(d);
                Domain.GetChangedObservable().Subscribe(x => ViewModel.Domain     = x).AddTo(d);
                LoginButton.GetClickedObservable().BindCommand(ViewModel.LoginCommand).AddTo(d);
                ViewModel.WhenAnyValue(x => x.IsLoggingIn).SubscribeStatus("Logging in...").AddTo(d);
                ViewModel.LoginCommand.ThrownExceptions.Subscribe(HandleLoginException).AddTo(d);
            });
        }