Example #1
0
        public override void ViewDidLoad()
        {
            View.BackgroundColor = UIColor.White;
            base.ViewDidLoad();

            var button = new UIButton(UIButtonType.RoundedRect);
            button.SetTitle("Search", UIControlState.Normal);
            Add(button);

            var text = new UITextField() { BorderStyle = UITextBorderStyle.RoundedRect };
            Add(text);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            var set = this.CreateBindingSet<SearchView, SearchViewModel>();
            set.Bind(button).To("Search");
            set.Bind(text).To(vm => vm.SearchText);
            set.Apply();

            var hPadding = 10;
            var vPadding = 10;
            var ButtonWidth = 100;

            View.AddConstraints(

                    button.AtTopOf(View).Plus(vPadding),
                    button.AtRightOf(View).Minus(hPadding),
                    button.Width().EqualTo(ButtonWidth),

                    text.AtLeftOf(View, hPadding),
                    text.ToLeftOf(button, hPadding),
                    text.WithSameTop(button)

                );
        }
        private void DecorTextFields(UITextField textField)
        {
            var tag = textField.Tag;

            var previousView = _textFieldList.FirstOrDefault((x) => x.Tag == tag - 1);

            this.AddSubview(textField);

            if (tag == 0)
            {
                this.AddConstraints(
                    textField.AtTopOf(this),
                    textField.AtLeftOf(this),
                    textField.AtBottomOf(this),
                    textField.Width().EqualTo((this.Bounds.Width - (_pinLength - 1) * TEXT_MARGIN) / _pinLength)
                    );
            }
            else
            {
                this.AddConstraints(
                    textField.AtTopOf(this),
                    textField.ToRightOf(previousView, TEXT_MARGIN),
                    textField.AtBottomOf(this),
                    textField.Width().EqualTo((this.Bounds.Width - (_pinLength - 1) * TEXT_MARGIN) / _pinLength)
                    );
            }
        }
        public override void ViewDidLoad()
        {
            View.BackgroundColor = UIColor.White;
            base.ViewDidLoad();

            var subTotal = new UITextField() { BorderStyle = UITextBorderStyle.RoundedRect };
            subTotal.KeyboardType = UIKeyboardType.DecimalPad;
            Add(subTotal);

            var seek = new UISlider()
                {
                    MinValue = 0,
                    MaxValue = 100,
                };
            Add(seek);

            var seekLabel = new UILabel();
            Add(seekLabel);

            var tipLabel = new UILabel();
            Add(tipLabel);

            var totalLabel = new UILabel();
            Add(totalLabel);

            var set = this.CreateBindingSet<TipView, TipViewModel>();
            set.Bind(subTotal).To(vm => vm.SubTotal);
            set.Bind(seek).To(vm => vm.Generosity);
            set.Bind(seekLabel).To(vm => vm.Generosity);
            set.Bind(tipLabel).To(vm => vm.Tip);
            set.Bind(totalLabel).To("SubTotal + Tip");
            set.Apply();

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            var margin = 10;
            View.AddConstraints(
                    subTotal.AtLeftOf(View, margin),
                    subTotal.AtTopOf(View, margin),
                    subTotal.AtRightOf(View, margin),

                    seek.WithSameLeft(subTotal),
                    seek.Below(subTotal, margin),
                    seek.ToLeftOf(seekLabel, margin),
                    seek.WithRelativeWidth(seekLabel, 3),

                    seekLabel.WithSameRight(subTotal),
                    seekLabel.WithSameTop(seek),

                    tipLabel.Below(seek, margin),
                    tipLabel.WithSameLeft(seek),
                    tipLabel.WithSameWidth(totalLabel),

                    totalLabel.WithSameTop(tipLabel),
                    totalLabel.ToRightOf(tipLabel, margin),
                    totalLabel.WithSameRight(subTotal)
                );
        }
        public override void ViewDidLoad()
        {
            View.BackgroundColor = UIColor.White;
            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
            {
                EdgesForExtendedLayout = UIRectEdge.None;
            }

            var button = new UIButton(UIButtonType.RoundedRect);

            button.SetTitle("Search", UIControlState.Normal);
            Add(button);

            var text = new UITextField()
            {
                BorderStyle = UITextBorderStyle.RoundedRect
            };

            Add(text);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            var set = this.CreateBindingSet <SearchView, SearchViewModel>();

            set.Bind(button).To("Search");
            set.Bind(text).To(vm => vm.SearchText);
            set.Apply();

            var hPadding    = 10;
            var vPadding    = 10;
            var ButtonWidth = 100;

            View.AddConstraints(

                button.AtTopOf(View).Plus(vPadding),
                button.AtRightOf(View).Minus(hPadding),
                button.Width().EqualTo(ButtonWidth),

                text.AtLeftOf(View, hPadding),
                text.ToLeftOf(button, hPadding),
                text.WithSameTop(button)

                );
        }
Example #5
0
        protected override void SetupConstraints()
        {
            base.SetupConstraints();

            View.AddConstraints(new[]
            {
                _searchTextField.AtTopOf(View, 15),
                _searchTextField.AtLeftOf(View, 20),
                _searchTextField.AtRightOf(View, 20),

                _separatorView.Below(_searchTextField, 15),
                _separatorView.AtLeftOf(View),
                _separatorView.AtRightOf(View),
                _separatorView.Height().EqualTo(1),

                _tableView.Below(_separatorView),
                _tableView.AtLeftOf(View),
                _tableView.AtRightOf(View),
                _tableView.AtBottomOf(View)
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.Blue;
            TheViewController    = this;

            //Enumerate SVG with BundleResource action in the Resources/svg folder
            //var path = Path.Combine(NSBundle.MainBundle.BundlePath,"svg");
            var bundleSvgs = new List <string>(); //Directory.EnumerateFiles(path, "*.svg").Select(Path.GetFileName).OrderBy(s => s).ToList();

            //Enumerate SVG with EmbeddedResource action in the XamSvgDemo.Shared project, in the images folder.
            var assembly   = typeof(App).GetTypeInfo().Assembly;
            var sharedSvgs = assembly.GetManifestResourceNames().Where(n => n.EndsWith(".svg")).OrderBy(n => n).ToArray();

            //Combine both lists
            var svgNames = bundleSvgs.Select(s => "svg/" + s).Concat(
                sharedSvgs.Select(s => "res:" + s)
                ).ToList();

            var index = 0;

#if !USEAUTOLAYOUT
            //Fix width, let height be changed by UISvgImageView
            var bounds = UIScreen.MainScreen.Bounds;
            image = new UISvgImageView(svgNames[index], bounds.Width, 0)
            {
                Frame = new CGRect(0, 0, bounds.Width, bounds.Height)
            };
#else
            image = new UISvgImageView(svgNames[index]);
#endif

            image.Layer.BorderWidth = 1;
            image.Layer.BorderColor = UIColor.Green.CGColor;
            View.Add(image);

            title = new UILabel
            {
                TextColor     = UIColor.White,
                Font          = UIFont.SystemFontOfSize(14f),
                LineBreakMode = UILineBreakMode.CharacterWrap,
                Lines         = 0,
#if !USEAUTOLAYOUT
                Frame = new CGRect(0, 30, 320, 100),
#endif
            };
            View.Add(title);

#if USEAUTOLAYOUT
            var back = new UIView {
                BackgroundColor = UIColor.DarkGray.ColorWithAlpha(.6f)
            };
            var back2 = new UIView {
                BackgroundColor = UIColor.Clear
            };
            var inputUrl = new UITextField
            {
                TextColor = UIColor.White, Font = UIFont.SystemFontOfSize(14f),

                AttributedPlaceholder = new NSMutableAttributedString("Enter url of svg file, or tap anywhere for demo",
                                                                      foregroundColor: UIColor.Gray, font: UIFont.ItalicSystemFontOfSize(12)),
                KeyboardType           = UIKeyboardType.Url, AutocorrectionType = UITextAutocorrectionType.No,
                AutocapitalizationType = UITextAutocapitalizationType.None,
                //ReturnKeyType = UIReturnKeyType.Go,
                //EnablesReturnKeyAutomatically = true, ShouldReturn =
            };
            //var inputOk = new UISvgImageView("res:images.download", 25, colorMapping: "000000=FF546D", colorMappingSelected: "000000=00FF59")
            //{
            //    UserInteractionEnabled = true,
            //};
            var inputOk = new UISvgImageView
            {
                UserInteractionEnabled = true,
                TranslatesAutoresizingMaskIntoConstraints = false,
                FillWidth            = 25,
                ColorMapping         = "000000=FF546D",
                ColorMappingSelected = "000000=00FF59",
                BundleName           = "res:images.download",
                IsLoadAsync          = false
            };


            var btn = new UIButton();
            btn.SetTitle("Test1", UIControlState.Normal);
            btn.SetContentCompressionResistancePriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Vertical);

            //var inputOk = new UISvgImageView("", 25); //for debug
            View.Add(back);
            View.Add(back2);
            View.SendSubviewToBack(back);
            View.SendSubviewToBack(image); //image behind back
            View.Add(inputUrl);
            View.Add(inputOk);
            View.Add(btn);

            inputOk.AddGestureRecognizer(new UITapGestureRecognizer(tap =>
            {
                inputUrl.ResignFirstResponder();
                var dontWait = LoadSvg(inputUrl.Text);
            }));

            inputUrl.EditingDidBegin += (sender, args) =>
            {
                inputUrl.SelectAll(this);
            };

            inputUrl.SetContentHuggingPriority((float)UILayoutPriority.FittingSizeLevel, UILayoutConstraintAxis.Horizontal);
            inputOk.SetContentCompressionResistancePriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Horizontal);
            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            View.AddConstraints(
                back.WithSameTop(inputOk).Minus(5),
                back.AtLeftOf(View),
                back.AtRightOf(View),
                back.WithSameBottom(title).Plus(5),

                back2.Below(back),
                back2.AtLeftOf(View),
                back2.AtRightOf(View),
                back2.AtBottomOf(View),

                inputUrl.AtLeftOf(View, 5),
                inputUrl.WithSameCenterY(inputOk),

                inputOk.AtTopOf(View, 30),
                inputOk.AtRightOf(View, 5),
                inputOk.ToRightOf(inputUrl, 5),

                title.Below(inputUrl, 20),
                title.AtLeftOf(View, 5),
                title.AtRightOf(View, 5),
                //No height for title, use its intrinsic height

                btn.AtRightOf(View),
                btn.AtLeftOf(View),
                btn.AtBottomOf(View),

                image.Below(back),
                image.AtLeftOf(View),
                //Test: Width forced, free height
                image.WithSameWidth(View),
                //Test: Width forced, Height forced to view height
                //image.Height().LessThanOrEqualTo().HeightOf(View)
                image.Above(btn)
                //Test: Width forced, Height forced (50)
                );


            back2.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                index            = ++index % svgNames.Count;
                image.BundleName = svgNames[index];
                title.Text       = $"Displaying {svgNames[index]}";
                title.TextColor  = UIColor.White;
            })
            {
                NumberOfTapsRequired = 1
            });


            btn.TouchUpInside += (sender, args) =>
            {
                //var sb = UIStoryboard.FromName("TestFullWidthConstraint", null);
                //var vc = sb.InstantiateViewController("TestFullWidthConstraintViewController");
                var sb = UIStoryboard.FromName("AllViews", null);

                //var vc = sb.InstantiateViewController(nameof(TestUpdateViewController));
                var vc = sb.InstantiateViewController(nameof(TestImageFactoryViewController));

                NavigationController.PushViewController(vc, true);
            };
#endif
            image.FillMode = SvgFillMode.Fit;

            NavigationItem.TitleView = new UISvgImageView("res:images.atom")
            {
                IsLoadAsync   = false,
                FillMode      = SvgFillMode.Fit,
                AlignmentMode = SvgAlignmentMode.Center,
                Frame         = new CGRect(0, 0, NavigationController.NavigationBar.Bounds.Width, NavigationController.NavigationBar.Bounds.Height)
            };

            //var t = new UIImageView(new CGRect(0, 0, 100, 100));
            //t.Image = LoadLastSvgFromString();
            //View.Add(t);

            //image.UserInteractionEnabled = true;


            //var bounds = SvgFactory.GetBounds("res:images.logoImage", 100, 100, fillMode: SvgFillMode.Fit);
            //var image = SvgFactory.FromBundle("res:images.logoImage", 100, 100, fillMode: SvgFillMode.Fit);
        }
Example #7
0
        public override void ViewDidLoad()
        {
            View.BackgroundColor = UIColor.White;
            base.ViewDidLoad();

            // ios7 layout
            if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
            {
                EdgesForExtendedLayout = UIRectEdge.None;
            }

            var subTotal = new UITextField()
            {
                BorderStyle = UITextBorderStyle.RoundedRect
            };

            subTotal.KeyboardType = UIKeyboardType.DecimalPad;
            Add(subTotal);

            var seek = new UISlider()
            {
                MinValue = 0,
                MaxValue = 100,
            };

            Add(seek);

            var seekLabel = new UILabel();

            Add(seekLabel);

            var tipLabel = new UILabel();

            Add(tipLabel);

            var totalLabel = new UILabel();

            Add(totalLabel);

            var set = this.CreateBindingSet <TipView, TipViewModel>();

            set.Bind(subTotal).To(vm => vm.SubTotal);
            set.Bind(seek).To(vm => vm.Generosity);
            set.Bind(seekLabel).To(vm => vm.Generosity);
            set.Bind(tipLabel).To(vm => vm.Tip);
            set.Bind(totalLabel).To("SubTotal + Tip");
            set.Apply();

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            var margin = 10;

            View.AddConstraints(
                subTotal.AtLeftOf(View, margin),
                subTotal.AtTopOf(View, margin),
                subTotal.AtRightOf(View, margin),

                seek.WithSameLeft(subTotal),
                seek.Below(subTotal, margin),
                seek.ToLeftOf(seekLabel, margin),
                seek.WithRelativeWidth(seekLabel, 3),

                seekLabel.WithSameRight(subTotal),
                seekLabel.WithSameTop(seek),

                tipLabel.Below(seek, margin),
                tipLabel.WithSameLeft(seek),
                tipLabel.WithSameWidth(totalLabel),

                totalLabel.WithSameTop(tipLabel),
                totalLabel.ToRightOf(tipLabel, margin),
                totalLabel.WithSameRight(subTotal)
                );
        }
        public override void LoadView ()
        {
            View = new UIView ()
                .Apply (Style.Screen);

            View.Add (inputsContainer = new UIView ().Apply (Style.Login.InputsContainer));

            inputsContainer.Add (topBorder = new UIView ().Apply (Style.Login.InputsBorder));

            inputsContainer.Add (emailTextField = new UITextField () {
                Placeholder = "LoginEmailHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                KeyboardType = UIKeyboardType.EmailAddress,
                ReturnKeyType = UIReturnKeyType.Next,
                ClearButtonMode = UITextFieldViewMode.Always,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Login.EmailField));

            inputsContainer.Add (middleBorder = new UIView ().Apply (Style.Login.InputsBorder));

            inputsContainer.Add (passwordTextField = new UITextField () {
                Placeholder = "LoginPasswordHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType = UITextAutocorrectionType.No,
                SecureTextEntry = true,
                ReturnKeyType = UIReturnKeyType.Go,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Login.PasswordField));

            inputsContainer.Add (bottomBorder = new UIView ().Apply (Style.Login.InputsBorder));

            View.Add (passwordActionButton = new UIButton ()
                .Apply (Style.Login.LoginButton));
            passwordActionButton.SetTitle ("LoginLoginButtonText".Tr (), UIControlState.Normal);
            passwordActionButton.TouchUpInside += OnPasswordActionButtonTouchUpInside;

            inputsContainer.AddConstraints (
                topBorder.AtTopOf (inputsContainer),
                topBorder.AtLeftOf (inputsContainer),
                topBorder.AtRightOf (inputsContainer),
                topBorder.Height ().EqualTo (1f),

                emailTextField.Below (topBorder),
                emailTextField.AtLeftOf (inputsContainer, 20f),
                emailTextField.AtRightOf (inputsContainer, 10f),
                emailTextField.Height ().EqualTo (42f),

                middleBorder.Below (emailTextField),
                middleBorder.AtLeftOf (inputsContainer, 20f),
                middleBorder.AtRightOf (inputsContainer),
                middleBorder.Height ().EqualTo (1f),

                passwordTextField.Below (middleBorder),
                passwordTextField.AtLeftOf (inputsContainer, 20f),
                passwordTextField.AtRightOf (inputsContainer),
                passwordTextField.Height ().EqualTo (42f),

                bottomBorder.Below (passwordTextField),
                bottomBorder.AtLeftOf (inputsContainer),
                bottomBorder.AtRightOf (inputsContainer),
                bottomBorder.AtBottomOf (inputsContainer),
                bottomBorder.Height ().EqualTo (1f)
            );

            inputsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

            View.AddConstraints (
                inputsContainer.AtTopOf (View, 80f),
                inputsContainer.AtLeftOf (View),
                inputsContainer.AtRightOf (View),

                passwordActionButton.Below (inputsContainer, 20f),
                passwordActionButton.AtLeftOf (View),
                passwordActionButton.AtRightOf (View),
                passwordActionButton.Height ().EqualTo (60f)
            );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();
        }
Example #9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (RespondsToSelector(new Selector("setEdgesForExtendedLayout:")))
            {
                EdgesForExtendedLayout = UIRectEdge.None;
            }

            View.BackgroundColor = UIColor.White;

            var isConnectedLabel = new UILabel {
                Text = "Is Connected?"
            };

            var isWifiLabel = new UILabel {
                Text = "Is Wifi?"
            };

            var isCellularLabel = new UILabel {
                Text = "Is Cellular?"
            };

            var isConnected = new UILabel();
            var isWifi      = new UILabel();
            var isCellular  = new UILabel();

            var hostNameEntry = new UITextField {
                Placeholder = "Enter host name (ostebaronen.dk)"
            };
            var checkHostNameButton = new UIButton(UIButtonType.System);

            checkHostNameButton.SetTitle("Resolve host name", UIControlState.Normal);
            var hostNameResolvedLabel = new UILabel();

            var bset = this.CreateBindingSet <TestViewController, TestViewModel>();

            bset.Bind(isConnected).To(vm => vm.Connectivity.IsConnected);
            bset.Bind(isWifi).To(vm => vm.Connectivity.IsWifi);
            bset.Bind(isCellular).To(vm => vm.Connectivity.IsCellular);

            bset.Bind(hostNameEntry).To(vm => vm.HostName);
            bset.Bind(hostNameResolvedLabel).To(vm => vm.HostResolved);
            bset.Apply();

            checkHostNameButton.TouchUpInside += (sender, args) => {
                ViewModel.ResolveHostCommand.Execute(null);
            };

            View.Add(isConnectedLabel);
            View.Add(isWifiLabel);
            View.Add(isCellularLabel);
            View.Add(isConnected);
            View.Add(isWifi);
            View.Add(isCellular);
            View.Add(hostNameEntry);
            View.Add(checkHostNameButton);
            View.Add(hostNameResolvedLabel);
            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            nfloat padding = 10f;

            View.AddConstraints(
                isConnectedLabel.AtTopOf(View, padding),
                isConnectedLabel.AtLeftOf(View, padding),
                isConnectedLabel.AtRightOf(View, padding),

                isConnected.Below(isConnectedLabel, padding),
                isConnected.AtLeftOf(View, padding),
                isConnected.AtRightOf(View, padding),

                isWifiLabel.Below(isConnected, padding),
                isWifiLabel.AtLeftOf(View, padding),
                isWifiLabel.AtRightOf(View, padding),

                isWifi.Below(isWifiLabel, padding),
                isWifi.AtLeftOf(View, padding),
                isWifi.AtRightOf(View, padding),

                isCellularLabel.Below(isWifi, padding),
                isCellularLabel.AtLeftOf(View, padding),
                isCellularLabel.AtRightOf(View, padding),

                isCellular.Below(isCellularLabel, padding),
                isCellular.AtLeftOf(View, padding),
                isCellular.AtRightOf(View, padding),

                hostNameEntry.Below(isCellular, padding),
                hostNameEntry.AtLeftOf(View, padding),
                hostNameEntry.AtRightOf(View, padding),

                checkHostNameButton.Below(hostNameEntry, padding),
                checkHostNameButton.AtLeftOf(View, padding),
                checkHostNameButton.AtRightOf(View, padding),

                hostNameResolvedLabel.Below(checkHostNameButton, padding),
                hostNameResolvedLabel.AtLeftOf(View, padding),
                hostNameResolvedLabel.AtRightOf(View, padding)
                );
        }
        public override void LoadView()
        {
            View = new UIView()
                   .Apply(Style.Screen);

            View.Add(inputsContainer = new UIView().Apply(Style.Signup.InputsContainer));

            inputsContainer.Add(topBorder = new UIView().Apply(Style.Signup.InputsBorder));

            inputsContainer.Add(emailTextField = new UITextField()
            {
                Placeholder            = "SignupEmailHint".Tr(),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                KeyboardType           = UIKeyboardType.EmailAddress,
                ReturnKeyType          = UIReturnKeyType.Next,
                ClearButtonMode        = UITextFieldViewMode.Always,
                ShouldReturn           = HandleShouldReturn,
            }.Apply(Style.Signup.EmailField));
            emailTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add(middleBorder = new UIView().Apply(Style.Signup.InputsBorder));

            inputsContainer.Add(passwordTextField = new PasswordTextField()
            {
                Placeholder            = "SignupPasswordHint".Tr(),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType     = UITextAutocorrectionType.No,
                SecureTextEntry        = true,
                ReturnKeyType          = UIReturnKeyType.Go,
                ShouldReturn           = HandleShouldReturn,
            }.Apply(Style.Signup.PasswordField));
            passwordTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add(bottomBorder = new UIView().Apply(Style.Signup.InputsBorder));

            View.Add(passwordActionButton = new UIButton()
                                            .Apply(Style.Signup.SignupButton));
            passwordActionButton.SetTitle("SignupSignupButtonText".Tr(), UIControlState.Normal);
            passwordActionButton.TouchUpInside += OnPasswordActionButtonTouchUpInside;

            View.Add(googleActionButton = new UIButton()
                                          .Apply(Style.Signup.GoogleButton));
            googleActionButton.SetTitle("SignupGoogleButtonText".Tr(), UIControlState.Normal);
            googleActionButton.TouchUpInside += OnGoogleActionButtonTouchUpInside;

            View.Add(legalLabel = new TTTAttributedLabel()
            {
                Delegate = new LegalLabelDelegate(),
            }.Apply(Style.Signup.LegalLabel));
            SetLegalText(legalLabel);

            inputsContainer.AddConstraints(
                topBorder.AtTopOf(inputsContainer),
                topBorder.AtLeftOf(inputsContainer),
                topBorder.AtRightOf(inputsContainer),
                topBorder.Height().EqualTo(1f),

                emailTextField.Below(topBorder),
                emailTextField.AtLeftOf(inputsContainer, 20f),
                emailTextField.AtRightOf(inputsContainer, 10f),
                emailTextField.Height().EqualTo(42f),

                middleBorder.Below(emailTextField),
                middleBorder.AtLeftOf(inputsContainer, 20f),
                middleBorder.AtRightOf(inputsContainer),
                middleBorder.Height().EqualTo(1f),

                passwordTextField.Below(middleBorder),
                passwordTextField.AtLeftOf(inputsContainer, 20f),
                passwordTextField.AtRightOf(inputsContainer),
                passwordTextField.Height().EqualTo(42f),

                bottomBorder.Below(passwordTextField),
                bottomBorder.AtLeftOf(inputsContainer),
                bottomBorder.AtRightOf(inputsContainer),
                bottomBorder.AtBottomOf(inputsContainer),
                bottomBorder.Height().EqualTo(1f)
                );

            inputsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                inputsContainer.AtTopOf(View, 80f),
                inputsContainer.AtLeftOf(View),
                inputsContainer.AtRightOf(View),

                passwordActionButton.Below(inputsContainer, 20f),
                passwordActionButton.AtLeftOf(View),
                passwordActionButton.AtRightOf(View),
                passwordActionButton.Height().EqualTo(60f),

                googleActionButton.Below(passwordActionButton, 5f),
                googleActionButton.AtLeftOf(View),
                googleActionButton.AtRightOf(View),
                googleActionButton.Height().EqualTo(60f),

                legalLabel.AtBottomOf(View, 30f),
                legalLabel.AtLeftOf(View, 40f),
                legalLabel.AtRightOf(View, 40f)
                );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            ResetSignupButtonState();
        }
Example #11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.FromRGB(204, 242, 255);

            _contentConteiner = new UIView();
            _scrollView       = new UIScrollView();
            _scrollView.AddSubview(_contentConteiner);
            Add(_scrollView);


            _scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            _scrollView.AddConstraints(_contentConteiner.FullWidthOf(_scrollView));
            _scrollView.AddConstraints(_contentConteiner.FullHeightOf(_scrollView));

            var _BackBarButton = new UIBarButtonItem();

            _BackBarButton.Title = string.Empty;
            NavigationItem.RightBarButtonItem = _BackBarButton;
            var _MenuBarButton = new UIBarButtonItem();

            _BackBarButton.Title             = "Back";
            NavigationItem.LeftBarButtonItem = _BackBarButton;


            _labelError           = new UILabel();
            _labelError.TextColor = UIColor.Red;
            _labelError.Font      = _labelError.Font.WithSize(10);
            _contentConteiner.AddSubview(_labelError);

            _textUserName                    = new UITextField();
            _textUserName.Placeholder        = "Login";
            _textUserName.Layer.CornerRadius = 5;
            _textUserName.Layer.BorderWidth  = 2;
            _textUserName.BorderStyle        = UITextBorderStyle.RoundedRect;
            _textUserName.ShouldReturn       = (textField) => {
                textField.ResignFirstResponder();
                return(true);
            };
            _contentConteiner.AddSubview(_textUserName);

            _textUserPassword                    = new UITextField();
            _textUserPassword.Placeholder        = "Password";
            _textUserPassword.Layer.CornerRadius = 5;
            _textUserPassword.Layer.BorderWidth  = 2;
            _textUserPassword.SecureTextEntry    = true;
            _textUserPassword.BorderStyle        = UITextBorderStyle.RoundedRect;
            _textUserPassword.ShouldReturn       = (textField) => {
                textField.ResignFirstResponder();
                return(true);
            };
            _contentConteiner.AddSubview(_textUserPassword);

            _textUserPasswordRepeat                    = new UITextField();
            _textUserPasswordRepeat.Placeholder        = "Password repeat";
            _textUserPasswordRepeat.Layer.CornerRadius = 5;
            _textUserPasswordRepeat.Layer.BorderWidth  = 2;
            _textUserPasswordRepeat.SecureTextEntry    = true;
            _textUserPasswordRepeat.BorderStyle        = UITextBorderStyle.RoundedRect;
            _textUserPasswordRepeat.ShouldReturn       = (textField) => {
                textField.ResignFirstResponder();
                return(true);
            };
            _contentConteiner.AddSubview(_textUserPasswordRepeat);

            _passwordPattern               = new UILabel();
            _passwordPattern.Text          = "password must contain at least 6 characters, min 1 letter UpperCase,min 1 digit";
            _passwordPattern.Font          = _passwordPattern.Font.WithSize(10);
            _passwordPattern.LineBreakMode = UILineBreakMode.WordWrap;
            _passwordPattern.Lines         = 0;
            _contentConteiner.AddSubview(_passwordPattern);

            _imageUserPhoto = new UIImageView();
            _imageUserPhoto.Layer.CornerRadius = this._imageUserPhoto.Frame.Size.Height / 2;
            _imageUserPhoto.ClipsToBounds      = true;
            _imageUserPhoto.BackgroundColor    = UIColor.LightGray;
            _contentConteiner.AddSubview(_imageUserPhoto);

            _buttonPhoto = new UIButton();
            _buttonPhoto.Layer.CornerRadius = this._buttonPhoto.Frame.Size.Height / 2;
            _buttonPhoto.ClipsToBounds      = true;
            _buttonPhoto.BackgroundColor    = UIColor.Clear;
            _buttonPhoto.TouchUpInside     += ChoosePicture;
            _contentConteiner.AddSubview(_buttonPhoto);

            _buttonCreate = new UIButton(UIButtonType.RoundedRect);
            _buttonCreate.SetTitle("Create", UIControlState.Normal);
            _buttonCreate.Layer.CornerRadius = 5;
            _buttonCreate.BackgroundColor    = UIColor.Blue;
            _buttonCreate.SetTitleColor(UIColor.White, UIControlState.Normal);
            _contentConteiner.AddSubview(_buttonCreate);

            var set = this.CreateBindingSet <RegistrationView, RegistrationViewModel>();

            set.Bind(_textUserName).To(vm => vm.UserLogin);
            set.Bind(_labelError).To(vm => vm.Error);
            set.Bind(_textUserPassword).To(vm => vm.UserPassword);
            set.Bind(_textUserPasswordRepeat).To(vm => vm.UserPasswordRepeat);
            set.Bind(_buttonCreate).To(vm => vm.CreateUserCommand);
            set.Bind(_imageUserPhoto).For(v => v.Image).To(vm => vm.UserImage).WithConversion("ByteToUIImage");
            set.Bind(_BackBarButton).To(vm => vm.BackToCommand);
            set.Apply();

            //conastraint
            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(_scrollView.FullWidthOf(View));
            View.AddConstraints(_scrollView.FullHeightOf(View));
            View.AddConstraints(
                _contentConteiner.WithSameWidth(View),
                _contentConteiner.WithSameHeight(View).SetPriority(UILayoutPriority.DefaultLow)
                );

            _contentConteiner.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            _contentConteiner.AddConstraints(

                _labelError.WithSameCenterX(_contentConteiner),
                //_labelError.WithSameWidth(_contentConteiner).Minus(100),
                _labelError.AtTopOf(_contentConteiner),
                _labelError.Height().EqualTo(13),

                _textUserName.AtLeftOf(_contentConteiner, 25),
                _textUserName.WithSameWidth(_contentConteiner).Minus(135),
                _textUserName.Below(_labelError, 60),

                _textUserPassword.AtLeftOf(_contentConteiner, 25),
                _textUserPassword.WithSameWidth(_contentConteiner).Minus(135),
                _textUserPassword.Below(_textUserName, 40),

                _textUserPasswordRepeat.AtLeftOf(_contentConteiner, 25),
                _textUserPasswordRepeat.WithSameWidth(_contentConteiner).Minus(135),
                _textUserPasswordRepeat.Below(_textUserPassword, 40),

                _imageUserPhoto.AtRightOf(_contentConteiner, 25),
                _imageUserPhoto.WithSameCenterY(_textUserName),
                _imageUserPhoto.Width().EqualTo(80),
                _imageUserPhoto.Height().EqualTo(80),

                _buttonPhoto.WithSameCenterX(_imageUserPhoto),
                _buttonPhoto.Width().EqualTo(80),
                _buttonPhoto.Height().EqualTo(80),
                _buttonPhoto.Below(_imageUserPhoto, -80)
                );
            View.AddConstraints(_passwordPattern.Below(_textUserPasswordRepeat, 2));
            View.AddConstraints(_passwordPattern.FullWidthOf(View, 25));

            View.AddConstraints(_buttonCreate.FullWidthOf(View, 25));
            View.AddConstraints(_buttonCreate.Below(_passwordPattern, 25));
            View.AddConstraints(_buttonCreate.Height().LessThanOrEqualTo(35));

            // very important to make scrolling work
            var bottomViewConstraint = _contentConteiner.Subviews.Last()
                                       .AtBottomOf(_contentConteiner).Minus(20);

            _contentConteiner.AddConstraints(bottomViewConstraint);

            //disable swipe
            CreateGestureRecognizer();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.Blue;
            TheViewController = this;

            //Enumerate SVG with BundleResource action in the Resources/svg folder
            //var path = Path.Combine(NSBundle.MainBundle.BundlePath,"svg");
            var bundleSvgs = new List<string>(); //Directory.EnumerateFiles(path, "*.svg").Select(Path.GetFileName).OrderBy(s => s).ToList();

            //Enumerate SVG with EmbeddedResource action in the XamSvgDemo.Shared project, in the images folder.
            var assembly = typeof (App).GetTypeInfo().Assembly;
            var sharedSvgs = assembly.GetManifestResourceNames().Where(n => n.EndsWith(".svg")).OrderBy(n => n).ToArray();

            //Combine both lists
            var svgNames = bundleSvgs.Select(s => "svg/" + s).Concat(
                            sharedSvgs.Select(s => "res:" + s)
                            ).ToList();

            var index = 0;

#if !USEAUTOLAYOUT
            //Fix width, let height be changed by UISvgImageView
            var bounds = UIScreen.MainScreen.Bounds;
            image = new UISvgImageView(svgNames[index], bounds.Width, 0) { Frame = new CGRect(0,0,bounds.Width, bounds.Height) };
#else
            image = new UISvgImageView(svgNames[index]);
#endif

            image.Layer.BorderWidth = 1;
            image.Layer.BorderColor = UIColor.Green.CGColor;
            View.Add(image);

            title = new UILabel
            {
                TextColor=UIColor.White,
                Font = UIFont.SystemFontOfSize(14f),
                LineBreakMode = UILineBreakMode.CharacterWrap,
                Lines = 0,
#if !USEAUTOLAYOUT
                Frame = new CGRect(0,30,320,100),
#endif
            };
            View.Add(title);

#if USEAUTOLAYOUT
            var back = new UIView {BackgroundColor = UIColor.DarkGray.ColorWithAlpha(.6f)};
            var back2 = new UIView { BackgroundColor = UIColor.Clear };
            var inputUrl = new UITextField
            {
                TextColor = UIColor.White, Font = UIFont.SystemFontOfSize(14f),

                AttributedPlaceholder = new NSMutableAttributedString("Enter url of svg file, or tap anywhere for demo",
                    foregroundColor: UIColor.Gray, font: UIFont.ItalicSystemFontOfSize(12)),
                KeyboardType = UIKeyboardType.Url, AutocorrectionType = UITextAutocorrectionType.No,
                AutocapitalizationType = UITextAutocapitalizationType.None,
                //ReturnKeyType = UIReturnKeyType.Go,
                //EnablesReturnKeyAutomatically = true, ShouldReturn = 
            };
            //var inputOk = new UISvgImageView("res:images.download", 25, colorMapping: "000000=FF546D", colorMappingSelected: "000000=00FF59")
            //{
            //    UserInteractionEnabled = true,
            //};
            var inputOk = new UISvgImageView
            {
                UserInteractionEnabled = true,
                TranslatesAutoresizingMaskIntoConstraints = false,
                FillWidth = 25,
                ColorMapping="000000=FF546D",
                ColorMappingSelected="000000=00FF59",
                BundleName = "res:images.download"
            };
            //var inputOk = new UISvgImageView("", 25); //for debug
            View.Add(back);
            View.Add(back2);
            View.SendSubviewToBack(back);
            View.SendSubviewToBack(image); //image behind back
            View.Add(inputUrl);
            View.Add(inputOk);

            inputOk.AddGestureRecognizer(new UITapGestureRecognizer(tap =>
            {
                inputUrl.ResignFirstResponder();
                var dontWait = LoadSvg(inputUrl.Text);
            }));

            inputUrl.EditingDidBegin += (sender, args) =>
            {
                inputUrl.SelectAll(this);
            };

            inputUrl.SetContentHuggingPriority((float)UILayoutPriority.FittingSizeLevel, UILayoutConstraintAxis.Horizontal);
            inputOk.SetContentCompressionResistancePriority((float)UILayoutPriority.Required, UILayoutConstraintAxis.Horizontal);
            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            View.AddConstraints(
                back.WithSameTop(inputOk).Minus(5),
                back.AtLeftOf(View),
                back.AtRightOf(View),
                back.WithSameBottom(title).Plus(5),

                back2.Below(back),
                back2.AtLeftOf(View),
                back2.AtRightOf(View),
                back2.AtBottomOf(View),

                inputUrl.AtLeftOf(View, 5),
                inputUrl.WithSameCenterY(inputOk),

                inputOk.AtTopOf(View,30),
                inputOk.AtRightOf(View, 5),
                inputOk.ToRightOf(inputUrl,5),

                title.Below(inputUrl, 20),
                title.AtLeftOf(View, 5),
                title.AtRightOf(View,5),
                //No height for title, use its intrinsic height

                image.AtBottomOf(View),
                image.AtLeftOf(View),
                //Test: Width forced, free height
                image.WithSameWidth(View),
                //Test: Width forced, Height forced to view height
                image.Height().LessThanOrEqualTo().HeightOf(View)
                //Test: Width forced, Height forced (50)
                );
#endif
            image.FillMode = SvgFillMode.Fit;

            //var t = new UIImageView(new CGRect(0, 0, 100, 100));
            //t.Image = LoadLastSvgFromString();
            //View.Add(t);

            //image.UserInteractionEnabled = true;
            back2.AddGestureRecognizer(new UITapGestureRecognizer(() =>
            {
                index = ++index%svgNames.Count;
                image.BundleName = svgNames[index];
                title.Text = $"Displaying {svgNames[index]}";
                title.TextColor = UIColor.White;

            }) { NumberOfTapsRequired = 1 });

        }
Example #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.FromRGB(204, 242, 255);

            var    border = new CALayer();
            nfloat width  = 2;

            border.BorderColor = UIColor.Black.CGColor;
            border.BorderWidth = width;

            ViewModel.Show();

            _contentConteiner = new UIView();
            _scrollView       = new UIScrollView();
            _scrollView.AddSubview(_contentConteiner);
            Add(_scrollView);

            var _BackBarButton = new UIBarButtonItem();

            _BackBarButton.Title             = "Back";
            NavigationItem.LeftBarButtonItem = _BackBarButton;

            _peopleConroller = new ABPeoplePickerNavigationController();
            _peopleConroller.SelectPerson2 += SelectPeople;
            _peopleConroller.Cancelled     += delegate
            {
                this.DismissModalViewController(true);
            };

            _labelTaskName = new UILabel();
            _contentConteiner.AddSubview(_labelTaskName);


            _labelError           = new UILabel();
            _labelError.Font      = _labelError.Font.WithSize(10);
            _labelError.TextColor = UIColor.Red;
            _contentConteiner.AddSubview(_labelError);

            _textEdit              = new UITextField();
            _textEdit.Placeholder  = "todo...";
            _textEdit.BorderStyle  = UITextBorderStyle.RoundedRect;
            _textEdit.ShouldReturn = (textField) =>
            {
                textField.ResignFirstResponder();
                return(true);
            };
            _contentConteiner.AddSubview(_textEdit);

            _textContactName              = new UITextField();
            _textContactName.Placeholder  = "add contact...";
            _textContactName.BorderStyle  = UITextBorderStyle.RoundedRect;
            _textContactName.ShouldReturn = (textField) =>
            {
                textField.ResignFirstResponder();
                return(true);
            };
            _contentConteiner.AddSubview(_textContactName);

            _textContactPhone               = new UITextField();
            _textContactPhone.Placeholder   = "add Phone...";
            _textContactPhone.KeyboardType  = UIKeyboardType.NamePhonePad;
            _textContactPhone.ReturnKeyType = UIReturnKeyType.Done;
            _textContactPhone.BorderStyle   = UITextBorderStyle.RoundedRect;
            _textContactPhone.ShouldReturn  = (textField) =>
            {
                textField.ResignFirstResponder();
                return(true);
            };
            _contentConteiner.AddSubview(_textContactPhone);

            _buttonSelectContact = new UIButton();
            _buttonSelectContact.BackgroundColor = UIColor.Blue;
            _buttonSelectContact.SetTitle("Add", UIControlState.Normal);
            _buttonSelectContact.Layer.CornerRadius = 5;
            _buttonSelectContact.Layer.BorderWidth  = 1;
            _buttonSelectContact.TouchUpInside     += delegate { PresentModalViewController(_peopleConroller, true); };
            _contentConteiner.AddSubview(_buttonSelectContact);

            _buttonCall = new UIButton();
            _buttonCall.BackgroundColor = UIColor.Blue;
            _buttonCall.SetTitle("Call", UIControlState.Normal);
            _buttonCall.Layer.CornerRadius = 5;
            _buttonCall.Layer.BorderWidth  = 1;
            _contentConteiner.AddSubview(_buttonCall);

            _swith    = new UISwitch();
            _swith.On = true;
            _contentConteiner.AddSubview(_swith);

            _buttonSave = new UIButton(UIButtonType.Custom);
            _buttonSave.BackgroundColor    = UIColor.Blue;
            _buttonSave.Layer.CornerRadius = 5;
            _buttonSave.Layer.BorderWidth  = 1;
            _buttonSave.SetTitle("Save", UIControlState.Normal);
            _contentConteiner.AddSubview(_buttonSave);

            _buttonDelete = new UIButton(UIButtonType.Custom);
            _buttonDelete.Layer.CornerRadius = 5;
            _buttonDelete.Layer.BorderWidth  = 1;
            _buttonDelete.BackgroundColor    = UIColor.Blue;
            _buttonDelete.SetTitle("Delete", UIControlState.Normal);
            _buttonDelete.TitleColor(UIControlState.Selected);
            _contentConteiner.AddSubview(_buttonDelete);

            var set = this.CreateBindingSet <ItemView, ItemViewModel>();

            set.Bind(_BackBarButton).To(vm => vm.BackToCommand);
            set.Bind(_labelTaskName).To(vm => vm.TaskName);
            set.Bind(_textEdit).To(vm => vm.TaskContent);
            set.Bind(_swith).To(vm => vm.TaskDone);
            set.Bind(_buttonSave).To(vm => vm.SaveItem);
            set.Bind(_buttonDelete).To(vm => vm.DeleteItem);
            set.Bind(_textContactName).To(vm => vm.ContactName);
            set.Bind(_textContactPhone).To(vm => vm.ContactPhone);
            set.Bind(_buttonCall).To(vm => vm.PhoneCallCommand);
            set.Bind(_labelError).To(vm => vm.Error);
            set.Apply();

            //conastraint
            _scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            _scrollView.AddConstraints(_contentConteiner.FullWidthOf(_scrollView));
            _scrollView.AddConstraints(_contentConteiner.FullHeightOf(_scrollView));

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(_scrollView.FullWidthOf(View));
            View.AddConstraints(_scrollView.FullHeightOf(View));
            View.AddConstraints(
                _contentConteiner.WithSameWidth(View),
                _contentConteiner.WithSameHeight(View).SetPriority(UILayoutPriority.DefaultLow)
                );

            _contentConteiner.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            _contentConteiner.AddConstraints(

                _labelError.AtTopOf(_contentConteiner),
                _labelError.WithSameWidth(_contentConteiner),
                _labelError.WithSameCenterX(_contentConteiner),
                _labelError.Height().EqualTo(20),

                _labelTaskName.WithSameCenterX(_contentConteiner),
                _labelTaskName.Below(_labelError, 25),
                _labelTaskName.WithSameWidth(_contentConteiner).Minus(130),
                _labelTaskName.Height().LessThanOrEqualTo(60),

                _textEdit.WithSameCenterX(_contentConteiner),
                _textEdit.Below(_labelTaskName, 20),
                _textEdit.WithSameWidth(_contentConteiner).Minus(25),
                _textEdit.Height().LessThanOrEqualTo(60),

                _textContactName.AtLeftOf(_contentConteiner, 25),
                _textContactName.Below(_textEdit, 20),
                _textContactName.WithSameWidth(_contentConteiner).Minus(130),
                _textContactName.Height().EqualTo(40),

                _textContactPhone.AtLeftOf(_contentConteiner, 25),
                _textContactPhone.Below(_textContactName, 20),
                _textContactPhone.WithSameWidth(_contentConteiner).Minus(130),
                _textContactPhone.Height().EqualTo(40),

                _buttonSelectContact.ToRightOf(_textContactName, 20),
                _buttonSelectContact.WithSameCenterY(_textContactName),
                _buttonSelectContact.Width().EqualTo(80),

                _swith.AtLeftOf(_contentConteiner, 25),
                _swith.Below(_textContactPhone, 20),

                _buttonCall.WithSameCenterY(_textContactPhone),
                _buttonCall.ToRightOf(_textContactPhone, 20),
                _buttonCall.Width().EqualTo(80),

                _buttonSave.AtLeftOf(_contentConteiner, 25),
                _buttonSave.Below(_swith, 40),
                _buttonSave.Width().EqualTo(80),
                _buttonSave.Height().LessThanOrEqualTo(35),

                _buttonDelete.WithSameCenterX(_buttonCall),
                _buttonDelete.Below(_swith, 40),
                _buttonDelete.Width().EqualTo(80),
                _buttonDelete.Height().LessThanOrEqualTo(35)

                );
            // very important to make scrolling work
            var bottomViewConstraint = _contentConteiner.Subviews.Last()
                                       .AtBottomOf(_contentConteiner).Minus(20);

            _contentConteiner.AddConstraints(bottomViewConstraint);
        }
Example #14
0
        private void SetupConstraints2()
        {
            ScrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            _containerView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                _containerView.WithSameWidth(View),

                _background.AtTopOf(View),
                _background.AtLeftOf(View),
                _background.AtRightOf(View),
                _background.AtBottomOf(View)
                );

            ScrollView.AddConstraints(
                _containerView.AtTopOf(ScrollView),
                _containerView.AtLeftOf(ScrollView),
                _containerView.AtRightOf(ScrollView),
                _containerView.AtBottomOf(ScrollView),
                _containerView.Height().EqualTo(UIScreen.MainScreen.Bounds.Height)
                );

            _containerView.AddConstraints(
                _logo.AtTopOf(_containerView, 40),
                _logo.WithSameCenterX(_containerView),

                _indicator.Below(_logo, 30),
                _indicator.WithSameCenterX(_logo),

                _registerButton.AtBottomOf(_containerView, 60),
                _registerButton.WithSameCenterX(_containerView),

                _forgotPasswordButton.AtRightOf(_password, 15),
                _forgotPasswordButton.Height().EqualTo(15),
                _forgotPasswordButton.Width().EqualTo(15),
                _forgotPasswordButton.WithSameCenterY(_password),

                _signinButton.Above(_registerButton, 40),
                _signinButton.Height().EqualTo(40),
                _signinButton.WithSameLeft(_password),
                _signinButton.WithSameRight(_password),

                _passwordRuler.Above(_signinButton, 15),
                _passwordRuler.WithSameLeft(_registerButton),
                _passwordRuler.WithSameRight(_forgotPasswordButton),
                _passwordRuler.Height().EqualTo(0),

                _password.Above(_passwordRuler, 0),
                _password.AtRightOf(_containerView, 15),
                _password.Height().EqualTo(40),
                _password.AtLeftOf(_containerView, 15),

                _passwordImage.WithSameCenterY(_password),
                _passwordImage.WithSameLeft(_passwordRuler),
                _passwordImage.Height().EqualTo(0),
                _passwordImage.Width().EqualTo(0),

                _emailRuler.Above(_password, 15),
                _emailRuler.WithSameLeft(_registerButton),
                _emailRuler.WithSameRight(_forgotPasswordButton),
                _emailRuler.Height().EqualTo(0),

                _email.Above(_emailRuler, 0),
                _email.AtRightOf(_containerView, 15),
                _email.Height().EqualTo(40),
                _email.AtLeftOf(_containerView, 15),

                _emailImage.WithSameCenterY(_email),
                _emailImage.WithSameLeft(_emailRuler),
                _emailImage.Height().EqualTo(0),
                _emailImage.Width().EqualTo(0)
                );
        }
        private void SetupView()
        {
            NavigationController.SetNavigationBarHidden(true, true);

            View.BackgroundColor = UIColor.White;

            _logoImage             = new UIImageView();
            _logoImage.Image       = UIImage.FromBundle("login_logo");
            _logoImage.Frame       = new CGRect(0, 0, _logoImage.Image.CGImage.Width, _logoImage.Image.CGImage.Height);
            _logoImage.ContentMode = UIViewContentMode.ScaleAspectFit;

            var firstAttributes = new UIStringAttributes
            {
                ForegroundColor = UIColor.FromRGB(36, 183, 128),
                Font            = UIFont.FromName("ArialMT", 15f)
            };

            _loginTextField = new UITextField(new CGRect())
            {
                AttributedPlaceholder = new NSAttributedString("Username...", firstAttributes),
            };
            _loginTextField.TextColor = UIColor.FromRGB(36, 183, 128);
            _loginTextField.Font      = UIFont.FromName("ArialMT", 15f);


            _passwordTextField = new UITextField(new CGRect())
            {
                AttributedPlaceholder = new NSAttributedString("Password...", firstAttributes),
                SecureTextEntry       = true
            };
            _passwordTextField.TextColor = UIColor.FromRGB(36, 183, 128);
            _passwordTextField.Font      = UIFont.FromName("ArialMT", 15f);


            _loginButton = new UIButton(UIButtonType.System);
            _loginButton.SetTitle("Login", UIControlState.Normal);
            _loginButton.Font = UIFont.FromName("ArialMT", 15f);
            _loginButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            _loginButton.Layer.BorderWidth  = 1;
            _loginButton.BackgroundColor    = UIColor.FromRGB(36, 183, 128);
            _loginButton.Layer.CornerRadius = 10;
            _loginButton.Layer.BorderColor  = UIColor.Black.CGColor;


            Add(_logoImage);
            Add(_loginTextField);
            Add(_passwordTextField);
            Add(_loginButton);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(_logoImage.AtTopOf(View, 80),
                                _logoImage.Height().EqualTo(90),
                                _logoImage.Width().EqualTo(90),
                                _logoImage.WithSameCenterX(View),
                                _loginTextField.WithSameCenterX(View),
                                _loginTextField.Below(_logoImage, 40),
                                _loginTextField.AtLeftOf(View, 40),
                                _loginTextField.AtRightOf(View, 40),
                                _passwordTextField.WithSameCenterX(_loginTextField),
                                _passwordTextField.Below(_loginTextField, 20),
                                _passwordTextField.AtLeftOf(View, 40),
                                _passwordTextField.AtRightOf(View, 40),
                                _loginButton.WithSameCenterX(_passwordTextField),
                                _loginButton.Below(_passwordTextField, 40),
                                _loginButton.AtLeftOf(View, 40),
                                _loginButton.AtRightOf(View, 40)
                                );
        }
Example #16
0
        public override void LoadView ()
        {
            View = new UIView ()
                .Apply (Style.Screen);

            View.Add (inputsContainer = new UIView ().Apply (Style.Signup.InputsContainer));

            inputsContainer.Add (topBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            inputsContainer.Add (emailTextField = new UITextField () {
                Placeholder = "SignupEmailHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                KeyboardType = UIKeyboardType.EmailAddress,
                ReturnKeyType = UIReturnKeyType.Next,
                ClearButtonMode = UITextFieldViewMode.Always,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Signup.EmailField));
            emailTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add (middleBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            inputsContainer.Add(passwordTextField = new PasswordTextField () {
                Placeholder = "SignupPasswordHint".Tr (),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType = UITextAutocorrectionType.No,
                SecureTextEntry = true,
                ReturnKeyType = UIReturnKeyType.Go,
                ShouldReturn = HandleShouldReturn,
            }.Apply (Style.Signup.PasswordField));
            passwordTextField.EditingChanged += OnTextFieldEditingChanged;

            inputsContainer.Add (bottomBorder = new UIView ().Apply (Style.Signup.InputsBorder));

            View.Add (passwordActionButton = new UIButton ()
                .Apply (Style.Signup.SignupButton));
            passwordActionButton.SetTitle ("SignupSignupButtonText".Tr (), UIControlState.Normal);
            passwordActionButton.TouchUpInside += OnPasswordActionButtonTouchUpInside;

            View.Add (googleActionButton = new UIButton ()
                .Apply (Style.Signup.GoogleButton));
            googleActionButton.SetTitle ("SignupGoogleButtonText".Tr (), UIControlState.Normal);
            googleActionButton.TouchUpInside += OnGoogleActionButtonTouchUpInside;

            View.Add (legalLabel = new TTTAttributedLabel () {
                Delegate = new LegalLabelDelegate (),
            }.Apply (Style.Signup.LegalLabel));
            SetLegalText (legalLabel);

            inputsContainer.AddConstraints (
                topBorder.AtTopOf (inputsContainer),
                topBorder.AtLeftOf (inputsContainer),
                topBorder.AtRightOf (inputsContainer),
                topBorder.Height ().EqualTo (1f),

                emailTextField.Below (topBorder),
                emailTextField.AtLeftOf (inputsContainer, 20f),
                emailTextField.AtRightOf (inputsContainer, 10f),
                emailTextField.Height ().EqualTo (42f),

                middleBorder.Below (emailTextField),
                middleBorder.AtLeftOf (inputsContainer, 20f),
                middleBorder.AtRightOf (inputsContainer),
                middleBorder.Height ().EqualTo (1f),

                passwordTextField.Below (middleBorder),
                passwordTextField.AtLeftOf (inputsContainer, 20f),
                passwordTextField.AtRightOf (inputsContainer),
                passwordTextField.Height ().EqualTo (42f),

                bottomBorder.Below (passwordTextField),
                bottomBorder.AtLeftOf (inputsContainer),
                bottomBorder.AtRightOf (inputsContainer),
                bottomBorder.AtBottomOf (inputsContainer),
                bottomBorder.Height ().EqualTo (1f)
            );

            inputsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

            View.AddConstraints (
                inputsContainer.AtTopOf (View, 80f),
                inputsContainer.AtLeftOf (View),
                inputsContainer.AtRightOf (View),

                passwordActionButton.Below (inputsContainer, 20f),
                passwordActionButton.AtLeftOf (View),
                passwordActionButton.AtRightOf (View),
                passwordActionButton.Height ().EqualTo (60f),

                googleActionButton.Below (passwordActionButton, 5f),
                googleActionButton.AtLeftOf (View),
                googleActionButton.AtRightOf (View),
                googleActionButton.Height ().EqualTo (60f),

                legalLabel.AtBottomOf (View, 30f),
                legalLabel.AtLeftOf (View, 40f),
                legalLabel.AtRightOf (View, 40f)
            );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();

            ResetSignupButtonState ();
        }
Example #17
0
        public override void LoadView()
        {
            View = new UIView()
                   .Apply(Style.Screen);

            View.Add(inputsContainer = new UIView().Apply(Style.Login.InputsContainer));

            inputsContainer.Add(topBorder = new UIView().Apply(Style.Login.InputsBorder));

            inputsContainer.Add(emailTextField = new UITextField()
            {
                Placeholder            = "LoginEmailHint".Tr(),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                KeyboardType           = UIKeyboardType.EmailAddress,
                ReturnKeyType          = UIReturnKeyType.Next,
                ClearButtonMode        = UITextFieldViewMode.Always,
                ShouldReturn           = HandleShouldReturn,
                AutocorrectionType     = UITextAutocorrectionType.No
            }.Apply(Style.Login.EmailField));

            inputsContainer.Add(middleBorder = new UIView().Apply(Style.Login.InputsBorder));

            inputsContainer.Add(passwordTextField = new PasswordTextField()
            {
                Placeholder            = "LoginPasswordHint".Tr(),
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType     = UITextAutocorrectionType.No,
                SecureTextEntry        = true,
                ReturnKeyType          = UIReturnKeyType.Go,
                ShouldReturn           = HandleShouldReturn,
            }.Apply(Style.Login.PasswordField));

            inputsContainer.Add(bottomBorder = new UIView().Apply(Style.Login.InputsBorder));

            View.Add(passwordActionButton = new UIButton()
                                            .Apply(Style.Login.LoginButton));
            passwordActionButton.SetTitle("LoginLoginButtonText".Tr(), UIControlState.Normal);
            passwordActionButton.TouchUpInside += OnPasswordActionButtonTouchUpInside;

            inputsContainer.AddConstraints(
                topBorder.AtTopOf(inputsContainer),
                topBorder.AtLeftOf(inputsContainer),
                topBorder.AtRightOf(inputsContainer),
                topBorder.Height().EqualTo(1f),

                emailTextField.Below(topBorder),
                emailTextField.AtLeftOf(inputsContainer, 20f),
                emailTextField.AtRightOf(inputsContainer, 10f),
                emailTextField.Height().EqualTo(42f),

                middleBorder.Below(emailTextField),
                middleBorder.AtLeftOf(inputsContainer, 20f),
                middleBorder.AtRightOf(inputsContainer),
                middleBorder.Height().EqualTo(1f),

                passwordTextField.Below(middleBorder),
                passwordTextField.AtLeftOf(inputsContainer, 20f),
                passwordTextField.AtRightOf(inputsContainer),
                passwordTextField.Height().EqualTo(42f),

                bottomBorder.Below(passwordTextField),
                bottomBorder.AtLeftOf(inputsContainer),
                bottomBorder.AtRightOf(inputsContainer),
                bottomBorder.AtBottomOf(inputsContainer),
                bottomBorder.Height().EqualTo(1f)
                );

            inputsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                inputsContainer.AtTopOf(View, 80f),
                inputsContainer.AtLeftOf(View),
                inputsContainer.AtRightOf(View),

                passwordActionButton.Below(inputsContainer, 20f),
                passwordActionButton.AtLeftOf(View),
                passwordActionButton.AtRightOf(View),
                passwordActionButton.Height().EqualTo(60f)
                );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
        }