public UIMainCalendarItemView()
        {
            UIControl touchControl = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _completedBarContainer = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            touchControl.Add(_completedBarContainer);
            _completedBarContainer.StretchHeight(touchControl);

            _labelTitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor = UIColor.White,
                Font      = UIFont.PreferredCaption1
            };
            touchControl.Add(_labelTitle);
            _labelTitle.StretchHeight(touchControl, top: 6, bottom: 6);

            touchControl.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[completedBar(0)]-6-[title]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                            "completedBar", _completedBarContainer,
                                                                            "title", _labelTitle));

            this.Add(touchControl);
            touchControl.StretchWidthAndHeight(this);

            touchControl.TouchUpInside += TouchControl_TouchUpInside;
        }
示例#2
0
        private void InitializeViews()
        {
            base.TranslatesAutoresizingMaskIntoConstraints = false;
            base.BackgroundColor = new UIColor(235f / 255f, 1);

            // [ [labelName] [labelGPA] ]
            // [ semesterView           ]
            // [ buttonAddSemester      ]

            // stackView
            // + viewNameAndGpa
            //   + labelName
            //   + labelGpa
            // + semesterView
            // + buttonAddSemester

            var stackView = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 12
            };

            // Name and GPA
            var viewNameAndGpa = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            viewNameAndGpa.TouchUpInside += new WeakEventHandler(delegate { OnRequestEditYear?.Invoke(this, DataContext as ViewItemYear); }).Handler;
            {
                var labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelName, nameof(ViewItemYear.Name));
                viewNameAndGpa.AddSubview(labelName);

                var labelGpa = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelGpa, nameof(ViewItemYear.GPA), (gpa) =>
                {
                    return(((double)gpa).ToString("0.0##"));
                });
                viewNameAndGpa.AddSubview(labelGpa);

                viewNameAndGpa.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelName]->=6-[labelGpa]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary("labelName", labelName, "labelGpa", labelGpa)));
                labelName.StretchHeight(viewNameAndGpa);
                labelGpa.StretchHeight(viewNameAndGpa);
            }
            stackView.AddArrangedSubview(viewNameAndGpa);
            viewNameAndGpa.StretchWidth(stackView);

            // Semester
            var stackViewSemesters = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8
            };

            _itemsSourceSemesters = new BareUIStackViewItemsSourceAdapter <UISemesterView>(stackViewSemesters);
            _itemsSourceSemesters.OnViewCreated += _itemsSourceSemesters_OnViewCreated;
            stackView.AddArrangedSubview(stackViewSemesters);
            stackViewSemesters.StretchWidth(stackView);

            // Add semester button
            var buttonAddSemester = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonAddSemester.SetTitle("Add Semester", UIControlState.Normal);
            buttonAddSemester.TouchUpInside += new WeakEventHandler(ButtonAddSemester_TouchUpInside).Handler;
            stackView.AddArrangedSubview(buttonAddSemester);
            buttonAddSemester.StretchWidth(stackView);

            base.AddSubview(stackView);
            stackView.StretchWidthAndHeight(this, top: 6, bottom: 6, left: 8, right: 8);
        }
示例#3
0
        public UIDayScheduleSnapshot()
        {
            var background = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor
            };

            {
                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 = UIColorCompat.SecondaryLabelColor
                        };
                        _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);
        }
示例#4
0
        public override void OnViewModelLoadedOverride()
        {
            var safeView = BareUISafeView.CreateAndAddTo(View);

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

                var viewCenterContainer = new UIStackView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Axis    = UILayoutConstraintAxis.Vertical,
                    Spacing = 8
                };
                {
                    var icon = new UIImageView(UIImage.FromBundle("PowerPlannerIcon"))
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        ContentMode = UIViewContentMode.ScaleAspectFit
                    };
                    icon.SetHeight(100);
                    viewCenterContainer.AddArrangedSubview(icon);

                    // In iOS 13, WhiteLarge was deprecated and Large was added
                    var progressRing = new UIActivityIndicatorView(UIDevice.CurrentDevice.CheckSystemVersion(13, 0) ? UIActivityIndicatorViewStyle.Large : UIActivityIndicatorViewStyle.WhiteLarge)
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Color = UIColor.White
                    };
                    progressRing.StartAnimating();
                    viewCenterContainer.AddUnderVisiblity(progressRing, BindingHost, nameof(ViewModel.IsSyncing));

                    var labelSyncing = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text          = PowerPlannerResources.GetString("LoginPage_String_SyncingAccount"),
                        TextColor     = new UIColor(1, 1),
                        Font          = UIFont.PreferredTitle2,
                        TextAlignment = UITextAlignment.Center
                    };
                    viewCenterContainer.AddUnderVisiblity(labelSyncing, BindingHost, nameof(ViewModel.IsSyncing));

                    var labelSyncError = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text          = PowerPlannerResources.GetString("String_SyncError"),
                        TextColor     = new UIColor(1, 1),
                        Font          = UIFont.PreferredTitle2,
                        TextAlignment = UITextAlignment.Center
                    };
                    viewCenterContainer.AddUnderVisiblity(labelSyncError, BindingHost, nameof(ViewModel.IsSyncing), invert: true);

                    var buttonTryAgain = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Try again");
                    buttonTryAgain.TranslatesAutoresizingMaskIntoConstraints = false;
                    buttonTryAgain.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.TryAgain(); }).Handler;
                    viewCenterContainer.AddUnderVisiblity(buttonTryAgain, BindingHost, nameof(ViewModel.IsSyncing), invert: true);

                    var labelErrorDescription = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        TextColor     = new UIColor(0.9f, 1),
                        Font          = UIFont.PreferredCaption1,
                        TextAlignment = UITextAlignment.Left,
                        Lines         = 0
                    };
                    BindingHost.SetLabelTextBinding(labelErrorDescription, nameof(ViewModel.Error));
                    viewCenterContainer.AddUnderVisiblity(labelErrorDescription, BindingHost, nameof(ViewModel.Error));
                }
                safeView.Add(viewCenterContainer);
                viewCenterContainer.StretchWidth(safeView, left: 16, right: 16);

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

                safeView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-16-[viewTopSpacer(==viewLowerSpacer)][viewCenterContainer][viewLowerSpacer]-16-|", NSLayoutFormatOptions.AlignAllCenterX, null, new NSDictionary(
                                                                                "viewCenterContainer", viewCenterContainer,
                                                                                "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      = PowerPlannerResources.GetString("MainMenuItem_Settings")
                    };
                    buttonSettings.Add(label);
                    label.StretchHeight(buttonSettings);

                    buttonSettings.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[image(22)]-8-[label]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                      "image", settingsImage,
                                                                                      "label", label));
                }
                BindingHost.SetVisibilityBinding(buttonSettings, nameof(ViewModel.IsSyncing), invert: true);
                safeView.Add(buttonSettings);

                buttonSettings.TouchUpInside += new WeakEventHandler(delegate { ViewModel.OpenSettings(asPopup: true); }).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();
        }
示例#5
0
        private void InitializeViews()
        {
            base.TranslatesAutoresizingMaskIntoConstraints = false;
            base.BackgroundColor = new UIColor(247f / 255f, 1);

            // [ [labelName] [labelDates] ]
            // [ [class] [credits] [gpa]  ]
            // [ stackViewClasses         ]
            // [ buttonOpenSemester       ]

            // stackView
            // + viewNameAndDates
            //   + labelName
            //   + labelDates
            // + stackViewClassesTable
            //   + viewClassesTableHeader
            //     + labelHeaderClass
            //     + labelHeaderCredits
            //     + labelHeaderGpa
            //   + stackViewClasses
            //   + viewClassesTableFooter
            //     + labelTotal
            //     + labelTotalCredits
            //     + labelTotalGpa
            // + buttonAddSemester

            var stackView = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8
            };

            // Name and dates
            var viewNameAndDates = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            viewNameAndDates.TouchUpInside += new WeakEventHandler(delegate { OnRequestEditSemester?.Invoke(this, DataContext as ViewItemSemester); }).Handler;
            {
                var labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelName, nameof(ViewItemSemester.Name));
                viewNameAndDates.AddSubview(labelName);

                var labelDates = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font          = UIFont.PreferredCaption2,
                    TextColor     = UIColor.DarkGray,
                    Lines         = 0,
                    TextAlignment = UITextAlignment.Right
                };
                BindingHost.SetLabelTextBinding(labelDates, nameof(ViewItemSemester.Start), delegate
                {
                    return(SemesterToSemesterViewStartEndStringConverter.Convert(DataContext as ViewItemSemester));
                });
                viewNameAndDates.AddSubview(labelDates);

                viewNameAndDates.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelName]->=6-[labelDates]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                        "labelName", labelName,
                                                                                        "labelDates", labelDates)));
                labelName.StretchHeight(viewNameAndDates);
                labelDates.StretchHeight(viewNameAndDates);
            }
            stackView.AddArrangedSubview(viewNameAndDates);
            viewNameAndDates.StretchWidth(stackView);

            // Table
            var classesTouchContainer = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            classesTouchContainer.TouchUpInside += new WeakEventHandler(delegate { OnRequestOpenSemester?.Invoke(this, DataContext as ViewItemSemester); }).Handler;
            {
                var stackViewClassesTable = new UIStackView()
                {
                    Axis = UILayoutConstraintAxis.Vertical,
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    // Table header
                    var viewClassesTableHeader = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        var labelHeaderClass = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text      = "Class",
                            Font      = UIFont.PreferredCaption2,
                            TextColor = UIColor.DarkGray
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderClass);

                        var labelHeaderCredits = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Font          = UIFont.PreferredCaption2,
                            Text          = "Credits",
                            TextColor     = UIColor.DarkGray,
                            TextAlignment = UITextAlignment.Right
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderCredits);

                        var labelHeaderGpa = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Font          = UIFont.PreferredCaption2,
                            Text          = "GPA",
                            TextColor     = UIColor.DarkGray,
                            TextAlignment = UITextAlignment.Right
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderGpa);

                        viewClassesTableHeader.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelHeaderClass]->=6-[labelHeaderCredits(50)]-6-[labelHeaderGpa(50)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                                      "labelHeaderClass", labelHeaderClass,
                                                                                                      "labelHeaderCredits", labelHeaderCredits,
                                                                                                      "labelHeaderGpa", labelHeaderGpa)));
                        labelHeaderClass.StretchHeight(viewClassesTableHeader);
                        labelHeaderCredits.StretchHeight(viewClassesTableHeader);
                        labelHeaderGpa.StretchHeight(viewClassesTableHeader);
                    }
                    stackViewClassesTable.AddArrangedSubview(viewClassesTableHeader);
                    viewClassesTableHeader.StretchWidth(stackViewClassesTable);

                    // Classes stack view
                    var stackViewClasses = new UIStackView()
                    {
                        Axis = UILayoutConstraintAxis.Vertical,
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    _itemsSourceClasses = new BareUIStackViewItemsSourceAdapter <UIClassView>(stackViewClasses);
                    stackViewClassesTable.AddArrangedSubview(stackViewClasses);
                    stackViewClasses.StretchWidth(stackViewClassesTable);

                    // Totals
                    var viewClassesTableFooter = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        var labelTotal = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text = "Total",
                            Font = UIFont.PreferredFootnote
                        };
                        viewClassesTableFooter.AddSubview(labelTotal);

                        var labelTotalCredits = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            TextAlignment = UITextAlignment.Right,
                            Font          = UIFont.PreferredFootnote
                        };
                        BindingHost.SetLabelTextBinding <double>(labelTotalCredits, nameof(ViewItemSemester.CreditsEarned), (credits) =>
                        {
                            return(CreditsToStringConverter.Convert(credits));
                        });
                        viewClassesTableFooter.AddSubview(labelTotalCredits);

                        var labelTotalGpa = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            TextAlignment = UITextAlignment.Right,
                            Font          = UIFont.PreferredFootnote
                        };
                        BindingHost.SetLabelTextBinding <double>(labelTotalGpa, nameof(ViewItemSemester.GPA), (gpa) =>
                        {
                            return(GpaToStringConverter.Convert(gpa));
                        });
                        viewClassesTableFooter.AddSubview(labelTotalGpa);

                        viewClassesTableFooter.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelTotal]->=6-[labelTotalCredits(50)]-6-[labelTotalGpa(50)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                                      "labelTotal", labelTotal,
                                                                                                      "labelTotalCredits", labelTotalCredits,
                                                                                                      "labelTotalGpa", labelTotalGpa)));
                        labelTotal.StretchHeight(viewClassesTableFooter);
                        labelTotalCredits.StretchHeight(viewClassesTableFooter);
                        labelTotalGpa.StretchHeight(viewClassesTableFooter);
                    }
                    stackViewClassesTable.AddArrangedSubview(viewClassesTableFooter);
                    viewClassesTableFooter.StretchWidth(stackViewClassesTable);
                }
                classesTouchContainer.Add(stackViewClassesTable);
                stackViewClassesTable.StretchWidthAndHeight(classesTouchContainer);
            }
            stackView.AddArrangedSubview(classesTouchContainer);
            classesTouchContainer.StretchWidth(stackView);

            // Add semester button
            var buttonOpenSemester = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonOpenSemester.SetTitle("Open Semester", UIControlState.Normal);
            buttonOpenSemester.TouchUpInside += new WeakEventHandler(ButtonOpenSemester_TouchUpInside).Handler;
            stackView.AddArrangedSubview(buttonOpenSemester);
            buttonOpenSemester.StretchWidth(stackView);

            base.AddSubview(stackView);
            stackView.StretchWidthAndHeight(this, top: 6, bottom: 6, left: 8, right: 8);
        }
示例#6
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();
        }
示例#7
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;
        }