Beispiel #1
0
        public WelcomeController()
        {
            View.BackgroundColor = Styling.Colors.WelcomeBackgroundColor;

            var welcomeView = new UIView
            {
                BackgroundColor = UIColor.White,
                ClipsToBounds   = true,
            };

            welcomeView.Layer.CornerRadius = 8;

            var image = new UIImageView
            {
                Image       = UIImage.FromBundle("Images/blueLogoWelcomeScreen"),
                ContentMode = UIViewContentMode.ScaleAspectFit
            };

            var welcomeLabel = new UILabel
            {
                Text          = "Welcome to the\nOptimizely Tutorial App",
                Lines         = 2,
                TextAlignment = UITextAlignment.Center,
            };

            welcomeLabel.Font = UIFont.FromName("Gotham-Light", 18);

            var textLabel = new UILabel
            {
                Text          = "Please open your browser to\ndevelopers.optimizely.com/ios",
                Lines         = 2,
                TextAlignment = UITextAlignment.Center,
            };

            textLabel.Font = UIFont.FromName("Gotham-Light", 14);

            var button = new CustomButton
            {
                BackgroundColor = Styling.Colors.ButtonGreen,
                TitleText       = "Got it. Let's go!"
            };

            // [OPTIMIZELY] Below is an example of if you want to tag
            // ids manually
            // OptimizelyiOS.UIView_Optimizely.GetOptimizelyId(button);

            button.TouchUpInside += Button_TouchUpInside;

            welcomeView.AddSubview(image);
            welcomeView.AddSubview(welcomeLabel);
            welcomeView.AddSubview(textLabel);
            welcomeView.AddSubview(button);

            welcomeView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            welcomeView.AddConstraints(
                image.WithSameCenterX(welcomeView),
                image.WithSameTop(welcomeView).Plus(40),
                image.WithSameLeft(welcomeView).Plus(30),
                image.WithSameRight(welcomeView).Minus(30),

                welcomeView.WithSameCenterX(welcomeView),
                welcomeLabel.Below(image).Plus(50),
                welcomeLabel.WithSameLeft(welcomeView).Plus(15),
                welcomeLabel.WithSameRight(welcomeView).Minus(15),

                textLabel.WithSameCenterX(welcomeView),
                textLabel.Below(welcomeLabel).Plus(50),
                textLabel.WithSameWidth(welcomeLabel),

                button.WithSameCenterX(welcomeView),
                button.Below(textLabel).Plus(50),
                button.Width().EqualTo(200),
                button.Height().EqualTo(50)
                );

            View.AddSubview(welcomeView);
            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                welcomeView.WithSameCenterX(View),
                welcomeView.WithSameCenterY(View).Minus(10),
                welcomeView.WithSameLeft(View).Plus(30),
                welcomeView.WithSameRight(View).Minus(30),
                welcomeView.Width().EqualTo(View.Bounds.Width - 60),
                welcomeView.Height().EqualTo(380)
                );
        }
Beispiel #2
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)
                );
        }