public override void LoadView ()
		{
			View = new UIView ();
			View.BackgroundColor = UIColor.White;

			var imageView = new UIImageView ();
			imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
			imageView.TranslatesAutoresizingMaskIntoConstraints = false;
			ImageView = imageView;
			View.Add (ImageView);

			var ratingControl = new RatingControl ();
			ratingControl.TranslatesAutoresizingMaskIntoConstraints = false;
			ratingControl.AddTarget (RatingChanges, UIControlEvent.ValueChanged);
			RatingControl = ratingControl;
			View.Add (RatingControl);

			var overlayButton = new OverlayView ();
			overlayButton.TranslatesAutoresizingMaskIntoConstraints = false;
			OverlayButton = overlayButton;
			View.Add (OverlayButton);

			UpdatePhoto ();

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("|[imageView]|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"imageView", imageView));

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|[imageView]|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"imageView", imageView));

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("[ratingControl]-|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"ratingControl", ratingControl));

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("[overlayButton]-|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"overlayButton", overlayButton));

			View.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:[overlayButton]-[ratingControl]-|",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"overlayButton", overlayButton,
				"ratingControl", ratingControl));

			var constraints = new List<NSLayoutConstraint> ();

			constraints.AddRange (NSLayoutConstraint.FromVisualFormat ("|-(>=20)-[ratingControl]",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"ratingControl", ratingControl));

			constraints.AddRange (NSLayoutConstraint.FromVisualFormat ("|-(>=20)-[overlayButton]",
				NSLayoutFormatOptions.DirectionLeadingToTrailing,
				"overlayButton", overlayButton));

			foreach (var constraint in constraints)
				constraint.Priority = (int)UILayoutPriority.Required - 1;

			View.AddConstraints (constraints.ToArray ());
		}
		public override void LoadView ()
		{
			UIView view = new UIView ();
			view.BackgroundColor = UIColor.White;

			gameView = new TTTGameView () {
				ImageForPlayer = ImageForPlayer,
				ColorForPlayer = ColorForPlayer,
				UserInteractionEnabled = false,
				TranslatesAutoresizingMaskIntoConstraints = false
			};

			view.AddSubview (gameView);
			gameView.Game = Game;

			nfloat topHeight = UIApplication.SharedApplication.StatusBarFrame.Size.Height +
				NavigationController.NavigationBar.Frame.Size.Height;

			view.AddConstraints (NSLayoutConstraint.FromVisualFormat ("|-margin-[gameView]-margin-|",
				(NSLayoutFormatOptions)0,
				"margin", Margin,
				"gameView", gameView));

			view.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|-topHeight-[gameView]-bottomHeight-|",
				(NSLayoutFormatOptions)0,
				"topHeight", topHeight + Margin,
				"gameView", gameView,
				"bottomHeight", Margin));

			View = view;
		}
		public override void LoadView ()
		{
			UIView baseView = new UIView ();
			baseView.BackgroundColor = UIColor.FromWhiteAlpha (0f, .15f);

			UIView view = new UIView (new RectangleF (-100f, -50f, 240f, 120f)) {
				AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin |
				UIViewAutoresizing.FlexibleBottomMargin |
				UIViewAutoresizing.FlexibleTopMargin |
				UIViewAutoresizing.FlexibleRightMargin,
				BackgroundColor = UIColor.FromPatternImage (UIImage.FromBundle ("barBackground"))
			};
			baseView.AddSubview (view);

			UIButton cancelButton = UIButton.FromType (UIButtonType.System);
			cancelButton.TouchUpInside += close;
			cancelButton.TranslatesAutoresizingMaskIntoConstraints = false;
			cancelButton.SetTitle ("Cancel", UIControlState.Normal);
			view.AddSubview (cancelButton);

			UIButton postButton = UIButton.FromType (UIButtonType.System);
			postButton.TouchUpInside += post;
			postButton.TranslatesAutoresizingMaskIntoConstraints = false;
			postButton.SetTitle ("Post", UIControlState.Normal);
			view.AddSubview (postButton);

			messageTextView = new UITextView () {
				BackgroundColor = UIColor.Clear,
				TranslatesAutoresizingMaskIntoConstraints = false
			};
			view.AddSubview (messageTextView);

			NSDictionary views = NSDictionary.FromObjectsAndKeys (
				new NSObject[] { postButton, cancelButton, messageTextView },
				new NSString[] { new NSString ("postButton"),
				new NSString ("cancelButton"),
				new NSString ("messageTextView")
			}
			);

			baseView.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-8-[messageTextView]-8-|", (NSLayoutFormatOptions)0, null, views)
			);
			baseView.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-8-[cancelButton]->=20-[postButton]-8-|", (NSLayoutFormatOptions)0, null, views)
			);
			baseView.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"V:|-8-[messageTextView]-[cancelButton]-8-|", (NSLayoutFormatOptions)0, null, views)
			);
			baseView.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"V:|-8-[messageTextView]-[postButton]-8-|", (NSLayoutFormatOptions)0, null, views)
			);

			View = baseView;
		}
        public override void LoadView ()
        {
            var view = new UIView ().Apply (Style.Screen);

            view.Add (nameTextField = new TextField () {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AttributedPlaceholder = new NSAttributedString (
                    "NewProjectNameHint".Tr (),
                    foregroundColor: Color.Gray
                ),
                ShouldReturn = (tf) => tf.ResignFirstResponder (),
            } .Apply (Style.NewProject.NameField));
            nameTextField.EditingChanged += (sender, e) => ValidateProjectName ();

            view.Add (clientButton = new UIButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            } .Apply (Style.NewProject.ClientButton).Apply (Style.NewProject.NoClient));
            clientButton.SetTitle ("NewProjectClientHint".Tr (), UIControlState.Normal);
            clientButton.TouchUpInside += OnClientButtonTouchUpInside;

            view.AddConstraints (VerticalLinearLayout (view));

            EdgesForExtendedLayout = UIRectEdge.None;
            View = view;

            var addBtn = new UIBarButtonItem (
                "NewProjectAdd".Tr (), UIBarButtonItemStyle.Plain, OnSetBtnPressed)
            .Apply (Style.NavLabelButton).Apply (Style.DisableNavLabelButton);
            addBtn.Enabled = false;
            NavigationItem.RightBarButtonItem = addBtn;
        }
        public override void LoadView ()
        {
            var view = new UIView ().Apply (Style.Screen);

            view.Add (nameTextField = new TextField () {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AttributedPlaceholder = new NSAttributedString (
                    "NewProjectNameHint".Tr (),
                    foregroundColor: Color.Gray
                ),
                ShouldReturn = (tf) => tf.ResignFirstResponder (),
            }.Apply (Style.NewProject.NameField).Apply (BindNameField));
            nameTextField.EditingChanged += OnNameFieldEditingChanged;

            view.Add (clientButton = new UIButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.NewProject.ClientButton).Apply (BindClientButton));
            clientButton.TouchUpInside += OnClientButtonTouchUpInside;

            view.AddConstraints (VerticalLinearLayout (view));

            EdgesForExtendedLayout = UIRectEdge.None;
            View = view;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem (
                "NewProjectAdd".Tr (), UIBarButtonItemStyle.Plain, OnNavigationBarAddClicked)
                .Apply (Style.NavLabelButton);
        }
        public override void LoadView ()
        {
            View = new UIView ().Apply (Style.Screen);

            Add (new SeparatorView ().Apply (Style.Settings.Separator));
            Add (askProjectView = new LabelSwitchView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.Settings.RowBackground).Apply (BindAskProjectView));
            askProjectView.Label.Apply (Style.Settings.SettingLabel);
            askProjectView.Label.Text = "SettingsAskProject".Tr ();
            askProjectView.Switch.ValueChanged += OnAskProjectViewValueChanged;

            Add (new SeparatorView ().Apply (Style.Settings.Separator));
            Add (new UILabel () {
                Text = "SettingsAskProjectDesc".Tr (),
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.Settings.DescriptionLabel));

            Add (new SeparatorView ().Apply (Style.Settings.Separator));
            Add (mobileTagView = new LabelSwitchView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.Settings.RowBackground).Apply (BindMobileTagView));
            mobileTagView.Label.Apply (Style.Settings.SettingLabel);
            mobileTagView.Label.Text = "SettingsMobileTag".Tr ();
            mobileTagView.Switch.ValueChanged += OnMobileTagViewValueChanged;

            Add (new SeparatorView ().Apply (Style.Settings.Separator));
            Add (new UILabel () {
                Text = "SettingsMobileTagDesc".Tr (),
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.Settings.DescriptionLabel));

            View.AddConstraints (MakeConstraints (View));
        }
		public override void LoadView ()
		{
			UIView view = new UIView ();
			view.BackgroundColor = UIColor.White;

			gameView = new TTTGameView () {
				ImageForPlayer = ImageForPlayer,
				ColorForPlayer = ColorForPlayer,
				UserInteractionEnabled = false,
				TranslatesAutoresizingMaskIntoConstraints = false
			};

			view.AddSubview (gameView);
			gameView.Game = Game;

			float topHeight = UIApplication.SharedApplication.StatusBarFrame.Size.Height +
				NavigationController.NavigationBar.Frame.Size.Height;
			NSDictionary bindings = NSDictionary.FromObjectAndKey (gameView, new NSString ("gameView"));
			NSDictionary metrics = NSDictionary.FromObjectsAndKeys (
				new NSObject[] { new NSNumber (topHeight + Margin),
				new NSNumber (Margin), new NSNumber (Margin)
			},
				new NSString [] { 
				new NSString ("topHeight"), 
				new NSString ("bottomHeight"),
				new NSString ("margin")
			});

			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-margin-[gameView]-margin-|", (NSLayoutFormatOptions)0,
				metrics, bindings));
			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"V:|-topHeight-[gameView]-bottomHeight-|", (NSLayoutFormatOptions)0,
				metrics, bindings));

			View = view;
		}
        public UICustomProgressView()
        {
            currentProgressLabel = new UILabel();
            currentProgressLabel.Text = "10000000";

            ofProgressLabel = new UILabel();
            ofProgressLabel.Text = "of";

            totalProgressLabel = new UILabel();
            totalProgressLabel.Text = "10000000";

            progressNoContainer = new UIView();
            progressNoContainer.BackgroundColor = UIColor.Yellow;
            progressNoContainer.Layer.BorderColor = UIColor.Red.CGColor;
            progressNoContainer.Layer.BorderWidth = 2f;

            progressNoContainer.AddSubviews(new UIView[] { currentProgressLabel, ofProgressLabel, totalProgressLabel });
            progressNoContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            progressNoContainer.AddConstraints(new[]
            {
                currentProgressLabel.AtTopOf(progressNoContainer),
                currentProgressLabel.WithSameCenterX(progressNoContainer).Minus(25),
                currentProgressLabel.Height().EqualTo(30),

                ofProgressLabel.WithSameTop(currentProgressLabel),
                ofProgressLabel.ToRightOf(currentProgressLabel).Plus(5),
                ofProgressLabel.WithSameHeight(currentProgressLabel),

                totalProgressLabel.WithSameBottom(ofProgressLabel),
                totalProgressLabel.ToRightOf(ofProgressLabel).Plus(5),
                totalProgressLabel.WithSameHeight(ofProgressLabel)
            });

            AddSubviews(new[] { progressNoContainer });
            this.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            this.AddConstraints(new[]
            {
                progressNoContainer.WithSameCenterY(this),
                progressNoContainer.WithSameRight(this).Minus(10),
                progressNoContainer.Width().EqualTo(100),
                progressNoContainer.Height().EqualTo(30)
            });
        }
        public override void LoadView ()
        {
            var view = new UIView ().Apply (Style.Screen);

            view.Add (NameTextField = new TextField {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AttributedPlaceholder = new NSAttributedString (
                    "NewClientNameHint".Tr (),
                    foregroundColor: Color.Gray
                ),
                ShouldReturn = (tf) => tf.ResignFirstResponder (),
            } .Apply (Style.NewProject.NameField));

            NameTextField.EditingChanged += (sender, e) => ValidateClientName ();
            view.AddConstraints (VerticalLinearLayout (view));
            EdgesForExtendedLayout = UIRectEdge.None;
            View = view;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem (
                "NewClientAdd".Tr (), UIBarButtonItemStyle.Plain, OnNavigationBarAddClicked)
            .Apply (Style.DisableNavLabelButton);
            NavigationItem.RightBarButtonItem.Enabled = false;
        }
Пример #10
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.NavigationController.SetNavigationBarHidden(true, false);

            _buttons = new List <ImageButton>();

            Title = "Home";

            var mainView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var buttonView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            Add(mainView);

            /* ----- image views ----- */

            _locationView = new LocationView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            var logoImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Image       = UIImage.FromFile("logo.png"),
            };

            var bottomImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFill,
                Image       = UIImage.FromFile("bg-bottom.jpg"),
            };

            var transparentBackgroundView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Black,
                Alpha           = 0.05f
            };

            _progressView = new UIActivityIndicatorView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Color = UIColor.Black,
            };

            _screenSaverView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Alpha  = 0.0f,
                Hidden = false
            };

            var screenSaverTapGesture = new UITapGestureRecognizer(() =>
            {
                _screenSaverView.Alpha  = 0.0f;
                _screenSaverView.Hidden = true;
                _screenSaverShowing     = false;

                ViewModel.ResetActions();
            });

            _screenSaverView.AddGestureRecognizer(screenSaverTapGesture);

            mainView.Add(_locationView);
            mainView.Add(_progressView);
            mainView.Add(logoImageView);

            mainView.Add(buttonView);

            buttonView.Add(bottomImageView);
            buttonView.Add(transparentBackgroundView);

            mainView.Add(_screenSaverView);

            /* ----- image views ----- */

            /* ----- buttons ----- */

            var buttonViews = new DictionaryViews()
            {
                { "bottomImageView", bottomImageView },
                { "transparentBackgroundView", transparentBackgroundView },
            };

            for (int i = 0; i < _buttonTitles.Length; i++)
            {
                var button = new ImageButton()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                };

                var title = _buttonTitles[i];

                StyleButton(button, _buttonImagePaths[i], _buttonTitles[i]);
                buttonViews.Add(title.ToLower() + "Button", button);
                buttonView.Add(button);
                // add to button list so we can perform flips
                _buttons.Add(button);
            }

            /* ----- buttons ----- */

            var views = new DictionaryViews()
            {
                { "mainView", mainView },
            };

            var mainViews = new DictionaryViews()
            {
                { "locationView", _locationView },
                { "progressView", _progressView },
                { "logoImageView", logoImageView },
                { "buttonView", buttonView },
                { "screenSaverView", _screenSaverView },
            };

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[mainView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mainView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            mainView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[locationView][logoImageView][buttonView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[progressView][logoImageView][buttonView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[screenSaverView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[screenSaverView]|", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[progressView]|", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[locationView]|", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[buttonView]|", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(new[] { NSLayoutConstraint.Create(buttonView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, _locationView, NSLayoutAttribute.Height, 0.8f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(logoImageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.Width, 0.3f, 0) })
                // height is proportional to width
                .Concat(new[] { NSLayoutConstraint.Create(logoImageView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, logoImageView, NSLayoutAttribute.Width, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(logoImageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .ToArray());

            buttonView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[bottomImageView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[transparentBackgroundView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-1-[searchButton]-1-[blogButton(searchButton)]-1-|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-1-[ratesButton]-1-[settingsButton(ratesButton)]-1-|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-1-[feedbackButton]-1-[shareButton(feedbackButton)]-1-|", NSLayoutFormatOptions.DirectionLeftToRight, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[bottomImageView]|", NSLayoutFormatOptions.AlignAllTop, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[transparentBackgroundView]|", NSLayoutFormatOptions.AlignAllTop, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-1-[searchButton]-1-[ratesButton(searchButton)]-1-[feedbackButton(searchButton)]-1-|", NSLayoutFormatOptions.AlignAllTop, null, buttonViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-1-[blogButton]-1-[settingsButton(blogButton)]-1-[shareButton(blogButton)]-1-|", NSLayoutFormatOptions.AlignAllTop, null, buttonViews))
                .ToArray());

            // search button
            this.BindCommand(ViewModel, x => x.SearchCommand, x => x._buttons[0]);

            this.WhenActivated(d =>
            {
                // HACK: Clean this up with proper navigation
                ViewModel.OnShow(new Dictionary <string, object>());
            });
        }
        void InitializeControls()
        {
            View.BackgroundColor = UIColor.Clear;
            _internalView = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _headerLabel = new UILabel {
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                BackgroundColor = HeaderBackgroundColor,
                TextColor = HeaderTextColor,
                Text = HeaderText,
                TextAlignment = UITextAlignment.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _cancelButton = UIButton.FromType(UIButtonType.System);
            _cancelButton.SetTitleColor(HeaderTextColor, UIControlState.Normal);
            _cancelButton.BackgroundColor = UIColor.Clear;
            _cancelButton.SetTitle(CancelButtonText, UIControlState.Normal);
            _cancelButton.TouchUpInside += CancelButtonTapped;
            _cancelButton.TranslatesAutoresizingMaskIntoConstraints = false;
            AddButtonSizeConstraints (_cancelButton);

            _doneButton = UIButton.FromType(UIButtonType.System);
            _doneButton.SetTitleColor(HeaderTextColor, UIControlState.Normal);
            _doneButton.BackgroundColor = UIColor.Clear;
            _doneButton.SetTitle(DoneButtonText, UIControlState.Normal);
            _doneButton.TouchUpInside += DoneButtonTapped;
            _doneButton.TranslatesAutoresizingMaskIntoConstraints = false;
            AddButtonSizeConstraints (_doneButton);

            UIView picker = null;
            switch(PickerType)
            {
                case ModalPickerType.Date:
                    picker = DatePicker;
                    break;
                case ModalPickerType.Custom:
                    picker = PickerView;
                    break;
                default:
                    break;
            }
            picker.BackgroundColor = UIColor.White;
            _internalView.AddSubview (picker);
            _internalView.BackgroundColor = HeaderBackgroundColor;

            _internalView.AddSubview(_headerLabel);
            _internalView.AddSubview (_cancelButton);
            _internalView.AddSubview(_doneButton);

            _internalView.AddConstraints (new[] {
                NSLayoutConstraint.Create (_cancelButton, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _internalView, NSLayoutAttribute.Top, 1f, 7f),
                NSLayoutConstraint.Create (_cancelButton, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _internalView, NSLayoutAttribute.Leading, 1f, 10f),
                NSLayoutConstraint.Create (_headerLabel, NSLayoutAttribute.Baseline, NSLayoutRelation.Equal, _cancelButton, NSLayoutAttribute.Baseline, 1f, 0f),
                NSLayoutConstraint.Create (_headerLabel, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _cancelButton, NSLayoutAttribute.Trailing, 1f, 10f),
                NSLayoutConstraint.Create (_doneButton, NSLayoutAttribute.Baseline, NSLayoutRelation.Equal, _headerLabel, NSLayoutAttribute.Baseline, 1f, 0f),
                NSLayoutConstraint.Create (_doneButton, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, _headerLabel, NSLayoutAttribute.Trailing, 1f, 10f),
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, _doneButton, NSLayoutAttribute.Trailing, 1f, 10f),
                NSLayoutConstraint.Create (picker, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, _internalView, NSLayoutAttribute.CenterX, 1f, 0f),
                NSLayoutConstraint.Create (picker, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _internalView, NSLayoutAttribute.Bottom, 1f, 0f),
                NSLayoutConstraint.Create (picker, NSLayoutAttribute.Top, NSLayoutRelation.Equal, _cancelButton, NSLayoutAttribute.Bottom, 1f, 5f),
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, picker, NSLayoutAttribute.Width, 1f, 0f),
            });

            Add(_internalView);
            View.AddConstraints (new[] {
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1f, 0f),
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1f, 0f),
                NSLayoutConstraint.Create (_internalView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, View, NSLayoutAttribute.Bottom, 1f, 0f)
            });
        }
Пример #12
0
        public override void LoadView ()
        {
            base.LoadView ();

            isUserLogged = UserDefaults.BoolForKey (IsUserLoggedKey);
            isAppActive = UserDefaults.BoolForKey (AppActiveEntryKey);
            isAppOnBackground = UserDefaults.BoolForKey (AppBackgroundEntryKey);

            marginTop = (isUserLogged && isAppActive) ? 10f : 1f;
            height = (isUserLogged && isAppActive) ? 250f : 62f; // 4 x 60f(cells),

            var v = new UIView {
                BackgroundColor = UIColor.Clear,
                Frame = new CGRect (0,0, UIScreen.MainScreen.Bounds.Width, height),
            };

            v.Add (tableView = new UITableView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear,
                TableFooterView = new UIView(),
                ScrollEnabled = false,
                RowHeight = cellHeight,
            });

            v.Add (openAppView = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Hidden = true,
            });

            UIView bg;
            openAppView.Add (bg = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Black,
                Alpha = 0.1f,
            });

            UILabel textView;
            openAppView.Add (textView = new UILabel {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.FromName ("Helvetica", 13f),
                Text = isAppActive ? "NoLoggedUser".Tr() : "NoActiveApp".Tr(),
                TextColor = UIColor.White,
                BackgroundColor = UIColor.Clear,
            });

            openAppView.Add (openAppBtn = new StartStopBtn {
                TranslatesAutoresizingMaskIntoConstraints = false,
                IsActive = true,
            });

            openAppView.AddConstraints (

                bg.AtTopOf (openAppView),
                bg.AtLeftOf (openAppView),
                bg.AtRightOf (openAppView),
                bg.AtBottomOf (openAppView),

                textView.WithSameCenterY (openAppView),
                textView.AtLeftOf (openAppView, 50f),
                textView.WithSameHeight (openAppView),
                textView.AtRightOf (openAppView),

                openAppBtn.Width().EqualTo (35f),
                openAppBtn.Height().EqualTo (35f),
                openAppBtn.AtRightOf (openAppView, 15f),
                openAppBtn.WithSameCenterY (openAppView),

                null
            );

            v.AddConstraints (

                tableView.AtTopOf (v),
                tableView.WithSameWidth (v),
                tableView.Height().EqualTo (height - marginTop).SetPriority (UILayoutPriority.DefaultLow),
                tableView.AtBottomOf (v),

                openAppView.AtTopOf (v),
                openAppView.WithSameWidth (v),
                openAppView.Height().EqualTo (cellHeight),

                null
            );

            View = v;
        }
Пример #13
0
        public override void ViewDidLoad()
        {
            View = new UIView {
                BackgroundColor = UIColor.White
            };
            base.ViewDidLoad();

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

            var searchField = new UITextField(CGRect.Empty)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BorderStyle = UITextBorderStyle.RoundedRect
            };

            View.Add(searchField);
            var searchButton = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            searchButton.SetTitle("Search", UIControlState.Normal);
            searchButton.SetContentHuggingPriority(250, UILayoutConstraintAxis.Horizontal);
            View.Add(searchButton);
            var tableView = new UITableView(CGRect.Empty)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            View.Add(tableView);

            View.AddConstraints(new []
            {
                NSLayoutConstraint.Create(searchField, NSLayoutAttribute.Top, NSLayoutRelation.Equal,
                                          TopLayoutGuide, NSLayoutAttribute.Bottom, 1.0f, 10),
                NSLayoutConstraint.Create(searchField, NSLayoutAttribute.Left, NSLayoutRelation.Equal,
                                          View, NSLayoutAttribute.Left, 1.0f, 10),
                NSLayoutConstraint.Create(searchField, NSLayoutAttribute.Right, NSLayoutRelation.Equal,
                                          searchButton, NSLayoutAttribute.Left, 1.0f, -10),

                NSLayoutConstraint.Create(searchButton, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal,
                                          searchField, NSLayoutAttribute.CenterY, 1.0f, 0),
                NSLayoutConstraint.Create(searchButton, NSLayoutAttribute.Right, NSLayoutRelation.Equal,
                                          View, NSLayoutAttribute.Right, 1.0f, -10),

                NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Top, NSLayoutRelation.Equal,
                                          searchField, NSLayoutAttribute.Bottom, 1.0f, 10),
                NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Left, NSLayoutRelation.Equal,
                                          View, NSLayoutAttribute.Left, 1.0f, 0),
                NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Right, NSLayoutRelation.Equal,
                                          View, NSLayoutAttribute.Right, 1.0f, 0),
                NSLayoutConstraint.Create(tableView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal,
                                          View, NSLayoutAttribute.Bottom, 1.0f, 0),
            });

            var source = new MvxSimpleTableViewSource(tableView,
                                                      SearchResultTableViewCell.Key.ToString(), SearchResultTableViewCell.Key.ToString());

            tableView.Source = source;

            var set = this.CreateBindingSet <FirstView, Core.ViewModels.FirstViewModel>();

            set.Bind(searchField).To(vm => vm.SearchWord);
            set.Bind(searchButton).To(vm => vm.DoSearchCommand);
            set.Bind(source).For(v => v.ItemsSource).To(vm => vm.SearchResults);
            set.Bind(source).For(v => v.SelectionChangedCommand).To(vm => vm.FeedSelectCommand);
            set.Apply();

            searchButton.TouchUpInside += (sender, e) => searchField.ResignFirstResponder();
        }
Пример #14
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();
        }
        /// <summary>
        /// Loads the view.
        /// </summary>
        public override void LoadView()
        {
            //
            var view = new UIView(UIScreen.MainScreen.Bounds);
            view.BackgroundColor = UIColor.DarkGray;
            mMusicFlowView = new SCSiriWaveformView(view.Bounds);
            mMusicFlowView.TranslatesAutoresizingMaskIntoConstraints = false;
            view.Add (mMusicFlowView);
            this.View = view;

            NSLayoutConstraint constraintRatio = NSLayoutConstraint.Create (mMusicFlowView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, mMusicFlowView, NSLayoutAttribute.Height, 1.0f, 0.0f);
            NSLayoutConstraint constraintCenterX = NSLayoutConstraint.Create (mMusicFlowView,NSLayoutAttribute.CenterX ,NSLayoutRelation.Equal,view,NSLayoutAttribute.CenterX,1.0f,0.0f);
            NSLayoutConstraint constraintCenterY = NSLayoutConstraint.Create (mMusicFlowView,NSLayoutAttribute.CenterY,NSLayoutRelation.Equal,view,NSLayoutAttribute.CenterY,1.0f, 0.0f);
            NSLayoutConstraint constraintWidth = NSLayoutConstraint.Create (mMusicFlowView,NSLayoutAttribute.Width,NSLayoutRelation.Equal,view,NSLayoutAttribute.Width,1.0f,0.0f);

            mMusicFlowView.AddConstraint (constraintRatio);
            view.AddConstraints (new NSLayoutConstraint[]{constraintWidth, constraintCenterX, constraintCenterY});
        }
Пример #16
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)
                );
        }
Пример #17
0
        private void SetupConstraints()
        {
            ScrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            _containerView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                _containerView.WithSameWidth(View),
                _containerView.Height().EqualTo(UIScreen.MainScreen.Bounds.Height)
                );

            ScrollView.AddConstraints(
                _containerView.AtTopOf(ScrollView),
                _containerView.AtLeftOf(ScrollView),
                _containerView.AtRightOf(ScrollView),
                _containerView.AtBottomOf(ScrollView)
                );

            _containerView.AddConstraints(
                _settingsHeader.AtTopOf(_containerView, 15),
                _settingsHeader.AtLeftOf(_containerView, 14),
                _settingsHeader.AtRightOf(_containerView, 14),

                _settingsContainer.Below(_settingsHeader, 5),
                _settingsContainer.AtLeftOf(_containerView),
                _settingsContainer.AtRightOf(_containerView),

                _settingsTopRuler.AtTopOf(_settingsContainer),
                _settingsTopRuler.AtLeftOf(_settingsContainer),
                _settingsTopRuler.AtRightOf(_settingsContainer),
                _settingsTopRuler.Height().EqualTo(1),

                _disableAllMailsText.Below(_settingsTopRuler, 15),
                _disableAllMailsText.AtLeftOf(_containerView, 14),

                _dailyDigestDescription.Below(_disableAllMailsText),
                _dailyDigestDescription.AtLeftOf(_containerView, 14),
                _dailyDigestDescription.ToLeftOf(_disableAllMails, 5),

                _disableAllMails.AtRightOf(_containerView, 14),
                _disableAllMails.WithSameTop(_disableAllMailsText),
                _disableAllMails.Height().EqualTo(30),
                _disableAllMails.Width().EqualTo(30),

                _dailyDigestRuler.Below(_dailyDigestDescription, 15),
                _dailyDigestRuler.AtLeftOf(_containerView, 14),
                _dailyDigestRuler.AtRightOf(_containerView, 14),
                _dailyDigestRuler.Height().EqualTo(1),

                _disableDailyDigestText.Below(_dailyDigestRuler, 15),
                _disableDailyDigestText.AtLeftOf(_containerView, 14),

                _weeklyDigestDescription.Below(_disableDailyDigestText),
                _weeklyDigestDescription.AtLeftOf(_containerView, 14),
                _weeklyDigestDescription.ToLeftOf(_disableDailyDigest, 5),

                _disableDailyDigest.AtRightOf(_containerView, 14),
                _disableDailyDigest.WithSameTop(_disableDailyDigestText),
                _disableDailyDigest.Height().EqualTo(30),
                _disableDailyDigest.Width().EqualTo(30),

                _weeklyDigestRuler.Below(_weeklyDigestDescription, 15),
                _weeklyDigestRuler.AtLeftOf(_containerView, 14),
                _weeklyDigestRuler.AtRightOf(_containerView, 14),
                _weeklyDigestRuler.Height().EqualTo(1),

                _disableNewFeedPostText.Below(_weeklyDigestRuler, 15),
                _disableNewFeedPostText.AtLeftOf(_containerView, 14),
                _disableNewFeedPostText.ToRightOf(_disableAllMails, 5),

                _contactInvitesDescription.Below(_disableNewFeedPostText),
                _contactInvitesDescription.AtLeftOf(_containerView, 14),
                _contactInvitesDescription.ToLeftOf(_disableNewFeedPost, 5),

                _disableNewFeedPost.AtRightOf(_containerView, 14),
                _disableNewFeedPost.WithSameTop(_disableNewFeedPostText),
                _disableNewFeedPost.Height().EqualTo(30),
                _disableNewFeedPost.Width().EqualTo(30),

                _contactInvitesRuler.Below(_contactInvitesDescription, 15),
                _contactInvitesRuler.AtLeftOf(_containerView, 14),
                _contactInvitesRuler.AtRightOf(_containerView, 14),
                _contactInvitesRuler.Height().EqualTo(1),

                _disableNewFeedPostCommentText.Below(_contactInvitesRuler, 15),
                _disableNewFeedPostCommentText.AtLeftOf(_containerView, 14),
                _disableNewFeedPostCommentText.ToRightOf(_disableAllMails, 5),

                _mentionsDescription.Below(_disableNewFeedPostCommentText),
                _mentionsDescription.AtLeftOf(_containerView, 14),
                _mentionsDescription.ToLeftOf(_disableNewFeedPostComment, 5),

                _disableNewFeedPostComment.AtRightOf(_containerView, 14),
                _disableNewFeedPostComment.WithSameTop(_disableNewFeedPostCommentText),
                _disableNewFeedPostComment.Height().EqualTo(30),
                _disableNewFeedPostComment.Width().EqualTo(30),

                _mentionsRuler.Below(_mentionsDescription, 15),
                _mentionsRuler.AtLeftOf(_containerView, 14),
                _mentionsRuler.AtRightOf(_containerView, 14),
                _mentionsRuler.Height().EqualTo(1),

                _workspaceText.Below(_mentionsRuler, 15),
                _workspaceText.AtLeftOf(_containerView, 14),
                _workspaceText.ToRightOf(_disableAllMails, 5),

                _workspaceDescription.Below(_workspaceText),
                _workspaceDescription.AtLeftOf(_containerView, 14),
                _workspaceDescription.ToLeftOf(_workspace, 5),

                _workspace.AtRightOf(_containerView, 14),
                _workspace.WithSameTop(_workspaceText),
                _workspace.Height().EqualTo(30),
                _workspace.Width().EqualTo(30),

                _workspaceRuler.Below(_workspaceDescription, 15),
                _workspaceRuler.AtLeftOf(_containerView, 14),
                _workspaceRuler.AtRightOf(_containerView, 14),
                _workspaceRuler.Height().EqualTo(1),

                _assignText.Below(_workspaceRuler, 15),
                _assignText.AtLeftOf(_containerView, 14),

                _assignDescription.Below(_assignText),
                _assignDescription.AtLeftOf(_containerView, 14),
                _assignDescription.ToLeftOf(_assign, 5),

                _assign.AtRightOf(_containerView, 14),
                _assign.WithSameTop(_assignText),
                _assign.Height().EqualTo(30),
                _assign.Width().EqualTo(30),

                _assignRuler.Below(_assignDescription, 15),
                _assignRuler.AtLeftOf(_containerView, 14),
                _assignRuler.AtRightOf(_containerView, 14),
                _assignRuler.Height().EqualTo(1),

                _settingsBottomRuler.Below(_assignRuler, 15),
                _settingsBottomRuler.AtBottomOf(_settingsContainer),
                _settingsBottomRuler.AtLeftOf(_settingsContainer),
                _settingsBottomRuler.AtRightOf(_settingsContainer),
                _settingsBottomRuler.Height().EqualTo(1)
                );
        }
Пример #18
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();
        }
Пример #19
0
        public UIGradeCell(string cellId) : base(cellId)
        {
            var graySideBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromWhiteAlpha(180 / 255f, 1)
            };

            ContentView.AddSubview(graySideBar);
            graySideBar.SetWidth(8);
            graySideBar.PinToLeft(ContentView);
            graySideBar.StretchHeight(ContentView);

            _completionBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            ContentView.AddSubview(_completionBar);
            _completionBar.SetWidth(8);
            _completionBar.PinToLeft(ContentView);
            ContentView.AddConstraint(NSLayoutConstraint.Create(
                                          _completionBar,
                                          NSLayoutAttribute.CenterY,
                                          NSLayoutRelation.Equal,
                                          ContentView,
                                          NSLayoutAttribute.CenterY,
                                          1,
                                          0));

            _stackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis = UILayoutConstraintAxis.Vertical
            };

            var titleAndGrade = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            {
                _labelTitle = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredCaption1
                };
                BindingHost.SetLabelTextBinding(_labelTitle, nameof(DataContext.Name));
                titleAndGrade.Add(_labelTitle);
                _labelTitle.StretchHeight(titleAndGrade);

                _labelGrade = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredCaption2.Bold()
                };
                BindingHost.SetLabelTextBinding(_labelGrade, nameof(DataContext.GradeSubtitle));
                titleAndGrade.Add(_labelGrade);
                _labelGrade.StretchHeight(titleAndGrade);

                titleAndGrade.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[title][grade]-16-|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                 "title", _labelTitle,
                                                                                 "grade", _labelGrade));

                // Don't let grade compress, the title should be the one that shrinks
                _labelGrade.SetContentCompressionResistancePriority(501, UILayoutConstraintAxis.Horizontal);
                _labelTitle.SetContentCompressionResistancePriority(499, UILayoutConstraintAxis.Horizontal);

                // Don't let the grade unnecessarily expand either
                _labelGrade.SetContentHuggingPriority(501, UILayoutConstraintAxis.Horizontal);
            }
            _stackView.AddArrangedSubview(titleAndGrade);
            titleAndGrade.StretchWidth(_stackView);

            _labelDescription = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.PreferredCaption1,
                TextColor = UIColor.DarkGray
            };
            BindingHost.SetLabelTextBinding(_labelDescription, nameof(DataContext.Details));
            _stackView.AddArrangedSubview(_labelDescription);
            _labelDescription.StretchWidth(_stackView);

            ContentView.AddSubview(_stackView);
            _stackView.StretchWidthAndHeight(ContentView, left: 16, top: 8, bottom: 8);

            BindingHost.SetBinding(nameof(DataContext.IsDropped), delegate
            {
                if (_constraintCompletionBarHeight != null)
                {
                    ContentView.RemoveConstraint(_constraintCompletionBarHeight);
                }

                nfloat multiplier = 1;
                if (DataContext.IsDropped)
                {
                    multiplier = 0;
                }
                _constraintCompletionBarHeight = NSLayoutConstraint.Create(
                    _completionBar,
                    NSLayoutAttribute.Height,
                    NSLayoutRelation.Equal,
                    ContentView,
                    NSLayoutAttribute.Height,
                    multiplier,
                    0);
                ContentView.AddConstraint(_constraintCompletionBarHeight);
            });
        }
Пример #20
0
        public UITaskCell(string cellId) : base(cellId)
        {
            var graySideBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromWhiteAlpha(180 / 255f, 1)
            };

            ContentView.AddSubview(graySideBar);
            graySideBar.SetWidth(8);
            graySideBar.PinToLeft(ContentView);
            graySideBar.StretchHeight(ContentView);

            _completionBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            ContentView.AddSubview(_completionBar);
            _completionBar.SetWidth(8);
            _completionBar.PinToLeft(ContentView);
            ContentView.AddConstraint(NSLayoutConstraint.Create(
                                          _completionBar,
                                          NSLayoutAttribute.CenterY,
                                          NSLayoutRelation.Equal,
                                          ContentView,
                                          NSLayoutAttribute.CenterY,
                                          1,
                                          0));

            _stackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis = UILayoutConstraintAxis.Vertical
            };

            var titleAndDescription = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            {
                _labelTitle = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredCaption1
                };
                titleAndDescription.Add(_labelTitle);
                _labelTitle.StretchHeight(titleAndDescription);

                _labelDescription = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font      = UIFont.PreferredCaption2,
                    TextColor = UIColor.DarkGray
                };
                titleAndDescription.Add(_labelDescription);
                _labelDescription.StretchHeight(titleAndDescription);

                titleAndDescription.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[title][description]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                       "title", _labelTitle,
                                                                                       "description", _labelDescription));

                // Don't let title compress, the description should be the one that shrinks
                _labelTitle.SetContentCompressionResistancePriority(501, UILayoutConstraintAxis.Horizontal);
                _labelDescription.SetContentCompressionResistancePriority(499, UILayoutConstraintAxis.Horizontal);

                // Don't let the title unnecessarily expand either
                _labelTitle.SetContentHuggingPriority(501, UILayoutConstraintAxis.Horizontal);
            }
            _stackView.AddArrangedSubview(titleAndDescription);
            titleAndDescription.StretchWidth(_stackView);

            _labelSubtitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font = UIFont.PreferredCaption1
            };
            _stackView.AddArrangedSubview(_labelSubtitle);
            _labelSubtitle.StretchWidth(_stackView);

            ContentView.AddSubview(_stackView);
            _stackView.StretchWidthAndHeight(ContentView, left: 16, top: 8, bottom: 8);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ReactiveUIAroundMe.iOS.AddUmpireAlertView"/> class.
        /// </summary>
        public AddUmpireAlertView()
        {
            Layer.BorderWidth = 1;
            Layer.BorderColor = iOSColorPalette.GradientStroke3.CGColor;

            BackgroundColor = UIColor.White;

            var topView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            CreateViewGradient(topView);

            var cancelButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            cancelButton.SetTitle("Cancel", UIControlState.Normal);
            cancelButton.SetTitleColor(iOSColorPalette.Red, UIControlState.Normal);

            var saveButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            saveButton.SetTitle("Save", UIControlState.Normal);
            saveButton.SetTitleColor(iOSColorPalette.Red, UIControlState.Normal);

            var retireButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = iOSColorPalette.Red
            };

            retireButton.SetTitle("Retire", UIControlState.Normal);
            retireButton.SetTitleColor(UIColor.White, UIControlState.Normal);

            var titleLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Font          = UIFont.FromName("Helvetica", 16f),
                Text          = "Edit",
            };

            var firstNameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "First Name"
            };

            var surnameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "Surname"
            };

            topView.Add(saveButton);
            topView.Add(titleLabel);
            topView.Add(cancelButton);

            Add(topView);
            Add(retireButton);
            Add(firstNameTextField);
            Add(surnameTextField);

            var topViews = new DictionaryViews()
            {
                { "cancelButton", cancelButton },
                { "saveButton", saveButton },
                { "titleLabel", titleLabel },
            };

            var views = new DictionaryViews()
            {
                { "topView", topView },
                { "retireButton", retireButton },
                { "firstNameTextField", firstNameTextField },
                { "surnameTextField", surnameTextField },
            };

            topView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("H:|-5-[cancelButton]-2-[titleLabel(cancelButton)]-2-[saveButton(cancelButton)]-5-|", NSLayoutFormatOptions.AlignAllTop, null, topViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[cancelButton]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[titleLabel]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|[saveButton]|", NSLayoutFormatOptions.DirectionLeftToRight, null, topViews))
                .ToArray());

            AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[topView(40)]-[firstNameTextField][surnameTextField][retireButton(35)]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[topView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[firstNameTextField]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[surnameTextField]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[retireButton]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            // create the binding set
            //var set = this.CreateBindingSet<AddUmpireAlertView, UmpireViewModel>();
            //set.Bind(firstNameTextField).To(vm => vm.FirstName);
            //set.Bind(surnameTextField).To(vm => vm.Surname);
            //set.Bind(cancelButton).To(vm => vm.CancelCommand);
            //set.Bind(saveButton).To(vm => vm.SaveCommand);
            //set.Bind(retireButton).To(vm => vm.RetireCommand);

            //set.Apply();
        }
Пример #22
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var mainView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.White
            };

            var buttonView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear
            };

            var imageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Image       = new UIImage("moby.png")
            };

            var descriptionLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center
            };

            var currentLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Left,
            };

            var endLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Right,
            };

            progressSlider = new UISlider()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                MinValue = 0
            };

            progressSlider.ValueChanged += progressSliderValueChanged;

            playButton = new UIButton(UIButtonType.Custom)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };
            playButton.TouchUpInside += handlePlayButton;
            playButton.SetImage(UIImage.FromFile("play.png"), UIControlState.Normal);

            var rewindButton = new UIButton(UIButtonType.Custom)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            rewindButton.TouchUpInside += handleRewindForwardButton;
            rewindButton.SetImage(UIImage.FromFile("rewind.png"), UIControlState.Normal);

            var fastForwardButton = new UIButton(UIButtonType.Custom)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            fastForwardButton.TouchUpInside += handleRewindForwardButton;
            fastForwardButton.SetImage(UIImage.FromFile("fast_forward.png"), UIControlState.Normal);

            var views = new DictionaryViews()
            {
                { "mainView", mainView },
                { "buttonView", buttonView },
                { "imageView", imageView },
                { "descriptionLabel", descriptionLabel },
                { "currentLabel", currentLabel },
                { "endLabel", endLabel },
                { "progressSlider", progressSlider },
                { "playButton", playButton },
                { "rewindButton", rewindButton },
                { "fastForwardButton", fastForwardButton }
            };

            View.Add(mainView);

            mainView.Add(imageView);
            mainView.Add(descriptionLabel);
            mainView.Add(buttonView);
            mainView.Add(currentLabel);
            mainView.Add(endLabel);
            mainView.Add(progressSlider);

            buttonView.Add(playButton);
            buttonView.Add(rewindButton);
            buttonView.Add(fastForwardButton);

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[mainView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mainView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            mainView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-100-[imageView(200)]-[descriptionLabel(30)]-[buttonView(50)]-[currentLabel(30)]-[progressSlider]", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-100-[imageView(200)]-[descriptionLabel(30)]-[buttonView(50)]-[endLabel(30)]-[progressSlider]", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-20-[progressSlider]-20-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-25-[currentLabel(100)]", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[endLabel(100)]-25-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[descriptionLabel]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-5-[imageView]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(new[] { NSLayoutConstraint.Create(buttonView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1, 0) })
                .ToArray());

            buttonView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-5-[rewindButton]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[playButton]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-5-[fastForwardButton]-5-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-20-[rewindButton]-[playButton(100)]-[fastForwardButton]-20-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            // create the binding set
            var set = this.CreateBindingSet <AudioPlayerPage, AudioPlayerPageViewModel>();

            set.Bind(this).For("Title").To(vm => vm.Title);
            set.Bind(descriptionLabel).To(vm => vm.DescriptionMessage);
            set.Bind(currentLabel).To(vm => vm.CurrentTimeStr);
            set.Bind(endLabel).To(vm => vm.EndTimeStr);
            set.Bind(progressSlider).For(v => v.Value).To(vm => vm.CurrentTime).TwoWay().Apply();
            set.Bind(progressSlider).For(v => v.MaxValue).To(vm => vm.EndTime);
            set.Bind(playButton).To(vm => vm.PlayPauseCommand);
            set.Bind(rewindButton).To(vm => vm.RewindCommand);
            set.Bind(fastForwardButton).To(vm => vm.ForwardCommand);
            set.Apply();

            model = (AudioPlayerPageViewModel)DataContext;
        }
 public void AddConstraint(string rule, UIView view, AutoLayoutConstraints constraints)
 {
     view.AddConstraints (NSLayoutConstraint.FromVisualFormat (rule, 0, new NSDictionary (), constraints.Dictionary ()));
 }
            private static void ConstructDateTimeView (UIView view, ref UILabel dateLabel, ref UILabel timeLabel)
            {
                view.Add (dateLabel = new UILabel ().Apply (Style.EditTimeEntry.DateLabel));
                view.Add (timeLabel = new UILabel ().Apply (Style.EditTimeEntry.TimeLabel));
                view.AddConstraints (
                    dateLabel.AtTopOf (view, 10f),
                    dateLabel.AtLeftOf (view, 10f),
                    dateLabel.AtRightOf (view, 10f),

                    timeLabel.Below (dateLabel, 2f),
                    timeLabel.AtBottomOf (view, 10f),
                    timeLabel.AtLeftOf (view, 10f),
                    timeLabel.AtRightOf (view, 10f)
                );
                view.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints ();
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Title = "Checkout";

            var footerView = new UIView (new CGRect (0, 0, View.Bounds.Width, 164));

            var creditCardButton = new UIButton (UIButtonType.RoundedRect);
            creditCardButton.SetTitle ("Checkout with Credit Card", UIControlState.Normal);
            creditCardButton.BackgroundColor = UIColor.FromRGBA (0.48f, 0.71f, 0.36f, 1.0f);
            creditCardButton.Layer.CornerRadius = 6;
            creditCardButton.SetTitleColor (UIColor.White, UIControlState.Normal);
            creditCardButton.TranslatesAutoresizingMaskIntoConstraints = false;
            creditCardButton.TouchUpInside += CheckoutWithCreditCard;
            footerView.AddSubview (creditCardButton);

            var webCheckoutButton = new UIButton (UIButtonType.RoundedRect);
            webCheckoutButton.SetTitle ("Web Checkout", UIControlState.Normal);
            webCheckoutButton.BackgroundColor = UIColor.FromRGBA (0.48f, 0.71f, 0.36f, 1.0f);
            webCheckoutButton.Layer.CornerRadius = 6;
            webCheckoutButton.SetTitleColor (UIColor.White, UIControlState.Normal);
            webCheckoutButton.TranslatesAutoresizingMaskIntoConstraints = false;
            webCheckoutButton.TouchUpInside += CheckoutOnWeb;
            footerView.AddSubview (webCheckoutButton);

            var applePayButton = BUYPaymentButton.Create (BUYPaymentButtonType.Buy, BUYPaymentButtonStyle.Black);
            applePayButton.TranslatesAutoresizingMaskIntoConstraints = false;
            applePayButton.TouchUpInside += CheckoutWithApplePay;
            footerView.AddSubview (applePayButton);

            var views = NSDictionary.FromObjectsAndKeys (new [] {
                creditCardButton,
                webCheckoutButton,
                applePayButton
            }, new [] {
                "creditCardButton",
                "webCheckoutButton",
                "applePayButton"
            });
            footerView.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|-[creditCardButton]-|", 0, null, views));
            footerView.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|-[webCheckoutButton]-|", 0, null, views));
            footerView.AddConstraints (NSLayoutConstraint.FromVisualFormat ("H:|-[applePayButton]-|", 0, null, views));
            footerView.AddConstraints (NSLayoutConstraint.FromVisualFormat ("V:|-[creditCardButton(44)]-[webCheckoutButton(==creditCardButton)]-[applePayButton(==creditCardButton)]-|", 0, null, views));

            TableView.TableFooterView = footerView;

            // Prefetch the shop object for Apple Pay
            client.GetShop ((shop, error) => {
                this.shop = shop;
            });
        }
Пример #26
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 ();
        }
Пример #27
0
        public static void AddSubviewDock(this UIView containerView, UIView subView, UIEdgeInsets?insets = null, DockTarget leftTarget = null, DockTarget topTarget = null, DockTarget rightTarget = null, DockTarget bottomTarget = null)
        {
            if (insets == null)
            {
                insets = UIEdgeInsets.Zero;
            }

            subView.TranslatesAutoresizingMaskIntoConstraints = false;
            containerView.AddSubview(subView);

            NSLayoutConstraint leftConstraint = null, topConstraint = null, rightConstraint = null, bottomConstraint = null;

            if (leftTarget != null)
            {
                switch (leftTarget.TargetType)
                {
                case DockTargetType.DockToContainer:
                    leftConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Left, 1f, insets.Value.Left);
                    break;

                case DockTargetType.DockToView:
                    leftConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, leftTarget.View, NSLayoutAttribute.Right, 1.0f, insets.Value.Left);
                    break;

                case DockTargetType.FixedLength:
                    leftConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Left, 1.0f, leftTarget.FixedLength + insets.Value.Left);
                    break;

                case DockTargetType.PercentageOfContainer:
                    throw new NotSupportedException("PercentageOfContainer is not valid for left dock target");
                    break;
                }
            }

            if (topTarget != null)
            {
                switch (topTarget.TargetType)
                {
                case DockTargetType.DockToContainer:
                    topConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Top, 1f, insets.Value.Top);
                    break;

                case DockTargetType.DockToView:
                    topConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, topTarget.View, NSLayoutAttribute.Bottom, 1.0f, insets.Value.Top);
                    break;

                case DockTargetType.FixedLength:
                    topConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Top, 1f, topTarget.FixedLength + insets.Value.Top);
                    break;

                case DockTargetType.PercentageOfContainer:
                    throw new NotSupportedException("PercentageOfContainer is not valid for top dock target");
                    break;
                }
            }

            if (rightTarget != null)
            {
                switch (rightTarget.TargetType)
                {
                case DockTargetType.DockToContainer:
                    rightConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Right, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Right, 1f, -insets.Value.Right);
                    break;

                case DockTargetType.DockToView:
                    rightConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Right, NSLayoutRelation.Equal, rightTarget.View, NSLayoutAttribute.Left, 1.0f, -insets.Value.Right);
                    break;

                case DockTargetType.FixedLength:
                    rightConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1.0f, rightTarget.FixedLength - insets.Value.Right);
                    break;

                case DockTargetType.PercentageOfContainer:
                    rightConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Width, rightTarget.Percentage, -insets.Value.Right);
                    break;
                }
            }

            if (bottomTarget != null)
            {
                switch (bottomTarget.TargetType)
                {
                case DockTargetType.DockToContainer:
                    bottomConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Bottom, 1f, -insets.Value.Bottom);
                    break;

                case DockTargetType.DockToView:
                    bottomConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, bottomTarget.View, NSLayoutAttribute.Top, 1.0f, -insets.Value.Bottom);
                    break;

                case DockTargetType.FixedLength:
                    bottomConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1.0f, bottomTarget.FixedLength - insets.Value.Bottom);
                    break;

                case DockTargetType.PercentageOfContainer:
                    bottomConstraint = NSLayoutConstraint.Create(subView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Height, bottomTarget.Percentage, -insets.Value.Bottom);
                    break;
                }
            }

            var constraints = new[] { leftConstraint, topConstraint, rightConstraint, bottomConstraint }.Where(c => c != null).ToArray();

            if (constraints.Any())
            {
                containerView.AddConstraints(constraints);
            }
        }
Пример #28
0
        public override void OnViewModelLoadedOverride()
        {
            AddTopSectionDivider();

            if (ViewModel.Message != null)
            {
                StackView.AddSpacing(8);

                var labelMessage = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text  = ViewModel.Message,
                    Font  = UIFont.PreferredCaption1,
                    Lines = 0
                };

                StackView.AddArrangedSubview(labelMessage);
                labelMessage.StretchWidth(StackView, left: 16, right: 16);

                StackView.AddSpacing(8);

                AddSectionDivider();
            }

            AddTextField(new UITextField()
            {
                Placeholder                   = "Username",
                AutocapitalizationType        = UITextAutocapitalizationType.None,
                AutocorrectionType            = UITextAutocorrectionType.No,
                KeyboardType                  = UIKeyboardType.ASCIICapable,
                ReturnKeyType                 = UIReturnKeyType.Next,
                EnablesReturnKeyAutomatically = true
            }, nameof(ViewModel.Username), firstResponder: true);

            AddDivider();

            AddTextField(new UITextField()
            {
                Placeholder     = "Password",
                SecureTextEntry = true,
                ReturnKeyType   = UIReturnKeyType.Go,
                EnablesReturnKeyAutomatically = true
            }, nameof(ViewModel.Password));

            AddSectionDivider();

            _buttonLogin = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _buttonLogin.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { Login(); }).Handler;
            _buttonLogin.SetTitle("Log In", UIControlState.Normal);
            StackView.AddArrangedSubview(_buttonLogin);
            _buttonLogin.StretchWidth(StackView);
            _buttonLogin.SetHeight(44);

            AddDivider(fullWidth: true);

            var forgotViews = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = ColorResources.InputSectionDividers
            };

            {
                var leftSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                forgotViews.Add(leftSpacer);
                var rightSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                forgotViews.Add(rightSpacer);

                var buttonForgotUsername = new UIButton(UIButtonType.System)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HorizontalAlignment = UIControlContentHorizontalAlignment.Right,
                    Font = UIFont.PreferredCaption1
                };
                buttonForgotUsername.TouchUpInside += new WeakEventHandler(delegate { ViewModel.ForgotUsername(); }).Handler;
                buttonForgotUsername.SetTitle("Forgot Username", UIControlState.Normal);
                forgotViews.Add(buttonForgotUsername);
                buttonForgotUsername.StretchHeight(forgotViews);

                var verticalDivider = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    BackgroundColor = UIColor.FromWhiteAlpha(0.7f, 1)
                };
                forgotViews.Add(verticalDivider);
                verticalDivider.StretchHeight(forgotViews, top: 16, bottom: 16);

                var buttonForgotPassword = new UIButton(UIButtonType.System)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HorizontalAlignment = UIControlContentHorizontalAlignment.Left,
                    Font = UIFont.PreferredCaption1
                };
                buttonForgotPassword.TouchUpInside += new WeakEventHandler(delegate { ViewModel.ForgotPassword(); }).Handler;
                buttonForgotPassword.SetTitle("Forgot Password", UIControlState.Normal);
                forgotViews.Add(buttonForgotPassword);
                buttonForgotPassword.StretchHeight(forgotViews);

                forgotViews.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[leftSpacer][forgotUsername]-8-[verticalDivider(1)]-8-[forgotPassword][rightSpacer(==leftSpacer)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                   "forgotUsername", buttonForgotUsername,
                                                                                   "verticalDivider", verticalDivider,
                                                                                   "forgotPassword", buttonForgotPassword,
                                                                                   "leftSpacer", leftSpacer,
                                                                                   "rightSpacer", rightSpacer)));
            }
            StackView.AddArrangedSubview(forgotViews);
            forgotViews.StretchWidth(StackView);
            forgotViews.SetHeight(44);

            ViewModel.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged).Handler;

            base.OnViewModelLoadedOverride();
        }
Пример #29
0
        private void SetupConstraints()
        {
            ScrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            _containerView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                _containerView.WithSameWidth(View),
                _containerView.Height().EqualTo(UIScreen.MainScreen.Bounds.Height)
                );

            ScrollView.AddConstraints(
                _containerView.AtTopOf(ScrollView),
                _containerView.AtLeftOf(ScrollView),
                _containerView.AtRightOf(ScrollView)
                );

            _containerView.AddConstraints(

                _passwordHeader.AtTopOf(_containerView, 8),
                _passwordHeader.AtLeftOf(_containerView, 14),
                _passwordHeader.AtRightOf(_containerView, 14),

                _passwordContainer.Below(_passwordHeader, 8),
                _passwordContainer.AtLeftOf(_containerView),
                _passwordContainer.AtRightOf(_containerView),

                _passwordTopRuler.AtTopOf(_passwordContainer),
                _passwordTopRuler.AtLeftOf(_passwordContainer),
                _passwordTopRuler.AtRightOf(_passwordContainer),
                _passwordTopRuler.Height().EqualTo(1),

                _oldPasswordHeader.Below(_passwordTopRuler, 18),
                _oldPasswordHeader.AtLeftOf(_passwordContainer, 14),
                _oldPasswordHeader.AtRightOf(_passwordContainer, 14),

                _oldPassword.Below(_oldPasswordHeader, 6),
                _oldPassword.AtLeftOf(_passwordContainer, 14),
                _oldPassword.AtRightOf(_passwordContainer, 14),
                _oldPassword.Height().EqualTo(40),

                _newPasswordHeader.Below(_oldPassword, 18),
                _newPasswordHeader.AtLeftOf(_passwordContainer, 14),
                _newPasswordHeader.AtRightOf(_passwordContainer, 14),

                _newPassword.Below(_newPasswordHeader, 6),
                _newPassword.AtLeftOf(_passwordContainer, 14),
                _newPassword.AtRightOf(_passwordContainer, 14),
                _newPassword.Height().EqualTo(40),

                _confirmPasswordHeader.Below(_newPassword, 18),
                _confirmPasswordHeader.AtLeftOf(_passwordContainer, 14),
                _confirmPasswordHeader.AtRightOf(_passwordContainer, 14),

                _confirmPassword.Below(_confirmPasswordHeader, 6),
                _confirmPassword.AtLeftOf(_passwordContainer, 14),
                _confirmPassword.AtRightOf(_passwordContainer, 14),
                _confirmPassword.Height().EqualTo(40),

                _passwordBottomRuler.Below(_confirmPassword, 18),
                _passwordBottomRuler.AtBottomOf(_passwordContainer),
                _passwordBottomRuler.AtLeftOf(_passwordContainer),
                _passwordBottomRuler.AtRightOf(_passwordContainer),
                _passwordBottomRuler.Height().EqualTo(1)
                );
        }
Пример #30
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();
        }
 public static void AddConstraints(this UIView view, params FluentLayout[] fluentLayouts)
 {
     view.AddConstraints(fluentLayouts
                         .SelectMany(fluent => fluent.ToLayoutConstraints())
                         .ToArray());
 }
Пример #32
0
        public override void OnViewModelLoadedOverride()
        {
            // [viewTextContainer]
            // [viewButtons]
            var safeView = BareUISafeView.CreateAndAddTo(View);

            {
                var viewTopSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                safeView.Add(viewTopSpacer);
                viewTopSpacer.StretchWidth(safeView);

                var viewTextContainer = new UIStackView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Axis    = UILayoutConstraintAxis.Vertical,
                    Spacing = 8
                };
                {
                    var labelTitle = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text          = "Power Planner",
                        TextColor     = new UIColor(1, 1),
                        Font          = UIFont.PreferredTitle1,
                        TextAlignment = UITextAlignment.Center
                    };
                    viewTextContainer.AddArrangedSubview(labelTitle);
                    labelTitle.StretchWidth(viewTextContainer);

                    var labelSubtitle = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text          = "The ultimate homework planner",
                        TextColor     = new UIColor(0.9f, 1),
                        Font          = UIFont.PreferredCaption1,
                        TextAlignment = UITextAlignment.Center
                    };
                    viewTextContainer.AddArrangedSubview(labelSubtitle);
                    labelSubtitle.StretchWidth(viewTextContainer);
                }
                safeView.Add(viewTextContainer);
                viewTextContainer.StretchWidth(safeView, left: 16, right: 16);

                var viewLowerSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                safeView.Add(viewLowerSpacer);
                viewLowerSpacer.StretchWidth(safeView);

                var viewButtons = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    var buttonLogin = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Log In");
                    buttonLogin.TranslatesAutoresizingMaskIntoConstraints = false;
                    buttonLogin.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.Login(); }).Handler;
                    viewButtons.Add(buttonLogin);
                    buttonLogin.StretchHeight(viewButtons);

                    var buttonCreateAccount = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Create Account");
                    buttonCreateAccount.TranslatesAutoresizingMaskIntoConstraints = false;
                    buttonCreateAccount.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.CreateAccount(); }).Handler;
                    viewButtons.Add(buttonCreateAccount);
                    buttonCreateAccount.StretchHeight(viewButtons);

                    viewButtons.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:|[buttonLogin(==buttonCreateAccount)]-8-[buttonCreateAccount]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                       "buttonLogin", buttonLogin,
                                                                                       "buttonCreateAccount", buttonCreateAccount)));
                }
                safeView.Add(viewButtons);
                viewButtons.StretchWidth(safeView, left: 16, right: 16);

                safeView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-16-[viewTopSpacer(==viewLowerSpacer)][viewTextContainer][viewLowerSpacer]-16-[viewButtons]-16-|", NSLayoutFormatOptions.AlignAllCenterX, null, new NSDictionary(
                                                                                "viewTextContainer", viewTextContainer,
                                                                                "viewButtons", viewButtons,
                                                                                "viewTopSpacer", viewTopSpacer,
                                                                                "viewLowerSpacer", viewLowerSpacer)));

                var buttonSettings = new UIControl()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    var settingsImage = new UIImageView(UIImage.FromBundle("TabSettings").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate))
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        TintColor   = UIColor.White,
                        ContentMode = UIViewContentMode.ScaleAspectFit
                    };
                    buttonSettings.Add(settingsImage);
                    settingsImage.StretchHeight(buttonSettings, top: 4, bottom: 4);

                    var label = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Font      = UIFont.PreferredCaption1,
                        TextColor = UIColor.White,
                        Text      = "About"
                    };
                    buttonSettings.Add(label);
                    label.StretchHeight(buttonSettings);

                    buttonSettings.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[image(22)]-8-[label]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                      "image", settingsImage,
                                                                                      "label", label));
                }
                safeView.Add(buttonSettings);
                buttonSettings.TouchUpInside += new WeakEventHandler(delegate { OpenAboutPageAsPopup(); }).Handler;
                buttonSettings.PinToTop(safeView, top: UIDevice.CurrentDevice.CheckSystemVersion(11, 0) ? 12 : 28); // We do this comparison since on iOS 11 the safe view adds extra padding
                buttonSettings.PinToLeft(safeView, left: 12);
                buttonSettings.SetHeight(30);
            }

            base.OnViewModelLoadedOverride();
        }
Пример #33
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)
              );
        }
Пример #34
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            var videoContainer = new UIView();

            videoContainer.BackgroundColor = ColorHelper.SystemBackgroundColor;
            View.AddSubview(videoContainer);

            var remoteVideoView = _webRtcClient.RemoteVideoView;

            remoteVideoView.BackgroundColor = UIColor.SystemGrayColor;
            videoContainer.AddSubview(remoteVideoView);

            var localVideoView = _webRtcClient.LocalVideoView;

            localVideoView.BackgroundColor = UIColor.SystemBlueColor;
            videoContainer.AddSubview(localVideoView);

            var controlsContainer = new UIView();

            controlsContainer.BackgroundColor = ColorHelper.SystemBackgroundColor;
            View.AddSubview(controlsContainer);

            var connectButton = new UIButton(UIButtonType.System);

            connectButton.SetTitle("Connect", UIControlState.Normal);
            connectButton.TouchUpInside += ConnectButton_TouchUpInside;
            controlsContainer.AddSubview(connectButton);

            var disconnectButton = new UIButton(UIButtonType.System);

            disconnectButton.SetTitle("Disconnect", UIControlState.Normal);
            disconnectButton.TouchUpInside += DisconnectButton_TouchUpInside;
            controlsContainer.AddSubview(disconnectButton);

            var waveButton = new UIButton(UIButtonType.System);

            waveButton.SetTitle("👋", UIControlState.Normal);
            waveButton.TouchUpInside += SendWaveButton_TouchUpInside;
            controlsContainer.AddSubview(waveButton);

            videoContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            controlsContainer.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            videoContainer.AddConstraints(new[]
            {
                remoteVideoView.WithSameCenterX(videoContainer),
                remoteVideoView.WithSameCenterY(videoContainer),
                remoteVideoView.WithSameHeight(videoContainer),
                remoteVideoView.WithSameWidth(videoContainer),

                localVideoView.WithSameLeft(videoContainer),
                localVideoView.WithSameBottom(videoContainer),
                localVideoView.WithRelativeHeight(videoContainer, 0.25f),
                localVideoView.Width()
                .EqualTo()
                .HeightOf(videoContainer)
                .WithMultiplier(0.25f * 16 / 9f),
            });

            controlsContainer.AddConstraints(new[]
            {
                connectButton.AtLeftOf(controlsContainer, 5f),
                connectButton.WithSameCenterY(controlsContainer),

                waveButton.WithSameCenterX(controlsContainer),
                waveButton.WithSameCenterY(controlsContainer),

                disconnectButton.AtRightOf(controlsContainer, 5f),
                disconnectButton.WithSameCenterY(controlsContainer),
            });

            View.AddConstraints(new[]
            {
                remoteVideoView.WithSameTop(View),
                remoteVideoView.WithSameLeft(View),
                remoteVideoView.WithSameRight(View),
                remoteVideoView.WithSameWidth(View),
                remoteVideoView.Above(controlsContainer),

                controlsContainer.WithSameBottom(View),
                controlsContainer.WithSameWidth(View),
                controlsContainer.WithRelativeHeight(View, 0.20f),
            });

            DispatchQueue.MainQueue.DispatchAsync(async() =>
            {
                var cameraStatus = await Permissions.RequestAsync <Permissions.Camera>();
                var micStatus    = await Permissions.RequestAsync <Permissions.Microphone>();

                _webRtcClient.SetupMediaTracks();

                var ipAddrField = default(UITextField);
                var portField   = default(UITextField);

                var alertVc = UIAlertController.Create("Socket Address", null, UIAlertControllerStyle.Alert);
                alertVc.AddTextField((tf) =>
                {
                    ipAddrField    = tf;
                    tf.Placeholder = "IP Address";
                    tf.Text        = "192.168.1.119";
                });
                alertVc.AddTextField((tf) =>
                {
                    portField      = tf;
                    tf.Placeholder = "Port";
                    tf.Text        = "8080";
                });

                alertVc.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (a) =>
                {
                    var ip   = ipAddrField.Text;
                    var port = portField.Text;
                    var url  = new NSUrl($"ws://{ip}:{port}");

                    _socket = new WebSocket(url);
                    _socket.ReceivedMessage += SocketReceiveMessage;
                    _socket.Open();
                }));

                PresentViewController(alertVc, true, null);
            });
        }
        public override void LoadView ()
        {
            var scrollView = new UIScrollView ().Apply (Style.Screen);

            scrollView.Add (wrapper = new UIView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            });

            wrapper.Add (startStopView = new StartStopView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
                StartTime = model.StartTime,
                StopTime = model.StopTime,
            }.Apply (BindStartStopView));
            startStopView.SelectedChanged += OnStartStopViewSelectedChanged;

            wrapper.Add (datePicker = new UIDatePicker () {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Hidden = DatePickerHidden,
                Alpha = 0,
            }.Apply (Style.EditTimeEntry.DatePicker).Apply (BindDatePicker));
            datePicker.ValueChanged += OnDatePickerValueChanged;

            wrapper.Add (projectButton = new ProjectClientTaskButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (BindProjectButton));
            projectButton.TouchUpInside += OnProjectButtonTouchUpInside;

            wrapper.Add (descriptionTextField = new TextField () {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AttributedPlaceholder = new NSAttributedString (
                    "EditEntryDesciptionTimerHint".Tr (),
                    foregroundColor: Color.Gray
                ),
                ShouldReturn = (tf) => tf.ResignFirstResponder (),
            }.Apply (Style.EditTimeEntry.DescriptionField).Apply (BindDescriptionField));
            descriptionTextField.EditingChanged += OnDescriptionFieldEditingChanged;
            descriptionTextField.EditingDidEnd += (s, e) => CommitDescriptionChanges ();

            wrapper.Add (tagsButton = new UIButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.EditTimeEntry.TagsButton).Apply (BindTagsButton));
            tagsButton.TouchUpInside += OnTagsButtonTouchUpInside;

            wrapper.Add (billableSwitch = new LabelSwitchView () {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text = "EditEntryBillable".Tr (),
            }.Apply (Style.EditTimeEntry.BillableContainer).Apply (BindBillableSwitch));
            billableSwitch.Label.Apply (Style.EditTimeEntry.BillableLabel);
            billableSwitch.Switch.ValueChanged += OnBillableSwitchValueChanged;

            wrapper.Add (deleteButton = new UIButton () {
                TranslatesAutoresizingMaskIntoConstraints = false,
            }.Apply (Style.EditTimeEntry.DeleteButton));
            deleteButton.SetTitle ("EditEntryDelete".Tr (), UIControlState.Normal);
            deleteButton.TouchUpInside += OnDeleteButtonTouchUpInside;

            wrapper.AddConstraints (VerticalLinearLayout (wrapper));
            scrollView.AddConstraints (
                wrapper.AtTopOf (scrollView),
                wrapper.AtBottomOf (scrollView),
                wrapper.AtLeftOf (scrollView),
                wrapper.AtRightOf (scrollView),
                wrapper.WithSameWidth (scrollView),
                wrapper.Height ().GreaterThanOrEqualTo ().HeightOf (scrollView).Minus (64f),
                null
            );

            View = scrollView;
        }
Пример #36
0
        protected override void InitializeObjects()
        {
            base.InitializeObjects();

            var topView           = new UIView();
            var scrollView        = new UIScrollView();
            var topTextRowView    = new UIView();
            var centerTextRowView = new UIView();
            var bottomTextRowView = new UIView();
            var bottomView        = new UIView();
            var profileNavigationBarBackground = new UIImageView(UIImage.FromBundle(@"Images/navigation_bar_background.png"));

            backHomeView = UIButton.FromType(UIButtonType.Custom);
            backHomeView.SetImage(UIImage.FromFile(@"Images/ic_back.png"), UIControlState.Normal);
            nameOfPageLabel           = LabelInformationAboutPage(UIColor.White, "Profile", UIFont.BoldSystemFontOfSize(16f));
            informationAboutPageLabel = LabelInformationAboutPage(UIColor.FromRGB(29, 157, 189), "Please, Enter Your Personal Information.", UIFont.FromName("Helvetica", 14f));

            // Hide navigation bar
            NavigationController.SetNavigationBarHidden(true, false);
            View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile(@"Images/tab_background.png").Scale(View.Frame.Size));
            profileNavigationBarBackground.Frame = new CGRect(10, 10, profileNavigationBarBackground.Image.CGImage.Width, profileNavigationBarBackground.Image.CGImage.Height);

            var labelView = new UIView();

            labelView.AddIfNotNull(nameOfPageLabel, informationAboutPageLabel);
            labelView.AddConstraints(
                nameOfPageLabel.AtTopOf(labelView, 20),
                nameOfPageLabel.WithSameCenterX(labelView),
                nameOfPageLabel.WithSameCenterY(labelView),
                nameOfPageLabel.WithSameWidth(labelView),
                nameOfPageLabel.WithRelativeHeight(labelView, 0.3f),

                informationAboutPageLabel.Below(nameOfPageLabel, 5),
                informationAboutPageLabel.WithSameWidth(labelView),
                informationAboutPageLabel.WithSameCenterX(labelView),
                informationAboutPageLabel.WithRelativeHeight(labelView, 0.3f)
                );

            topView.AddIfNotNull(profileNavigationBarBackground, backHomeView, labelView);
            topView.AddConstraints(
                profileNavigationBarBackground.WithSameWidth(topView),
                profileNavigationBarBackground.WithSameHeight(topView),
                profileNavigationBarBackground.AtTopOf(topView),

                backHomeView.WithSameCenterY(topView),
                backHomeView.AtLeftOf(topView, 20),
                backHomeView.WithRelativeWidth(topView, 0.1f),
                backHomeView.WithRelativeHeight(topView, 0.2f),

                labelView.WithSameCenterX(topView),
                labelView.WithSameCenterY(topView),
                labelView.WithRelativeWidth(topView, 0.8f),
                labelView.WithRelativeHeight(topView, 0.6f)
                );

            firstNameTextField = TextFieldInitializer("First Name");
            lastNameTextField  = TextFieldInitializer("Last Name");
            emailTextField     = TextFieldInitializer("Email");
            addressTextField   = TextFieldInitializer("Address");
            cityTextField      = TextFieldInitializer("City");
            zipCodeTextField   = TextFieldInitializer("Zip Code");

            stateTextField        = TextFieldInitializer("State");
            statesPicker          = new UIPickerView();
            statesPickerViewModel = new MvxPickerViewModel(statesPicker);
            statesPicker.Model    = statesPickerViewModel;
            statesPicker.ShowSelectionIndicator = true;
            statesPicker.BackgroundColor        = UIColor.White;


            addLicenseButton    = ProfileButtonManager.ButtonInitiaziler("Add License Plate", UIImage.FromFile(@"Images/ProfileView/ic_license.png"));
            addCreditCardButton = ProfileButtonManager.ButtonInitiaziler("Add Credit Card", UIImage.FromFile(@"Images/ProfileView/ic_card.png"));

            topTextRowView.AddIfNotNull(firstNameTextField, lastNameTextField);
            topTextRowView.AddConstraints(
                firstNameTextField.AtTopOf(topTextRowView),
                firstNameTextField.AtLeftOf(topTextRowView),
                firstNameTextField.WithRelativeWidth(topTextRowView, 0.475f),
                firstNameTextField.WithSameHeight(topTextRowView),

                lastNameTextField.AtTopOf(topTextRowView),
                lastNameTextField.AtRightOf(topTextRowView),
                lastNameTextField.WithRelativeWidth(topTextRowView, 0.475f),
                lastNameTextField.WithSameHeight(topTextRowView)
                );

            centerTextRowView.AddIfNotNull(emailTextField, addressTextField, cityTextField);
            centerTextRowView.AddConstraints(
                emailTextField.AtTopOf(centerTextRowView),
                emailTextField.WithSameCenterX(centerTextRowView),
                emailTextField.WithSameWidth(centerTextRowView),
                emailTextField.WithRelativeHeight(centerTextRowView, 0.3f),

                addressTextField.Below(emailTextField, 10),
                addressTextField.WithSameCenterX(centerTextRowView),
                addressTextField.WithSameWidth(centerTextRowView),
                addressTextField.WithRelativeHeight(centerTextRowView, 0.3f),

                cityTextField.Below(addressTextField, 10),
                cityTextField.WithSameCenterX(centerTextRowView),
                cityTextField.WithSameWidth(centerTextRowView),
                cityTextField.WithRelativeHeight(centerTextRowView, 0.3f)
                );

            bottomTextRowView.AddIfNotNull(stateTextField, zipCodeTextField);
            bottomTextRowView.AddConstraints(
                stateTextField.AtTopOf(bottomTextRowView),
                stateTextField.AtLeftOf(bottomTextRowView),
                stateTextField.WithRelativeWidth(bottomTextRowView, 0.475f),
                stateTextField.WithSameHeight(bottomTextRowView),

                zipCodeTextField.AtTopOf(bottomTextRowView),
                zipCodeTextField.AtRightOf(bottomTextRowView),
                zipCodeTextField.WithRelativeWidth(bottomTextRowView, 0.475f),
                zipCodeTextField.WithSameHeight(bottomTextRowView)
                );

            bottomView.AddIfNotNull(addLicenseButton, addCreditCardButton);
            bottomView.AddConstraints(
                addLicenseButton.AtTopOf(bottomView),
                addLicenseButton.WithSameCenterX(bottomView),
                addLicenseButton.WithSameWidth(bottomView),
                addLicenseButton.WithRelativeHeight(bottomView, 0.4f),

                addCreditCardButton.Below(addLicenseButton, 10),
                addCreditCardButton.WithSameCenterX(bottomView),
                addCreditCardButton.WithSameWidth(bottomView),
                addCreditCardButton.WithRelativeHeight(bottomView, 0.4f)
                );

            scrollView.AddIfNotNull(topTextRowView, centerTextRowView, bottomTextRowView, bottomView);
            scrollView.AddConstraints(
                topTextRowView.AtTopOf(scrollView, 30),
                topTextRowView.WithSameWidth(scrollView),
                topTextRowView.WithSameCenterX(scrollView),
                topTextRowView.WithRelativeHeight(scrollView, 0.12f),

                centerTextRowView.Below(topTextRowView, 10),
                centerTextRowView.WithSameWidth(scrollView),
                centerTextRowView.AtLeftOf(scrollView),
                centerTextRowView.AtRightOf(scrollView),
                centerTextRowView.WithRelativeHeight(scrollView, 0.4f),

                bottomTextRowView.Below(centerTextRowView, 10),
                bottomTextRowView.WithSameWidth(scrollView),
                bottomTextRowView.WithSameCenterX(scrollView),
                bottomTextRowView.WithRelativeHeight(scrollView, 0.12f),

                bottomView.Below(bottomTextRowView, 10),
                bottomView.WithSameWidth(scrollView),
                bottomView.AtLeftOf(scrollView),
                bottomView.AtRightOf(scrollView),
                bottomView.AtBottomOf(scrollView, 100),
                bottomView.WithRelativeHeight(scrollView, 0.27f)
                );

            View.AddIfNotNull(topView, scrollView);
            View.AddConstraints(
                topView.AtTopOf(View),
                topView.WithSameWidth(View),
                topView.WithRelativeHeight(View, 0.2f),

                scrollView.Below(topView, 30),
                scrollView.AtLeftOf(View, 30),
                scrollView.AtRightOf(View, 30),
                scrollView.WithRelativeHeight(View, 0.8f)
                );
            EnableNextKeyForTextFields(firstNameTextField.TextFieldWithValidator.TextField, lastNameTextField.TextFieldWithValidator.TextField, emailTextField.TextFieldWithValidator.TextField,
                                       addressTextField.TextFieldWithValidator.TextField, cityTextField.TextFieldWithValidator.TextField, stateTextField.TextFieldWithValidator.TextField,
                                       zipCodeTextField.TextFieldWithValidator.TextField);
        }
Пример #37
0
        public static void AddLayoutConstraints(this UIView view, Expression <Func <bool> > constraints)
        {
            var cs = ConstrainLayout(view, constraints, UILayoutPriority.Required);

            view.AddConstraints(cs);
        }
        private void UpdateLayoutMode()
        {
            // Clean up from previous state
            if (_prevLayoutMode != null)
            {
                // If for some reason state didn't change, do nothing
                if (_prevLayoutMode.Value == ViewModel.LayoutMode)
                {
                    return;
                }

                // On iOS we make these the same, so ignore changes between them
                if ((_prevLayoutMode.Value == ScheduleViewModel.LayoutModes.FullEditing || _prevLayoutMode.Value == ScheduleViewModel.LayoutModes.SplitEditing) &&
                    (ViewModel.LayoutMode == ScheduleViewModel.LayoutModes.FullEditing || ViewModel.LayoutMode == ScheduleViewModel.LayoutModes.SplitEditing))
                {
                    return;
                }

                switch (_prevLayoutMode.Value)
                {
                case ScheduleViewModel.LayoutModes.SplitEditing:
                case ScheduleViewModel.LayoutModes.FullEditing:
                    _editingView.RemoveFromSuperview();
                    break;

                case ScheduleViewModel.LayoutModes.Welcome:
                    _welcomeView.RemoveFromSuperview();
                    break;
                }
            }

            _prevLayoutMode = ViewModel.LayoutMode;

            if (ViewModel.LayoutMode == ScheduleViewModel.LayoutModes.Normal)
            {
                NavItem.RightBarButtonItem = _editButton;
                Title = "Schedule";
            }
            else if (ViewModel.LayoutMode == ScheduleViewModel.LayoutModes.SplitEditing ||
                     ViewModel.LayoutMode == ScheduleViewModel.LayoutModes.FullEditing)
            {
                if (_editingView == null)
                {
                    _editingView = new UIScrollView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        ShowsHorizontalScrollIndicator            = false,
                        BackgroundColor = UIColor.White
                    };
                    var actualEditingView = new UIScheduleEditingView(ViewModel);
                    _editingView.Add(actualEditingView);
                    actualEditingView.ConfigureForVerticalScrolling(_editingView, top: 16, bottom: 16);

                    MainScreenViewController.ListenToTabBarHeightChanged(ref _tabBarHeightListener, delegate
                    {
                        _editingView.ContentInset = new UIEdgeInsets(0, 0, MainScreenViewController.TAB_BAR_HEIGHT, 0);
                    });
                }

                ContentView.Add(_editingView);
                _editingView.StretchWidthAndHeight(ContentView);

                NavItem.RightBarButtonItem = _doneButton;
                Title = "Edit Schedule";
            }
            else
            {
                if (_welcomeView == null)
                {
                    _welcomeView = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        BackgroundColor = UIColor.White
                    };
                    {
                        // New user
                        var topSpacer = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _welcomeView.Add(topSpacer);
                        topSpacer.StretchWidth(_welcomeView);

                        var bottomSpacer = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _welcomeView.Add(bottomSpacer);
                        bottomSpacer.StretchWidth(_welcomeView);

                        var title = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text = "Welcome to Power Planner!",
                            AdjustsFontSizeToFitWidth = true,
                            Font          = UIFont.PreferredTitle3,
                            TextAlignment = UITextAlignment.Center
                        };
                        _welcomeView.Add(title);
                        title.StretchWidth(_welcomeView, left: 16, right: 16);

                        var subtitle = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text          = "To get started, add your classes and schedule!",
                            Lines         = 0,
                            Font          = UIFont.PreferredCaption1,
                            TextAlignment = UITextAlignment.Center
                        };
                        _welcomeView.Add(subtitle);
                        subtitle.StretchWidth(_welcomeView, left: 16, right: 16);

                        var buttonAddClass = new UIButton(UIButtonType.System)
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        buttonAddClass.SetTitle("Add Class", UIControlState.Normal);
                        buttonAddClass.SetTitleColor(new UIColor(1, 1), UIControlState.Normal);
                        buttonAddClass.BackgroundColor = ColorResources.PowerPlannerAccentBlue;
                        buttonAddClass.TouchUpInside  += new WeakEventHandler <EventArgs>(delegate { ViewModel.AddClass(); }).Handler;
                        _welcomeView.Add(buttonAddClass);
                        buttonAddClass.StretchWidth(_welcomeView, left: 16, right: 16);
                        buttonAddClass.SetMaxWidth(250);

                        _welcomeView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[topSpacer(==bottomSpacer)][title]-8-[subtitle]-16-[buttonAddClass][bottomSpacer]-32-|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                        "topSpacer", topSpacer,
                                                                                        "title", title,
                                                                                        "subtitle", subtitle,
                                                                                        "buttonAddClass", buttonAddClass,
                                                                                        "bottomSpacer", bottomSpacer));

                        // Returning user (we add on top so it remains clickable
                        if (ViewModel.IsReturningUserVisible)
                        {
                            var returningUser = new UILabel()
                            {
                                TranslatesAutoresizingMaskIntoConstraints = false,
                                Text = PowerPlannerResources.GetString("SchedulePage_TextBlockReturningUser.Text"),
                                Font = UIFont.PreferredCaption1
                            };
                            _welcomeView.Add(returningUser);
                            returningUser.StretchWidth(_welcomeView, left: 16, right: 16);

                            var buttonLogIn = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Log In");
                            buttonLogIn.TranslatesAutoresizingMaskIntoConstraints = false;
                            buttonLogIn.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.LogIn(); }).Handler;
                            _welcomeView.Add(buttonLogIn);
                            buttonLogIn.PinToLeft(_welcomeView, left: 16);

                            _welcomeView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-16-[returningUser]-8-[buttonLogIn]", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                            "returningUser", returningUser,
                                                                                            "buttonLogIn", buttonLogIn));
                        }
                    }
                }

                // Display the welcome view on top of everything, including on top of the nav bar
                ContentView.Add(_welcomeView);
                _welcomeView.StretchWidth(ContentView);

                NavItem.RightBarButtonItem = null;
                Title = "Edit Schedule";

                MainScreenViewController.ListenToTabBarHeightChanged(ref _welcomeViewTabBarHeightListener, delegate
                {
                    _welcomeView.StretchHeight(ContentView, top: 0, bottom: (float)MainScreenViewController.TAB_BAR_HEIGHT);
                });
            }
        }
Пример #39
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //base.StyleNavigationBar();

            View.BackgroundColor = UIColor.White;

            Title = "Login";

            var mainView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            Add(mainView);

            _usernameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "Username",
            };

            _passwordTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder     = "Password",
                SecureTextEntry = true,
            };

            var errorLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Font          = UIFont.FromName("Helvetica", 20f),
                TextColor     = iOSColorPalette.Red,
            };

            _loginButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font            = UIFont.FromName("Alfa Slab One", 20f),
                BackgroundColor = iOSColorPalette.Blue
            };
            _loginButton.SetTitle("Login", UIControlState.Normal);
            _loginButton.SetTitleColor(UIColor.White, UIControlState.Normal);

            var activityIndicatorView = new CustomIndicatorView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Color  = UIColor.Black,
                Hidden = true,
            };

            mainView.Add(_usernameTextField);
            mainView.Add(_passwordTextField);
            mainView.Add(errorLabel);
            mainView.Add(_loginButton);
            mainView.Add(activityIndicatorView);

            var views = new DictionaryViews()
            {
                { "mainView", mainView },
            };

            var mainViews = new DictionaryViews()
            {
                { "usernameTextField", _usernameTextField },
                { "passwordTextField", _passwordTextField },
                { "errorLabel", errorLabel },
                { "loginButton", _loginButton },
                { "activityIndicatorView", activityIndicatorView }
            };

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[mainView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mainView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            mainView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-140-[usernameTextField]-40-[passwordTextField]-40-[loginButton]-40-[errorLabel]-40-[activityIndicatorView(60)]", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[usernameTextField(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[passwordTextField(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[loginButton(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[errorLabel(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[activityIndicatorView(60)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(new[] { NSLayoutConstraint.Create(_usernameTextField, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(_passwordTextField, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(_loginButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(errorLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(activityIndicatorView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .ToArray());

            // create the binding set
            //var set = this.CreateBindingSet<LoginPage, LoginPageViewModel>();
            //set.Bind(usernameTextField).To(vm => vm.Username);
            //set.Bind(passwordTextField).To(vm => vm.Password);
            //set.Bind(_loginButton).To(vm => vm.LoginCommand);
            //set.Bind(errorLabel).To(vm => vm.ErrorMessage);
            //set.Bind(errorLabel).For("Hidden").To(vm => vm.IsError).WithConversion("NotValueConverter", false);
            //set.Bind(activityIndicatorView).For("IsRunning").To(vm => vm.IsLoading);
            //set.Apply();

            this.WhenActivated(d =>
            {
                this.Bind(ViewModel, x => x.Username, x => x._usernameTextField.Text);
                this.Bind(ViewModel, x => x.Password, x => x._passwordTextField.Text);

                this.BindCommand(ViewModel, x => x.LoginCommand, x => x._loginButton);
            });
        }
		public override void LoadView ()
		{
			UIView view = new UIView ();

			UIButton newButton = UIButton.FromType (UIButtonType.System);
			newButton.TranslatesAutoresizingMaskIntoConstraints = false;
			newButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
			newButton.SetTitle ("New Game", UIControlState.Normal);
			newButton.TitleLabel.Font = UIFont.PreferredBody;
			newButton.TouchUpInside += newGame;
			view.AddSubview (newButton);

			UIButton pauseButton = UIButton.FromType (UIButtonType.System);
			pauseButton.TranslatesAutoresizingMaskIntoConstraints = false;
			pauseButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
			pauseButton.SetTitle ("Pause", UIControlState.Normal);
			pauseButton.TitleLabel.Font = UIFont.PreferredBody;
			pauseButton.TouchUpInside += togglePause;
			view.AddSubview (pauseButton);

			gameView = new TTTGameView () {
				ImageForPlayer = ImageForPlayer,
				ColorForPlayer = ColorForPlayer,
				CanSelect = CanSelect,
				DidSelect = DidSelect,
				TranslatesAutoresizingMaskIntoConstraints = false,
				Game = Profile.CurrentGame
			};
			view.AddSubview (gameView);

			float topHeight = UIApplication.SharedApplication.StatusBarFrame.Size.Height;
			UITabBar tabBar = TabBarController.TabBar;
			float bottomHeight = tabBar.Translucent ? tabBar.Frame.Size.Height : 0;
			NSDictionary metrics = NSDictionary.FromObjectsAndKeys (
				new NSNumber[] { new NSNumber (topHeight + ControllerMargin),
				new NSNumber (bottomHeight + ControllerMargin),
				new NSNumber (ControllerMargin)
			},
				new NSString[] { new NSString ("topHeight"), new NSString ("bottomHeight"),
				new NSString ("margin")
			}
			);
			NSDictionary bindings = NSDictionary.FromObjectsAndKeys (
				new NSObject[] { newButton, pauseButton, gameView },
				new NSString [] { 
				new NSString ("newButton"), new NSString ("pauseButton"),
				new NSString ("gameView")
			}
			);
			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-margin-[gameView]-margin-|", (NSLayoutFormatOptions)0,
				metrics, bindings
			));
			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"|-margin-[pauseButton(==newButton)]-[newButton]-margin-|",
				(NSLayoutFormatOptions)0, metrics, bindings
			));
			view.AddConstraints (NSLayoutConstraint.FromVisualFormat (
				"V:|-topHeight-[gameView]-margin-[newButton]-bottomHeight-|",
				(NSLayoutFormatOptions)0, metrics, bindings
			));
			view.AddConstraint (NSLayoutConstraint.Create (pauseButton,
			                                               NSLayoutAttribute.Baseline,
			                                               NSLayoutRelation.Equal,
			                                               newButton,
			                                               NSLayoutAttribute.Baseline,
			                                               1f,
			                                               0f));

			View = view;
		}
        MKAnnotationView GetViewForAnnotation(MKMapView mapView, IMKAnnotation annotation)
        {
            MKAnnotationView annotationView = null;

              if (annotation is MKUserLocation)
            return null;

              var anno = annotation as MKPointAnnotation;
              var customPin = GetCustomPin(anno);
              if (customPin == null)
              {
            throw new Exception("Custom pin not found");
              }

              annotationView = mapView.DequeueReusableAnnotation(customPin.Id);
              if (annotationView == null)
              {
            // RFP:: create the cutom annotation view setting its properties to match the CustomPin on the map
            annotationView = new CustomMKPinAnnotationView(annotation, customPin.Id);
            ((CustomMKPinAnnotationView)annotationView).Id = customPin.Id;
            ((CustomMKPinAnnotationView)annotationView).FirstLine = customPin.FirstLine;
            ((CustomMKPinAnnotationView)annotationView).SecondLine = customPin.SecondLine;
            ((CustomMKPinAnnotationView)annotationView).ThirdLine = customPin.ThirdLine;
            ((CustomMKPinAnnotationView)annotationView).FourthLine = customPin.FourthLine;

            // RFP:: create a new view to be used for annotationView.DetailCalloutAccessoryView
            var newCalloutView = new UIView();
            newCalloutView.TranslatesAutoresizingMaskIntoConstraints = false; // we are using autolayout, not struts

            // RFP:: create and add 3 new UILabels. The normal secondary line on the pin will be replaced by replacing the DetailCalloutAccessoryView, so in total there will be 4 lines
            var label1 = CreateBasicLabel();
            var label2 = CreateBasicLabel();
            var label3 = CreateBasicLabel();
            newCalloutView.Add(label1);
            newCalloutView.Add(label2);
            newCalloutView.Add(label3);

            // RFP:: measure how big a text field is and calculate the height needed for the callout
            label1.Text = "TEMP"; // used to measure height
            var heightOfLabel = label1.GetSizeRequest(double.PositiveInfinity, double.PositiveInfinity).Request.Height;
            var heightOfCallout = (float)(heightOfLabel * 3 + CALLOUT_Y_OFFSET); // the height of the callout is 3 times the height of the label subtracting height used to shift callout view up to be under main text

            // RFP:: setup the constraints for the new callout view
            newCalloutView.AddConstraints(new[]
            {
              NSLayoutConstraint.Create(newCalloutView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, heightOfCallout),
            });

            // RFP:: setup the constraints for each of the new labels
            newCalloutView.AddConstraints(new[]
            {
              NSLayoutConstraint.Create(label1, NSLayoutAttribute.Top, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Top, 1, CALLOUT_Y_OFFSET), // offsetting up X pixels to be right under primary text line (otherwise there is a gap)
              NSLayoutConstraint.Create(label1, NSLayoutAttribute.Left, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Left, 1, 0), // setting label to match parents left edge
              NSLayoutConstraint.Create(label1, NSLayoutAttribute.Right, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Right, 1, 0), // setting label to match parents right edge
            });
            newCalloutView.AddConstraints(new[]
            {
              NSLayoutConstraint.Create(label2, NSLayoutAttribute.Top, NSLayoutRelation.Equal, label1, NSLayoutAttribute.Bottom, 1, 0), // setting top of label to be at bottom of previous label
              NSLayoutConstraint.Create(label2, NSLayoutAttribute.Left, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Left, 1, 0), // setting label to match parents left edge
              NSLayoutConstraint.Create(label2, NSLayoutAttribute.Right, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Right, 1, 0), // setting label to match parents right edge
            });
            newCalloutView.AddConstraints(new[]
            {
              NSLayoutConstraint.Create(label3, NSLayoutAttribute.Top, NSLayoutRelation.Equal, label2, NSLayoutAttribute.Bottom, 1, 0), // setting top of label to be at bottom of previous label
              NSLayoutConstraint.Create(label3, NSLayoutAttribute.Left, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Left, 1, 0), // setting label to match parents left edge
              NSLayoutConstraint.Create(label3, NSLayoutAttribute.Right, NSLayoutRelation.Equal, newCalloutView, NSLayoutAttribute.Right, 1, 0), // setting label to match parents right edge
            });

            // RFP:: replace the DetailCalloutAccessoryView with our new view
            annotationView.DetailCalloutAccessoryView = newCalloutView;
              }

              // RFP:: Get a handle on the fields in the callout to update their text values (both if newly created or reused per DequeueReusableAnnotation)
              var textField1 = annotationView.DetailCalloutAccessoryView.Subviews[0] as UILabel;
              var textField2 = annotationView.DetailCalloutAccessoryView.Subviews[1] as UILabel;
              var textField3 = annotationView.DetailCalloutAccessoryView.Subviews[2] as UILabel;
              textField1.Text = customPin.SecondLine;
              textField2.Text = customPin.ThirdLine;
              textField3.Text = customPin.FourthLine;

              // RFP:: make sure the callout is shown
              annotationView.CanShowCallout = true;

              return annotationView;
        }
Пример #42
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,
            }.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 ();
        }
        public override void LoadView()
        {
            UIView view = new UIView();

            UIButton newButton = UIButton.FromType(UIButtonType.System);

            newButton.TranslatesAutoresizingMaskIntoConstraints = false;
            newButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            newButton.SetTitle("New Game", UIControlState.Normal);
            newButton.TitleLabel.Font = UIFont.PreferredBody;
            newButton.TouchUpInside  += newGame;
            view.AddSubview(newButton);

            UIButton pauseButton = UIButton.FromType(UIButtonType.System);

            pauseButton.TranslatesAutoresizingMaskIntoConstraints = false;
            pauseButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            pauseButton.SetTitle("Pause", UIControlState.Normal);
            pauseButton.TitleLabel.Font = UIFont.PreferredBody;
            pauseButton.TouchUpInside  += togglePause;
            view.AddSubview(pauseButton);

            gameView = new TTTGameView()
            {
                ImageForPlayer = ImageForPlayer,
                ColorForPlayer = ColorForPlayer,
                CanSelect      = CanSelect,
                DidSelect      = DidSelect,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Game = Profile.CurrentGame
            };
            view.AddSubview(gameView);

            float    topHeight    = UIApplication.SharedApplication.StatusBarFrame.Size.Height;
            UITabBar tabBar       = TabBarController.TabBar;
            float    bottomHeight = tabBar.Translucent ? tabBar.Frame.Size.Height : 0;

            var mTopHeight    = new NSNumber(topHeight + ControllerMargin);
            var mBottomHeight = new NSNumber(bottomHeight + ControllerMargin);
            var mMargin       = new NSNumber(ControllerMargin);

            view.AddConstraints(NSLayoutConstraint.FromVisualFormat("|-margin-[gameView]-margin-|",
                                                                    (NSLayoutFormatOptions)0,
                                                                    "margin", mMargin,
                                                                    "gameView", gameView));
            view.AddConstraints(NSLayoutConstraint.FromVisualFormat("|-margin-[pauseButton(==newButton)]-[newButton]-margin-|",
                                                                    (NSLayoutFormatOptions)0,
                                                                    "margin", mMargin,
                                                                    "pauseButton", pauseButton,
                                                                    "newButton", newButton));
            view.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-topHeight-[gameView]-margin-[newButton]-bottomHeight-|",
                                                                    (NSLayoutFormatOptions)0,
                                                                    "topHeight", mTopHeight,
                                                                    "gameView", gameView,
                                                                    "margin", mMargin,
                                                                    "newButton", newButton,
                                                                    "bottomHeight", mBottomHeight));
            view.AddConstraint(NSLayoutConstraint.Create(
                                   pauseButton, NSLayoutAttribute.Baseline,
                                   NSLayoutRelation.Equal,
                                   newButton, NSLayoutAttribute.Baseline,
                                   1f, 0f));

            View = view;
        }
 public static void AddConstraints(this UIView view, IEnumerable <FluentLayout> fluentLayouts)
 {
     view.AddConstraints(fluentLayouts
                         .SelectMany(fluent => fluent.ToLayoutConstraints())
                         .ToArray());
 }
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            //
             m_navigationTitle = @"Audio Recorder";

            //
            this.View.TintColor = NormalTintColor;
            mMusicFlowView.BackgroundColor = this.View.BackgroundColor;
            mMusicFlowView.IdleAmplitude = 0;

            //Unique recording URL
            var fileName = NSProcessInfo.ProcessInfo.GloballyUniqueString;

            var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
            var tmp = Path.Combine (documents, "..", "tmp");

            m_recordingFilePath = Path.Combine(tmp,String.Format("{0}.m4a",fileName));
             {

                m_flexItem1 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace,null,null);
                m_flexItem2 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace,null,null);

                var img = UIImage.FromBundle("audio_record");

                m_recordButton = new UIBarButtonItem(img,UIBarButtonItemStyle.Plain,RecordingButtonAction);
                m_playButton = new UIBarButtonItem(UIBarButtonSystemItem.Play,PlayAction);
                m_pauseButton = new UIBarButtonItem(UIBarButtonSystemItem.Pause,PauseAction);
                m_trashButton = new UIBarButtonItem(UIBarButtonSystemItem.Trash,DeleteAction);

                this.SetToolbarItems (new UIBarButtonItem[]{ m_playButton, m_flexItem1, m_recordButton, m_flexItem2, m_trashButton}, false);

                 m_playButton.Enabled = false;
                 m_trashButton.Enabled = false;
             }

             // Define the recorder setting
             {
                var audioSettings = new AudioSettings () {
                    Format = AudioFormatType.MPEG4AAC,
                    SampleRate = 44100.0f,
                    NumberChannels = 2,
                };

                NSError err = null;

                m_audioRecorder = AVAudioRecorder.Create (NSUrl.FromFilename (m_recordingFilePath), audioSettings,out err);

                // Initiate and prepare the recorder
                m_audioRecorder.WeakDelegate = this;
                m_audioRecorder.MeteringEnabled = true;

                mMusicFlowView.PrimaryWaveLineWidth = 3.0f;
                mMusicFlowView.SecondaryWaveLineWidth = 1.0f;
             }

             //Navigation Bar Settings
             {
                this.NavigationItem.Title = @"Audio Recorder";
                m_cancelButton = new UIBarButtonItem(UIBarButtonSystemItem.Cancel,CancelAction);
                this.NavigationItem.LeftBarButtonItem = m_cancelButton;

                m_doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, DoneAction);
             }

             //Player Duration View
            {
                m_viewPlayerDuration = new UIView ();
                m_viewPlayerDuration.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                m_viewPlayerDuration.BackgroundColor = UIColor.Clear;

                m_labelCurrentTime = new UILabel ();
                m_labelCurrentTime.Text = NSStringExtensions.TimeStringForTimeInterval (0);
                m_labelCurrentTime.Font =  UIFont.BoldSystemFontOfSize(14.0f);
                m_labelCurrentTime.TextColor = NormalTintColor;
                m_labelCurrentTime.TranslatesAutoresizingMaskIntoConstraints = false;

                m_playerSlider = new UISlider(new CGRect(0, 0, this.View.Bounds.Size.Width, 64));
                 m_playerSlider.MinimumTrackTintColor = PlayingTintColor;
                 m_playerSlider.Value = 0;

                m_playerSlider.TouchDown += SliderStart;
                m_playerSlider.ValueChanged += SliderMoved;
                m_playerSlider.TouchUpInside += SliderEnd;
                m_playerSlider.TouchUpOutside += SliderEnd;
                 m_playerSlider.TranslatesAutoresizingMaskIntoConstraints = false;

                m_labelRemainingTime = new UILabel();
                m_labelCurrentTime.Text = NSStringExtensions.TimeStringForTimeInterval (0);
                 m_labelRemainingTime.UserInteractionEnabled = true;
                m_labelRemainingTime.AddGestureRecognizer (new UITapGestureRecognizer(TapRecognizer));
                m_labelRemainingTime.Font = m_labelCurrentTime.Font;
                 m_labelRemainingTime.TextColor = m_labelCurrentTime.TextColor;
                 m_labelRemainingTime.TranslatesAutoresizingMaskIntoConstraints = false;

                m_viewPlayerDuration.Add (m_labelCurrentTime);
                m_viewPlayerDuration.Add (m_playerSlider);
                m_viewPlayerDuration.Add (m_labelRemainingTime);

                NSLayoutConstraint constraintCurrentTimeLeading = NSLayoutConstraint.Create (m_labelCurrentTime,NSLayoutAttribute.Leading,NSLayoutRelation.Equal,m_viewPlayerDuration,NSLayoutAttribute.Leading,1.0f, 10.0f);
                NSLayoutConstraint constraintCurrentTimeTrailing =  NSLayoutConstraint.Create (m_playerSlider,NSLayoutAttribute.Leading,NSLayoutRelation.Equal,m_labelCurrentTime,NSLayoutAttribute.Trailing,1.0f,10);

                NSLayoutConstraint constraintRemainingTimeLeading =  NSLayoutConstraint.Create (m_labelRemainingTime,NSLayoutAttribute.Leading,NSLayoutRelation.Equal,m_playerSlider,NSLayoutAttribute.Trailing,1.0f, 10.0f);
                NSLayoutConstraint constraintRemainingTimeTrailing =  NSLayoutConstraint.Create (m_viewPlayerDuration,NSLayoutAttribute.Trailing,NSLayoutRelation.Equal,m_labelRemainingTime,NSLayoutAttribute.Trailing,1.0f,10.0f);

                NSLayoutConstraint constraintCurrentTimeCenter = NSLayoutConstraint.Create (m_labelCurrentTime,NSLayoutAttribute.CenterY,NSLayoutRelation.Equal,m_viewPlayerDuration,NSLayoutAttribute.CenterY,1.0f,0.0f);

                NSLayoutConstraint constraintSliderCenter = NSLayoutConstraint.Create (m_playerSlider,NSLayoutAttribute.CenterY,NSLayoutRelation.Equal,m_viewPlayerDuration,NSLayoutAttribute.CenterY,1.0f,0.0f);

                NSLayoutConstraint constraintRemainingTimeCenter = NSLayoutConstraint.Create (m_labelRemainingTime,NSLayoutAttribute.CenterY,NSLayoutRelation.Equal,m_viewPlayerDuration,NSLayoutAttribute.CenterY,1.0f,0.0f);

                m_viewPlayerDuration.AddConstraints(new NSLayoutConstraint[]{constraintCurrentTimeLeading,constraintCurrentTimeTrailing,constraintRemainingTimeLeading,constraintRemainingTimeTrailing,constraintCurrentTimeCenter,constraintSliderCenter,constraintRemainingTimeCenter});

            }
        }