public override void OnViewModelLoadedOverride() { _tableView.Source = new TableViewSource(_tableView, ViewModel); var labelNothingHere = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Lines = 0, Font = UIFont.PreferredCallout, Text = "No tasks! Tap the \"+\" button in the top right to add tasks and events.", TextColor = UIColor.LightGray, TextAlignment = UITextAlignment.Center, Hidden = true }; View.Add(labelNothingHere); labelNothingHere.StretchWidth(View, left: 32, right: 32); labelNothingHere.StretchHeight(View, top: 16, bottom: 16); BindingHost.SetBinding(nameof(ViewModel.HasNoItems), delegate { labelNothingHere.Hidden = !ViewModel.HasNoItems; }); base.OnViewModelLoadedOverride(); }
public EditClassDetailsViewController() { // NOTE: This view isn't used anymore, I simply use AddClass with details enabled instead Title = "Edit Details"; BackButtonText = "Cancel"; PositiveNavBarButton = new PopupRightNavBarButtonItem("Save", delegate { ViewModel.Save(); }); AddSectionDivider(); var textViewDetails = new UITextView() { // Doesn't support placeholder: https://stackoverflow.com/questions/1328638/placeholder-in-uitextview ScrollEnabled = false, Editable = true }; StackView.AddArrangedSubview(textViewDetails); textViewDetails.StretchWidth(StackView); textViewDetails.SetMinimumHeight(60); BindingHost.SetTextViewTextBinding(textViewDetails, nameof(ViewModel.Details)); AddSectionDivider(); }
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); }
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); }
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 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); }); }
public override void OnViewModelLoadedOverride() { AddTopSectionDivider(); AddSpacing(8); var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Enter your email address to recover your username.", Lines = 0 }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); AddSpacing(8); AddDivider(); var textField = new UITextField() { Placeholder = "Email address", AutocapitalizationType = UITextAutocapitalizationType.None, AutocorrectionType = UITextAutocorrectionType.Yes, KeyboardType = UIKeyboardType.EmailAddress, ReturnKeyType = UIReturnKeyType.Go, EnablesReturnKeyAutomatically = true }; AddTextField(textField, nameof(ViewModel.Email), firstResponder: true); AddSectionDivider(); var buttonRecover = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false }; buttonRecover.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { Recover(); }).Handler; buttonRecover.SetTitle("Recover", UIControlState.Normal); StackView.AddArrangedSubview(buttonRecover); buttonRecover.StretchWidth(StackView); buttonRecover.SetHeight(44); AddBottomSectionDivider(); BindingHost.SetBinding(nameof(ViewModel.IsRecoveringUsernames), delegate { if (ViewModel.IsRecoveringUsernames) { ShowLoadingOverlay(false); } else { HideLoadingOverlay(); } }); base.OnViewModelLoadedOverride(); }
public UIEditingGradeScaleView(ConfigureClassGradeScaleViewController controller) { _controller = new WeakReference <ConfigureClassGradeScaleViewController>(controller); var textFieldStartingGrade = new UITextField() { TranslatesAutoresizingMaskIntoConstraints = false, Placeholder = "Starting Grade", AdjustsFontSizeToFitWidth = true, KeyboardType = UIKeyboardType.DecimalPad }; BindingHost.SetTextFieldTextBinding <double>(textFieldStartingGrade, nameof(PowerPlannerSending.GradeScale.StartGrade), TextToDoubleConverter.Convert, TextToDoubleConverter.ConvertBack); this.Add(textFieldStartingGrade); textFieldStartingGrade.StretchHeight(this, bottom: 1); var textFieldGpa = new UITextField() { TranslatesAutoresizingMaskIntoConstraints = false, Placeholder = "GPA", AdjustsFontSizeToFitWidth = true, KeyboardType = UIKeyboardType.DecimalPad }; BindingHost.SetTextFieldTextBinding <double>(textFieldGpa, nameof(PowerPlannerSending.GradeScale.GPA), TextToDoubleConverter.Convert, TextToDoubleConverter.ConvertBack); this.Add(textFieldGpa); textFieldGpa.StretchHeight(this, bottom: 1); // Delete button var buttonDelete = new UIButton(UIButtonType.Custom) { TranslatesAutoresizingMaskIntoConstraints = false, TintColor = UIColor.Red }; buttonDelete.SetImage(UIImage.FromBundle("DeleteIcon").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal); buttonDelete.TouchUpInside += new WeakEventHandler(ButtonDelete_TouchUpInside).Handler; this.Add(buttonDelete); buttonDelete.StretchHeight(this, bottom: 1); this.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[startingGrade]-8-[gpa(==startingGrade)]-8-[delete(44)]-16-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, "startingGrade", textFieldStartingGrade, "gpa", textFieldGpa, "delete", buttonDelete)); var divider = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = ColorResources.InputDividers }; this.Add(divider); divider.StretchWidth(this); divider.SetHeight(1f); divider.PinToBottom(this); this.SetHeight(45); }
public override void OnViewModelLoadedOverride() { AddTopSectionDivider(); AddSpacing(8); var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Are you sure you want to delete your account?", Lines = 0 }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); AddSpacing(8); AddDivider(); var switchDeleteOnline = new BareUISwitch() { TranslatesAutoresizingMaskIntoConstraints = false, Header = "Delete online account" }; BindingHost.SetSwitchBinding(switchDeleteOnline, nameof(ViewModel.DeleteOnlineAccountToo)); StackView.AddArrangedSubview(switchDeleteOnline); switchDeleteOnline.StretchWidth(StackView); switchDeleteOnline.SetHeight(44); AddSectionDivider(); var buttonDelete = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false, TintColor = UIColor.Red }; buttonDelete.TouchUpInside += new WeakEventHandler <EventArgs>(async delegate { try { ShowLoadingOverlay(); await ViewModel.DeleteAsync(); } catch { } HideLoadingOverlay(); }).Handler; buttonDelete.SetTitle("Yes, Delete Account", UIControlState.Normal); StackView.AddArrangedSubview(buttonDelete); buttonDelete.StretchWidth(StackView); buttonDelete.SetHeight(44); AddBottomSectionDivider(); base.OnViewModelLoadedOverride(); }
public UIEditingWeightCategoryView(EditClassWeightCategoriesViewController controller) { _controller = new WeakReference <EditClassWeightCategoriesViewController>(controller); var textFieldName = new UITextField() { TranslatesAutoresizingMaskIntoConstraints = false, Placeholder = "Name", AdjustsFontSizeToFitWidth = true }; BindingHost.SetTextFieldTextBinding(textFieldName, nameof(EditingWeightCategoryViewModel.Name)); this.Add(textFieldName); textFieldName.StretchHeight(this, bottom: 1); var textFieldWeight = new UITextField() { TranslatesAutoresizingMaskIntoConstraints = false, Placeholder = "Weight", AdjustsFontSizeToFitWidth = true, KeyboardType = UIKeyboardType.DecimalPad }; BindingHost.SetTextFieldTextBinding <double>(textFieldWeight, nameof(EditingWeightCategoryViewModel.Weight), WeightValueToTextBoxTextConverter.Convert, WeightValueToTextBoxTextConverter.ConvertBack); this.Add(textFieldWeight); textFieldWeight.StretchHeight(this, bottom: 1); // Delete button var buttonDelete = new UIButton(UIButtonType.Custom) { TranslatesAutoresizingMaskIntoConstraints = false, TintColor = UIColor.Red }; buttonDelete.SetImage(UIImage.FromBundle("DeleteIcon").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal); buttonDelete.TouchUpInside += new WeakEventHandler(ButtonDelete_TouchUpInside).Handler; this.Add(buttonDelete); buttonDelete.StretchHeight(this, bottom: 1); this.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[name]-8-[weight(60)]-8-[delete(44)]-16-|", NSLayoutFormatOptions.DirectionLeadingToTrailing, "name", textFieldName, "weight", textFieldWeight, "delete", buttonDelete)); var divider = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false, BackgroundColor = ColorResources.InputDividers }; this.Add(divider); divider.StretchWidth(this); divider.SetHeight(1f); divider.PinToBottom(this); this.SetHeight(45); }
public override void OnViewModelLoadedOverride() { AddTopSectionDivider(); AddTextField(new UITextField() { Placeholder = "Username", AutocapitalizationType = UITextAutocapitalizationType.None, AutocorrectionType = UITextAutocorrectionType.No, KeyboardType = UIKeyboardType.ASCIICapable, ReturnKeyType = UIReturnKeyType.Next, EnablesReturnKeyAutomatically = true }, nameof(ViewModel.Username), firstResponder: true); AddDivider(); AddTextField(new UITextField() { Placeholder = "Email address", AutocapitalizationType = UITextAutocapitalizationType.None, AutocorrectionType = UITextAutocorrectionType.Yes, KeyboardType = UIKeyboardType.EmailAddress, ReturnKeyType = UIReturnKeyType.Go, EnablesReturnKeyAutomatically = true }, nameof(ViewModel.Email)); AddSectionDivider(); var buttonResetPassword = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false }; buttonResetPassword.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ResetPassword(); }).Handler; buttonResetPassword.SetTitle("Reset password", UIControlState.Normal); StackView.AddArrangedSubview(buttonResetPassword); buttonResetPassword.StretchWidth(StackView); buttonResetPassword.SetHeight(44); AddBottomSectionDivider(); BindingHost.SetBinding(nameof(ViewModel.IsResettingPassword), delegate { if (ViewModel.IsResettingPassword) { ShowLoadingOverlay(false); } else { HideLoadingOverlay(); } }); base.OnViewModelLoadedOverride(); }
public override void OnViewModelLoadedOverride() { BindingHost.SetIsEnabledBinding(_tableView, nameof(ViewModel.IsEnabled)); _tableView.AddCheckableCellWithDescription(PowerPlannerResources.GetString("Settings_GradeOptions_GpaType_Standard.Text"), PowerPlannerResources.GetString("Settings_GradeOptions_GpaType_StandardExplanation.Text"), BindingHost, nameof(ViewModel.IsStandard)); _tableView.AddCheckableCellWithDescription(PowerPlannerResources.GetString("Settings_GradeOptions_GpaType_PassFail.Text"), PowerPlannerResources.GetString("Settings_GradeOptions_GpaType_PassFailExplanation.Text"), BindingHost, nameof(ViewModel.IsPassFail)); _tableView.Compile(); base.OnViewModelSetOverride(); }
public override void OnViewModelAndViewLoadedOverride() { Title = ViewModel.State == AddSemesterViewModel.OperationState.Adding ? "Add Semester" : "Edit Semester"; ViewModel.SupportsStartEnd = true; BackButtonText = "Cancel"; PositiveNavBarButton = new PopupRightNavBarButtonItem("Save", delegate { Save(); }); AddTopSectionDivider(); AddTextField(new UITextField() { Placeholder = "Name (ex: Fall)", ReturnKeyType = UIReturnKeyType.Done, EnablesReturnKeyAutomatically = true }, nameof(ViewModel.Name), firstResponder: ViewModel.State == AddSemesterViewModel.OperationState.Adding); AddSectionDivider(); var datePickerStart = new BareUIInlineDatePicker(this, left: 16, right: 16) { TranslatesAutoresizingMaskIntoConstraints = false, HeaderText = "Start Date" }; BindingHost.SetDateBinding(datePickerStart, nameof(ViewModel.StartDate)); StackView.AddArrangedSubview(datePickerStart); datePickerStart.StretchWidth(StackView); datePickerStart.SetHeight(44); AddDivider(); var datePickerEnd = new BareUIInlineDatePicker(this, left: 16, right: 16) { TranslatesAutoresizingMaskIntoConstraints = false, HeaderText = "End Date" }; BindingHost.SetDateBinding(datePickerEnd, nameof(ViewModel.EndDate)); StackView.AddArrangedSubview(datePickerEnd); datePickerEnd.StretchWidth(StackView); datePickerEnd.SetHeight(44); AddSectionDivider(); AddDeleteButtonWithConfirmation("Delete Semester", ViewModel.Delete, "Delete semester?", "Are you sure you want to delete this semester and all of its classes, grades, and homework?"); AddBottomSectionDivider(); base.OnViewModelAndViewLoadedOverride(); }
public ConfigureClassPassingGradeViewController() { Title = PowerPlannerResources.GetString("Settings_GradeOptions_ListItemPassingGrade.Title"); PowerPlannerUIHelper.ConfigureForInputsStyle(this); var cancelButton = new UIBarButtonItem() { Title = PowerPlannerResources.GetStringCancel() }; cancelButton.Clicked += new WeakEventHandler <EventArgs>(CancelButton_Clicked).Handler; NavigationItem.LeftBarButtonItem = cancelButton; var saveButton = new UIBarButtonItem() { Title = PowerPlannerResources.GetStringSave() }; saveButton.Clicked += new WeakEventHandler <EventArgs>(SaveButton_Clicked).Handler; NavigationItem.RightBarButtonItem = saveButton; StackView.AddSectionDivider(); var textFieldPassingGrade = new UITextField() { TranslatesAutoresizingMaskIntoConstraints = false, KeyboardType = UIKeyboardType.DecimalPad, AdjustsFontSizeToFitWidth = true, Placeholder = PowerPlannerResources.GetExamplePlaceholderString(60.ToString()) }; BindingHost.SetTextFieldTextBinding <double>(textFieldPassingGrade, nameof(ViewModel.PassingGrade), converter: TextToDoubleConverter.Convert, backConverter: TextToDoubleConverter.ConvertBack); AddTextField(StackView, textFieldPassingGrade, firstResponder: true); StackView.AddSectionDivider(); StackView.AddSpacing(16); var labelDescription = new UILabel() { Text = PowerPlannerResources.GetString("Settings_GradeOptions_PassingGrade_Explanation.Text"), Lines = 0, Font = UIFont.PreferredCaption1, TextColor = UIColor.LightGray }; StackView.AddArrangedSubview(labelDescription); labelDescription.StretchWidth(StackView, left: 16, right: 16); StackView.AddSpacing(16); StackView.AddBottomSectionDivider(); }
private void AddSwitch(string header, string bindingName) { var container = new BareUISwitch() { TranslatesAutoresizingMaskIntoConstraints = false, Header = header }; BindingHost.SetSwitchBinding(container, bindingName); StackView.AddArrangedSubview(container); container.StretchWidth(StackView); container.SetHeight(44); }
public override void OnViewModelAndViewLoadedOverride() { _accountBindingHost = new BindingHost() { BindingObject = ViewModel.CurrentAccount }; InitializeTable(); // Watch for online account changing _accountBindingHost.SetBinding(nameof(ViewModel.CurrentAccount.IsOnlineAccount), OnIsOnlineAccountChanged); base.OnViewModelAndViewLoadedOverride(); }
/// <summary> /// Adds a text field /// </summary> /// <param name="textField"></param> /// <param name="textBindingPropertyName"></param> /// <param name="firstResponder">Whether this text box should get the first focus on the page, causing the keyboard to appear</param> protected void AddTextField(UIStackView stackView, UITextField textField, string textBindingPropertyName = null, bool firstResponder = false) { textField.TranslatesAutoresizingMaskIntoConstraints = false; textField.AdjustsFontSizeToFitWidth = true; if (textBindingPropertyName != null) { BindingHost.SetTextFieldTextBinding(textField, textBindingPropertyName); } stackView.AddArrangedSubview(textField); textField.StretchWidth(stackView, left: 16, right: 16); textField.SetHeight(44); RegisterTextField(textField, firstResponder); }
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); }
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() { _tableView.AddDescriptionCell("Power Planner automatically sets reminders for each task and event."); _tableView.StartNewGroup(); var switchDayBefore = new BareUISwitch() { TranslatesAutoresizingMaskIntoConstraints = false, Header = "Day Before" }; BindingHost.SetSwitchBinding(switchDayBefore, nameof(ViewModel.RemindersDayBefore)); var cellDayBefore = new BareUITableViewCell("dayBefore"); cellDayBefore.ContentView.Add(switchDayBefore); switchDayBefore.StretchWidthAndHeight(cellDayBefore.ContentView); _tableView.AddCell(cellDayBefore, delegate { }); // Have to provide action so it remains clickable _tableView.AddCaptionDescriptionCell("This reminds you the day before your incomplete tasks or events are due. It will remind you 10 minutes after your last class, or at 3:00 PM if you don't have any classes that day."); _tableView.StartNewGroup(); var switchDayOf = new BareUISwitch() { TranslatesAutoresizingMaskIntoConstraints = false, Header = "Day Of" }; BindingHost.SetSwitchBinding(switchDayOf, nameof(ViewModel.RemindersDayOf)); var cellDayOf = new BareUITableViewCell("dayOf"); cellDayOf.ContentView.Add(switchDayOf); switchDayOf.StretchWidthAndHeight(cellDayOf.ContentView); _tableView.AddCell(cellDayOf, delegate { }); _tableView.AddCaptionDescriptionCell("This reminds you on the same day that your incomplete tasks or events are due. It will remind you 1 hour before your class starts, or at 6:00 PM if your class doesn't meet on that day."); _tableView.Compile(); base.OnViewModelLoadedOverride(); }
public ClassDetailsViewController() { Title = "Details"; var textViewDetails = new UITextView() { TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.PreferredBody, 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; BindingHost.SetTextViewTextBinding(textViewDetails, nameof(ViewModel.Details)); StackView.AddArrangedSubview(textViewDetails); textViewDetails.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); }); }
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); }
public override void OnViewModelSetOverride() { var uiSwitch = new BareUISwitch() { TranslatesAutoresizingMaskIntoConstraints = false, Header = "Round Grades Up" }; BindingHost.SetSwitchBinding(uiSwitch, nameof(ViewModel.RoundGradesUp)); BindingHost.SetIsEnabledBinding(uiSwitch, nameof(ViewModel.IsEnabled)); var cell = new BareUITableViewCell("roundGradesUp"); cell.ContentView.Add(uiSwitch); uiSwitch.StretchWidthAndHeight(cell.ContentView); _tableView.AddCell(cell, delegate { }); // Have to provide action so it remains clickable _tableView.AddCaptionDescriptionCell(PowerPlannerResources.GetString("ClassPage_TextBlockRoundGradesUpHelpBody.Text")); _tableView.Compile(); base.OnViewModelSetOverride(); }
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 EditClassCreditsViewController() { Title = "Credits"; PowerPlannerUIHelper.ConfigureForInputsStyle(this); 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; StackView.AddSectionDivider(); var textFieldCredits = new UITextField() { TranslatesAutoresizingMaskIntoConstraints = false, KeyboardType = UIKeyboardType.DecimalPad, AdjustsFontSizeToFitWidth = true, Placeholder = "ex: 3" }; BindingHost.SetTextFieldTextBinding <double>(textFieldCredits, nameof(ViewModel.Credits), converter: CreditsToTextBoxTextConverter.Convert, backConverter: CreditsToTextBoxTextConverter.ConvertBack); AddTextField(StackView, textFieldCredits, firstResponder: true); StackView.AddSectionDivider(); }
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(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); }
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(); }
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); }
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(); }