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(); }); }
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(); }
public ConfigureClassGradeScaleViewController() { Title = "Grade Scale"; var cancelButton = new UIBarButtonItem() { Title = "Cancel" }; cancelButton.Clicked += new WeakEventHandler <EventArgs>(CancelButton_Clicked).Handler; NavigationItem.LeftBarButtonItem = cancelButton; var saveButton = new UIBarButtonItem() { Title = "Save" }; saveButton.Clicked += new WeakEventHandler <EventArgs>(SaveButton_Clicked).Handler; NavigationItem.RightBarButtonItem = saveButton; PowerPlannerUIHelper.ConfigureForInputsStyle(this); StackView.AddTopSectionDivider(); var savedScalesContainer = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; { var pickerSavedScales = new BareUIInlinePickerView(this, left: 16, right: 16) { TranslatesAutoresizingMaskIntoConstraints = false, HeaderText = "Scale" }; BindingHost.SetItemsSourceBinding(pickerSavedScales, nameof(ViewModel.SavedGradeScales)); BindingHost.SetSelectedItemBinding(pickerSavedScales, nameof(ViewModel.SelectedSavedGradeScale)); savedScalesContainer.AddSubview(pickerSavedScales); pickerSavedScales.StretchHeight(savedScalesContainer); var buttonSaveScale = new UIButton(UIButtonType.Custom) { TranslatesAutoresizingMaskIntoConstraints = false, //TintColor = UIColor. }; buttonSaveScale.SetImage(UIImage.FromBundle("SaveAsIcon").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal); buttonSaveScale.TouchUpInside += new WeakEventHandler(ButtonSaveScale_TouchUpInside).Handler; savedScalesContainer.Add(buttonSaveScale); buttonSaveScale.StretchHeight(savedScalesContainer, bottom: 1); savedScalesContainer.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[picker][save(44)]-16-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, "picker", pickerSavedScales, "save", buttonSaveScale)); savedScalesContainer.SetHeight(44); } StackView.AddArrangedSubview(savedScalesContainer); savedScalesContainer.StretchWidth(StackView); StackView.AddSectionDivider(); var headerView = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; { var labelStartingGrade = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Starting Grade", Font = UIFont.PreferredBody.Bold() }; headerView.Add(labelStartingGrade); labelStartingGrade.StretchHeight(headerView, top: 8, bottom: 8); var labelGpa = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "GPA", Font = UIFont.PreferredBody.Bold() }; headerView.Add(labelGpa); labelGpa.StretchHeight(headerView, top: 8, bottom: 8); headerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[startingGrade][gpa(==startingGrade)]-52-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, "startingGrade", labelStartingGrade, "gpa", labelGpa)); } StackView.AddArrangedSubview(headerView); headerView.StretchWidth(StackView, left: 16, right: 16); StackView.AddDivider(); var scalesView = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; { _itemsSourceGradeScales = new BareUIViewItemsSourceAdapterAsStackPanel(scalesView, (w) => { return(new UIEditingGradeScaleView(this) { DataContext = w }); }); } StackView.AddArrangedSubview(scalesView); scalesView.StretchWidth(StackView, left: 16); var buttonAdd = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false }; buttonAdd.SetTitle("Add Grade Scale", UIControlState.Normal); buttonAdd.TouchUpInside += new WeakEventHandler(delegate { ViewModel.AddGradeScale(); }).Handler; StackView.AddArrangedSubview(buttonAdd); buttonAdd.StretchWidth(StackView); buttonAdd.SetHeight(44); StackView.AddBottomSectionDivider(); }