public override void ViewDidLoad() { base.ViewDidLoad(); var model = _filterController.Filter.Clone(); //Load the root var root = new RootElement(Title) { new Section("Filter") { (_open = new TrueFalseElement("Open?", model.Open)), (_labels = new InputElement("Labels", "bug,ui,@user", model.Labels) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), (_mentioned = new InputElement("Mentioned", "User", model.Mentioned) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), (_creator = new InputElement("Creator", "User", model.Creator) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), (_assignee = new InputElement("Assignee", "User", model.Assignee) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), (_milestone = new StyledStringElement("Milestone", "None", UITableViewCellStyle.Value1)), }, new Section("Order By") { (_sort = CreateEnumElement("Field", model.SortType)), (_asc = new TrueFalseElement("Ascending", model.Ascending)) }, new Section(string.Empty, "Saving this filter as a default will save it only for this repository.") { new StyledStringElement("Save as Default", () =>{ _filterController.ApplyFilter(CreateFilterModel(), true); CloseViewController(); }, Images.Size) { Accessory = UITableViewCellAccessory.None }, } }; RefreshMilestone(); _milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator; _milestone.Tapped += () => { var ctrl = new IssueMilestonesFilterViewController(_user, _repo, _milestoneHolder != null); ctrl.MilestoneSelected = (title, num, val) => { if (title == null && num == null && val == null) _milestoneHolder = null; else _milestoneHolder = new IssuesFilterModel.MilestoneKeyValue { Name = title, Value = val, IsMilestone = num.HasValue }; RefreshMilestone(); NavigationController.PopViewControllerAnimated(true); }; NavigationController.PushViewController(ctrl, true); }; Root = root; }
public override void ViewDidLoad() { Title = "New Issue"; base.ViewDidLoad(); _hud = this.CreateHud(); var vm = (IssueAddViewModel)ViewModel; NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => { View.EndEditing(true); vm.SaveCommand.Execute(null); }); var title = new InputElement("Title", string.Empty, string.Empty); title.Changed += (object sender, EventArgs e) => vm.Title = title.Value; var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1); assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator; assignedTo.Tapped += () => vm.GoToAssigneeCommand.Execute(null); var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1); milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator; milestone.Tapped += () => vm.GoToMilestonesCommand.Execute(null); var labels = new StyledStringElement("Labels".t(), "None", UITableViewCellStyle.Value1); labels.Accessory = UITableViewCellAccessory.DisclosureIndicator; labels.Tapped += () => vm.GoToLabelsCommand.Execute(null); var content = new MultilinedElement("Description"); content.Tapped += () => { var composer = new MarkdownComposerViewController { Title = "Issue Description", Text = content.Value }; composer.NewComment(this, (text) => { vm.Content = text; composer.CloseComposer(); }); }; vm.Bind(x => x.Title, x => title.Value = x); vm.Bind(x => x.Content, x => content.Value = x); vm.Bind(x => x.AssignedTo, x => { assignedTo.Value = x == null ? "Unassigned" : x.Login; Root.Reload(assignedTo, UITableViewRowAnimation.None); }); vm.Bind(x => x.Milestone, x => { milestone.Value = x == null ? "None" : x.Title; Root.Reload(milestone, UITableViewRowAnimation.None); }); vm.BindCollection(x => x.Labels, x => { labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name)); Root.Reload(labels, UITableViewRowAnimation.None); }); vm.Bind(x => x.IsSaving, x => { if (x) _hud.Show("Saving..."); else _hud.Hide(); }); Root = new RootElement(Title) { new Section { title, assignedTo, milestone, labels }, new Section { content } }; }
public override void ViewDidLoad() { base.ViewDidLoad(); _hud = this.CreateHud(); NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => { View.EndEditing(true); ViewModel.SaveCommand.Execute(null); }); var title = new InputElement("Title", string.Empty, string.Empty) { TextAlignment = UITextAlignment.Right }; title.Changed += (object sender, EventArgs e) => ViewModel.Title = title.Value; var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1); assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator; assignedTo.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null); var kind = new StyledStringElement("Issue Type", ViewModel.Kind, UITableViewCellStyle.Value1); kind.Accessory = UITableViewCellAccessory.DisclosureIndicator; kind.Tapped += () => { var ctrl = new IssueAttributesView(IssueModifyViewModel.Kinds, ViewModel.Kind) { Title = "Issue Type" }; ctrl.SelectedValue = x => ViewModel.Kind = x.ToLower(); NavigationController.PushViewController(ctrl, true); }; var priority = new StyledStringElement("Priority", ViewModel.Priority, UITableViewCellStyle.Value1); priority.Accessory = UITableViewCellAccessory.DisclosureIndicator; priority.Tapped += () => { var ctrl = new IssueAttributesView(IssueModifyViewModel.Priorities, ViewModel.Priority) { Title = "Priority" }; ctrl.SelectedValue = x => ViewModel.Priority = x.ToLower(); NavigationController.PushViewController(ctrl, true); }; var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1); milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator; milestone.Tapped += () => ViewModel.GoToMilestonesCommand.Execute(null); var component = new StyledStringElement("Component".t(), "None", UITableViewCellStyle.Value1); component.Accessory = UITableViewCellAccessory.DisclosureIndicator; component.Tapped += () => ViewModel.GoToComponentsCommand.Execute(null); var version = new StyledStringElement("Version".t(), "None", UITableViewCellStyle.Value1); version.Accessory = UITableViewCellAccessory.DisclosureIndicator; version.Tapped += () => ViewModel.GoToVersionsCommand.Execute(null); var content = new MultilinedElement("Description"); content.Tapped += () => { var composer = new Composer { Title = "Issue Description", Text = content.Value }; composer.NewComment(this, (text) => { ViewModel.Content = text; composer.CloseComposer(); }); }; ViewModel.Bind(x => x.IsSaving, x => { if (x) _hud.Show("Saving..."); else _hud.Hide(); }); Root = new RootElement(Title) { new Section { title, assignedTo, kind, priority }, new Section { milestone, component, version }, new Section { content } }; ViewModel.Bind(x => x.Title, x => { title.Value = x; Root.Reload(title, UITableViewRowAnimation.None); }, true); ViewModel.Bind(x => x.AssignedTo, x => { assignedTo.Value = x == null ? "Unassigned" : x.Username; Root.Reload(assignedTo, UITableViewRowAnimation.None); }, true); ViewModel.Bind(x => x.Kind, x => { kind.Value = x; Root.Reload(kind, UITableViewRowAnimation.None); }, true); ViewModel.Bind(x => x.Priority, x => { priority.Value = x; Root.Reload(priority, UITableViewRowAnimation.None); }, true); ViewModel.Bind(x => x.Milestone, x => { milestone.Value = x ?? "None"; Root.Reload(milestone, UITableViewRowAnimation.None); }, true); ViewModel.Bind(x => x.Component, x => { component.Value = x ?? "None"; Root.Reload(component, UITableViewRowAnimation.None); }, true); ViewModel.Bind(x => x.Version, x => { version.Value = x ?? "None"; Root.Reload(version, UITableViewRowAnimation.None); }, true); ViewModel.Bind(x => x.Content, x => { content.Value = x; Root.Reload(content, UITableViewRowAnimation.None); }, true); }