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;
                }));
            });
        }
Exemplo n.º 2
0
        void ReleaseDesignerOutlets()
        {
            if (DescriptionLabel != null)
            {
                DescriptionLabel.Dispose();
                DescriptionLabel = null;
            }

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

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

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

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

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

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