Example #1
0
        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();
                    });
                }));
            });
        }
Example #2
0
        void AddCommentTapped()
        {
            var composer = new MarkdownComposerViewController();
            composer.NewComment(this, async (text) => {

                var hud = this.CreateHud();
                hud.Show("Posting Comment...");
                if (await ViewModel.AddComment(text))
                    composer.CloseComposer();
                hud.Hide();
                composer.EnableSendButton = true;
            });
        }
Example #3
0
 private void ShowCommentComposer(int line)
 {
     var composer = new MarkdownComposerViewController();
     composer.NewComment(this, async (text) => {
         try
         {
             await composer.DoWorkAsync("Commenting...", () => ViewModel.PostComment(text, line));
             composer.CloseComposer();
         }
         catch (Exception e)
         {
             AlertDialogService.ShowAlert("Unable to Comment", e.Message);
             composer.EnableSendButton = true;
         }
     });
 }
Example #4
0
		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 } };
		}
Example #5
0
        void AddCommentTapped()
        {
            var composer = new MarkdownComposerViewController();
			composer.NewComment(this, async (text) => {
                try
                {
					await composer.DoWorkAsync("Commenting...".t(), () => ViewModel.AddComment(text));
					composer.CloseComposer();
                }
                catch (Exception e)
                {
					MonoTouch.Utilities.ShowAlert("Unable to post comment!", e.Message);
                }
                finally
                {
                    composer.EnableSendButton = true;
                }
            });
        }