public override void ViewDidLoad()
        {
            base.ViewDidLoad();

			//Load the root
            var root = new List<Section> {
                new Section() {
                    (_filterName = new EntryElement("Filter Name", "Filter Name", _currentFilter.FilterName) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None })
                },
				new Section("Filter") {
                    (_assignedTo = new EntryElement("Assigned To", "Anybody", _currentFilter.AssignedTo) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_reportedBy = new EntryElement("Reported By", "Anybody", _currentFilter.ReportedBy) { TextAlignment = UITextAlignment.Right, AutocorrectionType = UITextAutocorrectionType.No, AutocapitalizationType = UITextAutocapitalizationType.None }),
                    (_kindChoice = CreateMultipleChoiceElement("Kind", _currentFilter.Kind)),
                    (_statusChoice = CreateMultipleChoiceElement("Status", _currentFilter.Status)),
                    (_priorityChoice = CreateMultipleChoiceElement("Priority", _currentFilter.Priority)),
				},
				new Section("Order By") {
                    (_orderby = CreateEnumElement<IssuesFilterModel.Order>("Field", _currentFilter.OrderBy)),
				}
			};

            Root.Reset(root);
        }
Beispiel #2
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

            var save = NavigationItem.RightBarButtonItem = new UIBarButtonItem { Image = Images.Buttons.Save };

            var title = new EntryElement("Title", string.Empty, string.Empty) { TextAlignment = UITextAlignment.Right };
            var assignedTo = new StringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);
            var kind = new StringElement("Issue Type", ViewModel.Kind, UITableViewCellStyle.Value1);
            var priority = new StringElement("Priority", ViewModel.Priority, UITableViewCellStyle.Value1);
            var milestone = new StringElement("Milestone", "None", UITableViewCellStyle.Value1);
            var component = new StringElement("Component", "None", UITableViewCellStyle.Value1);
            var version = new StringElement("Version", "None", UITableViewCellStyle.Value1);
			var content = new MultilinedElement("Description");
	
            Root.Reset(new Section { title, assignedTo, kind, priority }, new Section { milestone, component, version }, new Section { content });

            OnActivation(d =>
            {
                d(ViewModel.Bind(x => x.IsSaving).SubscribeStatus("Saving..."));

                d(ViewModel.Bind(x => x.Title).Subscribe(x => title.Value = x));
                d(ViewModel.Bind(x => x.AssignedTo).Subscribe(x => assignedTo.Value = x == null ? "Unassigned" : x.Username));

                d(ViewModel.Bind(x => x.Kind, true).Subscribe(x => kind.Value = x));
                d(ViewModel.Bind(x => x.Priority, true).Subscribe(x => priority.Value = x));
                d(ViewModel.Bind(x => x.Milestone, true).Subscribe(x => milestone.Value = x ?? "None"));
                d(ViewModel.Bind(x => x.Component, true).Subscribe(x => component.Value = x ?? "None"));
                d(ViewModel.Bind(x => x.Version, true).Subscribe(x => version.Value = x ?? "None"));
                d(ViewModel.Bind(x => x.Content, true).Subscribe(x => version.Value = x));

                d(title.Changed.Subscribe(x =>  ViewModel.Title = x));
                d(version.Clicked.BindCommand(ViewModel.GoToVersionsCommand));
                d(assignedTo.Clicked.BindCommand(ViewModel.GoToAssigneeCommand));
                d(milestone.Clicked.BindCommand(ViewModel.GoToMilestonesCommand));
                d(component.Clicked.BindCommand(ViewModel.GoToComponentsCommand));

                d(save.GetClickedObservable().Subscribe(_ => {
                    View.EndEditing(true);
                    ViewModel.SaveCommand.Execute(null);
                }));

                d(content.Clicked.Subscribe(_ => 
                {
                    var composer = new Composer { Title = "Issue Description", Text = ViewModel.Content };
                    composer.NewComment(this, (text) => {
                        ViewModel.Content = text;
                        composer.CloseComposer();
                    });
                }));

                d(priority.Clicked.Subscribe(_ => 
                {
                    var ctrl = new IssueAttributesView(IssueModifyViewModel.Priorities, ViewModel.Priority) { Title = "Priority" };
                    ctrl.SelectedValue = x => ViewModel.Priority = x.ToLower();
                    NavigationController.PushViewController(ctrl, true);
                }));

                d(kind.Clicked.Subscribe(_ => 
                {
                    var ctrl = new IssueAttributesView(IssueModifyViewModel.Kinds, ViewModel.Kind) { Title = "Issue Type" };
                    ctrl.SelectedValue = x => ViewModel.Kind = x.ToLower();
                    NavigationController.PushViewController(ctrl, true);
                }));
            });
		}
Beispiel #3
0
        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);
        }