Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:MatchDayManagement.iOS.InjurySearchResultTableViewCell"/> class.
        /// </summary>
        /// <param name="handle">Handle.</param>
        protected EReactiveUIAroundMeListItemTableViewCell(IntPtr handle) : base(handle)
        {
            _nameLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromName("Helvetica", 16f),
                TextColor = UIColor.Clear.FromHex("#444444"),
            };

            _addressLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.FromName("Helvetica", 12f),
                TextColor = UIColor.Clear.FromHex("#666666")
            };

            _distanceLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.FromName("Helvetica", 12f),
                TextColor     = UIColor.Clear.FromHex("#666666"),
                TextAlignment = UITextAlignment.Right,
            };

            _arrowImageView = new UIImageView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ContentMode = UIViewContentMode.ScaleAspectFit,
            };

            _leftView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.Clear.FromHex("#ca505d")
            };

            var views = new DictionaryViews()
            {
                { "nameLabel", _nameLabel },
                { "addressLabel", _addressLabel },
                { "distanceLabel", _distanceLabel },
                { "arrowImageView", _arrowImageView },
            };

            ContentView.Add(_nameLabel);
            ContentView.Add(_addressLabel);
            ContentView.Add(_distanceLabel);
            ContentView.Add(_arrowImageView);

            ContentView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-10-[nameLabel][addressLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("V:|-10-[arrowImageView(20)][distanceLabel]-5-|", NSLayoutFormatOptions.DirectionLeftToRight, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-18-[nameLabel]-5-[arrowImageView(20)]-15-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|-18-[addressLabel]-5-[distanceLabel(60)]-15-|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            // selected view
            SelectedBackgroundView = new UIView(ContentView.Bounds)
            {
                BackgroundColor = UIColor.Clear.FromHex("#fefafa"),
            };

            SelectedBackgroundView.Add(_leftView);

            var selectedViews = new DictionaryViews()
            {
                { "leftView", _leftView }
            };

            SelectedBackgroundView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[leftView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, selectedViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[leftView(3)]", NSLayoutFormatOptions.AlignAllTop, null, selectedViews))
                .ToArray());
        }
Exemple #2
0
        public PromptsCollectionCell(CGRect frame) : base(frame)
        {
            dateLabelDay = new UILabel()
            {
                Frame     = new CGRect(borderSpace, 0, promptImageSize + 20, 30),
                Font      = UIFont.SystemFontOfSize(promptTextFontSize + 2),
                TextColor = UIColor.DarkGray
            };

            dateLabelFullDate = new UILabel()
            {
                Font          = UIFont.SystemFontOfSize(promptTextFontSize),
                TextAlignment = UITextAlignment.Right,
                TextColor     = UIColor.DarkGray
            };

            promptTextView = new UITextView()
            {
                BackgroundColor = UIColor.Clear,
                Font            = UIFont.SystemFontOfSize(promptTextFontSize),
                Editable        = false,
                Selectable      = false,
                TextAlignment   = UITextAlignment.Left,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            bubbleView = new UIView()
            {
                BackgroundColor = UIColor.FromRGB(255, 243, 213),
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            bubbleView.Layer.CornerRadius  = 15;
            bubbleView.Layer.MasksToBounds = true;

            promptImageView = new UIImageView()
            {
                Frame       = new CGRect(0, 0, promptImageSize, promptImageSize),
                ContentMode = UIViewContentMode.ScaleAspectFill,
                TintColor   = UIColor.FromRGB(198, 123, 112),
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            promptIsDoneButton = new UIButton()
            {
                TintColor = UIColor.Gray
            };

            shareToFeedButton = new UIButton()
            {
                TintColor = UIColor.Gray
            };

            addToCalendarButton = new UIButton()
            {
                TintColor = UIColor.Gray
            };

            ContentView.AddSubviews(dateLabelDay, dateLabelFullDate, bubbleView, promptTextView, promptImageView, promptIsDoneButton, shareToFeedButton, addToCalendarButton);

            // Add constraints
            // Get views being constrained
            var views = new NSMutableDictionary();

            views.Add(new NSString("v0"), promptImageView);

            int constraintPromptImage = promptImageSize;

            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:|-{borderSpace}-[v0({constraintPromptImage})]", 0, null, views));
            ContentView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-{spaceBetweenDateAndPrompt}-[v0({constraintPromptImage})]|", 0, null, views));
        }
Exemple #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            updateProfilePictureObserver = NSNotificationCenter.DefaultCenter.AddObserver(new NSString("UpdateProfilePicture"), UpdateProfilePicture);
            updateUserNameObserver       = NSNotificationCenter.DefaultCenter.AddObserver(new NSString("UpdateUserName"), UpdateUserName);

            View.BackgroundColor = UIColor.FromRGB(33, 33, 33);

            var scrollView = new UIScrollView(new RectangleF(0, 0, (float)View.Frame.Width, (float)View.Frame.Height));

            profileImageView                     = new UIImageView(new RectangleF(85, 20, 90, 90));
            profileImageView.ContentMode         = UIViewContentMode.ScaleAspectFill;
            profileImageView.Image               = UIImage.FromBundle("Profile");
            profileImageView.Layer.CornerRadius  = (profileImageView.Frame.Width / 2);
            profileImageView.Layer.MasksToBounds = true;

            var tapGestureRecognizer = new UITapGestureRecognizer(this, new ObjCRuntime.Selector("TapProfilePictureSelector:"));

            profileImageView.AddGestureRecognizer(tapGestureRecognizer);
            profileImageView.UserInteractionEnabled = true;

            if (LoginController.userModel.profilePicturePath != null)
            {
                Utils.SetImageFromNSUrlSession(LoginController.userModel.profilePicturePath, profileImageView, this, PictureType.Profile);
            }

            var editProfileButtonImageView = new UIImageView(new RectangleF(220, 20, 24, 24));

            editProfileButtonImageView.ContentMode         = UIViewContentMode.ScaleAspectFill;
            editProfileButtonImageView.Image               = UIImage.FromBundle("EditMenu");
            editProfileButtonImageView.Layer.MasksToBounds = true;
            var tapGestureRecognizerEdit = new UITapGestureRecognizer(this, new ObjCRuntime.Selector("TapProfilePictureSelector:"));

            editProfileButtonImageView.AddGestureRecognizer(tapGestureRecognizerEdit);
            editProfileButtonImageView.UserInteractionEnabled = true;

            userName               = new UILabel(new RectangleF(20, 120, 220, 20));
            userName.Font          = UIFont.SystemFontOfSize(14.0f);
            userName.TextAlignment = UITextAlignment.Center;
            userName.TextColor     = UIColor.White;
            userName.Text          = LoginController.userModel.name;

            var dividerLineView = new UIView(new RectangleF(20, 145, 220, 0.5f));

            dividerLineView.BackgroundColor = UIColor.FromRGB(80, 80, 80);

            var pagesItems     = new MenuPagesModel().MenuItems;
            var pagesTableView = new UITableView(new RectangleF(20, 150, 220, (pagesItems.Count * 40) - 10));

            pagesTableView.ContentInset    = new UIEdgeInsets(0, 20, 0, 0);
            pagesTableView.BackgroundColor = UIColor.Clear;
            pagesTableView.ScrollEnabled   = false;
            new MenuTableViewController(pagesTableView, pagesItems, menuViewController);

            var dividerLineView2 = new UIView(new RectangleF(20, (float)pagesTableView.Frame.Y + (float)pagesTableView.Frame.Height + 15, 220, 0.5f));

            dividerLineView2.BackgroundColor = UIColor.FromRGB(80, 80, 80);

            var filterLabel = new UILabel(new RectangleF(20, (float)dividerLineView2.Frame.Y + 5, 220, 20));

            filterLabel.Font          = UIFont.BoldSystemFontOfSize(12.0f);
            filterLabel.TextAlignment = UITextAlignment.Left;
            filterLabel.TextColor     = UIColor.FromRGB(80, 80, 80);
            filterLabel.Text          = "Filter";

            var filterTipLabel = new UILabel(new RectangleF(20, (float)dividerLineView2.Frame.Y + 5, 220, 20));

            filterTipLabel.Font          = UIFont.BoldSystemFontOfSize(9.0f);
            filterTipLabel.TextAlignment = UITextAlignment.Right;
            filterTipLabel.TextColor     = UIColor.FromRGB(196, 155, 9);
            filterTipLabel.Text          = "You may select more than one";

            var filterItems     = new MenuFilterModel().MenuItems;
            var filterTableView = new UITableView(new RectangleF(26, (float)filterLabel.Frame.Y + 15, 214, filterItems.Count * 40));

            filterTableView.ContentInset    = new UIEdgeInsets(0, 14, 0, 0);
            filterTableView.SeparatorColor  = UIColor.FromRGB(80, 80, 80);
            filterTableView.BackgroundColor = UIColor.Clear;
            filterTableView.ScrollEnabled   = false;
            new MenuTableViewController(filterTableView, filterItems, menuViewController);

            var dividerLineView3 = new UIView(new RectangleF(20, (float)filterTableView.Frame.Y + (float)filterTableView.Frame.Height + 15, 220, 0.5f));

            dividerLineView3.BackgroundColor = UIColor.FromRGB(80, 80, 80);

            #region Hashtag Menu
            //var dividerLineView3 = new UIView(new RectangleF(20, (float)filterTableView.Frame.Y + (float)filterTableView.Frame.Height + 25, 220, 0.5f));
            //dividerLineView3.BackgroundColor = UIColor.Black;

            //var hashtagLabel = new UILabel(new RectangleF(20, (float)dividerLineView3.Frame.Y + 5, 220, 20));
            //hashtagLabel.Font = UIFont.BoldSystemFontOfSize(12.0f);
            //hashtagLabel.TextAlignment = UITextAlignment.Left;
            //hashtagLabel.TextColor = UIColor.Black;
            //hashtagLabel.Text = "Hashtag";

            //var hashtagText = new UITextField(new RectangleF(20, (float)hashtagLabel.Frame.Y + 30, 220, 40));
            //hashtagText.BorderStyle = UITextBorderStyle.Bezel;
            //hashtagText.Placeholder = "inserts tags to filter here";
            #endregion

            #region Logout Button
            var logoutModel = new MenuLogoutModel();

            var logoutButton = new UIButton(new RectangleF(0, (float)dividerLineView3.Frame.Y + 5, (float)View.Frame.Width, 40));
            //logoutButton.BackgroundColor = UIColor.FromRGB(50, 50, 50);
            logoutButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                CredentialsService.DeleteCredentials();
                LoginController.tokenModel = null;
                LoginController.userModel  = null;

                var loginController = menuViewController.Storyboard.InstantiateViewController("LoginNavController");
                if (loginController != null)
                {
                    menuViewController.PresentViewController(loginController, true, null);
                }
            };


            var logoutIcoImageView = new UIImageView();
            logoutIcoImageView.ContentMode         = UIViewContentMode.ScaleAspectFit;
            logoutIcoImageView.Layer.MasksToBounds = true;
            logoutIcoImageView.TranslatesAutoresizingMaskIntoConstraints = false;
            logoutIcoImageView.Image = UIImage.FromBundle(logoutModel.ImageName);

            var logoutTitleLabel = new UILabel();
            logoutTitleLabel.Font      = UIFont.SystemFontOfSize(14);
            logoutTitleLabel.Text      = logoutModel.Title;
            logoutTitleLabel.TextColor = UIColor.White;
            logoutTitleLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            logoutButton.Add(logoutIcoImageView);
            logoutButton.Add(logoutTitleLabel);

            logoutButton.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-48-[v0(24)]-20-[v1]-8-|", new NSLayoutFormatOptions(), "v0", logoutIcoImageView, "v1", logoutTitleLabel));
            logoutButton.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-8-[v0(24)]", new NSLayoutFormatOptions(), "v0", logoutIcoImageView));
            logoutButton.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-10-[v0(24)]", new NSLayoutFormatOptions(), "v0", logoutTitleLabel));
            #endregion

            scrollView.AddSubview(profileImageView);
            scrollView.AddSubview(userName);
            scrollView.AddSubview(editProfileButtonImageView);
            scrollView.AddSubview(dividerLineView);
            scrollView.AddSubview(pagesTableView);
            scrollView.AddSubview(dividerLineView2);
            scrollView.AddSubview(filterLabel);
            scrollView.AddSubview(filterTipLabel);
            scrollView.AddSubview(filterTableView);
            scrollView.AddSubview(dividerLineView3);
            #region Hashtag Menu
            //scrollView.Add(dividerLineView3);
            //scrollView.Add(hashtagLabel);
            //scrollView.Add(hashtagText);
            #endregion
            scrollView.AddSubview(logoutButton);

            var scrollHeight = 20 + profileImageView.Frame.Height + 10 + userName.Frame.Height + 25 + dividerLineView.Frame.Height + 5 + pagesTableView.Frame.Height + 15 +
                               dividerLineView2.Frame.Height + 5 + filterLabel.Frame.Height + 10 + filterTableView.Frame.Height + 5 + dividerLineView3.Frame.Height + 5 +
                               logoutButton.Frame.Height + 40;

            if (scrollHeight > View.Frame.Height)
            {
                scrollView.ContentSize = new CGSize(View.Frame.Width, scrollHeight);
            }
            else
            {
                scrollView.ContentSize = new CGSize(View.Frame.Width, View.Frame.Height);
            }

            View.AddSubview(scrollView);
        }
        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;
        }
Exemple #5
0
        /// <summary>
        /// If you specify int.MaxValue for top padding, it'll become vertically centered
        /// </summary>
        /// <param name="topPadding"></param>
        /// <param name="leftPadding"></param>
        /// <param name="rightPadding"></param>
        public DifferentSemesterOverlayControl(int topPadding, int leftPadding, int rightPadding)
        {
            base.BackgroundColor = UIColor.FromWhiteAlpha(1, 0.4f);

            var control = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromWhiteAlpha(0, 0.7f)
            };

            {
                var labelHeader = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text          = "Different semester",
                    Font          = UIFont.PreferredSubheadline,
                    TextAlignment = UITextAlignment.Center,
                    TextColor     = UIColor.White
                };
                control.Add(labelHeader);
                labelHeader.StretchWidth(control, left: 4, right: 4);

                var labelBody = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text          = "This is a different semester. Tap this to view all of your semesters",
                    Font          = UIFont.PreferredCaption1,
                    TextAlignment = UITextAlignment.Center,
                    TextColor     = UIColor.White,
                    Lines         = 0
                };
                control.Add(labelBody);
                labelBody.StretchWidth(control, left: 4, right: 4);

                control.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-4-[header][body]-4-|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                           "header", labelHeader,
                                                                           "body", labelBody));

                control.TouchUpInside += new WeakEventHandler(delegate {
                    var mainScreenViewModel = PowerPlannerApp.Current.GetMainScreenViewModel();
                    if (mainScreenViewModel != null)
                    {
                        mainScreenViewModel.SelectedItem = PowerPlannerAppDataLibrary.NavigationManager.MainMenuSelections.Years;
                    }
                }).Handler;
            }
            this.Add(control);
            control.StretchWidth(this, left: leftPadding, right: rightPadding);
            if (topPadding == int.MaxValue)
            {
                var topView = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                var bottomView = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                this.Add(topView);
                this.Add(bottomView);
                this.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[topView][control][bottomView(topView)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                        "topView", topView,
                                                                        "control", control,
                                                                        "bottomView", bottomView));
            }
            else
            {
                control.PinToTop(this, topPadding);
            }

            this.TouchUpInside += new WeakEventHandler(delegate {
                this.RemoveFromSuperview();
            }).Handler;
        }
        private static void AddSubtitleLabel(
            this AVPlayerViewController controller)
        {
            UILabel label = controller.SubtitleLabel();

            if (label == null)
            {
                label = new UILabel();
            }

            bool isPad = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad;

            label.TranslatesAutoresizingMaskIntoConstraints = false;
            label.BackgroundColor          = UIColor.Clear;
            label.TextAlignment            = UITextAlignment.Center;
            label.Font                     = UIFont.BoldSystemFontOfSize(isPad ? 40.0f : 22.0f);
            label.TextColor                = UIColor.White;
            label.Lines                    = 0;
            label.Layer.ShadowColor        = UIColor.Black.CGColor;
            label.Layer.ShadowOffset       = new CGSize(1.0, 1.0);
            label.Layer.ShadowOpacity      = 0.9f;
            label.Layer.ShadowRadius       = 1.0f;
            label.Layer.ShouldRasterize    = true;
            label.Layer.RasterizationScale = UIScreen.MainScreen.Scale;
            label.LineBreakMode            = UILineBreakMode.WordWrap;
            controller.SetSubtitleLabel(label);

            if (controller.ContentOverlayView != null)
            {
                controller.ContentOverlayView.AddSubview(label);
            }
            else
            {
                throw new Exception("Initialize the player view before loading subtitles");
            }

            NSLayoutConstraint[] hConstraints = NSLayoutConstraint.FromVisualFormat(
                "H:|-(20)-[l]-(20)-|",
                0,
                null,
                NSDictionary.FromObjectAndKey(label, new NSString("l"))
                );
            controller.ContentOverlayView.AddConstraints(hConstraints);

            NSLayoutConstraint[] vConstraints = NSLayoutConstraint.FromVisualFormat(
                "V:[l]-(30)-|",
                0,
                null,
                NSDictionary.FromObjectAndKey(label, new NSString("l"))
                );
            controller.ContentOverlayView.AddConstraints(vConstraints);

            NSLayoutConstraint heightConstraint = NSLayoutConstraint.Create(
                label,
                NSLayoutAttribute.Height,
                NSLayoutRelation.Equal,
                null,
                NSLayoutAttribute.NoAttribute,
                1.0f,
                30.0f
                );

            controller.ContentOverlayView.AddConstraint(heightConstraint);
            controller.SetSubtitleConstraint(heightConstraint);
        }
        public UIDayScheduleSnapshot()
        {
            var background = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromWhiteAlpha(239 / 255f, 1)
            };

            {
                var paddingContainer = new UIControl()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    _stackViewHolidays = new UIStackView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Axis    = UILayoutConstraintAxis.Vertical,
                        Spacing = 1
                    };
                    paddingContainer.Add(_stackViewHolidays);
                    _stackViewHolidays.StretchWidth(paddingContainer);

                    _timetable = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        _scheduleGapLines = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleGapLines);
                        _scheduleGapLines.StretchWidthAndHeight(_timetable);

                        _scheduleTimesColumn = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleTimesColumn);
                        _scheduleTimesColumn.StretchHeight(_timetable);
                        _scheduleTimesColumn.SetWidth(TIME_INDICATOR_SIZE);
                        _scheduleTimesColumn.PinToLeft(_timetable);

                        var verticalDivider = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            BackgroundColor = UIColor.White
                        };
                        _timetable.Add(verticalDivider);
                        verticalDivider.StretchHeight(_timetable);
                        verticalDivider.SetWidth(GAP_SIZE);
                        verticalDivider.PinToLeft(_timetable, left: (int)TIME_INDICATOR_SIZE);

                        _scheduleItemsColumn = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleItemsColumn);
                        _scheduleItemsColumn.StretchHeight(_timetable);
                        _scheduleItemsColumn.StretchWidth(_timetable, left: TIME_INDICATOR_SIZE + GAP_SIZE + 8, right: 8);

                        // Normally we would have used constraints to lay these out horizontally, but for some reason constraints
                        // are acting up and the horizontal constraints weren't working correctly, so just pinning things to the left
                        // and applying correct padding
                        // Maybe it was because I originally forgot TranslatesAutoresizing on the verticalDivider... that would explain it
                    }
                    paddingContainer.Add(_timetable);
                    _timetable.StretchWidth(paddingContainer);

                    _holidaysItemsSourceAdapter = new BareUIStackViewItemsSourceAdapter <UIMainCalendarItemView>(_stackViewHolidays);

                    paddingContainer.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[holidays][timetable]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                        "holidays", _stackViewHolidays,
                                                                                        "timetable", _timetable));
                }
                background.Add(paddingContainer);
                paddingContainer.StretchWidthAndHeight(background);
            }
            this.Add(background);
            background.StretchWidthAndHeight(this, top: 16, bottom: 16);
        }
Exemple #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.View.BackgroundColor = UIColor.Clear;
#if __IOS__
            var datePicker = new UIDatePicker
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Date            = this.SelectedDateTime.ToNSDate(),
                BackgroundColor = BackgroundColor,
                Mode            = Mode,
                MinuteInterval  = MinuteInterval
            };
            if (Use24HourClock == true)
            {
                datePicker.Locale = NSLocale.FromLocaleIdentifier("NL");
            }

            if (MinimumDateTime != null)
            {
                datePicker.MinimumDate = MinimumDateTime.Value.ToNSDate();
            }

            if (MaximumDateTime != null)
            {
                datePicker.MaximumDate = MaximumDateTime.Value.ToNSDate();
            }
#elif __TVOS__
            var datePicker = new UIControl();
            //TODO: Fake Date picker on tvOS
#endif
            dimmedView = new UIView(this.View.Bounds)
            {
                AutoresizingMask   = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
                TintAdjustmentMode = UIViewTintAdjustmentMode.Dimmed,
                BackgroundColor    = UIColor.Black,
                Alpha = 0.7F
            };


            var dismissButton = new UIButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                UserInteractionEnabled = true
            };
            dismissButton.TouchUpInside += async(s, e) =>
            {
                await this.DismissViewControllerAsync(true);

                this.Cancel?.Invoke(this);
            };
            this.View.AddSubview(dismissButton);

            var containerView = new UIView
            {
                ClipsToBounds   = true,
                BackgroundColor = BackgroundColor,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            containerView.Layer.CornerRadius = 5.0f;
            this.View.AddSubview(containerView);

            containerView.AddSubview(datePicker);

            var buttonContainerView = new UIView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = BackgroundColor
            };
            buttonContainerView.Layer.CornerRadius = 5.0f;
            this.View.AddSubview(buttonContainerView);

            var buttonDividerView = new UIView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromRGBA(205 / 255, 205 / 255, 205 / 255, 1)
            };
            this.View.AddSubview(buttonDividerView);

            var cancelButton = new UIButton();
            cancelButton.TranslatesAutoresizingMaskIntoConstraints = false;
            cancelButton.SetTitle(this.CancelText, UIControlState.Normal);
            cancelButton.SetTitleColor(UIColor.Red, UIControlState.Normal);

            cancelButton.TitleLabel.Font = UIFont.SystemFontOfSize(this.FontSize);
            cancelButton.TouchUpInside  += async(s, e) =>
            {
                await this.DismissViewControllerAsync(true);

                this.Cancel?.Invoke(this);
            };
            buttonContainerView.AddSubview(cancelButton);

            var button = new UIButton(UIButtonType.System);
            button.TranslatesAutoresizingMaskIntoConstraints = false;
            button.TitleLabel.Font = UIFont.BoldSystemFontOfSize(this.FontSize);
            button.SetTitle(this.OkText, UIControlState.Normal);
            button.TouchUpInside += async(s, e) =>
            {
#if __IOS__
                this.SelectedDateTime = datePicker.Date.ToDateTime();
#endif
                await this.DismissViewControllerAsync(true);

                Ok?.Invoke(this);
            };
            buttonContainerView.AddSubview(button);

            var views = NSDictionary.FromObjectsAndKeys(
                new NSObject[]
            {
                dismissButton,
                containerView,
                datePicker,
                buttonContainerView,
                buttonDividerView,
                cancelButton,
                button
            },
                new NSObject[]
            {
                new NSString("DismissButton"),
                new NSString("DatePickerContainerView"),
                new NSString("datePicker"),
                new NSString("ButtonContainerView"),
                new NSString("ButtonDividerView"),
                new NSString("CancelButton"),
                new NSString("SelectButton")
            }
                );

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[CancelButton][ButtonDividerView(0.5)][SelectButton(CancelButton)]|", 0, null, views));

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[CancelButton]|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[ButtonDividerView]|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[SelectButton]|", 0, null, views));

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[datePicker]|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[datePicker]|", 0, null, views));

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[DismissButton]|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-5-[DatePickerContainerView]-5-|", 0, null, views));
            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-5-[ButtonContainerView]-5-|", 0, null, views));

            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|[DismissButton][DatePickerContainerView]-10-[ButtonContainerView(40)]-{5 + safeAreaInsets.Bottom}-|", 0, null, views));
        }
Exemple #9
0
        /// <summary>
        /// Configure this instance.
        /// </summary>
        private void configure()
        {
            this.TranslatesAutoresizingMaskIntoConstraints = false;
            this.BackgroundColor     = UIColor.DarkGray;
            this.Layer.CornerRadius  = CornerRadius;
            this.Layer.MasksToBounds = true;

            IconImageView = new UIImageView();
            IconImageView.TranslatesAutoresizingMaskIntoConstraints = false;
            IconImageView.BackgroundColor = UIColor.Clear;
            IconImageView.ContentMode     = IconContentMode;

            this.AddSubview(IconImageView);

            MessageLabel = new UILabel();
            MessageLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            MessageLabel.TextColor       = UIColor.White;
            MessageLabel.Font            = MessageTextFont;
            MessageLabel.BackgroundColor = UIColor.Clear;
            MessageLabel.LineBreakMode   = UILineBreakMode.CharacterWrap;
            MessageLabel.Lines           = 2;
            MessageLabel.TextAlignment   = UITextAlignment.Left;
            MessageLabel.Text            = Message;

            this.AddSubview(MessageLabel);

            ActionButton = new UIButton();
            ActionButton.TranslatesAutoresizingMaskIntoConstraints = false;
            ActionButton.Hidden          = string.IsNullOrEmpty(ActionText);
            ActionButton.BackgroundColor = UIColor.Clear;
            ActionButton.TitleLabel.Font = ActionTextFont;
            ActionButton.TitleLabel.AdjustsFontSizeToFitWidth = true;
            ActionButton.SetTitle(ActionText, UIControlState.Normal);
            ActionButton.SetTitleColor(ActionTextColor, UIControlState.Normal);
            ActionButton.TouchUpInside += (s, e) =>
            {
                if (!ActionButton.Hidden && ActionButton.Title(UIControlState.Normal) != String.Empty && ActionButton != null)
                {
                    ActionBlock(this);
                    dismissAnimated(true);
                }
            };

            this.AddSubview(ActionButton);

            SecondActionButton = new UIButton();
            SecondActionButton.TranslatesAutoresizingMaskIntoConstraints = false;
            SecondActionButton.BackgroundColor = UIColor.Clear;
            SecondActionButton.TitleLabel.Font = SecondActionTextFont;
            SecondActionButton.TitleLabel.AdjustsFontSizeToFitWidth = true;
            SecondActionButton.SetTitle(SecondActionText, UIControlState.Normal);
            SecondActionButton.SetTitleColor(SecondActionTextColor, UIControlState.Normal);
            SecondActionButton.TouchUpInside += (s, e) =>
            {
                if (!SecondActionButton.Hidden && SecondActionButton.Title(UIControlState.Normal) != String.Empty && SecondActionBlock != null)
                {
                    SecondActionBlock(this);
                    dismissAnimated(true);
                }
            };

            this.AddSubview(SecondActionButton);

            SeperateView = new UIView();
            SeperateView.TranslatesAutoresizingMaskIntoConstraints = false;
            SeperateView.BackgroundColor = UIColor.Gray;

            this.AddSubview(SeperateView);

            ActivityIndicatorView = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
            ActivityIndicatorView.TranslatesAutoresizingMaskIntoConstraints = false;
            ActivityIndicatorView.StopAnimating();

            this.AddSubview(ActivityIndicatorView);

            // Add constraints
            invalidateHorizontalConstraints();

            var vConstraintsForIconImageView = NSLayoutConstraint.FromVisualFormat(
                "V:|-2-[iconImageView]-2-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { IconImageView }, new NSObject[] { new NSString("iconImageView") })
                );

            var vConstraintsForMessageLabel = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[messageLabel]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { MessageLabel }, new NSObject[] { new NSString("messageLabel") })
                );

            var vConstraintsForSeperateView = NSLayoutConstraint.FromVisualFormat(
                "V:|-4-[seperateView]-4-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { SeperateView }, new NSObject[] { new NSString("seperateView") })
                );

            var vConstraintsForActionButton = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[actionButton]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { ActionButton }, new NSObject[] { new NSString("actionButton") })
                );

            var vConstraintsForSecondActionButton = NSLayoutConstraint.FromVisualFormat(
                "V:|-0-[secondActionButton]-0-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { SecondActionButton }, new NSObject[] { new NSString("secondActionButton") })
                );

            iconImageViewWidthConstraint = NSLayoutConstraint.Create(IconImageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarIconImageViewWidth);

            actionButtonWidthConstraint = NSLayoutConstraint.Create(ActionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarActionButtonMinWidth);

            secondActionButtonWidthConstraint = NSLayoutConstraint.Create(SecondActionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, TTGSnackbar.snackbarActionButtonMinWidth);

            var vConstraintsForActivityIndicatorView = NSLayoutConstraint.FromVisualFormat(
                "V:|-2-[activityIndicatorView]-2-|", 0, new NSDictionary(), NSDictionary.FromObjectsAndKeys(new NSObject[] { ActivityIndicatorView }, new NSObject[] { new NSString("activityIndicatorView") })
                );

            var hConstraintsForActivityIndicatorView = NSLayoutConstraint.FromVisualFormat(
                "H:[activityIndicatorView]-2-|",
                0,
                new NSDictionary(),
                NSDictionary.FromObjectsAndKeys(
                    new NSObject[] { ActivityIndicatorView },
                    new NSObject[] { new NSString("activityIndicatorView") })
                );

            IconImageView.AddConstraint(iconImageViewWidthConstraint);
            ActionButton.AddConstraint(actionButtonWidthConstraint);
            SecondActionButton.AddConstraint(secondActionButtonWidthConstraint);

            this.AddConstraints(hConstraints);
            this.AddConstraints(vConstraintsForIconImageView);
            this.AddConstraints(vConstraintsForMessageLabel);
            this.AddConstraints(vConstraintsForSeperateView);
            this.AddConstraints(vConstraintsForActionButton);
            this.AddConstraints(vConstraintsForSecondActionButton);
            this.AddConstraints(vConstraintsForActivityIndicatorView);
            this.AddConstraints(hConstraintsForActivityIndicatorView);
        }
        void SetArrows()
        {
            CleanUpArrows();

            if (Element.ShowArrows)
            {
                var o             = Element.Orientation == CarouselViewOrientation.Horizontal ? "H" : "V";
                var formatOptions = Element.Orientation == CarouselViewOrientation.Horizontal ? NSLayoutFormatOptions.AlignAllCenterY : NSLayoutFormatOptions.AlignAllCenterX;

                prevBtn                 = new UIButton();
                prevBtn.Hidden          = Element.Position == 0 || Element.ItemsSource.GetCount() == 0;
                prevBtn.BackgroundColor = Element.ArrowsBackgroundColor.ToUIColor();
                prevBtn.Alpha           = Element.ArrowsTransparency;
                prevBtn.TranslatesAutoresizingMaskIntoConstraints = false;

                var prevArrow      = new UIImageView();
                var prevArrowImage = new UIImage(Element.Orientation == CarouselViewOrientation.Horizontal ? "Prev.png" : "Up.png");
                prevArrow.Image = prevArrowImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                prevArrow.TranslatesAutoresizingMaskIntoConstraints = false;
                prevArrow.TintColor = Element.ArrowsTintColor.ToUIColor();
                prevBtn.AddSubview(prevArrow);

                prevBtn.TouchUpInside += PrevBtn_TouchUpInside;

                var prevViewsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { prevBtn, prevArrow }, new NSObject[] { new NSString("superview"), new NSString("prevArrow") });
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("[prevArrow(==17)]", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[prevArrow(==17)]", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[prevArrow]-(2)-|", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[prevArrow]", formatOptions, new NSDictionary(), prevViewsDictionary));

                pageController.View.AddSubview(prevBtn);

                nextBtn                 = new UIButton();
                nextBtn.Hidden          = Element.Position == Element.ItemsSource.GetCount() - 1 || Element.ItemsSource.GetCount() == 0;
                nextBtn.BackgroundColor = Element.ArrowsBackgroundColor.ToUIColor();
                nextBtn.Alpha           = Element.ArrowsTransparency;
                nextBtn.TranslatesAutoresizingMaskIntoConstraints = false;

                var nextArrow      = new UIImageView();
                var nextArrowImage = new UIImage(Element.Orientation == CarouselViewOrientation.Horizontal ? "Next.png" : "Down.png");
                nextArrow.Image = nextArrowImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                nextArrow.TranslatesAutoresizingMaskIntoConstraints = false;
                nextArrow.TintColor = Element.ArrowsTintColor.ToUIColor();
                nextBtn.AddSubview(nextArrow);

                nextBtn.TouchUpInside += NextBtn_TouchUpInside;

                var nextViewsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { nextBtn, nextArrow }, new NSObject[] { new NSString("superview"), new NSString("nextArrow") });
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("[nextArrow(==17)]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[nextArrow(==17)]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":|-(2)-[nextArrow]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[nextArrow]", formatOptions, new NSDictionary(), nextViewsDictionary));

                pageController.View.AddSubview(nextBtn);

                var btnsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { pageController.View, prevBtn, nextBtn }, new NSObject[] { new NSString("superview"), new NSString("prevBtn"), new NSString("nextBtn") });

                var w = Element.Orientation == CarouselViewOrientation.Horizontal ? 20 : 36;
                var h = Element.Orientation == CarouselViewOrientation.Horizontal ? 36 : 20;

                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[prevBtn(==" + w + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[prevBtn(==" + h + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":|[prevBtn]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[prevBtn]", formatOptions, new NSDictionary(), btnsDictionary));

                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[nextBtn(==" + w + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[nextBtn(==" + h + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[nextBtn]|", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[nextBtn]", formatOptions, new NSDictionary(), btnsDictionary));
            }
        }
Exemple #11
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("SettingsIcon").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();
        }
Exemple #12
0
        void SetupUserInterface()
        {
            _liveCameraStream = new UIView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _takePhotoButton = new UIButton {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _takePhotoButton.SetBackgroundImage(UIImage.FromFile("TakePhotoButton.png"), UIControlState.Normal);

            _toggleCameraButton = new UIButton {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _toggleCameraButton.SetBackgroundImage(UIImage.FromFile("ToggleCameraButton.png"), UIControlState.Normal);

            _toggleFlashButton = new UIButton {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _toggleFlashButton.SetBackgroundImage(UIImage.FromFile("NoFlashButton.png"), UIControlState.Normal);

            _cancelButton = new UIButton(UIButtonType.Custom)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _cancelButton.SetTitle("Cancel", UIControlState.Normal);
            _cancelButton.SetTitleColor(UIColor.White, UIControlState.Normal);

            View.Add(_liveCameraStream);
            View.Add(_takePhotoButton);
            View.Add(_toggleCameraButton);
            View.Add(_toggleFlashButton);
            View.Add(_cancelButton);

            var viewMetrics = new object[] {
                "cameraView", _liveCameraStream,
                "photoButton", _takePhotoButton,
                "photoButtonWidth", 70,
                "photoButtonHeight", 70,
                "photoButtonBottomMargin", 15,
                "cancelButton", _cancelButton,
                "cancelButtonWidth", 70,
                "cancelButtonHeight", 70,
                "cancelButtonMargin", 15,
                "toggleCameraButton", _toggleCameraButton,
                "toggleCameraButtonWidth", 35,
                "toggleCameraButtonHeight", 26,
                "toggleCameraButtonTopMargin", 20,
                "toggleCameraButtonRightMargin", 25,
                "toggleFlashButton", _toggleFlashButton,
                "toggleFlashButtonWidth", 37,
                "toggleFlashButtonHeight", 37,
                "toggleFlashButtonTopMargin", 20,
                "toggleFlashButtonLeftMargin", 25
            };

            var centerPhotoButton = NSLayoutConstraint.Create(View, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, _takePhotoButton, NSLayoutAttribute.CenterX, 1.0f, 0.0f);

            View.AddConstraint(centerPhotoButton);

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[photoButton(photoButtonWidth)]", 0, viewMetrics));
            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[photoButton(photoButtonHeight)]-(photoButtonBottomMargin)-|", 0, viewMetrics));

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-(cancelButtonMargin)-[cancelButton(cancelButtonWidth)]", 0, viewMetrics));
            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[cancelButton(cancelButtonHeight)]-(cancelButtonMargin)-|", 0, viewMetrics));

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[toggleCameraButton(toggleCameraButtonWidth)]-(toggleCameraButtonRightMargin)-|", 0, viewMetrics));
            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-(toggleCameraButtonTopMargin)-[toggleCameraButton(toggleCameraButtonHeight)]", 0, viewMetrics));

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-(toggleFlashButtonLeftMargin)-[toggleFlashButton(toggleFlashButtonWidth)]", 0, viewMetrics));
            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-(toggleFlashButtonLeftMargin)-[toggleFlashButton(toggleFlashButtonHeight)]", 0, viewMetrics));

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[cameraView]|", 0, viewMetrics));
            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[cameraView]|", 0, viewMetrics));

            View.SetNeedsUpdateConstraints();
        }