示例#1
0
		public override void ViewDidLoad()
		{
			Title = "Edit Issue";

			base.ViewDidLoad();

            var status = new StringElement("Status", ViewModel.Status, UITableViewCellStyle.Value1);
            var delete = new StringElement("Delete", AtlassianIcon.Delete.ToImage()) { Accessory = UITableViewCellAccessory.None };

            Root[0].Insert(1, UITableViewRowAnimation.None, status);
            Root.Insert(Root.Count, UITableViewRowAnimation.None, new Section { delete });

            OnActivation(d =>
            {
                d(ViewModel.Bind(x => x.Status, true).Subscribe(x => status.Value = x));
                d(delete.Clicked.BindCommand(ViewModel.DeleteCommand));
                d(status.Clicked.Subscribe(_ =>
                {
                    var ctrl = new IssueAttributesView(IssueModifyViewModel.Statuses, ViewModel.Status) { Title = "Status" };
                    ctrl.SelectedValue = x => ViewModel.Status = x.ToLower();
                    NavigationController.PushViewController(ctrl, true);
                }));
            });

		}
示例#2
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     var vm = (ChangesetBranchesViewModel) ViewModel;
     var weakVm = new WeakReference<ChangesetBranchesViewModel>(vm);
     BindCollection(vm.Branches, x => 
     {
         var e = new StringElement(x.Name);
         e.Clicked.Subscribe(_ => weakVm.Get()?.GoToBranchCommand.Execute(x));
         return e;
     });
 }
示例#3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

			var vm = (GroupsViewModel) ViewModel;
            var weakVm = new WeakReference<GroupsViewModel>(vm);
			BindCollection(vm.Organizations, x =>
			{
                var e = new StringElement(x.Name);
                e.Clicked.Select(_ => x).BindCommand(weakVm.Get()?.GoToGroupCommand);
				return e;
			});
        }
示例#4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var vm = (TeamsViewModel) ViewModel;
            var weakVm = new WeakReference<TeamsViewModel>(vm);
            BindCollection(vm.Teams, x => 
            {
                var e = new StringElement(x);
                e.Clicked.Subscribe(_ => weakVm.Get()?.GoToTeamCommand.Execute(x));
                return e;
            });
        }
示例#5
0
		private void CreateTable()
		{
			var application = Mvx.Resolve<IApplicationService>();
			var vm = (SettingsViewModel)ViewModel;
			var currentAccount = application.Account;

            var showOrganizationsInEvents = new BooleanElement("Show Teams under Events", currentAccount.ShowTeamEvents);
            showOrganizationsInEvents.Changed.Subscribe(e =>
			{ 
				currentAccount.ShowTeamEvents = e;
				application.Accounts.Update(currentAccount);
			});

            var showOrganizations = new BooleanElement("List Teams & Groups in Menu", currentAccount.ExpandTeamsAndGroups);
            showOrganizations.Changed.Subscribe(x =>
            {
				currentAccount.ExpandTeamsAndGroups = x;
				application.Accounts.Update(currentAccount);
			});

            var repoDescriptions = new BooleanElement("Show Repo Descriptions", currentAccount.RepositoryDescriptionInList);
            repoDescriptions.Changed.Subscribe(e =>
			{ 
				currentAccount.RepositoryDescriptionInList = e;
				application.Accounts.Update(currentAccount);
			});

            var startupView = new ButtonElement("Startup View", vm.DefaultStartupViewName);
            startupView.Clicked.BindCommand(vm.GoToDefaultStartupViewCommand);

            var sourceCommand = new ButtonElement("Source Code");
            sourceCommand.Clicked.Subscribe(_ => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://github.com/thedillonb/CodeBucket")));

            var twitter = new StringElement("Follow On Twitter");
            twitter.Clicked.Subscribe(_ => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://twitter.com/Codebucketapp")));

            var rate = new StringElement("Rate This App");
            rate.Clicked.Subscribe(_ => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://itunes.apple.com/us/app/codebucket/id551531422?mt=8")));

			//Assign the root
            ICollection<Section> root = new LinkedList<Section>();
            root.Add(new Section());
            root.Add(new Section { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView });
            root.Add(new Section(String.Empty, "Thank you for downloading. Enjoy!")
            {
                sourceCommand, twitter, rate,
                new StringElement("App Version", NSBundle.MainBundle.InfoDictionary.ValueForKey(new NSString("CFBundleVersion")).ToString())
            });
            Root.Reset(root);

		}
示例#6
0
 private static Element CreateElement(SourceTreeViewModel.SourceModel x, WeakReference<SourceTreeViewModel> viewModel)
 {
     if (x.Type.Equals("dir", StringComparison.OrdinalIgnoreCase))
     {
         var e = new StringElement(x.Name, AtlassianIcon.Devtoolsfolderclosed.ToImage());
         e.Clicked.Select(_ => x).BindCommand(viewModel.Get()?.GoToSourceCommand);
         return e;
     }
     if (x.Type.Equals("file", StringComparison.OrdinalIgnoreCase))
     {
         var e = new StringElement(x.Name, AtlassianIcon.Devtoolsfile.ToImage());
         e.Clicked.Select(_ => x).BindCommand(viewModel.Get()?.GoToSourceCommand);
         return e;
     }
     return new StringElement(x.Name) { Image = AtlassianIcon.Devtoolsfilebinary.ToImage() };
 }
示例#7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            HeaderView.Text = ViewModel.Username;
            Title = ViewModel.Username;

            var followers = new StringElement("Followers", AtlassianIcon.Star.ToImage());
            var events = new StringElement("Events", AtlassianIcon.Blogroll.ToImage());
            var organizations = new StringElement("Groups", AtlassianIcon.Group.ToImage());
            var repos = new StringElement("Repositories", AtlassianIcon.Devtoolsrepository.ToImage());
            var following = new StringElement("Following", AtlassianIcon.View.ToImage());
            var midSec = new Section(new UIView(new CGRect(0, 0, 0, 20f))) { events, organizations, followers, following };
            Root.Reset(midSec, new Section { repos });

            OnActivation(d =>
            {
                d(followers.Clicked.BindCommand(ViewModel.GoToFollowersCommand));
                d(events.Clicked.BindCommand(ViewModel.GoToEventsCommand));
                d(organizations.Clicked.BindCommand(ViewModel.GoToGroupsCommand));
                d(repos.Clicked.BindCommand(ViewModel.GoToRepositoriesCommand));
                d(following.Clicked.BindCommand(ViewModel.GoToFollowingCommand));

                d(ViewModel.Bind(x => x.User, true).IsNotNull().Subscribe(x =>
                {
                    if (x == null)
                    {
                        HeaderView.SetImage(null, Images.Avatar);
                    }
                    else
                    {
                        var name = x.FirstName + " " + x.LastName;
                        HeaderView.SubText = string.IsNullOrWhiteSpace(name) ? x.Username : name;
                        HeaderView.SetImage(new Avatar(x.Avatar).ToUrl(128), Images.Avatar);
                        RefreshHeaderView();
                    }
                }));
            });

//			if (!ViewModel.IsLoggedInUser)
//				NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowExtraMenu());
        }
示例#8
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			var sec = new Section();
			foreach (var val in _values)
			{
				var capture = val;
				var el = new StringElement(val);
				if (string.Equals(val, _selected, StringComparison.OrdinalIgnoreCase))
					el.Accessory = UIKit.UITableViewCellAccessory.Checkmark;
                el.Clicked.Subscribe(_ =>
                {
                    SelectedValue?.Invoke(capture);
                    NavigationController.PopViewController(true);
                });
				sec.Add(el);
			}

            Root.Reset(sec);
		}
示例#9
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			var vm = (DefaultStartupViewModel)ViewModel;
			BindCollection(vm.StartupViews, x => {
                var e = new StringElement(x);
                e.Clicked.Subscribe(_ => vm.SelectedStartupView = x);
				if (string.Equals(vm.SelectedStartupView, x))
					e.Accessory = UITableViewCellAccessory.Checkmark;
				return e;
			}, true);

            vm.Bind(x => x.SelectedStartupView, true).Subscribe(x =>
			{
				if (Root.Count == 0)
					return;
                foreach (var m in Root[0].Elements.Cast<StringElement>())
					m.Accessory = (string.Equals(m.Caption, x)) ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None;
			});
		}
示例#10
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			var viewSegment = new UISegmentedControl(new object[] {"Branches", "Tags"});
            NavigationItem.TitleView = viewSegment;

			var vm = (BranchesAndTagsViewModel)ViewModel;
            var weakVm = new WeakReference<BranchesAndTagsViewModel>(vm);

            BindCollection(vm.Items, x => {
                var e = new StringElement(x.Name);
                e.Clicked.Subscribe(MakeCallback(weakVm, x));
                return e;
            });
		
            OnActivation(d =>
            {
                d(vm.Bind(x => x.SelectedFilter, true).Subscribe(x => viewSegment.SelectedSegment = x));
                d(viewSegment.GetChangedObservable().Subscribe(x => vm.SelectedFilter = x));
            });
		}
示例#11
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = ViewModel.Name;

            var followers = new StringElement("Followers", AtlassianIcon.Star.ToImage());
            var events = new StringElement("Events", AtlassianIcon.Blogroll.ToImage());
            var organizations = new StringElement("Groups", AtlassianIcon.Group.ToImage());
            var repos = new StringElement("Repositories", AtlassianIcon.Devtoolsrepository.ToImage());
            var members = new StringElement("Members", AtlassianIcon.User.ToImage());
            var midSec = new Section(new UIView(new CGRect(0, 0, 0, 20f))) { events, organizations, members, followers };
            Root.Reset(midSec, new Section { repos });

            OnActivation(d => 
            {
                d(followers.Clicked.BindCommand(ViewModel.GoToFollowersCommand));
                d(events.Clicked.BindCommand(ViewModel.GoToEventsCommand));
                d(organizations.Clicked.BindCommand(ViewModel.GoToGroupsCommand));
                d(repos.Clicked.BindCommand(ViewModel.GoToRepositoriesCommand));
                d(members.Clicked.BindCommand(ViewModel.GoToMembersCommand));

                d(ViewModel.Bind(x => x.User, true).Subscribe(x =>
                {
                    if (x == null)
                    {
                        HeaderView.SetImage(null, Images.Avatar);
                    }
                    else
                    {
                        var name = x.FirstName + " " + x.LastName;
                        HeaderView.SubText = string.IsNullOrWhiteSpace(name) ? x.Username : name;
                        HeaderView.SetImage(new Avatar(x.Avatar).ToUrl(128), Images.Avatar);
                        RefreshHeaderView();
                    }
                }));
            });
        }
示例#12
0
		public void RenderIssue()
		{
			if (ViewModel.Issue == null)
				return;

            var avatar = new Avatar(ViewModel.Issue.ReportedBy?.Avatar);

			NavigationItem.RightBarButtonItem.Enabled = true;
            HeaderView.Text = ViewModel.Issue.Title;
            HeaderView.SetImage(avatar.ToUrl(), Images.Avatar);
            HeaderView.SubText = ViewModel.Issue.Content ?? "Updated " + ViewModel.Issue.UtcLastUpdated.Humanize();
            RefreshHeaderView();

            var split = new SplitButtonElement();
            split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString());
            split.AddButton("Watches", ViewModel.Issue.FollowerCount.ToString());

            ICollection<Section> root = new LinkedList<Section>();
            root.Add(new Section { split });

			var secDetails = new Section();

			if (!string.IsNullOrEmpty(ViewModel.Issue.Content))
			{
                _descriptionElement.SetValue(new MarkdownRazorView { Model = ViewModel.Issue.Content }.GenerateString());
				secDetails.Add(_descriptionElement);
			}

            _split1.Button1.Text = ViewModel.Issue.Status;
            _split1.Button2.Text = ViewModel.Issue.Priority;
            secDetails.Add(_split1);

            _split2.Button1.Text = ViewModel.Issue.Metadata.Kind;
            _split2.Button2.Text = ViewModel.Issue.Metadata.Component ?? "No Component";
			secDetails.Add(_split2);

            _split3.Button1.Text = ViewModel.Issue.Metadata.Version ?? "No Version";
            _split3.Button2.Text = ViewModel.Issue.Metadata.Milestone ?? "No Milestone";
            secDetails.Add(_split3);

            var assigneeElement = new StringElement("Assigned", ViewModel.Issue.Responsible != null ? ViewModel.Issue.Responsible.Username : "******", UITableViewCellStyle.Value1) {
                Image = AtlassianIcon.User.ToImage(),
			};
            assigneeElement.Clicked.BindCommand(ViewModel.GoToAssigneeCommand);
			secDetails.Add(assigneeElement);

			root.Add(secDetails);

            if (ViewModel.Comments.Any(x => !string.IsNullOrEmpty(x.Content)))
			{
				root.Add(new Section { _commentsElement });
			}

            var addComment = new StringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() };
            addComment.Clicked.Subscribe(_ => AddCommentTapped());
			root.Add(new Section { addComment });
            Root.Reset(root);
		}
示例#13
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);
                }));
            });
		}
示例#14
0
		public void Render(RepositoryDetailedModel model)
        {
            if (model == null)
                return;
            
			Title = model.Name;

            var avatar = new Avatar(model.Logo).ToUrl(128);
            ICollection<Section> root = new LinkedList<Section>();
            HeaderView.SubText = string.IsNullOrWhiteSpace(model.Description) ? "Updated " + model.UtcLastUpdated.Humanize() : model.Description;
            HeaderView.SetImage(avatar, Images.RepoPlaceholder);
            RefreshHeaderView();

            var sec1 = new Section();

            _split1.Button1.Image = model.IsPrivate ? AtlassianIcon.Locked.ToImage() : AtlassianIcon.Unlocked.ToImage();
            _split1.Button1.Text = model.IsPrivate ? "Private" : "Public";
            _split1.Button2.Text = string.IsNullOrEmpty(model.Language) ? "N/A" : model.Language;
            sec1.Add(_split1);

            _split3.Button1.Text = model.Scm.ApplyCase(LetterCasing.Title);
            _split3.Button2.Text = "Issues".ToQuantity(ViewModel.Issues);
            sec1.Add(_split3);

            _split2.Button1.Text = (model.UtcCreatedOn).ToString("MM/dd/yy");
            _split2.Button2.Text = model.Size.Bytes().ToString("#.##");
            sec1.Add(_split2);

            var owner = new StringElement("Owner", model.Owner) { Image = AtlassianIcon.User.ToImage(),  Accessory = UITableViewCellAccessory.DisclosureIndicator };
            owner.Clicked.BindCommand(ViewModel.GoToOwnerCommand);
            sec1.Add(owner);

			if (model.ForkOf != null)
            {
                var parent = new StringElement("Forked From", model.ForkOf.Name) { Image = AtlassianIcon.Devtoolsfork.ToImage(),  Accessory = UITableViewCellAccessory.DisclosureIndicator };
                parent.Clicked.Select(_ => model.ForkOf).BindCommand(ViewModel.GoToForkParentCommand);
                sec1.Add(parent);
            }

            var events = new StringElement("Events", AtlassianIcon.Blogroll.ToImage());
            events.Clicked.BindCommand(ViewModel.GoToEventsCommand);
            var sec2 = new Section { events };

            if (model.HasWiki)
            {
                var wiki = new StringElement("Wiki", AtlassianIcon.Edit.ToImage());
                wiki.Clicked.BindCommand(ViewModel.GoToWikiCommand);
                sec2.Add(wiki);
            }

            if (model.HasIssues)
            {
                var issues = new StringElement("Issues", AtlassianIcon.Flag.ToImage());
                issues.Clicked.BindCommand(ViewModel.GoToIssuesCommand);
                sec2.Add(issues);
            }

            if (ViewModel.HasReadme)
            {
                var readme = new StringElement("Readme", AtlassianIcon.Pagedefault.ToImage());
                readme.Clicked.BindCommand(ViewModel.GoToReadmeCommand);
                sec2.Add(readme);
            }

            var commits = new StringElement("Commits", AtlassianIcon.Devtoolscommit.ToImage());
            commits.Clicked.BindCommand(ViewModel.GoToCommitsCommand);

            var pullRequests = new StringElement("Pull Requests", AtlassianIcon.Devtoolspullrequest.ToImage());
            pullRequests.Clicked.BindCommand(ViewModel.GoToPullRequestsCommand);

            var source = new StringElement("Source", AtlassianIcon.Filecode.ToImage());
            source.Clicked.BindCommand(ViewModel.GoToSourceCommand);

            var sec3 = new Section { commits, pullRequests, source };
            foreach (var s in new[] { new Section { _split }, sec1, sec2, sec3 })
                root.Add(s);

            if (!String.IsNullOrEmpty(ViewModel.Repository.Website))
            {
                var website = new StringElement("Website", AtlassianIcon.Homepage.ToImage());
                website.Clicked.Select(_ => ViewModel.Repository.Website).BindCommand(ViewModel.GoToUrlCommand);
                root.Add(new Section { website });
            }

            Root.Reset(root);
        }
示例#15
0
 public static IDisposable BindValue <T>(this StringElement stringElement, IObservable <T> value)
 {
     return(value.Subscribe(x => stringElement.Value = x?.ToString()));
 }
示例#16
0
 public static IDisposable BindCaption <T>(this StringElement stringElement, IObservable <T> caption)
 {
     return(caption.Subscribe(x => stringElement.Caption = x?.ToString()));
 }
示例#17
0
        public void Render()
        {
			if (ViewModel.Commits == null || ViewModel.Commit == null)
				return;

            var titleMsg = (ViewModel.Commit.Message ?? string.Empty).Split(new [] { '\n' }, 2).FirstOrDefault();
            var avatarUrl = ViewModel.Commit.Author?.User?.Links?.Avatar?.Href;
            var node = ViewModel.Node.Substring(0, ViewModel.Node.Length > 10 ? 10 : ViewModel.Node.Length);

            Title = node;
            HeaderView.Text = titleMsg ?? node;
            HeaderView.SubText = "Commited " + (ViewModel.Commit.Date).Humanize();
            HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar);
            RefreshHeaderView();
     
            var split = new SplitButtonElement();
            split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString());
            split.AddButton("Participants", ViewModel.Commit.Participants.Count.ToString());
            split.AddButton("Approvals", ViewModel.Commit.Participants.Count(x => x.Approved).ToString());

            var commitModel = ViewModel.Commits;
            ICollection<Section> root = new LinkedList<Section>();
            root.Add(new Section { split });

            var detailSection = new Section();
            root.Add(detailSection);

            var user = ViewModel.Commit.Author?.User?.DisplayName ?? ViewModel.Commit.Author.Raw ?? "Unknown";
            detailSection.Add(new MultilinedElement(user, ViewModel.Commit.Message));

            if (ViewModel.ShowRepository)
            {
                var repo = new StringElement(ViewModel.Repository) { 
                    Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator, 
                    Lines = 1, 
                    TextColor = StringElement.DefaultDetailColor,
                    Image = AtlassianIcon.Devtoolsrepository.ToImage()
                };
                repo.Clicked.BindCommand(ViewModel.GoToRepositoryCommand);
                detailSection.Add(repo);
            }

			if (_viewSegment.SelectedSegment == 0)
			{

				var paths = ViewModel.Commits.GroupBy(y =>
				{
					var filename = "/" + y.File;
					return filename.Substring(0, filename.LastIndexOf("/", System.StringComparison.Ordinal) + 1);
				}).OrderBy(y => y.Key);

				foreach (var p in paths)
				{
					var fileSection = new Section(p.Key);
					foreach (var x in p)
					{
						var y = x;
						var file = x.File.Substring(x.File.LastIndexOf('/') + 1);
						var sse = new ChangesetElement(file, x.Type, x.Diffstat.Added, x.Diffstat.Removed);
                        sse.Clicked.Select(_ => y).BindCommand(ViewModel.GoToFileCommand);
						fileSection.Add(sse);
					}
					root.Add(fileSection);
				}
			}
			else if (_viewSegment.SelectedSegment == 1)
			{
				var commentSection = new Section();
				foreach (var comment in ViewModel.Comments)
				{
                    var name = comment.User.DisplayName ?? comment.User.Username;
                    var avatar = new Avatar(comment.User.Links?.Avatar?.Href);
                    commentSection.Add(new CommentElement(name, comment.Content.Raw, comment.CreatedOn, avatar));
				}

				if (commentSection.Elements.Count > 0)
					root.Add(commentSection);

                var addComment = new StringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() };
                addComment.Clicked.Subscribe(_ => AddCommentTapped());
				root.Add(new Section { addComment });
			}
			else if (_viewSegment.SelectedSegment == 2)
			{
				var likeSection = new Section();
                likeSection.AddAll(ViewModel.Commit.Participants.Where(x => x.Approved).Select(l => {
                    var avatar = new Avatar(l.User?.Links?.Avatar?.Href);
                    var el = new UserElement(l.User.DisplayName, string.Empty, string.Empty, avatar);
                    el.Clicked.Select(_ => l.User.Username).BindCommand(ViewModel.GoToUserCommand);
					return el;
				}));

				if (likeSection.Elements.Count > 0)
					root.Add(likeSection);

				StringElement approveButton;
                if (ViewModel.Commit.Participants.Any(x => x.User.Username.Equals(ViewModel.GetApplication().Account.Username) && x.Approved))
				{
                    approveButton = new StringElement("Unapprove") { Image = AtlassianIcon.Approve.ToImage() };
                    approveButton.Clicked.Subscribe(_ => this.DoWorkAsync("Unapproving...", ViewModel.Unapprove));
				}
				else
				{
                    approveButton = new StringElement("Approve") { Image = AtlassianIcon.Approve.ToImage() };
                    approveButton.Clicked.Subscribe(_ => this.DoWorkAsync("Approving...", ViewModel.Approve));
				}
				root.Add(new Section { approveButton });
			}

            Root.Reset(root); 
        }
示例#18
0
        public void Render()
        {
            if (ViewModel.PullRequest == null)
                return;

            var avatarUrl = ViewModel.PullRequest.Author?.Links?.Avatar?.Href;

            HeaderView.Text = ViewModel.PullRequest.Title;
            HeaderView.SubText = "Updated " + ViewModel.PullRequest.UpdatedOn.Humanize();
            HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar);
            RefreshHeaderView();

            var split = new SplitButtonElement();
            split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString());
            split.AddButton("Participants", ViewModel.PullRequest.Participants.Count.ToString());

            ICollection<Section> root = new LinkedList<Section>();
            root.Add(new Section { split });

            var secDetails = new Section();
            if (!string.IsNullOrWhiteSpace(ViewModel.Description))
            {
                var content = new MarkdownRazorView { Model = ViewModel.Description }.GenerateString();
                _descriptionElement.SetValue(content);
                secDetails.Add(_descriptionElement);
            }

            var commitsElement = new StringElement("Commits", AtlassianIcon.Devtoolscommit.ToImage());
            commitsElement.Clicked.BindCommand(ViewModel.GoToCommitsCommand);

			var merged = ViewModel.Merged;

            _split1.Button1.Text = ViewModel.PullRequest.CreatedOn.ToString("MM/dd/yy");
            _split1.Button2.Text = merged ? "Merged" : "Not Merged";
            secDetails.Add(_split1);
            secDetails.Add(commitsElement);
            root.Add(secDetails);

            if (!merged)
            {
                var mergeElement = new StringElement("Merge", AtlassianIcon.Approve.ToImage());
                mergeElement.Clicked.Subscribe(_ => MergeClick());
                root.Add(new Section { mergeElement });
            }

            var comments = ViewModel.Comments
                .Where(x => !string.IsNullOrEmpty(x.Content.Raw) && x.Inline == null)
                .OrderBy(x => (x.CreatedOn))
                .Select(x =>
                {
                    var name = x.User.DisplayName ?? x.User.Username ?? "Unknown";
                    var avatar = new Avatar(x.User.Links?.Avatar?.Href);
                    return new CommentViewModel(name, x.Content.Html, x.CreatedOn.Humanize(), avatar.ToUrl());
                }).ToList();

            if (comments.Count > 0)
            {
                var content = new CommentsRazorView { Model = comments.ToList() }.GenerateString();
                _commentsElement.SetValue(content);
                root.Add(new Section { _commentsElement });
            }


            var addComment = new StringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() };
            addComment.Clicked.Subscribe(_ => AddCommentTapped());
            root.Add(new Section { addComment });
            Root.Reset(root);
        }