Beispiel #1
0
        public override void OnViewModelLoadedOverride()
        {
            _tableView.AddDescriptionCell(PowerPlannerResources.GetString("Settings_SchoolTimeZone_Description.Text"));

            _tableView.StartNewGroup();

            var selectedTimeZone = new BareUIInlinePickerView(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText  = "Time zone",
                ItemsSource = ViewModel.AvailableTimeZones,
                ItemToPreviewStringConverter = item => SchoolTimeZoneSettingsViewModel.Format(item as TimeZoneInfo),
                ItemToViewConverter          = ConvertTimeZoneToInlineView
            };

            BindingHost.SetSelectedItemBinding(selectedTimeZone, nameof(ViewModel.SelectedSchoolTimeZone));
            var cellSelectedTimeZone = new BareUITableViewCell("selectedTimeZone");

            cellSelectedTimeZone.ContentView.Add(selectedTimeZone);
            selectedTimeZone.StretchWidth(cellSelectedTimeZone.ContentView);
            selectedTimeZone.SetHeight(44);
            _tableView.AddCell(cellSelectedTimeZone, delegate { }); // Have to provide action so it remains clickable

            _tableView.StartNewGroup();

            _tableView.AddCell("Save changes", ViewModel.Save);

            _tableView.AddCaptionDescriptionCell(PowerPlannerResources.GetString("Settings_SchoolTimeZone_RestartNote.Text"));

            _tableView.Compile();

            base.OnViewModelLoadedOverride();
        }
        public override void OnViewModelLoadedOverride()
        {
            _tableView.AddDescriptionCell(PowerPlannerResources.GetString("Settings_TwoWeekSchedule_Description.Text"));

            _tableView.StartNewGroup();

            var currentWeek = new BareUIInlinePickerView(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText  = "Current week",
                ItemsSource = ViewModel.AvailableCurrentWeekStrings
            };

            BindingHost.SetSelectedItemBinding(currentWeek, nameof(ViewModel.CurrentWeekString));
            var cellCurrentWeek = new BareUITableViewCell("currentWeek");

            cellCurrentWeek.ContentView.Add(currentWeek);
            currentWeek.StretchWidth(cellCurrentWeek.ContentView);
            currentWeek.SetHeight(44);
            _tableView.AddCell(cellCurrentWeek, delegate { }); // Have to provide action so it remains clickable

            _tableView.StartNewGroup();

            var weekChangesOn = new BareUIInlinePickerView(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText  = "Week changes on",
                ItemsSource = ViewModel.AvailableWeekChangesOnStrings
            };

            BindingHost.SetSelectedItemBinding(weekChangesOn, nameof(ViewModel.WeekChangesOnString));
            var cellWeekChangesOn = new BareUITableViewCell("weekChangesOn");

            cellWeekChangesOn.ContentView.Add(weekChangesOn);
            weekChangesOn.StretchWidth(cellWeekChangesOn.ContentView);
            weekChangesOn.SetHeight(44);
            _tableView.AddCell(cellWeekChangesOn, delegate { });

            _tableView.Compile();

            base.OnViewModelLoadedOverride();
        }
        public override void OnViewModelLoadedOverride()
        {
            Title = ViewModel.State == AddHomeworkViewModel.OperationState.Adding ?
                    ViewModel.Type == AddHomeworkViewModel.ItemType.Homework ? "Add Task" : "Add Event"
                : ViewModel.Type == AddHomeworkViewModel.ItemType.Homework ? "Edit Task" : "Edit Event";

            AddTopSectionDivider();

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

            AddDivider();

            var dateContainer = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical
            };

            {
                var datePicker = new BareUIInlineDatePicker(this, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetDateBinding(datePicker, nameof(ViewModel.Date));
                dateContainer.AddArrangedSubview(datePicker);
                datePicker.StretchWidth(dateContainer);
                datePicker.SetHeight(44);

                AddDivider(dateContainer);
            }
            AddUnderVisiblity(dateContainer, nameof(ViewModel.IsDatePickerVisible));

            var classContainer = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical
            };

            {
                var pickerClass = new BareUIInlinePickerView(this, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HeaderText          = "Class",
                    ItemToViewConverter = ConvertClassToInlineView
                };
                BindingHost.SetItemsSourceBinding(pickerClass, nameof(ViewModel.Classes));
                BindingHost.SetSelectedItemBinding(pickerClass, nameof(ViewModel.Class));
                classContainer.AddArrangedSubview(pickerClass);
                pickerClass.StretchWidth(classContainer);
                pickerClass.SetHeight(44);

                AddDivider(classContainer);
            }
            AddUnderVisiblity(classContainer, nameof(ViewModel.IsClassPickerVisible));

            var gradeWeightContainer = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical
            };

            {
                var pickerGradeWeight = new BareUIInlinePickerView(this, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HeaderText = "Grade Category"
                };
                BindingHost.SetItemsSourceBinding(pickerGradeWeight, nameof(ViewModel.WeightCategories));
                BindingHost.SetSelectedItemBinding(pickerGradeWeight, nameof(ViewModel.SelectedWeightCategory));
                gradeWeightContainer.AddArrangedSubview(pickerGradeWeight);
                pickerGradeWeight.StretchWidth(gradeWeightContainer);
                pickerGradeWeight.SetHeight(44);

                AddDivider(gradeWeightContainer);
            }
            AddUnderVisiblity(gradeWeightContainer, nameof(ViewModel.IsWeightCategoryPickerVisible));

            var pickerTime = new BareUIInlinePickerView(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText = "Time"
            };

            BindingHost.SetItemsSourceBinding(pickerTime, nameof(ViewModel.TimeOptions));
            BindingHost.SetSelectedItemBinding(pickerTime, nameof(ViewModel.SelectedTimeOption));
            StackView.AddArrangedSubview(pickerTime);
            pickerTime.StretchWidth(StackView);
            pickerTime.SetHeight(44);

            var stackViewPickerCustomTime = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical
            };

            AddDivider(stackViewPickerCustomTime);
            if (ViewModel.Type == AddHomeworkViewModel.ItemType.Homework)
            {
                var pickerDueTime = new BareUIInlineTimePicker(this, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HeaderText = "Due Time"
                };
                BindingHost.SetTimeBinding(pickerDueTime, nameof(ViewModel.StartTime));
                stackViewPickerCustomTime.AddArrangedSubview(pickerDueTime);
                pickerDueTime.StretchWidth(stackViewPickerCustomTime);
                pickerDueTime.SetHeight(44);
            }
            else
            {
                var pickerStartTime = new BareUIInlineTimePicker(this, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HeaderText = "Start Time"
                };
                BindingHost.SetTimeBinding(pickerStartTime, nameof(ViewModel.StartTime));
                stackViewPickerCustomTime.AddArrangedSubview(pickerStartTime);
                pickerStartTime.StretchWidth(stackViewPickerCustomTime);
                pickerStartTime.SetHeight(44);

                AddDivider(stackViewPickerCustomTime);

                var pickerEndTime = new BareUIInlineTimePicker(this, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HeaderText = "End Time"
                };
                BindingHost.SetTimeBinding(pickerEndTime, nameof(ViewModel.EndTime));
                stackViewPickerCustomTime.AddArrangedSubview(pickerEndTime);
                pickerEndTime.StretchWidth(stackViewPickerCustomTime);
                pickerEndTime.SetHeight(44);
            }
            var pickerCustomTimeContainer = new BareUIVisibilityContainer()
            {
                Child = stackViewPickerCustomTime
            };

            BindingHost.SetVisibilityBinding(pickerCustomTimeContainer, nameof(ViewModel.IsStartTimePickerVisible));
            StackView.AddArrangedSubview(pickerCustomTimeContainer);
            pickerCustomTimeContainer.StretchWidth(StackView);

            AddSectionDivider();

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

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

            if (ViewModel.IsRepeatsVisible)
            {
                AddSectionDivider();

                var switchRepeats = new BareUISwitch()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Header = PowerPlannerResources.GetString("RepeatingEntry_CheckBoxRepeats.Content")
                };
                BindingHost.SetSwitchBinding(switchRepeats, nameof(ViewModel.Repeats));
                StackView.AddArrangedSubview(switchRepeats);
                switchRepeats.StretchWidth(StackView);
                switchRepeats.SetHeight(44);

                StackView.AddUnderLazyVisibility(BindingHost, nameof(ViewModel.Repeats), delegate
                {
                    var recurrenceContainer = new UIStackView()
                    {
                        Axis = UILayoutConstraintAxis.Vertical
                    };
                    {
                        recurrenceContainer.AddDivider();

                        var tryForFreeContainer = new UIStackView()
                        {
                            Axis = UILayoutConstraintAxis.Vertical
                        };
                        {
                            tryForFreeContainer.AddSpacing(16);
                            var tryForFreeLabel = new UILabel()
                            {
                                TranslatesAutoresizingMaskIntoConstraints = false,
                                Text      = PowerPlannerResources.GetString("RepeatingEntry_TextBlockTryForFree.Text"),
                                Font      = UIFont.PreferredCaption1,
                                TextColor = UIColor.Red,
                                Lines     = 0
                            };
                            tryForFreeContainer.AddArrangedSubview(tryForFreeLabel);
                            tryForFreeLabel.StretchWidth(tryForFreeContainer, left: 16, right: 16);
                            tryForFreeContainer.AddSpacing(16);

                            tryForFreeContainer.AddDivider();
                        }
                        recurrenceContainer.AddUnderVisiblity(tryForFreeContainer, BindingHost, nameof(ViewModel.ShowRepeatingPremiumTrial));

                        var mustUpgradeContainer = new UIStackView()
                        {
                            Axis = UILayoutConstraintAxis.Vertical
                        };
                        {
                            mustUpgradeContainer.AddSpacing(16);
                            var mustUpgradeLabel = new UILabel()
                            {
                                TranslatesAutoresizingMaskIntoConstraints = false,
                                Text      = PowerPlannerResources.GetString("RepeatingEntry_TextBlockMustUpgrade.Text"),
                                Font      = UIFont.PreferredCaption1,
                                TextColor = UIColor.Red,
                                Lines     = 0
                            };
                            mustUpgradeContainer.AddArrangedSubview(mustUpgradeLabel);
                            mustUpgradeLabel.StretchWidth(mustUpgradeContainer, left: 16, right: 16);
                            mustUpgradeContainer.AddSpacing(8);

                            var buttonUpgrade = PowerPlannerUIHelper.CreatePowerPlannerBlueButton(PowerPlannerResources.GetString("Settings_UpgradeToPremium_ButtonUpgrade.Content"));
                            buttonUpgrade.TranslatesAutoresizingMaskIntoConstraints = false;
                            buttonUpgrade.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.UpgradeToPremiumForRepeating(); }).Handler;
                            mustUpgradeContainer.AddArrangedSubview(buttonUpgrade);
                            buttonUpgrade.StretchWidth(mustUpgradeContainer, left: 16, right: 16);
                            mustUpgradeContainer.AddSpacing(16);

                            mustUpgradeContainer.AddDivider();
                        }
                        recurrenceContainer.AddUnderVisiblity(mustUpgradeContainer, BindingHost, nameof(ViewModel.ShowRepeatingMustUpgradeToPremium));

                        var recurrenceView = new UIRecurrenceView(this)
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            ViewModel = ViewModel.RecurrenceControlViewModel
                        };
                        BindingHost.SetIsEnabledBinding(recurrenceView, nameof(ViewModel.IsRepeatingEntryEnabled));
                        recurrenceContainer.AddArrangedSubview(recurrenceView);
                        recurrenceView.StretchWidth(recurrenceContainer);

                        recurrenceContainer.AddDivider();

                        recurrenceContainer.AddSpacing(16);
                        var labelNoteCannotBulkEdit = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text      = PowerPlannerResources.GetString("RepeatingEntry_TextBlockNoteCannotBulkEdit.Text"),
                            Font      = UIFont.PreferredCaption1,
                            TextColor = UIColor.LightGray,
                            Lines     = 0
                        };
                        recurrenceContainer.AddArrangedSubview(labelNoteCannotBulkEdit);
                        labelNoteCannotBulkEdit.StretchWidth(recurrenceContainer, left: 16, right: 16);
                        recurrenceContainer.AddSpacing(16);
                    }
                    return(recurrenceContainer);
                });
            }

            AddBottomSectionDivider();

            BackButtonText       = "Cancel";
            PositiveNavBarButton = new PopupRightNavBarButtonItem("Save", delegate { Save(); });

            base.OnViewModelLoadedOverride();
        }
Beispiel #4
0
        public override void OnViewModelLoadedOverride()
        {
            base.OnViewModelLoadedOverride();

            if (ViewModel.State == AddClassTimeViewModel.OperationState.Adding)
            {
                Title = "Add Time";
            }
            else
            {
                Title = "Edit Times";
            }

            BackButtonText       = "Cancel";
            PositiveNavBarButton = new PopupRightNavBarButtonItem("Save", delegate { ViewModel.Save(); });

            AddTopSectionDivider();

            if (ViewModel.IsInDifferentTimeZone)
            {
                AddSpacing(12);

                var timeZoneWarning = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text      = PowerPlannerResources.GetString("DifferentTimeZoneWarning.Text"),
                    TextColor = UIColor.Red,
                    Font      = UIFont.PreferredCaption1,
                    Lines     = 0
                };
                StackView.AddArrangedSubview(timeZoneWarning);
                timeZoneWarning.StretchWidth(StackView, left: 16, right: 16);

                AddSpacing(12);

                AddSectionDivider();
            }

            var timePickerFrom = new BareUIInlineTimePicker(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText = "From"
            };

            BindingHost.SetTimeBinding(timePickerFrom, nameof(ViewModel.StartTime));
            StackView.AddArrangedSubview(timePickerFrom);
            timePickerFrom.StretchWidth(StackView);
            timePickerFrom.SetHeight(44);

            AddDivider();

            var timePickerTo = new BareUIInlineTimePicker(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText = "To"
            };

            BindingHost.SetTimeBinding(timePickerTo, nameof(ViewModel.EndTime));
            StackView.AddArrangedSubview(timePickerTo);
            timePickerTo.StretchWidth(StackView);
            timePickerTo.SetHeight(44);

            AddSectionDivider();

            AddTextField(new UITextField()
            {
                Placeholder   = "Room",
                ReturnKeyType = UIReturnKeyType.Default
            }, nameof(ViewModel.Room));

            AddSectionDivider();

            AddSwitch(DateTools.ToLocalizedString(DayOfWeek.Monday), nameof(ViewModel.IsMondayChecked));
            AddDivider();
            AddSwitch(DateTools.ToLocalizedString(DayOfWeek.Tuesday), nameof(ViewModel.IsTuesdayChecked));
            AddDivider();
            AddSwitch(DateTools.ToLocalizedString(DayOfWeek.Wednesday), nameof(ViewModel.IsWednesdayChecked));
            AddDivider();
            AddSwitch(DateTools.ToLocalizedString(DayOfWeek.Thursday), nameof(ViewModel.IsThursdayChecked));
            AddDivider();
            AddSwitch(DateTools.ToLocalizedString(DayOfWeek.Friday), nameof(ViewModel.IsFridayChecked));
            AddDivider();
            AddSwitch(DateTools.ToLocalizedString(DayOfWeek.Saturday), nameof(ViewModel.IsSaturdayChecked));
            AddDivider();
            AddSwitch(DateTools.ToLocalizedString(DayOfWeek.Sunday), nameof(ViewModel.IsSundayChecked));

            AddSectionDivider();

            var pickerWeek = new BareUIInlinePickerView(this, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText  = "Week",
                ItemsSource = ViewModel.AvailableScheduleWeekStrings
            };

            BindingHost.SetSelectedItemBinding(pickerWeek, nameof(ViewModel.ScheduleWeekString));
            StackView.AddArrangedSubview(pickerWeek);
            pickerWeek.StretchWidth(StackView);
            pickerWeek.SetHeight(44);

            AddDivider();

            AddSpacing(6);

            var weekExplanation = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text      = PowerPlannerResources.GetString("EditingClassScheduleItemView_TextBlockWeekDescription.Text"),
                Lines     = 0,
                Font      = UIFont.PreferredCaption1,
                TextColor = UIColor.LightGray
            };

            StackView.AddArrangedSubview(weekExplanation);
            weekExplanation.StretchWidth(StackView, 16, 16);

            AddSpacing(12);

            AddSectionDivider();

            AddDeleteButtonWithConfirmation("Delete Class Times", ViewModel.Delete, "Delete class times?", "Are you sure you want to delete these class times?");

            AddBottomSectionDivider();
        }
        private void InitializeViews()
        {
            // [pickerRepeatsEvery]

            // 1 - 364
            uint[] intervalNumberRange   = GenerateNumberSequence(1, 364);
            var    pickerIntervalAndType = new BareUIInlinePickerView(_viewController, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText = PowerPlannerResources.GetString("RepeatingEntry_TextBlockRepeatEvery.Text"),
                Components = new IEnumerable[]
                {
                    intervalNumberRange,
                    ViewModel.RepeatOptionsAsStrings
                },
                SelectedItem = new object[]
                {
                    ViewModel.GetRepeatIntervalAsNumber(),
                   ViewModel.SelectedRepeatOptionAsString
                }
            };

            pickerIntervalAndType.SelectionChanged += PickerIntervalAndType_SelectionChanged;
            this.AddArrangedSubview(pickerIntervalAndType);
            pickerIntervalAndType.StretchWidth(this);
            pickerIntervalAndType.SetHeight(44);

            var repeatOnContainer = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical
            };

            {
                repeatOnContainer.AddDivider();

                _pickerRepeatOn = new UIInlineMultiDayPickerView(_viewController, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HeaderText   = PowerPlannerResources.GetString("RepeatingEntry_TextBlockRepeatOn.Text"),
                    SelectedDays = ViewModel.DayCheckBoxes.Where(i => i.IsChecked).Select(i => i.DayOfWeek).ToArray()
                };
                _pickerRepeatOn.SelectionsChanged += PickerRepeatOn_SelectionsChanged;
                repeatOnContainer.AddArrangedSubview(_pickerRepeatOn);
                _pickerRepeatOn.StretchWidth(repeatOnContainer);
                _pickerRepeatOn.SetHeight(44);
            }
            this.AddUnderVisiblity(repeatOnContainer, _bindingHost, nameof(ViewModel.AreDayCheckBoxesVisible));

            this.AddDivider();

            var pickerEndType = new BareUIInlinePickerView(_viewController, left: 16, right: 16)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                HeaderText  = PowerPlannerResources.GetString("RepeatingEntry_TextBlockEnds.Text"),
                ItemsSource = new string[]
                {
                    PowerPlannerResources.GetString("RepeatingEntry_RadioButtonEndsOn.Content"),
                    PowerPlannerResources.GetString("RepeatingEntry_RadioButtonEndsAfter.Content")
                }
            };

            if (ViewModel.SelectedEndOption == RecurrenceControlViewModel.EndOptions.Date)
            {
                pickerEndType.SelectedItem = pickerEndType.ItemsSource.OfType <object>().First();
            }
            else
            {
                pickerEndType.SelectedItem = pickerEndType.ItemsSource.OfType <object>().Last();
            }
            pickerEndType.SelectionChanged += PickerEndType_SelectionChanged;
            this.AddArrangedSubview(pickerEndType);
            pickerEndType.StretchWidth(this);
            pickerEndType.SetHeight(44);

            var endDateContainer = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical
            };

            {
                endDateContainer.AddDivider();

                var endDatePicker = new BareUIInlineDatePicker(_viewController, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HeaderText = PowerPlannerResources.GetString("EditHomeworkPage_DatePickerDate.Header"), // "Date"
                    Date       = ViewModel.EndDate
                };
                endDatePicker.DateChanged += EndDatePicker_DateChanged;
                endDateContainer.AddArrangedSubview(endDatePicker);
                endDatePicker.StretchWidth(endDateContainer);
                endDatePicker.SetHeight(44);
            }
            this.AddUnderVisiblity(endDateContainer, _bindingHost, nameof(ViewModel.IsEndDateChecked));

            var endOccurrencesContainer = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical
            };

            {
                endOccurrencesContainer.AddDivider();

                var endOccurrencesPicker = new BareUIInlinePickerView(_viewController, left: 16, right: 16)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    HeaderText   = PowerPlannerResources.GetCapitalizedString("RepeatingEntry_TextBlockOccurrences.Text"),
                    ItemsSource  = GenerateNumberSequence(2, 50),
                    SelectedItem = ViewModel.GetEndOccurrencesAsNumber()
                };
                endOccurrencesPicker.SelectionChanged += EndOccurrencesPicker_SelectionChanged;
                endOccurrencesContainer.AddArrangedSubview(endOccurrencesPicker);
                endOccurrencesPicker.StretchWidth(endOccurrencesContainer);
                endOccurrencesPicker.SetHeight(44);
            }
            this.AddUnderVisiblity(endOccurrencesContainer, _bindingHost, nameof(ViewModel.IsEndOccurrencesChecked));
        }
        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(); });
        }