protected override void Initialize() { base.Initialize(); var messageLabel = new NSTextField { StringValue = SnackBar.Message, Selectable = false, Alignment = SnackBar.Appearance.TextAlignment, TranslatesAutoresizingMaskIntoConstraints = false }; if (SnackBar.Appearance.Background != NativeSnackBarAppearance.DefaultColor) { messageLabel.BackgroundColor = SnackBar.Appearance.Background; } if (SnackBar.Appearance.Foreground != NativeSnackBarAppearance.DefaultColor) { messageLabel.TextColor = SnackBar.Appearance.Foreground; } if (SnackBar.Appearance.Font != NativeSnackBarAppearance.DefaultFont) { messageLabel.Font = SnackBar.Appearance.Font; } StackView.AddArrangedSubview(messageLabel); }
protected override void Initialize() { base.Initialize(); foreach (var action in SnackBar.Actions) { var actionButton = new NSButton { Title = action.ActionButtonText, WantsLayer = true, LineBreakMode = action.Appearance.LineBreakMode, }; if (SnackBar.Appearance.Background != NativeSnackButtonAppearance.DefaultColor) { actionButton.Layer.BackgroundColor = action.Appearance.Background.CGColor; } if (SnackBar.Appearance.Font != NativeSnackButtonAppearance.DefaultFont) { actionButton.Font = action.Appearance.Font; } actionButton.Activated += async(s, e) => { await action.Action(); Dismiss(); }; StackView.AddArrangedSubview(actionButton); } }
public override void OnViewModelLoadedOverride() { AddSpacing(16); var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = PowerPlannerResources.GetString("Settings_SuccessfullyCreatedAccountPage_Message.Text"), Lines = 0 // Wraps text }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); AddHeader(PowerPlannerResources.GetString("TextBox_Username.Header")); AddText(ViewModel.Username); AddHeader(PowerPlannerResources.GetString("CreateAccountPage_TextBoxEmail.Header")); AddText(ViewModel.Email); AddSpacing(24); var buttonContinue = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Continue"); buttonContinue.TranslatesAutoresizingMaskIntoConstraints = false; buttonContinue.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.Continue(); }).Handler; StackView.AddArrangedSubview(buttonContinue); buttonContinue.StretchWidth(StackView, left: 16, right: 16); AddSpacing(16); base.OnViewModelLoadedOverride(); }
public override void OnViewModelLoadedOverride() { // Padding at top StackView.AddArrangedSubview(new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }.SetHeight(16)); foreach (var error in ViewModel.SyncErrors) { // In future should make this text selectable but that requires UITextView or UITextField but none of those // worked well here, so just switching to label for now var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = error.Name + "\n" + error.Date + "\n" + error.Message, Lines = 0 }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); // Padding StackView.AddArrangedSubview(new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }.SetHeight(16)); } base.OnViewModelLoadedOverride(); }
protected override void Initialize() { base.Initialize(); var messageLabel = new PaddedLabel(SnackBar.Layout.PaddingLeft, SnackBar.Layout.PaddingTop, SnackBar.Layout.PaddingRight, SnackBar.Layout.PaddingBottom) { Text = SnackBar.Message, Lines = 0, AdjustsFontSizeToFitWidth = true, TextAlignment = SnackBar.Appearance.TextAlignment }; if (SnackBar.Appearance.Background != NativeSnackBarAppearance.DefaultColor) { messageLabel.BackgroundColor = SnackBar.Appearance.Background; } if (SnackBar.Appearance.Foreground != NativeSnackBarAppearance.DefaultColor) { messageLabel.TextColor = SnackBar.Appearance.Foreground; } if (SnackBar.Appearance.Font != NativeSnackBarAppearance.DefaultFont) { messageLabel.Font = SnackBar.Appearance.Font; } _ = StackView ?? throw new NullReferenceException(); StackView.AddArrangedSubview(messageLabel); }
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); }); }
protected override void Initialize() { base.Initialize(); foreach (var action in SnackBar.Actions) { var actionButton = new UIButton(UIButtonType.System); if (action.Appearance.Background != NativeSnackButtonAppearance.DefaultColor) { actionButton.BackgroundColor = action.Appearance.Background; } if (action.Appearance.Foreground != NativeSnackButtonAppearance.DefaultColor) { actionButton.SetTitleColor(action.Appearance.Foreground, UIControlState.Normal); } if (action.Appearance.Font != NativeSnackButtonAppearance.DefaultFont) { actionButton.Font = action.Appearance.Font; } actionButton.SetTitle(action.ActionButtonText, UIControlState.Normal); actionButton.TitleLabel.LineBreakMode = action.Appearance.LineBreakMode; actionButton.TouchUpInside += async(s, e) => { await action.Action(); Dismiss(); }; StackView.AddArrangedSubview(actionButton); } }
protected override void Initialize() { base.Initialize(); var messageLabel = new UILabel { Text = SnackBar.Message, Lines = 0, AdjustsFontSizeToFitWidth = true, TextAlignment = SnackBar.Appearance.TextAlignment }; if (SnackBar.Appearance.Background != NativeSnackBarAppearance.DefaultColor) { messageLabel.BackgroundColor = SnackBar.Appearance.Background; } if (SnackBar.Appearance.Foreground != NativeSnackBarAppearance.DefaultColor) { messageLabel.TextColor = SnackBar.Appearance.Foreground; } if (SnackBar.Appearance.Font != NativeSnackBarAppearance.DefaultFont) { messageLabel.Font = SnackBar.Appearance.Font; } StackView.AddArrangedSubview(messageLabel); }
protected override void Initialize(CGRect cornerRadius) { base.Initialize(cornerRadius); var messageLabel = new PaddedLabel(SnackBar.Layout.PaddingLeft, SnackBar.Layout.PaddingTop, SnackBar.Layout.PaddingRight, SnackBar.Layout.PaddingBottom) { StringValue = SnackBar.Message, Selectable = false, Alignment = SnackBar.Appearance.TextAlignment, TranslatesAutoresizingMaskIntoConstraints = false }; if (SnackBar.Appearance.Background != NativeSnackBarAppearance.DefaultColor) { messageLabel.BackgroundColor = SnackBar.Appearance.Background; } if (SnackBar.Appearance.Foreground != NativeSnackBarAppearance.DefaultColor) { messageLabel.TextColor = SnackBar.Appearance.Foreground; } if (SnackBar.Appearance.Font != NativeSnackBarAppearance.DefaultFont) { messageLabel.Font = SnackBar.Appearance.Font; } StackView?.AddArrangedSubview(messageLabel); }
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 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(); }
protected override void Initialize() { base.Initialize(); foreach (var actionButton in SnackBar.Actions) { StackView?.AddArrangedSubview(actionButton); } }
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 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(); }
protected override void Initialize(CGRect cornerRadius) { base.Initialize(cornerRadius); _ = StackView ?? throw new NullReferenceException(); foreach (var actionButton in SnackBar.Actions) { StackView.AddArrangedSubview(actionButton); } }
private void AddText(string text) { var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = text, Lines = 0 // Wrap text }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); }
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(); }
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(); }
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); }
private void AddHeader(string text) { AddSpacing(16); var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = text, Font = UIFont.PreferredBody.Bold() }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); }
public override void OnViewModelLoadedOverride() { if (ViewModel.Usernames.Length == 0) { // Shouldn't happen return; } AddSpacing(16); var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Your username is: " + ViewModel.Usernames.First() }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); if (ViewModel.Usernames.Length > 1) { AddSpacing(16); var additionalHeader = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Additional usernames...", Font = UIFont.PreferredCaption1.Bold() }; StackView.AddArrangedSubview(additionalHeader); additionalHeader.StretchWidth(StackView, left: 16, right: 16); foreach (var username in ViewModel.Usernames.Skip(1)) { var additionalUsername = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = username, Font = UIFont.PreferredCaption1 }; StackView.AddArrangedSubview(additionalUsername); additionalUsername.StretchWidth(StackView, left: 16, right: 16); } } 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 override void OnViewModelLoadedOverride() { AddSpacing(16); var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = PowerPlannerResources.GetString("Welcome_ConnectAccountPage_Message.Text"), Lines = 0 // Wraps text }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); AddSpacing(24); var buttonLogIn = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Log In"); buttonLogIn.TranslatesAutoresizingMaskIntoConstraints = false; buttonLogIn.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.LogIn(); }).Handler; StackView.AddArrangedSubview(buttonLogIn); buttonLogIn.StretchWidth(StackView, left: 16, right: 16); AddSpacing(6); var labelHelp = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = PowerPlannerResources.GetString("Welcome_ConnectAccountPage_NeedHelp.Text"), Lines = 0, Font = UIFont.PreferredCaption1 }; StackView.AddArrangedSubview(labelHelp); labelHelp.StretchWidth(StackView, left: 16, right: 16); AddSpacing(16); base.OnViewModelLoadedOverride(); }
public override void OnViewModelLoadedOverride() { AddSpacing(16); var label = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = PowerPlannerResources.GetString("Welcome_ExistingUserPage_Message.Text"), Lines = 0 // Wraps text }; StackView.AddArrangedSubview(label); label.StretchWidth(StackView, left: 16, right: 16); AddSpacing(24); var buttonHasAccount = PowerPlannerUIHelper.CreatePowerPlannerBlueButton(PowerPlannerResources.GetString("Welcome_ExistingUserPage_ButtonHasAccount.Content")); buttonHasAccount.TranslatesAutoresizingMaskIntoConstraints = false; buttonHasAccount.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.HasAccount(); }).Handler; StackView.AddArrangedSubview(buttonHasAccount); buttonHasAccount.StretchWidth(StackView, left: 16, right: 16); AddSpacing(8); var buttonNoAccount = PowerPlannerUIHelper.CreatePowerPlannerBlueButton(PowerPlannerResources.GetString("Welcome_ExistingUserPage_ButtonNoAccount.Content")); buttonNoAccount.TranslatesAutoresizingMaskIntoConstraints = false; buttonNoAccount.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.NoAccount(); }).Handler; StackView.AddArrangedSubview(buttonNoAccount); buttonNoAccount.StretchWidth(StackView, left: 16, right: 16); AddSpacing(16); base.OnViewModelLoadedOverride(); }
public ViewGradeViewController() { Title = "View Grade"; var buttonEdit = new UIBarButtonItem(UIBarButtonSystemItem.Edit); buttonEdit.Clicked += new WeakEventHandler(delegate { ViewModel.Edit(); }).Handler; var buttonDelete = new UIBarButtonItem(UIBarButtonSystemItem.Trash); buttonDelete.Clicked += new WeakEventHandler(ButtonDelete_Clicked).Handler; NavItem.RightBarButtonItems = new UIBarButtonItem[] { buttonDelete, buttonEdit }; var labelTitle = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.PreferredTitle3, Lines = 0 }; _itemBindingHost.SetLabelTextBinding(labelTitle, nameof(ViewModel.Grade.Name)); StackView.AddArrangedSubview(labelTitle); labelTitle.StretchWidth(StackView); StackView.AddArrangedSubview(new UIView().SetHeight(4)); var labelSubtitle = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.PreferredSubheadline, Lines = 0 }; _itemBindingHost.SetLabelTextBinding(labelSubtitle, nameof(ViewItemGrade.GradeSubtitle)); _classBindingHost.SetBinding <byte[]>(nameof(ViewItemClass.Color), (color) => { labelSubtitle.TextColor = BareUIHelper.ToColor(color); }); StackView.AddArrangedSubview(labelSubtitle); labelSubtitle.StretchWidth(StackView); StackView.AddArrangedSubview(new UIView().SetHeight(4)); var labelDate = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.PreferredSubheadline, TextColor = UIColor.DarkGray }; _itemBindingHost.SetBinding <DateTime>(nameof(ViewItemGrade.Date), (date) => { labelDate.Text = date.ToString("d"); }); StackView.AddArrangedSubview(labelDate); labelDate.StretchWidth(StackView); StackView.AddArrangedSubview(new UIView().SetHeight(4)); var labelDetails = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Font = UIFont.PreferredCaption1, Lines = 0, TextColor = UIColor.DarkGray }; _itemBindingHost.SetLabelTextBinding(labelDetails, nameof(ViewItemGrade.Details)); StackView.AddArrangedSubview(labelDetails); labelDetails.StretchWidth(StackView); }
public 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 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 override void ViewDidLoad() { base.ViewDidLoad(); View.BackgroundColor = UIColor.Black; Title = Strings.Menu; _imgBackground = new UIImageView(UIImage.FromBundle("Background.jpg")) { //ContentMode = UIViewContentMode. }; _options = new StackView { Axis = UILayoutConstraintAxis.Vertical }; _lineHeaderTop = new UIView { BackgroundColor = UIColor.White }; _lineHeaderBottom = new UIView { BackgroundColor = UIColor.White }; _imgHeaderBackground = new UIImageView(UIImage.FromBundle("menu_header_background")) { ContentMode = UIViewContentMode.ScaleAspectFit }; _imgHeaderProfile = new UIImageView(UIImage.FromBundle("profile")) { BackgroundColor = UIColor.Black, ContentMode = UIViewContentMode.ScaleAspectFit, ClipsToBounds = true }; _imgHeaderProfile.Layer.CornerRadius = PROFILE_IMAGE_SIZE / 2; _lblHeaderName = new UILabel { Font = UIFont.SystemFontOfSize(22f, UIFontWeight.Bold), TextColor = UIColor.White, Text = "Darth Vader" }; _optionStatistics = new MenuOption(); _optionStatistics.Image.Image = UIImage.FromBundle("ic_statistics"); _optionStatistics.Label.Text = Strings.Statistics; _optionOther1 = new MenuOption(); _optionOther1.Image.Image = UIImage.FromBundle("ic_another_option"); _optionOther1.Label.Text = Strings.AnotherOption; _optionOther2 = new MenuOption(); _optionOther2.Image.Image = UIImage.FromBundle("ic_another_option"); _optionOther2.Label.Text = Strings.AnotherOption; View.AddSubviews(_imgBackground, _lineHeaderTop, _imgHeaderBackground, _lineHeaderBottom, _imgHeaderProfile, _lblHeaderName, _options); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); _options.AddArrangedSubview(_optionStatistics); _options.AddArrangedSubview(_optionOther1); _options.AddArrangedSubview(_optionOther2); View.AddConstraints( _imgBackground.AtLeftOf(View), _imgBackground.AtTopOf(View), _imgBackground.AtBottomOf(View), _imgBackground.AtRightOf(View), _lineHeaderTop.AtLeftOf(View), _lineHeaderTop.AtTopOf(View), _lineHeaderTop.AtRightOf(View), _lineHeaderTop.Height().EqualTo(.5f), _imgHeaderBackground.Below(_lineHeaderTop), _imgHeaderBackground.AtLeftOf(View), _imgHeaderBackground.AtRightOf(View), _imgHeaderBackground.Height().EqualTo(180f), _lineHeaderBottom.Below(_imgHeaderBackground), _lineHeaderBottom.AtLeftOf(View), _lineHeaderBottom.AtRightOf(View), _lineHeaderBottom.Height().EqualTo(.5f), _imgHeaderProfile.WithSameCenterX(_imgHeaderBackground), _imgHeaderProfile.WithSameCenterY(_imgHeaderBackground).Minus(20f), _imgHeaderProfile.Width().EqualTo(PROFILE_IMAGE_SIZE), _imgHeaderProfile.Height().EqualTo(PROFILE_IMAGE_SIZE), _lblHeaderName.WithSameCenterX(_imgHeaderBackground), _lblHeaderName.Below(_imgHeaderProfile), _options.Below(_lineHeaderBottom), _options.AtLeftOf(View), _options.AtRightOf(View) ); var set = this.CreateBindingSet <MenuView, MenuViewModel>(); set.Bind(_optionStatistics.Tap()).For(g => g.Command).To(vm => vm.ShowStatusCommand); set.Apply(); }
public override void OnViewModelLoadedOverride() { AddTopSectionDivider(); _errorContainer = new BareUIVisibilityContainer() { TranslatesAutoresizingMaskIntoConstraints = false, IsVisible = false }; { var stackViewIncorrect = new UIStackView() { Axis = UILayoutConstraintAxis.Vertical }; stackViewIncorrect.AddArrangedSubview(new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }.SetHeight(8)); _labelError = new UILabel() { TranslatesAutoresizingMaskIntoConstraints = false, Text = "Error", Lines = 0, TextColor = UIColor.Red }; stackViewIncorrect.AddArrangedSubview(_labelError); _labelError.StretchWidth(stackViewIncorrect, left: 16, right: 16); stackViewIncorrect.AddArrangedSubview(new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }.SetHeight(8)); AddDivider(stackViewIncorrect); _errorContainer.Child = stackViewIncorrect; } StackView.AddArrangedSubview(_errorContainer); _errorContainer.StretchWidth(StackView); var textField = new UITextField() { Placeholder = "New username", AutocapitalizationType = UITextAutocapitalizationType.None, AutocorrectionType = UITextAutocorrectionType.No, KeyboardType = UIKeyboardType.ASCIICapable, ReturnKeyType = UIReturnKeyType.Done }; textField.AddTarget(new WeakEventHandler <EventArgs>(delegate { _errorContainer.IsVisible = false; }).Handler, UIControlEvent.EditingChanged); AddTextField(textField, nameof(ViewModel.Username), firstResponder: true); AddSectionDivider(); var buttonContinue = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false }; buttonContinue.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.Update(); }).Handler; buttonContinue.SetTitle("Update Username", UIControlState.Normal); StackView.AddArrangedSubview(buttonContinue); buttonContinue.StretchWidth(StackView); buttonContinue.SetHeight(44); AddBottomSectionDivider(); ViewModel.ActionError += new WeakEventHandler <string>(ViewModel_ActionError).Handler; BindingHost.SetBinding(nameof(ViewModel.IsUpdatingUsername), delegate { IsLoadingOverlayVisible = ViewModel.IsUpdatingUsername; }); base.OnViewModelLoadedOverride(); }
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(); }