public void RenderComments() { var comments = ViewModel.Comments .Where(x => !string.IsNullOrEmpty(x.Content)) .Select(x => new CommentViewModel(x.AuthorInfo.Username, ViewModel.ConvertToMarkdown(x.Content), x.UtcCreatedOn.Humanize(), x.AuthorInfo.Avatar)); _commentsElement.LoadContent(new CommentsRazorView { Model = comments.ToList() }.GenerateString()); InvokeOnMainThread(RenderIssue); }
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()); var root = new RootElement(Title); root.Add(new Section { split }); var secDetails = new Section(); if (!string.IsNullOrEmpty(ViewModel.Issue.Content)) { _descriptionElement.LoadContent(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 StyledStringElement("Assigned", ViewModel.Issue.Responsible != null ? ViewModel.Issue.Responsible.Username : "******", UITableViewCellStyle.Value1) { Image = AtlassianIcon.User.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null); secDetails.Add(assigneeElement); root.Add(secDetails); if (ViewModel.Comments.Any(x => !string.IsNullOrEmpty(x.Content))) { root.Add(new Section { _commentsElement }); } var addComment = new StyledStringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() }; addComment.Tapped += AddCommentTapped; root.Add(new Section { addComment }); Root = root; }
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()); var root = new RootElement(Title); root.Add(new Section { split }); var secDetails = new Section(); if (!string.IsNullOrWhiteSpace(ViewModel.Description)) { if (_descriptionElement == null) { _descriptionElement = new WebElement("description"); _descriptionElement.UrlRequested = ViewModel.GoToUrlCommand.Execute; } _descriptionElement.LoadContent(new MarkdownRazorView { Model = ViewModel.Description }.GenerateString()); secDetails.Add(_descriptionElement); } 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(new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), AtlassianIcon.Devtoolscommit.ToImage())); root.Add(secDetails); if (!merged) { Action mergeAction = async() => { try { await this.DoWorkAsync("Merging...", ViewModel.Merge); } catch (Exception e) { MonoTouch.Utilities.ShowAlert("Unable to Merge", e.Message); } }; root.Add(new Section { new StyledStringElement("Merge", mergeAction, AtlassianIcon.Approve.ToImage()) }); } 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) { if (_commentsElement == null) { _commentsElement = new WebElement("comments"); _commentsElement.UrlRequested = ViewModel.GoToUrlCommand.Execute; } _commentsElement.LoadContent(new CommentsRazorView { Model = comments.ToList() }.GenerateString()); root.Add(new Section { _commentsElement }); } var addComment = new StyledStringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() }; addComment.Tapped += AddCommentTapped; root.Add(new Section { addComment }); Root = root; }