public override void ViewDidLoad() { base.ViewDidLoad(); var model = _filterController.Filter.Clone(); var save = new StringElement("Save as Default") { Accessory = UITableViewCellAccessory.None }; save.Clicked.Subscribe(_ => { _filterController.ApplyFilter(CreateFilterModel(), true); CloseViewController(); }); //Load the root var sections = new [] { new Section("Filter") { (_filter = CreateEnumElement("Type", model.FilterType)), (_open = new BooleanElement("Open?", model.Open)), (_labels = new EntryElement("Labels", "bug,ui,@user", model.Labels) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), }, new Section("Order By") { (_sort = CreateEnumElement("Field", model.SortType)), (_asc = new BooleanElement("Ascending", model.Ascending)) }, new Section() { save, } }; Root.Reset(sections); }
public override void ViewDidLoad() { base.ViewDidLoad(); TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 44f; var vm = (IssueAddViewModel)ViewModel; var saveButton = new UIBarButtonItem { Image = Images.Buttons.SaveButton }; NavigationItem.RightBarButtonItem = saveButton; var title = new EntryElement("Title", string.Empty, string.Empty); var assignedTo = new StringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1); var milestone = new StringElement("Milestone", "None", UITableViewCellStyle.Value1); var labels = new StringElement("Labels", "None", UITableViewCellStyle.Value1); var content = new MultilinedElement("Description"); Root.Reset(new Section { title, assignedTo, milestone, labels }, new Section { content }); OnActivation(d => { d(vm.Bind(x => x.IssueTitle, true).Subscribe(x => title.Value = x)); d(title.Changed.Subscribe(x => vm.IssueTitle = x)); d(vm.Bind(x => x.Content, true).Subscribe(x => content.Details = x)); d(labels.Clicked.Subscribe(_ => vm.GoToLabelsCommand.Execute(null))); d(milestone.Clicked.Subscribe(_ => vm.GoToMilestonesCommand.Execute(null))); d(assignedTo.Clicked.Subscribe(_ => vm.GoToAssigneeCommand.Execute(null))); d(vm.Bind(x => x.IsSaving).SubscribeStatus("Saving...")); d(vm.Bind(x => x.AssignedTo, true).Subscribe(x => { assignedTo.Value = x == null ? "Unassigned" : x.Login; })); d(vm.Bind(x => x.Milestone, true).Subscribe(x => { milestone.Value = x == null ? "None" : x.Title; })); d(vm.BindCollection(x => x.Labels, true).Subscribe(_ => { labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name)); })); d(saveButton.GetClickedObservable().Subscribe(_ => { View.EndEditing(true); vm.SaveCommand.Execute(null); })); d(content.Clicked.Subscribe(_ => { var composer = new MarkdownComposerViewController { Title = "Issue Description", Text = content.Details }; composer.NewComment(this, (text) => { vm.Content = text; composer.CloseComposer(); }); })); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var model = _filterController.Filter.Clone(); var save = new StringElement("Save as Default") { Accessory = UITableViewCellAccessory.None }; save.Clicked.Subscribe(_ => { _filterController.ApplyFilter(CreateFilterModel(), true); CloseViewController(); }); //Load the root var root = new [] { new Section("Filter") { (_open = new BooleanElement("Open?", model.Open)), (_labels = new EntryElement("Labels", "bug,ui,@user", model.Labels) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), (_mentioned = new EntryElement("Mentioned", "User", model.Mentioned) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), (_creator = new EntryElement("Creator", "User", model.Creator) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), (_assignee = new EntryElement("Assignee", "User", model.Assignee) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }), (_milestone = new StringElement("Milestone", "None", UITableViewCellStyle.Value1)), }, new Section("Order By") { (_sort = CreateEnumElement("Field", model.SortType)), (_asc = new BooleanElement("Ascending", model.Ascending)) }, new Section(string.Empty, "Saving this filter as a default will save it only for this repository.") { save } }; RefreshMilestone(); _milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator; _milestone.Clicked.Subscribe(_ => { 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.PopViewController(true); }; NavigationController.PushViewController(ctrl, true); }); Root.Reset(root); }
public override UITableViewCell GetCell(UITableView tv) { if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, cellkey); cell.SelectionStyle = UITableViewCellSelectionStyle.None; } cell.TextLabel.Text = Caption; var offset = (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) ? 20 : 90; cell.Frame = new CGRect(cell.Frame.X, cell.Frame.Y, tv.Frame.Width - offset, cell.Frame.Height); CGSize size = ComputeEntryPosition(tv, cell); var yOffset = (cell.ContentView.Bounds.Height - size.Height) / 2 - 1; var width = cell.ContentView.Bounds.Width - size.Width; if (textalignment == UITextAlignment.Right) { // Add padding if right aligned width -= 10; } var entryFrame = new CGRect(size.Width, yOffset + 2f, width, size.Height); if (entry == null) { entry = CreateTextField(entryFrame); entry.ValueChanged += (sender, e) => Value = entry.Text; entry.EditingChanged += (sender, e) => Value = entry.Text; entry.Ended += (sender, e) => Value = entry.Text; entry.AllEditingEvents += (sender, e) => Value = entry.Text; entry.ShouldReturn += delegate { if (ShouldReturn != null) { return(ShouldReturn()); } RootElement root = GetRootElement(); EntryElement focus = null; if (root == null) { return(true); } foreach (var s in root) { foreach (var e in s) { if (e == this) { focus = this; } else if (focus != null && e is EntryElement) { focus = e as EntryElement; break; } } if (focus != null && focus != this) { break; } } if (focus != this) { focus.BecomeFirstResponder(true); } else { focus.ResignFirstResponder(true); } return(true); }; entry.Started += delegate { EntryElement self = null; if (!returnKeyType.HasValue) { var returnType = UIReturnKeyType.Default; foreach (var e in Section) { if (e == this) { self = this; } else if (self != null && e is EntryElement) { returnType = UIReturnKeyType.Next; } } entry.ReturnKeyType = returnType; } else { entry.ReturnKeyType = returnKeyType.Value; } tv.ScrollToRow(IndexPath, UITableViewScrollPosition.Middle, true); }; cell.ContentView.AddSubview(entry); } else { entry.Frame = entryFrame; } if (becomeResponder) { entry.BecomeFirstResponder(); becomeResponder = false; } entry.KeyboardType = KeyboardType; entry.AutocapitalizationType = AutocapitalizationType; entry.AutocorrectionType = AutocorrectionType; cell.TextLabel.Text = Caption; cell.TextLabel.Font = TitleFont; cell.TextLabel.TextColor = TitleColor; return(cell); }