コード例 #1
0
        void LayoutViewElements()
        {
            View.AddConstraints(new FluentLayout[]
            {
                _vectorImageView.AtTopOf(View, iOSConstants.CONTENT_PADDING),

                _sizeSlider.AtBottomOf(View, iOSConstants.CONTENT_PADDING),
                _sizeSlider.AtLeftOf(View, iOSConstants.SIDE_PADDING),
                _sizeSlider.AtRightOf(View, iOSConstants.SIDE_PADDING),

                _vectorExplanantion.Above(_sizeSlider, iOSConstants.CONTENT_PADDING),
                _vectorExplanantion.AtLeftOf(View, iOSConstants.SIDE_PADDING),
                _vectorExplanantion.WithSameWidth(_sizeSlider),
                _vectorExplanantion.AtRightOf(View, iOSConstants.SIDE_PADDING),
            });
        }
コード例 #2
0
ファイル: HomeViewController.cs プロジェクト: wajsic/Chafu
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = "Chafu";

            var deleteAll = new UIBarButtonItem(UIBarButtonSystemItem.Trash)
            {
                TintColor = Configuration.BackgroundColor
            };


            NavigationController.NavigationBar.BarTintColor = Configuration.TintColor;
            NavigationController.NavigationBar.TintColor    = Configuration.BaseTintColor;
            NavigationItem.RightBarButtonItem = deleteAll;

            View.BackgroundColor = Configuration.BackgroundColor;

            Configuration.CropImage = true;

            var imageView = new UIImageView {
                BackgroundColor = UIColor.Black
            };
            var urlLabel     = new UILabel();
            var pickerButton = new UIButton(UIButtonType.System)
            {
                BackgroundColor = Configuration.TintColor,
                TintColor       = UIColor.Black
            };

            pickerButton.SetTitle("Pick Image", UIControlState.Normal);
            var albumButton = new UIButton(UIButtonType.System)
            {
                BackgroundColor = Configuration.TintColor,
                TintColor       = UIColor.Black
            };

            albumButton.SetTitle("Show Album", UIControlState.Normal);

            var chafu = new ChafuViewController {
                HasVideo = true
            };

            chafu.ImageSelected += (sender, image) =>
            {
                DispatchQueue.MainQueue.DispatchAsync(() =>
                {
                    imageView.Image = image;
                });

                CopyImageToLocalFolder(image);
            };
            chafu.VideoSelected += (sender, videoUrl) =>
            {
                urlLabel.Text = videoUrl.AbsoluteString;
                CopyVideoToLocalFolder(videoUrl);
            };
            chafu.Closed += (sender, e) =>
            {
                /* do stuff on closed */
            };

            pickerButton.TouchUpInside += (sender, args) =>
            {
                NavigationController.PresentModalViewController(chafu, true);
            };

            var albumViewController = new AlbumViewController
            {
                LazyDataSource = (view, size, mediaTypes) =>
                                 new LocalFilesDataSource(view, size, mediaTypes)
                {
                    ImagesPath = TempPath()
                },
                LazyDelegate     = (view, source) => new LocalFilesDelegate(view, (LocalFilesDataSource)source),
                ShowExtraButton  = true,
                ShowDoneButton   = false,
                ShowDeleteButton = true
            };

            albumViewController.Extra += (sender, args) =>
            {
                albumViewController.Dismiss();
                NavigationController.PresentModalViewController(chafu, true);
            };

            albumViewController.ImageSelected += (sender, image) =>
            {
                imageView.Image = image;
            };

            albumButton.TouchUpInside += (sender, args) =>
            {
                // Test InitialSelectedImage by selecting random path
                albumViewController.InitialSelectedImagePath = GetRandomPath();

                NavigationController.PresentModalViewController(albumViewController, true);
            };

            deleteAll.Clicked += (sender, args) =>
            {
                DeleteAllStuff();
                ((LocalFilesDataSource)albumViewController.AlbumDataSource)?.UpdateImageSource(TempPath());
            };

            Add(imageView);
            Add(urlLabel);
            Add(pickerButton);
            Add(albumButton);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            EdgesForExtendedLayout = UIRectEdge.None;

            View.AddConstraints(
                imageView.Width().EqualTo().HeightOf(imageView),
                imageView.AtTopOf(View, 5),
                imageView.AtLeftOf(View, 5),
                imageView.AtRightOf(View, 5),
                imageView.Above(urlLabel, 10),

                urlLabel.AtLeftOf(View, 5),
                urlLabel.AtRightOf(View, 5),
                urlLabel.Above(pickerButton, 10),

                pickerButton.AtLeftOf(View, 50),
                pickerButton.AtRightOf(View, 50),
                pickerButton.Height().EqualTo(50),
                pickerButton.Above(albumButton, 20),

                albumButton.AtLeftOf(View, 50),
                albumButton.AtRightOf(View, 50),
                albumButton.Height().EqualTo(50),
                albumButton.AtBottomOf(View, 10f)
                );
        }
コード例 #3
0
        public VisualEditorViewController()
        {
            View.BackgroundColor = Styling.Colors.BackgroundColor;

            View.AddGestureRecognizer(new UITapGestureRecognizer(ViewTap));

            var discountLabel = new UILabel
            {
                BackgroundColor = Styling.Colors.Green,
                Text            = "25% OFF YOUR FIRST ORDER IF YOU SIGN UP BY 9/1",
                Font            = UIFont.FromName("Gotham-Medium", 11),
                TextColor       = UIColor.White,
                TextAlignment   = UITextAlignment.Center
            };

            var image = new UIImageView
            {
                Image = UIImage.FromBundle("Images/widgetCoLogo_red"),
            };

            var emailLabel = new UILabel
            {
                Text = "Email",
                Font = UIFont.FromName("Gotham-Light", 10)
            };
            var emailField = new CustomTextField
            {
                Placeholder = "*****@*****.**"
            };

            var phoneLabel = new UILabel
            {
                Text = "Phone Number:",
                Font = UIFont.FromName("Gotham-Light", 10)
            };

            var phoneField = new CustomTextField
            {
                Placeholder = "(555)-555-5555"
            };

            var passwordLabel = new UILabel
            {
                Text = "Password",
                Font = UIFont.FromName("Gotham-Light", 10)
            };

            var passwordField = new CustomTextField
            {
                SecureTextEntry = true,
            };

            var button = new CustomButton
            {
                TitleText = "Take me to the widgets"
            };

            View.AddSubviews(emailLabel, emailField, phoneLabel, phoneField, passwordLabel, passwordField, button, discountLabel, image);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                discountLabel.WithSameTop(View),
                discountLabel.WithSameLeft(View),
                discountLabel.WithSameRight(View),
                discountLabel.Height().EqualTo(30),

                phoneLabel.WithSameLeft(phoneField),
                phoneLabel.WithSameCenterY(View),

                phoneField.WithSameCenterX(View),
                phoneField.Height().EqualTo(30),
                phoneField.Width().EqualTo(200),
                phoneField.Below(phoneLabel).Plus(5),

                emailField.WithSameLeft(phoneField),
                emailField.WithSameWidth(phoneField),
                emailField.WithSameHeight(phoneField),
                emailField.Above(phoneLabel).Minus(15),

                emailLabel.WithSameLeft(phoneField),
                emailLabel.Above(emailField).Minus(5),

                image.WithSameCenterX(View),
                image.Above(emailLabel).Minus(15),

                passwordLabel.WithSameLeft(phoneField),
                passwordLabel.Below(phoneField).Plus(15),

                passwordField.WithSameLeft(phoneField),
                passwordField.WithSameWidth(phoneField),
                passwordField.WithSameHeight(phoneField),
                passwordField.Below(passwordLabel).Plus(5),

                button.Below(passwordField).Plus(20),
                button.WithSameCenterX(View),
                button.WithSameWidth(phoneField),
                button.Height().EqualTo(50)
                );
        }
コード例 #4
0
        public UIButton ResetButton; //resets the button to the default settings

        public ButtonMaintenanceScreen()
        {
            GeneralMaintenanceScreen.Saved += SaveGeneral; //

            //create screen
            Screen = new UIViewController();
            Screen.View.BackgroundColor = UIColor.White;

            //create button
            Button = new ButtonData();

            //create media picker
            MediaPicker = new UIImagePickerController();
            //MediaPicker.VideoExportPreset = AVAssetExportSessionPreset.HighestQuality.ToString();
            //System.Diagnostics.Debug.WriteLine(MediaPicker.VideoExportPreset);
            MediaPicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
            MediaPicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
            //MediaPicker.ImageExportPreset = UIImagePickerControllerImageUrlExportPreset.Current;
            MediaPicker.VideoExportPreset     = AVAssetExportSessionPreset.Passthrough.GetConstant().ToString();
            MediaPicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
            MediaPicker.Canceled             += Handle_Canceled;

            //1. create views
            //create reset button
            ResetButton = new UIButton();
            ResetButton.BackgroundColor = UIColor.Green;
            ResetButton.SetTitle("Reset button\nsettings", UIControlState.Normal);
            ResetButton.SetTitleColor(UIColor.Black, UIControlState.Normal);

            //when video button clicked - open the media picker native interface
            ResetButton.TouchUpInside += ResetButtonData;

            ResetButton.Layer.BorderColor   = ButtonBorderColour.CGColor;
            ResetButton.Layer.BorderWidth   = ButtonBorderWidth;
            ResetButton.BackgroundColor     = ButtonBackgroundColour;
            ResetButton.LineBreakMode       = UILineBreakMode.WordWrap;//allow multiple lines for text inside video button
            ResetButton.VerticalAlignment   = UIControlContentVerticalAlignment.Center;
            ResetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            ResetButton.Layer.CornerRadius  = ButtonCornerRadius;

            //create video button
            VideoButton = new UIButton();
            VideoButton.BackgroundColor = UIColor.Green;
            VideoButton.SetTitle("Choose a video for\nthe button \nto play", UIControlState.Normal);
            VideoButton.SetTitleColor(UIColor.Black, UIControlState.Normal);

            //when video button clicked - open the media picker native interface
            VideoButton.TouchUpInside += (s, e) =>
            {
                try
                {
                    //set the media picker to show only videos
                    MediaPicker.MediaTypes = new string[] { UTType.Movie, UTType.Video }; //vids?
                    Screen.PresentViewControllerAsync(MediaPicker, true);
                }
                catch (Exception ex)
                {
                    //if the device doesn't have any videos, pop up an alert box with a message
                    Console.WriteLine(ex.Message);
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "No Videos Alert",
                        Message = "You don't have any videos to select. To download or record vids..."
                    };

                    alert.AddButton("OK");
                    alert.Show();
                }
            };

            VideoButton.Layer.BorderColor = ButtonBorderColour.CGColor;
            VideoButton.Layer.BorderWidth = ButtonBorderWidth;
            VideoButton.BackgroundColor   = ButtonBackgroundColour;
            VideoButton.LineBreakMode     = UILineBreakMode.WordWrap;//allow multiple lines for text inside video button
            //VideoButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; //center text
            VideoButton.VerticalAlignment   = UIControlContentVerticalAlignment.Center;
            VideoButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            VideoButton.Layer.CornerRadius  = ButtonCornerRadius;

            //create image button
            ImageButton = new UIButton();
            ImageButton.BackgroundColor = UIColor.Green;
            ImageButton.SetTitle("Choose an image for\nthe button thumbnail", UIControlState.Normal);
            ImageButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            //when image button clicked - open the media picker native interface
            ImageButton.TouchUpInside += (s, e) =>
            {
                try
                {
                    //set the media picker to show only images
                    MediaPicker.MediaTypes = new string[] { UTType.Image };
                    Screen.PresentViewControllerAsync(MediaPicker, true);
                }
                catch (Exception ex)
                {
                    //if the device doesn't have any images, pop up an alert box with a message
                    Console.WriteLine(ex.Message);
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "No Images Alert",
                        Message = "You don't have any images to select. To download or take photos..."
                    };

                    alert.AddButton("OK");
                    alert.Show();
                }
            };
            ImageButton.Layer.BorderColor   = ButtonBorderColour.CGColor;
            ImageButton.Layer.BorderWidth   = ButtonBorderWidth;
            ImageButton.BackgroundColor     = ButtonBackgroundColour;
            ImageButton.LineBreakMode       = UILineBreakMode.WordWrap;                   //allow multiple lines for text inside video button
            ImageButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; //center text
            ImageButton.Layer.CornerRadius  = ButtonCornerRadius;

            //create image box
            ImageBox = new UIImageView();
            ImageBox.Layer.BorderWidth  = ButtonBorderWidth;
            ImageBox.Layer.CornerRadius = ButtonCornerRadius;
            ImageBox.ClipsToBounds      = true;
            ImageBox.Layer.BorderColor  = UIColor.Gray.CGColor;


            //create video box
            VideoBox = new UIImageView();
            VideoBox.Layer.BorderWidth  = ButtonBorderWidth;
            VideoBox.Layer.CornerRadius = ButtonCornerRadius;
            VideoBox.ClipsToBounds      = true;
            VideoBox.Layer.BorderColor  = UIColor.Gray.CGColor;

            //create back button
            BackButton = new UIButton();
            BackButton.TouchUpInside += CloseScreen;
            BackButton.SetTitle("Back", UIControlState.Normal);
            BackButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            Screen.Add(BackButton); //add back button to screen
            BackButton.Layer.BorderColor  = ButtonBorderColour.CGColor;
            BackButton.Layer.BorderWidth  = ButtonBorderWidth;
            BackButton.BackgroundColor    = ButtonBackgroundColour;
            BackButton.Layer.CornerRadius = ButtonCornerRadius;

            //create save button
            SaveButton = new UIButton();
            SaveButton.BackgroundColor = UIColor.Red;
            SaveButton.TouchUpInside  += Save;
            SaveButton.SetTitle("Save", UIControlState.Normal);
            SaveButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            Screen.Add(SaveButton); //add save button to screen
            SaveButton.Layer.BorderColor  = ButtonBorderColour.CGColor;
            SaveButton.Layer.BorderWidth  = ButtonBorderWidth;
            SaveButton.BackgroundColor    = ButtonBackgroundColour;
            SaveButton.Layer.CornerRadius = ButtonCornerRadius;

            //create colour box
            ColourBox = new UIView();
            ColourBox.Layer.BorderWidth  = ButtonBorderWidth;
            ColourBox.Layer.CornerRadius = ButtonCornerRadius;
            ColourBox.Layer.BorderColor  = UIColor.Gray.CGColor;

            //create general button
            GeneralButton = new UIButton();
            GeneralButton.BackgroundColor = UIColor.Green;
            //open the general settings modal.
            //pass some app data
            GeneralButton.TouchUpInside += (o, s) =>
            {
                //remove?
                //GeneralMaintenanceScreen.ButtonsPerPage = ButtonsPerPage;
                //GeneralMaintenanceScreen.NumberOfPages = NumberOfPages;
                Screen.PresentModalViewController(GeneralMaintenanceScreen.Screen, false); //

                GeneralMaintenanceScreen.NumberOfPages    = this.NumberOfPages;
                GeneralMaintenanceScreen.ButtonsPerPage   = this.ButtonsPerPage;
                GeneralMaintenanceScreen.BordersThickness = this.ButtonBorderWidth;
                GeneralMaintenanceScreen.SetDropDowns();
                //ImageBox.Layer.BorderColor = UIColor.Clear.CGColor;
            };
            GeneralButton.SetTitle("JustButtons\nSettings", UIControlState.Normal);
            GeneralButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            GeneralButton.Layer.BorderColor   = ButtonBorderColour.CGColor;
            GeneralButton.Layer.BorderWidth   = ButtonBorderWidth;
            GeneralButton.BackgroundColor     = ButtonBackgroundColour;
            GeneralButton.Layer.CornerRadius  = ButtonCornerRadius;
            GeneralButton.LineBreakMode       = UILineBreakMode.WordWrap;                   //allow multiple lines for text inside video button
            GeneralButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; //center text

            //color sliders
            RedSlider = new UISlider();
            RedSlider.ValueChanged += UpdateBorderColor;

            GreenSlider = new UISlider();
            GreenSlider.ValueChanged += UpdateBorderColor;

            BlueSlider = new UISlider();
            BlueSlider.ValueChanged += UpdateBorderColor;

            //create labels
            VideoButtonTitle               = new UILabel();
            VideoButtonTitle.Text          = "Click below to change the video played:";
            VideoButtonTitle.TextColor     = UIColor.Black;
            VideoButtonTitle.TextAlignment = UITextAlignment.Left;
            VideoButtonTitle.LineBreakMode = UILineBreakMode.WordWrap;
            VideoButtonTitle.Lines         = 2;

            ImageButtonTitle               = new UILabel();
            ImageButtonTitle.Text          = "Click below to change the button's image:";
            ImageButtonTitle.TextColor     = UIColor.Black;
            ImageButtonTitle.TextAlignment = UITextAlignment.Left;
            ImageButtonTitle.LineBreakMode = UILineBreakMode.WordWrap;
            ImageButtonTitle.Lines         = 2;

            ColourBoxTitle               = new UILabel();
            ColourBoxTitle.Text          = "Adjust the sliders to change the border colour:";
            ColourBoxTitle.TextColor     = UIColor.Black;
            ColourBoxTitle.TextAlignment = UITextAlignment.Left;
            ColourBoxTitle.LineBreakMode = UILineBreakMode.WordWrap;
            ColourBoxTitle.Lines         = 2;

            SettingsButtonTitle               = new UILabel();
            SettingsButtonTitle.Text          = "Click below to change the number of pages and buttons, and border thickness:";
            SettingsButtonTitle.TextColor     = UIColor.Black;
            SettingsButtonTitle.TextAlignment = UITextAlignment.Left;
            SettingsButtonTitle.LineBreakMode = UILineBreakMode.WordWrap;
            SettingsButtonTitle.Lines         = 2;

            //2. add views to parent view
            Screen.View.Add(VideoButton);
            Screen.View.Add(ImageButton);
            Screen.View.Add(ImageBox);
            Screen.View.Add(VideoBox);
            Screen.View.Add(BackButton);
            Screen.View.Add(SaveButton);
            Screen.Add(ColourBox);
            Screen.Add(GeneralButton);
            Screen.Add(RedSlider);
            Screen.Add(GreenSlider);
            Screen.Add(BlueSlider);
            Screen.Add(ImageButtonTitle);
            Screen.Add(VideoButtonTitle);
            Screen.Add(ColourBoxTitle);
            Screen.Add(SettingsButtonTitle);
            Screen.Add(ResetButton);

            //3. call method on parent view
            Screen.View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            //4. add constraints
            Screen.View.AddConstraints(
                VideoButton.AtTopOf(Screen.View, UIApplication.SharedApplication.StatusBarFrame.Height + 75),
                VideoButton.AtLeftOf(Screen.View, 70),
                VideoButton.WithRelativeWidth(Screen.View, 0.19f),
                VideoButton.Height().EqualTo(100),

                ImageButton.Below(VideoButton, 80),
                ImageButton.WithSameLeft(VideoButton),
                ImageButton.WithSameWidth(VideoButton),
                ImageButton.WithSameHeight(VideoButton),

                VideoBox.WithSameTop(VideoButton),
                VideoBox.Left().EqualTo().RightOf(VideoButton).Plus(35),
                VideoBox.WithRelativeWidth(Screen.View, 0.17f),
                VideoBox.Height().EqualTo(100),

                ImageBox.WithSameTop(ImageButton),
                ImageBox.WithSameLeft(VideoBox),
                ImageBox.WithSameWidth(VideoBox),
                ImageBox.WithSameHeight(VideoBox),

                BackButton.WithSameTop(VideoButton),
                BackButton.AtRightOf(Screen.View, 70),
                BackButton.WithSameWidth(VideoButton),
                BackButton.WithSameHeight(VideoButton),

                SaveButton.WithSameTop(ImageButton),
                SaveButton.AtRightOf(Screen.View, 70),
                SaveButton.WithSameWidth(VideoButton),
                SaveButton.WithSameHeight(VideoButton),

                ColourBox.Below(ImageButton, 80),
                ColourBox.WithSameLeft(VideoButton),
                ColourBox.WithSameWidth(VideoButton),
                ColourBox.WithSameHeight(VideoBox),

                GeneralButton.Below(ColourBox, 80),
                GeneralButton.WithSameLeft(VideoButton),
                GeneralButton.WithSameWidth(VideoButton),
                GeneralButton.WithSameHeight(VideoButton),

                RedSlider.WithSameTop(ColourBox),
                RedSlider.Left().EqualTo().RightOf(ColourBox).Plus(35),
                RedSlider.WithRelativeWidth(Screen.View, 0.11f),
                RedSlider.WithSameHeight(ColourBox),

                GreenSlider.WithSameTop(ColourBox),
                GreenSlider.Left().EqualTo().RightOf(RedSlider).Plus(30),
                GreenSlider.WithSameWidth(RedSlider),
                GreenSlider.WithSameHeight(ColourBox),

                BlueSlider.WithSameTop(ColourBox),
                BlueSlider.Left().EqualTo().RightOf(GreenSlider).Plus(30),
                BlueSlider.WithSameWidth(RedSlider),
                BlueSlider.WithSameHeight(ColourBox),

                VideoButtonTitle.Above(VideoButton, 5),
                VideoButtonTitle.WithSameLeft(VideoButton),
                VideoButtonTitle.WithRelativeWidth(VideoButton, 3.1f),
                VideoButtonTitle.Height().EqualTo(80),

                ImageButtonTitle.Above(ImageButton, 5),
                ImageButtonTitle.WithSameLeft(VideoButtonTitle),
                ImageButtonTitle.WithSameWidth(VideoButtonTitle),
                ImageButtonTitle.WithSameHeight(VideoButtonTitle),

                ColourBoxTitle.Above(ColourBox, 5),
                ColourBoxTitle.WithSameLeft(VideoButtonTitle),
                ColourBoxTitle.WithSameWidth(VideoButtonTitle),
                ColourBoxTitle.WithSameHeight(VideoButtonTitle),

                SettingsButtonTitle.Above(GeneralButton, 5),
                SettingsButtonTitle.WithSameLeft(VideoButtonTitle),
                SettingsButtonTitle.WithSameWidth(VideoButtonTitle),
                SettingsButtonTitle.WithSameHeight(VideoButtonTitle),

                ResetButton.WithSameTop(GeneralButton),
                ResetButton.AtRightOf(Screen.View, 70),
                ResetButton.WithSameWidth(VideoButton),
                ResetButton.WithSameHeight(VideoButton)
                );
        }
コード例 #5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;

            _errorLable = new UILabel
            {
                Text          = Localization.IncorrectLoginOrPasswordMessage,
                TextColor     = UIColor.Red,
                TextAlignment = UITextAlignment.Center
            };
            _emailLable = new UILabel
            {
                Text          = Localization.LoginEntryText,
                TextColor     = UIColor.Blue,
                TextAlignment = UITextAlignment.Left
            };
            _passwordLable = new UILabel
            {
                Text          = Localization.PasswordEntryText,
                TextColor     = UIColor.Blue,
                TextAlignment = UITextAlignment.Left
            };

            _loginButton = new UIButton {
                BackgroundColor = UIColor.Gray
            };
            _loginButton.SetTitle(Localization.LoginButtonText, UIControlState.Normal);

            _emailTextField = new UITextField
            {
                Placeholder  = Localization.LoginEntryText,
                BorderStyle  = UITextBorderStyle.RoundedRect,
                KeyboardType = UIKeyboardType.EmailAddress,
                Text         = "test"
            };

            _passwordTextField = new UITextField
            {
                SecureTextEntry = true,
                BorderStyle     = UITextBorderStyle.RoundedRect,
                Placeholder     = Localization.PasswordEntryText,
                Text            = "test"
            };

            _emailTextField.EditingDidEndOnExit    += HideKeyboard;
            _passwordTextField.EditingDidEndOnExit += HideKeyboard;
            _loginButton.TouchUpInside             += Login;

            View.AddSubviews(_errorLable, _emailLable, _emailTextField, _passwordLable, _passwordTextField, _loginButton);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            const int entryWidth = 150;
            const int margin     = 10;

            _errorLable.Hidden = true;

            View.AddConstraints(
                _passwordLable.WithSameCenterX(View).Minus(entryWidth / 2),
                _passwordLable.WithSameCenterY(View),

                _passwordTextField.ToRightOf(_passwordLable, margin),
                _passwordTextField.WithSameTop(_passwordLable).Minus(3),
                _passwordTextField.Width().EqualTo(entryWidth),

                _emailLable.Above(_passwordLable, margin),
                _emailLable.WithSameLeft(_passwordLable),

                _emailTextField.ToRightOf(_emailLable),
                _emailTextField.WithSameLeft(_passwordTextField),
                _emailTextField.WithSameTop(_emailLable).Minus(3),
                _emailTextField.Width().EqualTo(entryWidth),

                _loginButton.Below(_passwordLable, margin),
                _loginButton.WithSameCenterX(View),
                _loginButton.Width().EqualTo(entryWidth),

                _errorLable.Above(_emailLable, margin),
                _errorLable.WithSameCenterX(View)
                );
        }
コード例 #6
0
        public VisualEditorViewController()
        {
            View.BackgroundColor = Styling.Colors.BackgroundColor;

              View.AddGestureRecognizer(new UITapGestureRecognizer(ViewTap));

              var discountLabel = new UILabel
              {
            BackgroundColor = Styling.Colors.Green,
            Text = "25% OFF YOUR FIRST ORDER IF YOU SIGN UP BY 9/1",
            Font = UIFont.FromName("Gotham-Medium", 11),
            TextColor = UIColor.White,
            TextAlignment = UITextAlignment.Center
              };

              var image = new UIImageView
              {
            Image = UIImage.FromBundle("Images/widgetCoLogo_red"),
              };

              var emailLabel = new UILabel
              {
            Text = "Email",
            Font = UIFont.FromName("Gotham-Light", 10)
              };
              var emailField = new CustomTextField
              {
            Placeholder = "*****@*****.**"
              };

              var phoneLabel = new UILabel
              {
            Text = "Phone Number:",
            Font = UIFont.FromName("Gotham-Light", 10)
              };

              var phoneField = new CustomTextField
              {
            Placeholder = "(555)-555-5555"
              };

              var passwordLabel = new UILabel
              {
            Text = "Password",
            Font = UIFont.FromName("Gotham-Light", 10)
              };

              var passwordField = new CustomTextField
              {
            SecureTextEntry = true,
              };

              var button = new CustomButton
              {
            TitleText = "Take me to the widgets"
              };

              View.AddSubviews(emailLabel, emailField, phoneLabel, phoneField, passwordLabel, passwordField, button, discountLabel, image);

              View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

              View.AddConstraints(
            discountLabel.WithSameTop(View),
            discountLabel.WithSameLeft(View),
            discountLabel.WithSameRight(View),
            discountLabel.Height().EqualTo(30),

            phoneLabel.WithSameLeft(phoneField),
            phoneLabel.WithSameCenterY(View),

            phoneField.WithSameCenterX(View),
            phoneField.Height().EqualTo(30),
            phoneField.Width().EqualTo(200),
            phoneField.Below(phoneLabel).Plus(5),

            emailField.WithSameLeft(phoneField),
            emailField.WithSameWidth(phoneField),
            emailField.WithSameHeight(phoneField),
            emailField.Above(phoneLabel).Minus(15),

            emailLabel.WithSameLeft(phoneField),
            emailLabel.Above(emailField).Minus(5),

            image.WithSameCenterX(View),
            image.Above(emailLabel).Minus(15),

            passwordLabel.WithSameLeft(phoneField),
            passwordLabel.Below(phoneField).Plus(15),

            passwordField.WithSameLeft(phoneField),
            passwordField.WithSameWidth(phoneField),
            passwordField.WithSameHeight(phoneField),
            passwordField.Below(passwordLabel).Plus(5),

            button.Below(passwordField).Plus(20),
            button.WithSameCenterX(View),
            button.WithSameWidth(phoneField),
            button.Height().EqualTo(50)
              );
        }