public ClassDetailsViewController()
        {
            Title = "Details";

            var labelDetails = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Lines = 0,
                Font  = UIFont.PreferredBody
            };

            BindingHost.SetLabelTextBinding(labelDetails, nameof(ViewModel.Details));
            StackView.AddArrangedSubview(labelDetails);
            labelDetails.StretchWidth(StackView);

            var labelNothingHere = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Lines         = 0,
                Font          = UIFont.PreferredCallout,
                Text          = "Tap the edit button in the top right to add details like the teacher's contact info, office hours, and anything else!",
                TextColor     = UIColor.LightGray,
                TextAlignment = UITextAlignment.Center
            };

            View.Add(labelNothingHere);
            labelNothingHere.StretchWidth(View, left: 16, right: 16);
            labelNothingHere.StretchHeight(View, top: 16, bottom: 16);
            BindingHost.SetBinding(nameof(ViewModel.Details), delegate
            {
                labelNothingHere.Hidden = !string.IsNullOrWhiteSpace(ViewModel.Details);
            });
        }
Beispiel #2
0
                public UIShowHideOldItemsCell(string cellId, ClassViewItemsGroup classItemsGroup, TaskOrEventType type) : base(cellId)
                {
                    ContentView.BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor;

                    _labelText = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Font          = UIFont.PreferredSubheadline,
                        TextColor     = ColorResources.PowerPlannerAccentBlue,
                        TextAlignment = UITextAlignment.Center
                    };

                    DataContext = classItemsGroup;

                    if (type == TaskOrEventType.Task)
                    {
                        BindingHost.SetLabelTextBinding(_labelText, nameof(classItemsGroup.IsPastCompletedTasksDisplayed), (isDisplayed) =>
                        {
                            return(((bool)isDisplayed) ? "Hide old tasks" : "Show old tasks");
                        });
                    }
                    else
                    {
                        BindingHost.SetLabelTextBinding(_labelText, nameof(classItemsGroup.IsPastCompletedEventsDisplayed), (isDisplayed) =>
                        {
                            return(((bool)isDisplayed) ? "Hide old events" : "Show old events");
                        });
                    }

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

                    ContentView.SetHeight(44);
                }
Beispiel #3
0
        private void InitializeTable()
        {
            _cellUsername = new UITableViewCell(UITableViewCellStyle.Default, "TableCell");
            _cellUsername.TextLabel.TextColor = UIColor.LightGray;
            _accountBindingHost.SetLabelTextBinding(_cellUsername.TextLabel, nameof(ViewModel.CurrentAccount.Username));
            _tableView.AddCell(_cellUsername, null);

            _tableView.StartNewGroup();

            _tableView.AddCell("Log Out", ViewModel.LogOut);
            _tableView.AddCell("Change Username", ViewModel.ChangeUsername);
            _tableView.AddCell("Change Password", ViewModel.ChangePassword);

            if (ViewModel.CurrentAccount.IsOnlineAccount)
            {
                _tableView.AddCell("Change Email Address", ViewModel.ChangeEmail);
            }

            if (!ViewModel.CurrentAccount.IsOnlineAccount)
            {
                _tableView.AddCell("Convert to Online Account", ViewModel.ConvertToOnline);
            }

            _tableView.StartNewGroup();

            var cellDelete = new UITableViewCell(UITableViewCellStyle.Default, "TableCell");

            cellDelete.TextLabel.Text          = "Delete Account";
            cellDelete.TextLabel.TextColor     = UIColor.Red;
            cellDelete.TextLabel.TextAlignment = UITextAlignment.Center;
            _tableView.AddCell(cellDelete, ViewModel.PromptConfirmDelete);

            _tableView.Compile();
        }
Beispiel #4
0
            public UIWeightSummaryView()
            {
                var labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredCaption1
                };

                BindingHost.SetLabelTextBinding(labelName, nameof(ViewItemWeightCategory.Name));
                Add(labelName);
                labelName.StretchHeight(this);

                var labelGrade = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font      = UIFont.PreferredCaption1,
                    TextColor = UIColor.DarkGray
                };

                BindingHost.SetLabelTextBinding(labelGrade, nameof(ViewItemWeightCategory.WeightAchievedAndTotalString));
                Add(labelGrade);
                labelGrade.StretchHeight(this);

                this.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[name]->=0-[grade]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                        "name", labelName,
                                                                        "grade", labelGrade));
                labelName.SetContentHuggingPriority(499, UILayoutConstraintAxis.Horizontal);
            }
Beispiel #5
0
            public UIGradesHeaderView(BindingHost classBindingHost, ClassGradesViewController viewController, out BareUIViewItemsSourceAdapterAsStackPanel itemsSourceWeightSummaries)
            {
                _viewController = viewController;

                _labelPercent = new UILabel()
                {
                    Font = UIFont.PreferredTitle2
                };
                classBindingHost.SetLabelTextBinding <double>(_labelPercent, nameof(ViewItemClass.Grade), converter: GradeToStringConverter.Convert);
                Add(_labelPercent);

                _labelGpa = new UILabel()
                {
                    Font          = UIFont.PreferredTitle3,
                    TextAlignment = UITextAlignment.Right
                };
                classBindingHost.SetLabelTextBinding(_labelGpa, nameof(ViewItemClass.GpaString));
                Add(_labelGpa);

                _labelCredits = new UILabel()
                {
                    Font          = UIFont.PreferredCaption1,
                    TextAlignment = UITextAlignment.Right
                };
                classBindingHost.SetLabelTextBinding <double>(_labelCredits, nameof(ViewItemClass.Credits), converter: CreditsToStringConverter.ConvertWithCredits);
                Add(_labelCredits);

                _buttonEditCredits = new UIButton(UIButtonType.System);
                _buttonEditCredits.SetTitle("Edit", UIControlState.Normal);
                _buttonEditCredits.TouchUpInside += new WeakEventHandler(delegate { _viewController.ViewModel.ConfigureGrades(); }).Handler;
                Add(_buttonEditCredits);

                _summaryCategories         = new UIView();
                itemsSourceWeightSummaries = new BareUIViewItemsSourceAdapterAsStackPanel(_summaryCategories, (o) => new UIWeightSummaryView()
                {
                    DataContext = o
                });
                viewController.BindingHost.SetBinding(nameof(ClassGradesViewModel.ShowWeightCategoriesSummary), delegate
                {
                    SetNeedsLayout(); // Will invoke LayoutSubviews in next display cycle
                });
                Add(_summaryCategories);
            }
Beispiel #6
0
 public UIWeightHeaderCell(NSString reuseIdentifier) : base(reuseIdentifier)
 {
     _labelName = new UILabel()
     {
         TranslatesAutoresizingMaskIntoConstraints = false,
         Font = UIFont.PreferredSubheadline.Bold()
     };
     _bindingHost.SetLabelTextBinding(_labelName, nameof(ViewItemWeightCategory.Name));
     ContentView.Add(_labelName);
     _labelName.StretchWidthAndHeight(ContentView, left: 15, top: 8, right: 0, bottom: 8);
 }
Beispiel #7
0
            public UIClassView()
            {
                const int CIRCLE_HEIGHT = 18;

                _circle      = new CAShapeLayer();
                _circle.Path = CGPath.EllipseFromRect(new CGRect(16, 12, CIRCLE_HEIGHT, CIRCLE_HEIGHT));
                BindingHost.SetColorBinding(_circle, nameof(ViewItemClass.Color));
                base.Layer.AddSublayer(_circle);

                _labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font  = UIFont.PreferredTitle3,
                    Lines = 1
                };
                BindingHost.SetLabelTextBinding(_labelName, nameof(ViewItemClass.Name));
                this.Add(_labelName);
                _labelName.StretchWidthAndHeight(this, left: CIRCLE_HEIGHT + 16 + 16, right: 16);

                this.SetHeight(44);
            }
            private void InitializeViews()
            {
                var labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredCaption1
                };

                BindingHost.SetLabelTextBinding(labelName, nameof(ViewItemClass.Name));
                this.AddSubview(labelName);

                var labelCredits = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font          = UIFont.PreferredCaption1,
                    TextAlignment = UITextAlignment.Right
                };

                BindingHost.SetLabelTextBinding(labelCredits, nameof(ViewItemClass.CreditsStringForYearsPage));
                this.AddSubview(labelCredits);

                var labelGpa = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font          = UIFont.PreferredCaption1,
                    TextAlignment = UITextAlignment.Right
                };

                BindingHost.SetLabelTextBinding(labelGpa, nameof(ViewItemClass.GpaStringForTableDisplay));
                this.AddSubview(labelGpa);

                this.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelName]->=6-[labelCredits(50)]-6-[labelGpa(50)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                            "labelName", labelName,
                                                                            "labelCredits", labelCredits,
                                                                            "labelGpa", labelGpa)));
                labelName.StretchHeight(this);
                labelCredits.StretchHeight(this);
                labelGpa.StretchHeight(this);
            }
            public UIGroupedTimeView()
            {
                base.TranslatesAutoresizingMaskIntoConstraints = false;

                BindingHost.SetVisibilityBinding(this, nameof(Group.IsVisible));

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

                var labelDayOfWeek = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredSubheadline
                };

                BindingHost.SetLabelTextBinding(labelDayOfWeek, nameof(Group.DayOfWeek));
                stackView.AddArrangedSubview(labelDayOfWeek);
                labelDayOfWeek.StretchWidth(stackView);

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

                _itemsSourceAdapter = new BareUIStackViewItemsSourceAdapter <UITimeView>(stackViewTimes);
                stackView.AddArrangedSubview(stackViewTimes);
                stackViewTimes.StretchWidth(stackView);

                base.AddSubview(stackView);
                stackView.StretchWidthAndHeight(this);
            }
        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);
        }
Beispiel #11
0
        public override void OnViewModelLoadedOverride()
        {
            bool isTask = ViewModel.Item.Type == TaskOrEventType.Task;

            BindingHost.SetBinding <string>(nameof(ViewModel.PageTitle), (t) => Title = StringWithCapitals(t));

            var buttonEdit = new UIBarButtonItem(UIBarButtonSystemItem.Edit);

            buttonEdit.Clicked += new WeakEventHandler(delegate { ViewModel.Edit(); }).Handler;

            var buttonMore = new UIBarButtonItem(UIImage.FromBundle("MenuVerticalIcon").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIBarButtonItemStyle.Plain, new WeakEventHandler(ButtonMore_Clicked).Handler);

            NavItem.RightBarButtonItems = new UIBarButtonItem[]
            {
                buttonMore,
                buttonEdit
            };

            int bottomSliderHeight = isTask ? CIRCLE_BUTTON_HEIGHT + 16 + 16 : 0;

            _scrollView = new UIScrollView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ShowsHorizontalScrollIndicator            = false
            };
            base.ContentView.AddSubview(_scrollView);
            _scrollView.StretchWidthAndHeight(base.ContentView, bottom: bottomSliderHeight);

            _stackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis = UILayoutConstraintAxis.Vertical
            };
            _scrollView.AddSubview(_stackView);
            _stackView.ConfigureForVerticalScrolling(_scrollView, top: 16, bottom: 16, left: 16, right: 16);

            _itemBindingHost = new BindingHost()
            {
                BindingObject = ViewModel.Item
            };
            _classBindingHost = new BindingHost();
            _itemBindingHost.SetBinding(nameof(ViewItemTaskOrEvent.Class), delegate
            {
                _classBindingHost.BindingObject = ViewModel.Item.Class;
            });

            var labelTitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredTitle3,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelTitle, nameof(ViewModel.Item.Name));
            _stackView.AddArrangedSubview(labelTitle);
            labelTitle.StretchWidth(_stackView);

            _stackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelSubtitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredSubheadline,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelSubtitle, nameof(ViewItemTaskOrEvent.Subtitle));
            _classBindingHost.SetBinding <byte[]>(nameof(ViewItemClass.Color), (color) =>
            {
                labelSubtitle.TextColor = BareUIHelper.ToColor(color);
            });
            _stackView.AddArrangedSubview(labelSubtitle);
            labelSubtitle.StretchWidth(_stackView);

            _stackView.AddArrangedSubview(new UIView().SetHeight(4));

            _stackView.AddSpacing(12);

            var textViewDetails = new UITextView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.PreferredBody,
                TextColor     = UIColorCompat.SecondaryLabelColor,
                Editable      = false,
                ScrollEnabled = false,

                // Link detection: http://iosdevelopertips.com/user-interface/creating-clickable-hyperlinks-from-a-url-phone-number-or-address.html
                DataDetectorTypes = UIDataDetectorType.All
            };

            // Lose the padding: https://stackoverflow.com/questions/746670/how-to-lose-margin-padding-in-uitextview
            textViewDetails.TextContainerInset = UIEdgeInsets.Zero;
            textViewDetails.TextContainer.LineFragmentPadding = 0;

            _itemBindingHost.SetTextViewTextBinding(textViewDetails, nameof(ViewItemTaskOrEvent.Details));
            _stackView.AddArrangedSubview(textViewDetails);
            textViewDetails.StretchWidth(_stackView);

            if (ViewModel.IsUnassigedMode)
            {
                var buttonAddGrade = new UIButton(UIButtonType.System)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                buttonAddGrade.SetTitle("Add Grade", UIControlState.Normal);
                buttonAddGrade.SetTitleColor(new UIColor(1, 1), UIControlState.Normal);
                buttonAddGrade.BackgroundColor = ColorResources.PowerPlannerAccentBlue;
                buttonAddGrade.TouchUpInside  += new WeakEventHandler <EventArgs>(delegate { ViewModel.AddGrade(); }).Handler;
                base.ContentView.Add(buttonAddGrade);

                // https://stackoverflow.com/questions/46344381/ios-11-layout-guidance-about-safe-area-for-iphone-x
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
                        buttonAddGrade.LeftAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.LeftAnchor, 16),
                        buttonAddGrade.RightAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.RightAnchor, -16),
                        buttonAddGrade.BottomAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.BottomAnchor, -16)
                    });
                }
                else
                {
                    buttonAddGrade.StretchWidth(base.ContentView, left: 16, right: 16);
                    buttonAddGrade.PinToBottom(base.ContentView, bottom: 16);
                }
            }

            else
            {
                var completionSliderVisibilityContainer = new BareUIVisibilityContainer()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    var completionSliderContainer = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        _completionSlider = new UISlider()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            MaxValue = 1,
                            MinValue = 0,
                            MinimumTrackTintColor = UIColor.FromRGB(42 / 255f, 222 / 255f, 42 / 255f),
                            ThumbTintColor        = UIColor.FromRGB(42 / 255f, 222 / 255f, 42 / 255f)
                        };
                        _itemBindingHost.SetSliderBinding(_completionSlider, nameof(ViewItemTaskOrEvent.PercentComplete));
                        _completionSlider.TouchUpInside  += new WeakEventHandler(CompletionSlider_ValueCommitted).Handler;
                        _completionSlider.TouchUpOutside += new WeakEventHandler(CompletionSlider_ValueCommitted).Handler;
                        completionSliderContainer.Add(_completionSlider);
                        _completionSlider.StretchHeight(completionSliderContainer);
                        _completionSlider.StretchWidth(completionSliderContainer, left: CIRCLE_BUTTON_HEIGHT + 8, right: CIRCLE_BUTTON_HEIGHT + 8);

                        var incompleteImageContainer = new UIControl()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        {
                            _incompleteImageView = new UIImageView()
                            {
                                TranslatesAutoresizingMaskIntoConstraints = false,
                                ContentMode = UIViewContentMode.ScaleAspectFit,
                                TintColor   = UIColor.LightGray
                            };
                            incompleteImageContainer.Add(_incompleteImageView);
                            _incompleteImageView.StretchHeight(incompleteImageContainer);
                            _incompleteImageView.SetWidth(CIRCLE_BUTTON_HEIGHT);
                            _incompleteImageView.PinToLeft(incompleteImageContainer);
                        }
                        incompleteImageContainer.TouchUpInside += new WeakEventHandler(delegate { _completionSlider.Value = 0; ViewModel.SetPercentComplete(0); UpdateSliderImages(); }).Handler;
                        completionSliderContainer.Add(incompleteImageContainer);
                        incompleteImageContainer.StretchHeight(completionSliderContainer);
                        incompleteImageContainer.PinToLeft(completionSliderContainer);
                        incompleteImageContainer.SetWidth(CIRCLE_BUTTON_HEIGHT);

                        var completeImageContainer = new UIControl()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        {
                            _completeImageView = new UIImageView()
                            {
                                TranslatesAutoresizingMaskIntoConstraints = false,
                                ContentMode = UIViewContentMode.ScaleAspectFit,
                                TintColor   = UIColor.LightGray
                            };
                            completeImageContainer.Add(_completeImageView);
                            _completeImageView.StretchHeight(completeImageContainer);
                            _completeImageView.SetWidth(CIRCLE_BUTTON_HEIGHT);
                            _completeImageView.PinToRight(completeImageContainer);
                        }
                        completeImageContainer.TouchUpInside += new WeakEventHandler(delegate { _completionSlider.Value = 1; ViewModel.SetPercentComplete(1); UpdateSliderImages(); }).Handler;
                        completionSliderContainer.Add(completeImageContainer);
                        completeImageContainer.StretchHeight(completionSliderContainer);
                        completeImageContainer.PinToRight(completionSliderContainer);
                        completeImageContainer.SetWidth(CIRCLE_BUTTON_HEIGHT);

                        _completionSlider.ValueChanged += new WeakEventHandler(delegate { UpdateSliderImages(); }).Handler;
                    }

                    completionSliderContainer.SetHeight(CIRCLE_BUTTON_HEIGHT);

                    completionSliderVisibilityContainer.Child = completionSliderContainer;
                }
                BindingHost.SetVisibilityBinding(completionSliderVisibilityContainer, nameof(ViewModel.IsCompletionSliderVisible));
                base.ContentView.Add(completionSliderVisibilityContainer);

                // https://stackoverflow.com/questions/46344381/ios-11-layout-guidance-about-safe-area-for-iphone-x
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
                        completionSliderVisibilityContainer.LeftAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.LeftAnchor, 16),
                        completionSliderVisibilityContainer.RightAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.RightAnchor, -16),
                        completionSliderVisibilityContainer.BottomAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.BottomAnchor, -16)
                    });
                }
                else
                {
                    completionSliderVisibilityContainer.StretchWidth(base.ContentView, left: 16, right: 16);
                    completionSliderVisibilityContainer.PinToBottom(base.ContentView, bottom: 16);
                }

                _itemBindingHost.SetBinding(nameof(ViewItemTaskOrEvent.PercentComplete), UpdateSliderImages);
            }

            base.OnViewModelLoadedOverride();
        }
Beispiel #12
0
        public ViewGradeViewController()
        {
            Title = "View Grade";

            var buttonEdit = new UIBarButtonItem(UIBarButtonSystemItem.Edit);

            buttonEdit.Clicked += new WeakEventHandler(delegate { ViewModel.Edit(); }).Handler;

            var buttonDelete = new UIBarButtonItem(UIBarButtonSystemItem.Trash);

            buttonDelete.Clicked += new WeakEventHandler(ButtonDelete_Clicked).Handler;

            NavItem.RightBarButtonItems = new UIBarButtonItem[]
            {
                buttonDelete,
                buttonEdit
            };

            var labelTitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredTitle3,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelTitle, nameof(ViewModel.Grade.Name));
            StackView.AddArrangedSubview(labelTitle);
            labelTitle.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelSubtitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredSubheadline,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelSubtitle, nameof(ViewItemGrade.GradeSubtitle));
            _classBindingHost.SetBinding <byte[]>(nameof(ViewItemClass.Color), (color) =>
            {
                labelSubtitle.TextColor = BareUIHelper.ToColor(color);
            });
            StackView.AddArrangedSubview(labelSubtitle);
            labelSubtitle.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelDate = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.PreferredSubheadline,
                TextColor = UIColor.DarkGray
            };

            _itemBindingHost.SetBinding <DateTime>(nameof(ViewItemGrade.Date), (date) =>
            {
                labelDate.Text = date.ToString("d");
            });
            StackView.AddArrangedSubview(labelDate);
            labelDate.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

            StackView.AddSpacing(12);

            var textViewDetails = new UITextView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.PreferredBody,
                TextColor     = UIColor.DarkGray,
                Editable      = false,
                ScrollEnabled = false,

                // Link detection: http://iosdevelopertips.com/user-interface/creating-clickable-hyperlinks-from-a-url-phone-number-or-address.html
                DataDetectorTypes = UIDataDetectorType.All
            };

            // Lose the padding: https://stackoverflow.com/questions/746670/how-to-lose-margin-padding-in-uitextview
            textViewDetails.TextContainerInset = UIEdgeInsets.Zero;
            textViewDetails.TextContainer.LineFragmentPadding = 0;

            _itemBindingHost.SetTextViewTextBinding(textViewDetails, nameof(ViewItemGrade.Details));
            StackView.AddArrangedSubview(textViewDetails);
            textViewDetails.StretchWidth(StackView);
        }
Beispiel #13
0
        public UIScheduleItemView(ViewItemSchedule item)
        {
            Item = item;
            m_classBindingHost.BindingObject = item.Class;

            m_classBindingHost.SetBackgroundColorBinding(this, nameof(item.Class.Color));

            var minTextHeight = UIFont.PreferredCaption1.LineHeight;

            var labelClass = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor = UIColor.White,
                Lines     = 0,
                Font      = UIFont.PreferredCaption1
            };

            m_classBindingHost.SetLabelTextBinding(labelClass, nameof(item.Class.Name));
            this.Add(labelClass);
            labelClass.StretchWidth(this, left: 4);

            // Time and room don't need to be data bound, since these views will be re-created if those change
            var labelTime = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text      = PowerPlannerResources.GetStringTimeToTime(DateTimeFormatterExtension.Current.FormatAsShortTime(item.StartTime), DateTimeFormatterExtension.Current.FormatAsShortTime(item.EndTime)),
                TextColor = UIColor.White,
                Lines     = 1,
                Font      = UIFont.PreferredCaption1
            };

            this.Add(labelTime);
            labelTime.StretchWidth(this, left: 4);

            labelTime.SetContentCompressionResistancePriority(1000, UILayoutConstraintAxis.Vertical);

            if (string.IsNullOrWhiteSpace(item.Room))
            {
                this.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-2-[labelClass(>={minTextHeight})][labelTime]->=2-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                            "labelClass", labelClass,
                                                                            "labelTime", labelTime)));
            }
            else
            {
                var labelRoom = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text      = item.Room.Trim(),
                    TextColor = UIColor.White,
                    Font      = UIFont.PreferredCaption1,
                    Lines     = 0
                };
                this.Add(labelRoom);
                labelRoom.StretchWidth(this, left: 4, right: 4);

                labelRoom.SetContentCompressionResistancePriority(900, UILayoutConstraintAxis.Vertical);

                this.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-2-[labelClass(>={minTextHeight})][labelTime][labelRoom]->=2-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                            "labelClass", labelClass,
                                                                            "labelTime", labelTime,
                                                                            "labelRoom", labelRoom)));
            }
        }
Beispiel #14
0
        public ViewGradeViewController()
        {
            Title = "View Grade";

            var buttonEdit = new UIBarButtonItem(UIBarButtonSystemItem.Edit);

            buttonEdit.Clicked += new WeakEventHandler(delegate { ViewModel.Edit(); }).Handler;

            var buttonDelete = new UIBarButtonItem(UIBarButtonSystemItem.Trash);

            buttonDelete.Clicked += new WeakEventHandler(ButtonDelete_Clicked).Handler;

            NavItem.RightBarButtonItems = new UIBarButtonItem[]
            {
                buttonDelete,
                buttonEdit
            };

            var labelTitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredTitle3,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelTitle, nameof(ViewModel.Grade.Name));
            StackView.AddArrangedSubview(labelTitle);
            labelTitle.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelSubtitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredSubheadline,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelSubtitle, nameof(ViewItemGrade.GradeSubtitle));
            _classBindingHost.SetBinding <byte[]>(nameof(ViewItemClass.Color), (color) =>
            {
                labelSubtitle.TextColor = BareUIHelper.ToColor(color);
            });
            StackView.AddArrangedSubview(labelSubtitle);
            labelSubtitle.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelDate = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.PreferredSubheadline,
                TextColor = UIColor.DarkGray
            };

            _itemBindingHost.SetBinding <DateTime>(nameof(ViewItemGrade.Date), (date) =>
            {
                labelDate.Text = date.ToString("d");
            });
            StackView.AddArrangedSubview(labelDate);
            labelDate.StretchWidth(StackView);

            StackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelDetails = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.PreferredCaption1,
                Lines     = 0,
                TextColor = UIColor.DarkGray
            };

            _itemBindingHost.SetLabelTextBinding(labelDetails, nameof(ViewItemGrade.Details));
            StackView.AddArrangedSubview(labelDetails);
            labelDetails.StretchWidth(StackView);
        }
        public UIEditClassScheduleView()
        {
            base.BackgroundColor = new UIColor(235f / 255f, 1);

            var headerView = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            {
                const int CIRCLE_HEIGHT = 18;

                _circle      = new CAShapeLayer();
                _circle.Path = CGPath.EllipseFromRect(new CGRect(8, 3, CIRCLE_HEIGHT, CIRCLE_HEIGHT));
                BindingHost.SetColorBinding(_circle, nameof(ViewItemClass.Color));
                headerView.Layer.AddSublayer(_circle);

                _labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font  = UIFont.PreferredTitle3,
                    Lines = 1
                };
                BindingHost.SetLabelTextBinding(_labelName, nameof(ViewItemClass.Name));
                headerView.Add(_labelName);
                _labelName.StretchWidthAndHeight(headerView, left:  CIRCLE_HEIGHT + 8 + 8, right: 8);

                headerView.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { OnRequestEditClass(this, DataContext as ViewItemClass); }).Handler;
            }
            this.Add(headerView);
            headerView.StretchWidth(this);

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

            {
                _timesAdapter = new BareUIStackViewItemsSourceAdapter <UIEditClassScheduleTimeView>(stackViewTimes);
                _timesAdapter.OnViewCreated += _timesAdapter_OnViewCreated;
            }
            this.Add(stackViewTimes);
            stackViewTimes.StretchWidth(this);

            // Button
            var buttonAdd = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonAdd.SetTitle("Add Time", UIControlState.Normal);
            buttonAdd.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { OnRequestAddTime?.Invoke(this, DataContext as ViewItemClass); }).Handler;
            this.Add(buttonAdd);
            buttonAdd.StretchWidth(this, left: 8, right: 8);

            this.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-8-[headerView]-8-[stackViewTimes]-8-[buttonAdd]-8-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                        "headerView", headerView,
                                                                        "stackViewTimes", stackViewTimes,
                                                                        "buttonAdd", buttonAdd)));
        }
        public override void OnViewModelLoadedOverride()
        {
            Title = ViewModel.State == AddGradeViewModel.OperationState.Adding ? "Add Grade" : "Edit Grade";

            AddTopSectionDivider();

            AddTextField(new UITextField()
            {
                Placeholder   = "Name",
                ReturnKeyType = UIReturnKeyType.Done,
                EnablesReturnKeyAutomatically = true
            }, nameof(ViewModel.Name), firstResponder: ViewModel.State == AddGradeViewModel.OperationState.Adding);

            AddDivider();

            base.OnViewModelLoadedOverride();

            // Grade received, grade total, and percent
            var gradesView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            {
                var textFieldReceived = new UITextField()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    ReturnKeyType             = UIReturnKeyType.Next,
                    KeyboardType              = UIKeyboardType.DecimalPad,
                    AdjustsFontSizeToFitWidth = true
                                                // TODO: Wire up Next button on keyboard by using ShouldReturn
                };
                BindingHost.SetTextFieldTextBinding <double>(textFieldReceived, nameof(ViewModel.GradeReceived), converter: GradeToTextBoxTextConverter.Convert, backConverter: GradeToTextBoxTextConverter.ConvertBack);
                if (ViewModel.State == AddGradeViewModel.OperationState.Editing && ViewModel.GradeReceived == Grade.UNGRADED)
                {
                    // When assigning grades to tasks, the empty grade becomes the first responder
                    textFieldReceived.BecomeFirstResponder();
                }
                gradesView.Add(textFieldReceived);
                textFieldReceived.StretchHeight(gradesView);

                var labelOutOf = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text = "out of",
                    Font = UIFont.PreferredCaption1
                };
                gradesView.Add(labelOutOf);
                labelOutOf.StretchHeight(gradesView);

                var textFieldTotal = new UITextField()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    ReturnKeyType             = UIReturnKeyType.Next,
                    KeyboardType              = UIKeyboardType.DecimalPad,
                    AdjustsFontSizeToFitWidth = true
                                                // TODO: Wire up Next button on keyboard
                };
                BindingHost.SetTextFieldTextBinding <double>(textFieldTotal, nameof(ViewModel.GradeTotal), converter: GradeToTextBoxTextConverter.Convert, backConverter: GradeToTextBoxTextConverter.ConvertBack);
                gradesView.Add(textFieldTotal);
                textFieldTotal.StretchHeight(gradesView);

                var labelPercent = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font = UIFont.PreferredBody
                };
                BindingHost.SetLabelTextBinding(labelPercent, nameof(ViewModel.GradePercent));
                gradesView.Add(labelPercent);
                labelPercent.StretchHeight(gradesView);

                gradesView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[received(46)]-4-[outOf]-4-[total(46)]->=0-[percent]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                              "received", textFieldReceived,
                                                                              "outOf", labelOutOf,
                                                                              "total", textFieldTotal,
                                                                              "percent", labelPercent));
            }
            StackView.AddArrangedSubview(gradesView);
            gradesView.StretchWidth(StackView, left: 16, right: 16);
            gradesView.SetHeight(44);

            AddDivider();

            var datePicker = new BareUIInlineDatePicker(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            BindingHost.SetDateBinding(datePicker, nameof(ViewModel.Date));
            StackView.AddArrangedSubview(datePicker);
            datePicker.StretchWidth(StackView);
            datePicker.SetHeight(44);

            AddDivider();

            var pickerGradeWeight = new BareUIInlinePickerView(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText = "Weight Category"
            };

            BindingHost.SetItemsSourceBinding(pickerGradeWeight, nameof(ViewModel.WeightCategories));
            BindingHost.SetSelectedItemBinding(pickerGradeWeight, nameof(ViewModel.SelectedWeightCategory));
            StackView.AddArrangedSubview(pickerGradeWeight);
            pickerGradeWeight.StretchWidth(StackView);
            pickerGradeWeight.SetHeight(44);

            AddDivider();

            var container = new BareUISwitch()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Header = "Is Dropped"
            };

            BindingHost.SetSwitchBinding(container, nameof(ViewModel.IsDropped));
            StackView.AddArrangedSubview(container);
            container.StretchWidth(StackView);
            container.SetHeight(44);

            AddDivider();

            var detailsView = new BareUITextView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "Details"
            };

            BindingHost.SetTextViewTextBinding(detailsView.TextView, nameof(ViewModel.Details));
            StackView.AddArrangedSubview(detailsView);
            detailsView.StretchWidth(StackView);
            detailsView.SetHeight(130);

            AddBottomSectionDivider();

            BackButtonText       = "Cancel";
            PositiveNavBarButton = new PopupRightNavBarButtonItem("Save", delegate { Save(); });
        }
Beispiel #17
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();
        }
Beispiel #18
0
        public UIGradeCell(string cellId) : base(cellId)
        {
            var graySideBar = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColor.FromWhiteAlpha(180 / 255f, 1)
            };

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

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

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

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

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

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

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

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

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

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

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

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

                nfloat multiplier = 1;
                if (DataContext.IsDropped)
                {
                    multiplier = 0;
                }
                _constraintCompletionBarHeight = NSLayoutConstraint.Create(
                    _completionBar,
                    NSLayoutAttribute.Height,
                    NSLayoutRelation.Equal,
                    ContentView,
                    NSLayoutAttribute.Height,
                    multiplier,
                    0);
                ContentView.AddConstraint(_constraintCompletionBarHeight);
            });
        }
        public UIScheduleItemView(ViewItemSchedule item)
        {
            Item = item;
            m_classBindingHost.BindingObject = item.Class;

            m_classBindingHost.SetBackgroundColorBinding(this, nameof(item.Class.Color));

            var minTextHeight = UIFont.PreferredCaption1.LineHeight;

            var labelClass = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextColor = UIColor.White,
                Lines     = 0,
                Font      = UIFont.PreferredCaption1
            };

            m_classBindingHost.SetLabelTextBinding(labelClass, nameof(item.Class.Name));
            this.Add(labelClass);
            labelClass.StretchWidth(this, left: 4);

            // Time and room don't need to be data bound, since these views will be re-created if those change
            var labelTime = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text      = PowerPlannerResources.GetStringTimeToTime(DateTimeFormatterExtension.Current.FormatAsShortTime(item.StartTime), DateTimeFormatterExtension.Current.FormatAsShortTime(item.EndTime)),
                TextColor = UIColor.White,
                Lines     = 1,
                Font      = UIFont.PreferredCaption1
            };

            this.Add(labelTime);
            labelTime.StretchWidth(this, left: 4);

            labelTime.SetContentCompressionResistancePriority(1000, UILayoutConstraintAxis.Vertical);

            if (string.IsNullOrWhiteSpace(item.Room))
            {
                this.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-2-[labelClass(>={minTextHeight})][labelTime]->=2-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                            "labelClass", labelClass,
                                                                            "labelTime", labelTime)));
            }
            else
            {
                var textViewRoom = new UITextView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text      = item.Room.Trim(),
                    TextColor = UIColor.White,
                    //TintColor = UIColor.White, // Link color
                    WeakLinkTextAttributes = new NSDictionary(UIStringAttributeKey.ForegroundColor, UIColor.White, UIStringAttributeKey.UnderlineStyle, 1), // Underline links and make them white
                    BackgroundColor        = UIColor.Clear,
                    Font          = UIFont.PreferredCaption1,
                    Editable      = false,
                    ScrollEnabled = false,

                    // Link detection: http://iosdevelopertips.com/user-interface/creating-clickable-hyperlinks-from-a-url-phone-number-or-address.html
                    DataDetectorTypes = UIDataDetectorType.All
                };

                // Lose the padding: https://stackoverflow.com/questions/746670/how-to-lose-margin-padding-in-uitextview
                textViewRoom.TextContainerInset = UIEdgeInsets.Zero;
                textViewRoom.TextContainer.LineFragmentPadding = 0;

                this.Add(textViewRoom);
                textViewRoom.StretchWidth(this, left: 4, right: 4);

                textViewRoom.SetContentCompressionResistancePriority(900, UILayoutConstraintAxis.Vertical);

                this.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-2-[labelClass(>={minTextHeight})][labelTime][labelRoom]->=2-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                            "labelClass", labelClass,
                                                                            "labelTime", labelTime,
                                                                            "labelRoom", textViewRoom)));
            }
        }
Beispiel #20
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);
        }
Beispiel #21
0
        public override void OnViewModelLoadedOverride()
        {
            bool isHomework = ViewModel.Item is ViewItemHomework;

            Title = isHomework ? "View Task" : "View Event";

            var buttonEdit = new UIBarButtonItem(UIBarButtonSystemItem.Edit);

            buttonEdit.Clicked += new WeakEventHandler(delegate { ViewModel.Edit(); }).Handler;

            var buttonDelete = new UIBarButtonItem(UIBarButtonSystemItem.Trash);

            buttonDelete.Clicked += new WeakEventHandler(ButtonDelete_Clicked).Handler;

            NavItem.RightBarButtonItems = new UIBarButtonItem[]
            {
                buttonDelete,
                buttonEdit
            };

            int bottomSliderHeight = isHomework ? CIRCLE_BUTTON_HEIGHT + 16 + 16 : 0;

            _scrollView = new UIScrollView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ShowsHorizontalScrollIndicator            = false
            };
            base.ContentView.AddSubview(_scrollView);
            _scrollView.StretchWidthAndHeight(base.ContentView, bottom: bottomSliderHeight);

            _stackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis = UILayoutConstraintAxis.Vertical
            };
            _scrollView.AddSubview(_stackView);
            _stackView.ConfigureForVerticalScrolling(_scrollView, top: 16, bottom: 16, left: 16, right: 16);

            _itemBindingHost = new BindingHost()
            {
                BindingObject = ViewModel.Item
            };
            _classBindingHost = new BindingHost();
            _itemBindingHost.SetBinding(nameof(ViewItemHomework.Class), delegate
            {
                _classBindingHost.BindingObject = ViewModel.Item.GetClassOrNull();
            });

            var labelTitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredTitle3,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelTitle, nameof(ViewModel.Item.Name));
            _stackView.AddArrangedSubview(labelTitle);
            labelTitle.StretchWidth(_stackView);

            _stackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelSubtitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredSubheadline,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelSubtitle, nameof(ViewItemHomework.Subtitle));
            _classBindingHost.SetBinding <byte[]>(nameof(ViewItemClass.Color), (color) =>
            {
                labelSubtitle.TextColor = BareUIHelper.ToColor(color);
            });
            _stackView.AddArrangedSubview(labelSubtitle);
            labelSubtitle.StretchWidth(_stackView);

            _stackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelDetails = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font      = UIFont.PreferredCaption1,
                Lines     = 0,
                TextColor = UIColor.DarkGray
            };

            _itemBindingHost.SetLabelTextBinding(labelDetails, nameof(ViewItemHomework.Details));
            _stackView.AddArrangedSubview(labelDetails);
            labelDetails.StretchWidth(_stackView);

            if (ViewModel.IsUnassigedMode)
            {
                var buttonConvertToGrade = new UIButton(UIButtonType.System)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                buttonConvertToGrade.SetTitle("Convert To Grade", UIControlState.Normal);
                buttonConvertToGrade.SetTitleColor(new UIColor(1, 1), UIControlState.Normal);
                buttonConvertToGrade.BackgroundColor = ColorResources.PowerPlannerAccentBlue;
                buttonConvertToGrade.TouchUpInside  += new WeakEventHandler <EventArgs>(delegate { ViewModel.ConvertToGrade(); }).Handler;
                base.ContentView.Add(buttonConvertToGrade);

                // https://stackoverflow.com/questions/46344381/ios-11-layout-guidance-about-safe-area-for-iphone-x
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
                        buttonConvertToGrade.LeftAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.LeftAnchor, 16),
                        buttonConvertToGrade.RightAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.RightAnchor, -16),
                        buttonConvertToGrade.BottomAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.BottomAnchor, -16)
                    });
                }
                else
                {
                    buttonConvertToGrade.StretchWidth(base.ContentView, left: 16, right: 16);
                    buttonConvertToGrade.PinToBottom(base.ContentView, bottom: 16);
                }
            }

            else if (isHomework)
            {
                var completionSliderContainer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    _completionSlider = new UISlider()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        MaxValue = 1,
                        MinValue = 0,
                        MinimumTrackTintColor = UIColor.FromRGB(42 / 255f, 222 / 255f, 42 / 255f),
                        ThumbTintColor        = UIColor.FromRGB(42 / 255f, 222 / 255f, 42 / 255f)
                    };
                    _itemBindingHost.SetSliderBinding(_completionSlider, nameof(ViewItemHomework.PercentComplete));
                    _completionSlider.TouchUpInside  += new WeakEventHandler(CompletionSlider_ValueCommitted).Handler;
                    _completionSlider.TouchUpOutside += new WeakEventHandler(CompletionSlider_ValueCommitted).Handler;
                    completionSliderContainer.Add(_completionSlider);
                    _completionSlider.StretchHeight(completionSliderContainer);
                    _completionSlider.StretchWidth(completionSliderContainer, left: CIRCLE_BUTTON_HEIGHT + 8, right: CIRCLE_BUTTON_HEIGHT + 8);

                    var incompleteImageContainer = new UIControl()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        _incompleteImageView = new UIImageView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            ContentMode = UIViewContentMode.ScaleAspectFit,
                            TintColor   = UIColor.LightGray
                        };
                        incompleteImageContainer.Add(_incompleteImageView);
                        _incompleteImageView.StretchHeight(incompleteImageContainer);
                        _incompleteImageView.SetWidth(CIRCLE_BUTTON_HEIGHT);
                        _incompleteImageView.PinToLeft(incompleteImageContainer);
                    }
                    incompleteImageContainer.TouchUpInside += new WeakEventHandler(delegate { _completionSlider.Value = 0; ViewModel.SetPercentComplete(0); UpdateSliderImages(); }).Handler;
                    completionSliderContainer.Add(incompleteImageContainer);
                    incompleteImageContainer.StretchHeight(completionSliderContainer);
                    incompleteImageContainer.PinToLeft(completionSliderContainer);
                    incompleteImageContainer.SetWidth(CIRCLE_BUTTON_HEIGHT);

                    var completeImageContainer = new UIControl()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        _completeImageView = new UIImageView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            ContentMode = UIViewContentMode.ScaleAspectFit,
                            TintColor   = UIColor.LightGray
                        };
                        completeImageContainer.Add(_completeImageView);
                        _completeImageView.StretchHeight(completeImageContainer);
                        _completeImageView.SetWidth(CIRCLE_BUTTON_HEIGHT);
                        _completeImageView.PinToRight(completeImageContainer);
                    }
                    completeImageContainer.TouchUpInside += new WeakEventHandler(delegate { _completionSlider.Value = 1; ViewModel.SetPercentComplete(1); UpdateSliderImages(); }).Handler;
                    completionSliderContainer.Add(completeImageContainer);
                    completeImageContainer.StretchHeight(completionSliderContainer);
                    completeImageContainer.PinToRight(completionSliderContainer);
                    completeImageContainer.SetWidth(CIRCLE_BUTTON_HEIGHT);

                    _completionSlider.ValueChanged += new WeakEventHandler(delegate { UpdateSliderImages(); }).Handler;
                }
                base.ContentView.Add(completionSliderContainer);
                completionSliderContainer.SetHeight(CIRCLE_BUTTON_HEIGHT);

                // https://stackoverflow.com/questions/46344381/ios-11-layout-guidance-about-safe-area-for-iphone-x
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
                        completionSliderContainer.LeftAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.LeftAnchor, 16),
                        completionSliderContainer.RightAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.RightAnchor, -16),
                        completionSliderContainer.BottomAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.BottomAnchor, -16)
                    });
                }
                else
                {
                    completionSliderContainer.StretchWidth(base.ContentView, left: 16, right: 16);
                    completionSliderContainer.PinToBottom(base.ContentView, bottom: 16);
                }

                _itemBindingHost.SetBinding(nameof(ViewItemHomework.PercentComplete), UpdateSliderImages);
            }

            base.OnViewModelLoadedOverride();
        }