public EditClassWeightCategoriesViewController() { Title = "Weight Categories"; 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); // No save/cancel button, implicitly saves when going back or exiting StackView.AddTopSectionDivider(); var headerView = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; { var labelName = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Name", Font = UIFont.PreferredBody.Bold() }; headerView.Add(labelName); labelName.StretchHeight(headerView, top: 8, bottom: 8); var labelWeight = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Weight", Font = UIFont.PreferredBody.Bold() }; headerView.Add(labelWeight); labelWeight.StretchHeight(headerView, top: 8, bottom: 8); headerView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[name][weight(60)]-52-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, "name", labelName, "weight", labelWeight)); } StackView.AddArrangedSubview(headerView); headerView.StretchWidth(StackView, left: 16, right: 16); StackView.AddDivider(); var weightsView = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; { _itemsSourceWeights = new BareUIViewItemsSourceAdapterAsStackPanel(weightsView, (w) => { return(new UIEditingWeightCategoryView(this) { DataContext = w }); }); } StackView.AddArrangedSubview(weightsView); weightsView.StretchWidth(StackView, left: 16); var buttonDelete = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false }; buttonDelete.SetTitle("Add Category", UIControlState.Normal); buttonDelete.TouchUpInside += new WeakEventHandler(delegate { ViewModel.AddWeightCategory(); }).Handler; StackView.AddArrangedSubview(buttonDelete); buttonDelete.StretchWidth(StackView); buttonDelete.SetHeight(44); StackView.AddBottomSectionDivider(); }
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(); }