public override void ViewDidLoad() { base.ViewDidLoad(); Title = ViewModel.Username; var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-", () => ViewModel.GoToFollowersCommand.ExecuteIfCan()); var following = split.AddButton("Following", "-", () => ViewModel.GoToFollowingCommand.ExecuteIfCan()); var events = new StyledStringElement("Events", () => ViewModel.GoToEventsCommand.ExecuteIfCan(), Images.Event); var organizations = new StyledStringElement("Organizations", () => ViewModel.GoToOrganizationsCommand.ExecuteIfCan(), Images.Group); var repos = new StyledStringElement("Repositories", () => ViewModel.GoToRepositoriesCommand.ExecuteIfCan(), Images.Repo); var gists = new StyledStringElement("Gists", () => ViewModel.GoToGistsCommand.ExecuteIfCan(), Images.Script); Root.Reset(new [] { new Section(HeaderView) { split }, new Section { events, organizations, repos, gists } }); if (!ViewModel.IsLoggedInUser) { NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s_, e_) => { _actionSheet = new UIActionSheet(ViewModel.Username); var followButton = ViewModel.IsFollowing.HasValue ? _actionSheet.AddButton(ViewModel.IsFollowing.Value ? "Unfollow" : "Follow") : -1; var cancelButton = _actionSheet.AddButton("Cancel"); _actionSheet.CancelButtonIndex = cancelButton; _actionSheet.DismissWithClickedButtonIndex(cancelButton, true); _actionSheet.Clicked += (s, e) => { if (e.ButtonIndex == followButton) { ViewModel.ToggleFollowingCommand.ExecuteIfCan(); } _actionSheet = null; }; _actionSheet.ShowInView(View); }); NavigationItem.RightBarButtonItem.EnableIfExecutable(ViewModel.WhenAnyValue(x => x.IsFollowing, x => x.HasValue)); } ViewModel.WhenAnyValue(x => x.User).Where(x => x != null).Subscribe(x => { HeaderView.SubText = x.Name; HeaderView.ImageUri = x.AvatarUrl; followers.Text = x.Followers.ToString(); following.Text = x.Following.ToString(); if (!string.IsNullOrEmpty(x.Name)) { HeaderView.SubText = x.Name; } ReloadData(); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-", () => ViewModel.GoToFollowersCommand.ExecuteIfCan()); var following = split.AddButton("Following", "-", () => ViewModel.GoToFollowingCommand.ExecuteIfCan()); var events = new StyledStringElement("Events", () => ViewModel.GoToEventsCommand.ExecuteIfCan(), Images.Event); var organizations = new StyledStringElement("Organizations", () => ViewModel.GoToOrganizationsCommand.ExecuteIfCan(), Images.Group); var repos = new StyledStringElement("Repositories", () => ViewModel.GoToRepositoriesCommand.ExecuteIfCan(), Images.Repo); var gists = new StyledStringElement("Gists", () => ViewModel.GoToGistsCommand.ExecuteIfCan(), Images.Script); Root.Reset(new [] { new Section(HeaderView) { split }, new Section { events, organizations, repos, gists } }); ViewModel.WhenAnyValue(x => x.User).Where(x => x != null).Subscribe(x => { HeaderView.ImageUri = x.AvatarUrl; followers.Text = x.Followers.ToString(); following.Text = x.Following.ToString(); HeaderView.SubText = string.IsNullOrEmpty(x.Name) ? null : x.Name; ReloadData(); }); }
public TestTreeView() { InitializeComponent(); RunButton = new SplitButtonElement(runButton); RunAllCommand = new MenuElement(runAllMenuItem); RunSelectedCommand = new MenuElement(runSelectedMenuItem); RunFailedCommand = new MenuElement(runFailedMenuItem); StopRunCommand = new MenuElement(stopRunMenuItem); FormatButton = new ToolStripElement<ToolStripDropDownButton>(formatButton); DisplayFormat = new CheckedMenuGroup( "displayFormat", nunitTreeMenuItem, fixtureListMenuItem, testListMenuItem); GroupBy = new CheckedMenuGroup( "testGrouping", byAssemblyMenuItem, byFixtureMenuItem, byCategoryMenuItem, byOutcomeMenuItem, byDurationMenuItem); RunContextCommand = new MenuElement(this.runMenuItem); ShowCheckBoxesCommand = new MenuElement(showCheckboxesMenuItem); ExpandAllCommand = new MenuElement(expandAllMenuItem); CollapseAllCommand = new MenuElement(collapseAllMenuItem); CollapseToFixturesCommand = new MenuElement(collapseToFixturesMenuItem); Tree = new TreeViewElement(treeView); }
public override void ViewDidLoad() { base.ViewDidLoad(); var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-", () => ViewModel.GoToFollowersCommand.ExecuteIfCan()); var following = split.AddButton("Following", "-", () => ViewModel.GoToFollowingCommand.ExecuteIfCan()); var events = new StringElement("Events", () => ViewModel.GoToEventsCommand.ExecuteIfCan(), Octicon.Rss.ToImage()); var organizations = new StringElement("Organizations", () => ViewModel.GoToOrganizationsCommand.ExecuteIfCan(), Octicon.Organization.ToImage()); var repos = new StringElement("Repositories", () => ViewModel.GoToRepositoriesCommand.ExecuteIfCan(), Octicon.Repo.ToImage()); var gists = new StringElement("Gists", () => ViewModel.GoToGistsCommand.ExecuteIfCan(), Octicon.Gist.ToImage()); Root.Reset(new [] { new Section { split }, new Section { events, organizations, repos, gists } }); this.WhenAnyValue(x => x.ViewModel.User).IsNotNull().Subscribe(x => { HeaderView.ImageUri = x.AvatarUrl; followers.Text = x.Followers.ToString(); following.Text = x.Following.ToString(); HeaderView.SubText = string.IsNullOrEmpty(x.Name) ? null : x.Name; RefreshHeaderView(); }); }
public TestTreeView() { InitializeComponent(); RunButton = new SplitButtonElement(runButton); RunAllCommand = new ToolStripMenuElement(runAllMenuItem); RunSelectedCommand = new ToolStripMenuElement(runSelectedMenuItem); RunFailedCommand = new ToolStripMenuElement(runFailedMenuItem); StopRunCommand = new ToolStripMenuElement(stopRunMenuItem); FormatButton = new ToolStripElement(formatButton); DisplayFormat = new CheckedMenuGroup( "displayFormat", nunitTreeMenuItem, fixtureListMenuItem, testListMenuItem); GroupBy = new CheckedMenuGroup( "testGrouping", byAssemblyMenuItem, byFixtureMenuItem, byCategoryMenuItem, byOutcomeMenuItem, byDurationMenuItem); RunContextCommand = new ToolStripMenuElement(this.runMenuItem); RunCheckedCommand = new ToolStripMenuElement(this.runCheckedMenuItem); ShowCheckBoxes = new ToolStripMenuElement(showCheckboxesMenuItem); ExpandAllCommand = new ToolStripMenuElement(expandAllMenuItem); CollapseAllCommand = new ToolStripMenuElement(collapseAllMenuItem); CollapseToFixturesCommand = new ToolStripMenuElement(collapseToFixturesMenuItem); Tree = new TreeViewElement(treeView); }
public override void ViewDidLoad() { base.ViewDidLoad(); var split = new SplitButtonElement(); var contributors = split.AddButton("Contributors", "-"); var lastCommit = split.AddButton("Last Commit", "-"); var addFeatureButton = new ButtonElement("Suggest a feature", () => ViewModel.GoToSuggestFeatureCommand.ExecuteIfCan(), Octicon.LightBulb.ToImage()); var addBugButton = new ButtonElement("Report a bug", () => ViewModel.GoToReportBugCommand.ExecuteIfCan(), Octicon.Bug.ToImage()); var featuresButton = new ButtonElement("Submitted Work Items", () => ViewModel.GoToFeedbackCommand.ExecuteIfCan(), Octicon.Clippy.ToImage()); this.WhenAnyValue(x => x.ViewModel.Contributors).Where(x => x.HasValue).SubscribeSafe(x => contributors.Text = (x.Value >= 100 ? "100+" : x.Value.ToString())); this.WhenAnyValue(x => x.ViewModel.LastCommit).Where(x => x.HasValue).SubscribeSafe(x => lastCommit.Text = x.Value.UtcDateTime.Humanize()); this.WhenAnyValue(x => x.ViewModel).Subscribe(x => HeaderView.ImageButtonAction = x != null ? new Action(x.GoToRepositoryCommand.ExecuteIfCan) : null); HeaderView.SubText = "This app is the product of hard work and great suggestions! Thank you to all whom provide feedback!"; HeaderView.Image = UIImage.FromFile("*****@*****.**"); Root.Reset(new Section { split }, new Section { addFeatureButton, addBugButton }, new Section { featuresButton }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-", ViewModel.GoToFollowersCommand.ExecuteIfCan); var following = split.AddButton("Following", "-", ViewModel.GoToFollowingCommand.ExecuteIfCan); var members = new DialogStringElement("Members", ViewModel.GoToMembersCommand.ExecuteIfCan, Images.Following); var teams = new DialogStringElement("Teams", ViewModel.GoToTeamsCommand.ExecuteIfCan, Images.Organization); var events = new DialogStringElement("Events", ViewModel.GoToEventsCommand.ExecuteIfCan, Images.Rss); var repos = new DialogStringElement("Repositories", ViewModel.GoToRepositoriesCommand.ExecuteIfCan, Images.Repo); var gists = new DialogStringElement("Gists", ViewModel.GoToGistsCommand.ExecuteIfCan, Images.Gist); Root.Reset(new Section { split }, new Section { members, teams }, new Section { events }, new Section { repos, gists }); this.WhenAnyValue(x => x.ViewModel.Organization) .IsNotNull() .Subscribe(x => { followers.Text = x != null ? x.Followers.ToString() : "-"; following.Text = x != null ? x.Following.ToString() : "-"; HeaderView.ImageUri = x.AvatarUrl; RefreshHeaderView(); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.SubText = "Organization"; var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-", () => ViewModel.GoToFollowersCommand.ExecuteIfCan()); var following = split.AddButton("Following", "-", () => ViewModel.GoToFollowingCommand.ExecuteIfCan()); var members = new StyledStringElement("Members", ViewModel.GoToMembersCommand.ExecuteIfCan, Images.Following); var teams = new StyledStringElement("Teams", ViewModel.GoToTeamsCommand.ExecuteIfCan, Images.Team); var events = new StyledStringElement("Events", ViewModel.GoToEventsCommand.ExecuteIfCan, Images.Event); var repos = new StyledStringElement("Repositories", ViewModel.GoToRepositoriesCommand.ExecuteIfCan, Images.Repo); var gists = new StyledStringElement("Gists", ViewModel.GoToGistsCommand.ExecuteIfCan, Images.Script); Root.Reset(new Section(HeaderView) { split }, new Section { members, teams }, new Section { events }, new Section { repos, gists }); ViewModel.WhenAnyValue(x => x.Organization).Where(x => x != null).Subscribe(x => { followers.Text = x.Followers.ToString(); following.Text = x.Following.ToString(); HeaderView.ImageUri = x.AvatarUrl; ReloadData(); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.Image = Images.LoginUserUnknown; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.35f))) .Switch() .Select(_ => this.WhenAnyValue(x => x.ViewModel.IsFollowing).Where(x => x.HasValue)) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => HeaderView.SetSubImage(x.Value ? Octicon.Star.ToImage() : null)); var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-"); var following = split.AddButton("Following", "-"); var events = new StringElement("Events", Octicon.Rss.ToImage()); var organizations = new StringElement("Organizations", Octicon.Organization.ToImage()); var repos = new StringElement("Repositories", Octicon.Repo.ToImage()); var gists = new StringElement("Gists", Octicon.Gist.ToImage()); var website = new StringElement("Website", Octicon.Globe.ToImage()) { Hidden = true }; Root.Reset(new [] { new Section { split }, new Section { events, organizations, repos, gists }, new Section { website } }); OnActivation(d => { d(followers.Clicked.InvokeCommand(ViewModel.GoToFollowersCommand)); d(following.Clicked.InvokeCommand(ViewModel.GoToFollowingCommand)); d(website.Clicked.InvokeCommand(ViewModel.GoToWebsiteCommand)); d(events.Clicked.InvokeCommand(ViewModel.GoToEventsCommand)); d(organizations.Clicked.InvokeCommand(ViewModel.GoToOrganizationsCommand)); d(repos.Clicked.InvokeCommand(ViewModel.GoToRepositoriesCommand)); d(gists.Clicked.InvokeCommand(ViewModel.GoToGistsCommand)); d(this.WhenAnyValue(x => x.ViewModel) .Where(x => !x.IsLoggedInUser) .Select(x => x.ShowMenuCommand) .ToBarButtonItem(UIBarButtonSystemItem.Action, x => NavigationItem.RightBarButtonItem = x)); d(this.WhenAnyValue(x => x.ViewModel.Avatar) .Subscribe(x => HeaderView.SetImage(x?.ToUri(128), Images.LoginUserUnknown))); d(this.WhenAnyValue(x => x.ViewModel.User.Name).Select(x => string.IsNullOrEmpty(x) ? null : x) .Subscribe(x => RefreshHeaderView(subtext: x))); d(followers.BindText(this.WhenAnyValue(x => x.ViewModel.User.Followers))); d(following.BindText(this.WhenAnyValue(x => x.ViewModel.User.Following))); d(this.WhenAnyValue(x => x.ViewModel.HasBlog).Subscribe(x => website.Hidden = !x)); }); }
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 override void ViewDidLoad() { Title = ViewModel.RepositorySlug; base.ViewDidLoad(); var header = new ImageAndTitleHeaderView { BackgroundColor = UIColor.GroupTableViewBackgroundColor, Image = Images.ProjectAvatar, Text = ViewModel.RepositorySlug }; TableView.TableHeaderView = header; TableView.TableFooterView = new UIView(); TableView.SeparatorInset = UIEdgeInsets.Zero; TableView.BackgroundColor = UIColor.GroupTableViewBackgroundColor; TableView.SectionHeaderHeight = 0.3f; var settingsSection = new Section(); var splitElement = new SplitButtonElement(); var forksButton = splitElement.AddButton("Forks", "0", () => ViewModel.GoToForksCommand.ExecuteIfCan()); var releatedButton = splitElement.AddButton("Related", "0", () => ViewModel.GoToRelatedCommand.ExecuteIfCan()); settingsSection.Add(splitElement); // // var eventsElement = new StyledStringElement("Events", () => {}, Images.Megaphone.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)); // settingsSection.Add(eventsElement); // // var readmeElement = new StyledStringElement("Readme", () => {}, Images.Readme.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)); // settingsSection.Add(readmeElement); // var codeSection = new Section(); codeSection.Add(new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), Images.Commit.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate))); codeSection.Add(new StyledStringElement("Source Code", () => ViewModel.GoToSourceCommand.Execute(null), Images.Build.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate))); codeSection.Add(new StyledStringElement("Pull Requests", () => ViewModel.GoToPullRequestsCommand.Execute(null), Images.Merge.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate))); var root = new RootElement(Title); root.Add(settingsSection); root.Add(codeSection); Root = root; ViewModel.WhenAnyValue(x => x.Repository).Where(x => x != null).Subscribe(x => { var selfLink = x.Project.Links["self"].FirstOrDefault(); if (selfLink == null || string.IsNullOrEmpty(selfLink.Href)) { return; } header.ImageUri = selfLink.Href + "/avatar.png"; }); ViewModel.WhenAnyValue(x => x.ForkedRepositories).Subscribe(x => forksButton.Text = x.ToString()); ViewModel.WhenAnyValue(x => x.RelatedRepositories).Subscribe(x => releatedButton.Text = x.ToString()); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = HeaderView.Text = ViewModel.RepositoryName; NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowMenu()); NavigationItem.RightBarButtonItem.EnableIfExecutable( ViewModel.WhenAnyValue(x => x.Repository, x => x.IsStarred, x => x.IsWatched) .Select(x => x.Item1 != null && x.Item2 != null && x.Item3 != null)); _split = new SplitButtonElement(); var stargazers = _split.AddButton("Stargazers", "-", () => ViewModel.GoToStargazersCommand.ExecuteIfCan()); var watchers = _split.AddButton("Watchers", "-", () => ViewModel.GoToWatchersCommand.ExecuteIfCan()); var collaborators = _split.AddButton("Contributors", "-", () => ViewModel.GoToCollaboratorsCommand.ExecuteIfCan()); ViewModel.WhenAnyValue(x => x.Collaborators).Subscribe(x => collaborators.Text = x.HasValue ? x.ToString() : "-"); Root.Reset(new Section(HeaderView) { _split }); ViewModel.WhenAnyValue(x => x.Readme).Where(x => x != null).Subscribe(_ => { // Not very efficient but it'll work for now. if (ViewModel.Repository != null) { Render(); } }); _splitElements[0] = new SplitElement(); _splitElements[1] = new SplitElement(); _splitElements[2] = new SplitElement(); _splitElements[2].Button2 = new SplitElement.SplitButton(Images.Size, "N/A"); ViewModel.WhenAnyValue(x => x.Repository).Where(x => x != null).Subscribe(x => { HeaderView.ImageUri = x.Owner.AvatarUrl; HeaderView.SubText = x.Description; stargazers.Text = x.StargazersCount.ToString(); watchers.Text = x.SubscribersCount.ToString(); _splitElements[0].Button1 = new SplitElement.SplitButton(x.Private ? Images.Locked : Images.Unlocked, x.Private ? "Private" : "Public"); _splitElements[0].Button2 = new SplitElement.SplitButton(Images.Language, x.Language ?? "N/A"); _splitElements[1].Button1 = new SplitElement.SplitButton(Images.Flag, x.OpenIssues + (x.OpenIssues == 1 ? " Issue" : " Issues")); _splitElements[1].Button2 = new SplitElement.SplitButton(Images.Fork, x.Forks + (x.Forks == 1 ? " Fork" : " Forks")); _splitElements[2].Button1 = new SplitElement.SplitButton(Images.Create, (x.CreatedAt.ToLocalTime()).ToString("MM/dd/yy")); Render(); }); ViewModel.WhenAnyValue(x => x.RepositorySize).Subscribe(x => _splitElements[2].Button2.Text = x ?? "N/A"); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.Image = Images.LoginUserUnknown; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.35f))) .Switch() .Select(_ => this.WhenAnyValue(x => x.ViewModel.IsFollowing).Where(x => x.HasValue)) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => HeaderView.SetSubImage(x.Value ? Octicon.Star.ToImage() : null)); var websiteElement = new StringElement("Website", () => ViewModel.GoToWebsiteCommand.ExecuteIfCan(), Octicon.Globe.ToImage()); var extraSection = new Section(); var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-", () => ViewModel.GoToFollowersCommand.ExecuteIfCan()); var following = split.AddButton("Following", "-", () => ViewModel.GoToFollowingCommand.ExecuteIfCan()); var events = new StringElement("Events", () => ViewModel.GoToEventsCommand.ExecuteIfCan(), Octicon.Rss.ToImage()); var organizations = new StringElement("Organizations", () => ViewModel.GoToOrganizationsCommand.ExecuteIfCan(), Octicon.Organization.ToImage()); var repos = new StringElement("Repositories", () => ViewModel.GoToRepositoriesCommand.ExecuteIfCan(), Octicon.Repo.ToImage()); var gists = new StringElement("Gists", () => ViewModel.GoToGistsCommand.ExecuteIfCan(), Octicon.Gist.ToImage()); Root.Reset(new [] { new Section { split }, new Section { events, organizations, repos, gists }, extraSection }); this.WhenAnyValue(x => x.ViewModel.IsLoggedInUser) .Subscribe(x => NavigationItem.RightBarButtonItem = x ? null : ViewModel.ShowMenuCommand.ToBarButtonItem(UIBarButtonSystemItem.Action)); this.WhenAnyValue(x => x.ViewModel.Avatar) .Subscribe(x => HeaderView.SetImage(x?.ToUri(128), Images.LoginUserUnknown)); this.WhenAnyValue(x => x.ViewModel.User).IsNotNull().Subscribe(x => { followers.Text = x.Followers.ToString(); following.Text = x.Following.ToString(); HeaderView.SubText = string.IsNullOrEmpty(x.Name) ? null : x.Name; RefreshHeaderView(); }); this.WhenAnyValue(x => x.ViewModel.HasBlog).Subscribe(x => { if (x && websiteElement.Section == null) { extraSection.Add(websiteElement); } else if (!x && websiteElement.Section != null) { extraSection.Remove(websiteElement); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.SetImage(null, Images.Avatar); HeaderView.Text = ViewModel.Username; var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-"); var following = split.AddButton("Following", "-"); var events = new StringElement("Events", Octicon.Rss.ToImage()); var organizations = new StringElement("Organizations", Octicon.Organization.ToImage()); var repos = new StringElement("Repositories", Octicon.Repo.ToImage()); var gists = new StringElement("Gists", Octicon.Gist.ToImage()); Root.Add(new [] { new Section { split }, new Section { events, organizations, repos, gists } }); ViewModel.Bind(x => x.User).Subscribe(x => { followers.Text = x?.Followers.ToString() ?? "-"; following.Text = x?.Following.ToString() ?? "-"; HeaderView.SubText = string.IsNullOrWhiteSpace(x?.Name) ? null : x.Name; HeaderView.SetImage(x?.AvatarUrl, Images.Avatar); RefreshHeaderView(); }); OnActivation(d => { d(followers.Clicked .Select(x => UsersViewController.CreateFollowersViewController(ViewModel.Username)) .Subscribe(x => NavigationController.PushViewController(x, true))); d(following.Clicked .Select(x => UsersViewController.CreateFollowingViewController(ViewModel.Username)) .Subscribe(x => NavigationController.PushViewController(x, true))); d(events.Clicked.BindCommand(ViewModel.GoToEventsCommand)); d(organizations.Clicked.BindCommand(ViewModel.GoToOrganizationsCommand)); d(gists.Clicked .Select(x => GistsViewController.CreateUserGistsViewController(ViewModel.Username)) .Subscribe(x => NavigationController.PushViewController(x, true))); d(ViewModel.Bind(x => x.Title, true).Subscribe(x => Title = x)); d(repos.Clicked.Subscribe(_ => { var vc = Repositories.RepositoriesViewController.CreateUserViewController(ViewModel.Username); NavigationController?.PushViewController(vc, true); })); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.SubText = "Organization"; HeaderView.Image = Images.LoginUserUnknown; var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-"); var following = split.AddButton("Following", "-"); var members = new StringElement("Members", Octicon.Person.ToImage()); var teams = new StringElement("Teams", Octicon.Organization.ToImage()); var events = new StringElement("Events", Octicon.Rss.ToImage()); var repos = new StringElement("Repositories", Octicon.Repo.ToImage()); var gists = new StringElement("Gists", Octicon.Gist.ToImage()); var membersAndTeams = new Section { members }; Root.Reset(new Section { split }, membersAndTeams, new Section { events }, new Section { repos, gists }); OnActivation(d => { d(followers.Clicked.InvokeCommand(ViewModel.GoToFollowersCommand)); d(following.Clicked.InvokeCommand(ViewModel.GoToFollowingCommand)); d(members.Clicked.InvokeCommand(ViewModel.GoToMembersCommand)); d(teams.Clicked.InvokeCommand(ViewModel.GoToTeamsCommand)); d(events.Clicked.InvokeCommand(ViewModel.GoToEventsCommand)); d(repos.Clicked.InvokeCommand(ViewModel.GoToRepositoriesCommand)); d(gists.Clicked.InvokeCommand(ViewModel.GoToGistsCommand)); d(this.WhenAnyValue(x => x.ViewModel.Avatar) .Subscribe(x => HeaderView.SetImage(x?.ToUri(128), Images.LoginUserUnknown))); var orgObs = this.WhenAnyValue(x => x.ViewModel.Organization); d(followers.BindText(orgObs.Select(x => x != null ? x.Followers.ToString() : "-"))); d(following.BindText(orgObs.Select(x => x != null ? x.Following.ToString() : "-"))); d(this.WhenAnyValue(x => x.ViewModel.CanViewTeams) .Where(x => x && teams.Section == null) .Subscribe(x => membersAndTeams.Add(teams))); d(this.WhenAnyValue(x => x.ViewModel.CanViewTeams) .Where(x => !x) .Subscribe(x => membersAndTeams.Remove(teams))); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowExtraMenu()); NavigationItem.RightBarButtonItem.EnableIfExecutable(ViewModel.WhenAnyValue(x => x.Commit).Select(x => x != null)); _split = new SplitButtonElement(); var additions = _split.AddButton("Additions", "-"); var deletions = _split.AddButton("Deletions", "-"); var parents = _split.AddButton("Parents", "-"); var headerSection = new Section(HeaderView) { _split }; Root.Reset(headerSection); ViewModel.WhenAnyValue(x => x.Commit).Where(x => x != null).Subscribe(x => { HeaderView.Image = Images.LoginUserUnknown; if (x.Author != null) { HeaderView.Text = x.Author.Login; HeaderView.ImageUri = x.Author.AvatarUrl; } else { HeaderView.Text = "Unknown Author"; } HeaderView.SubText = "Commited " + (x.Commit.Committer.Date).ToDaysAgo(); additions.Text = x.Stats.Additions.ToString(); deletions.Text = x.Stats.Deletions.ToString(); parents.Text = x.Parents.Count.ToString(); ReloadData(); }); ViewModel.WhenAnyValue(x => x.Commit).Where(x => x != null).Subscribe(Render); //ViewModel.BindCollection(x => x.Comments, a => Render()); }
public override void ViewDidLoad() { base.ViewDidLoad(); var split = new SplitButtonElement(); var contributors = split.AddButton("Contributors", "-"); var lastCommit = split.AddButton("Last Commit", "-"); var addFeatureButton = new ButtonElement("Suggest a feature", Octicon.LightBulb.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var addBugButton = new ButtonElement("Report a bug", Octicon.Bug.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var featuresButton = new ButtonElement("Submitted Work Items", Octicon.Clippy.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; HeaderView.SubText = "This app is the product of hard work and great suggestions! Thank you to all whom provide feedback!"; HeaderView.Image = UIImage.FromFile("*****@*****.**"); Root.Reset(new Section { split }, new Section { addFeatureButton, addBugButton }, new Section { featuresButton }); OnActivation(d => { d(addFeatureButton.Clicked.InvokeCommand(ViewModel.GoToSuggestFeatureCommand)); d(addBugButton.Clicked.InvokeCommand(ViewModel.GoToReportBugCommand)); d(featuresButton.Clicked.InvokeCommand(ViewModel.GoToFeedbackCommand)); d(HeaderView.Clicked.InvokeCommand(ViewModel.GoToRepositoryCommand)); d(this.WhenAnyValue(x => x.ViewModel.Contributors).Where(x => x.HasValue).SubscribeSafe(x => contributors.Text = (x.Value >= 100 ? "100+" : x.Value.ToString()))); d(this.WhenAnyValue(x => x.ViewModel.LastCommit).Where(x => x.HasValue).SubscribeSafe(x => lastCommit.Text = x.Value.UtcDateTime.Humanize())); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.SubText = "Organization"; HeaderView.Image = Images.LoginUserUnknown; var split = new SplitButtonElement(); var followers = split.AddButton("Followers", "-", () => ViewModel.GoToFollowersCommand.ExecuteIfCan()); var following = split.AddButton("Following", "-", () => ViewModel.GoToFollowingCommand.ExecuteIfCan()); var members = new StringElement("Members", () => ViewModel.GoToMembersCommand.ExecuteIfCan(), Octicon.Person.ToImage()); var teams = new StringElement("Teams", () => ViewModel.GoToTeamsCommand.ExecuteIfCan(), Octicon.Organization.ToImage()); var events = new StringElement("Events", () => ViewModel.GoToEventsCommand.ExecuteIfCan(), Octicon.Rss.ToImage()); var repos = new StringElement("Repositories", () => ViewModel.GoToRepositoriesCommand.ExecuteIfCan(), Octicon.Repo.ToImage()); var gists = new StringElement("Gists", () => ViewModel.GoToGistsCommand.ExecuteIfCan(), Octicon.Gist.ToImage()); var membersAndTeams = new Section { members }; Root.Reset(new Section { split }, membersAndTeams, new Section { events }, new Section { repos, gists }); this.WhenAnyValue(x => x.ViewModel.Avatar) .Subscribe(x => HeaderView.SetImage(x?.ToUri(128), Images.LoginUserUnknown)); this.WhenAnyValue(x => x.ViewModel.Organization) .IsNotNull() .Subscribe(x => { followers.Text = x != null ? x.Followers.ToString() : "-"; following.Text = x != null ? x.Following.ToString() : "-"; }); this.WhenAnyValue(x => x.ViewModel.CanViewTeams) .Where(x => x && teams.Section == null) .Subscribe(x => membersAndTeams.Add(teams)); this.WhenAnyValue(x => x.ViewModel.CanViewTeams) .Where(x => !x) .Subscribe(x => membersAndTeams.Remove(teams)); }
public SupportView() { _split = new SplitButtonElement(); var contributors = _split.AddButton("Contributors", "-"); var lastCommit = _split.AddButton("Last Commit", "-"); _addFeatureButton = new ButtonElement("Suggest a feature", () => ViewModel.GoToSuggestFeatureCommand.ExecuteIfCan(), Images.Update); _addBugButton = new ButtonElement("Report a bug", () => ViewModel.GoToReportBugCommand.ExecuteIfCan(), Images.Tag); _featuresButton = new ButtonElement("Submitted Work Items", () => ViewModel.GoToFeedbackCommand.ExecuteIfCan(), Images.Chart); this.WhenViewModel(x => x.Contributors).Where(x => x.HasValue).SubscribeSafe(x => contributors.Text = (x.Value >= 100 ? "100+" : x.Value.ToString())); this.WhenViewModel(x => x.LastCommit).Where(x => x.HasValue).SubscribeSafe(x => lastCommit.Text = x.Value.UtcDateTime.Humanize()); HeaderView.SubText = "This app is the product of hard work and great suggestions! Thank you to all whom provide feedback!"; HeaderView.Image = UIImage.FromFile("*****@*****.**"); }
public TestTreeView() { InitializeComponent(); RunButton = new SplitButtonElement(runButton); RunAllCommand = new ToolStripMenuElement(runAllMenuItem); RunSelectedCommand = new ToolStripMenuElement(runSelectedMenuItem); RunFailedCommand = new ToolStripMenuElement(runFailedMenuItem); TestParametersCommand = new ToolStripMenuElement(testParametersMenuItem); StopRunCommand = new ToolStripMenuElement(stopRunMenuItem); DebugButton = new SplitButtonElement(debugButton); DebugAllCommand = new ToolStripMenuElement(debugAllMenuItem); DebugSelectedCommand = new ToolStripMenuElement(debugSelectedMenuItem); DebugFailedCommand = new ToolStripMenuElement(debugFailedMenuItem); FormatButton = new ToolStripElement(formatButton); DisplayFormat = new CheckedToolStripMenuGroup( "displayFormat", nunitTreeMenuItem, fixtureListMenuItem, testListMenuItem); GroupBy = new CheckedToolStripMenuGroup( "testGrouping", byAssemblyMenuItem, byFixtureMenuItem, byCategoryMenuItem, byExtendedCategoryMenuItem, byOutcomeMenuItem, byDurationMenuItem); RunContextCommand = new ToolStripMenuElement(this.runMenuItem); RunCheckedCommand = new ToolStripMenuElement(this.runCheckedMenuItem); DebugContextCommand = new ToolStripMenuElement(this.debugMenuItem); DebugCheckedCommand = new ToolStripMenuElement(this.debugCheckedMenuItem); ActiveConfiguration = new ToolStripMenuElement(this.activeConfigMenuItem); ShowCheckBoxes = new ToolStripMenuElement(showCheckboxesMenuItem); ExpandAllCommand = new ToolStripMenuElement(expandAllMenuItem); CollapseAllCommand = new ToolStripMenuElement(collapseAllMenuItem); CollapseToFixturesCommand = new ToolStripMenuElement(collapseToFixturesMenuItem); Tree = new TreeViewElement(treeView); treeView.MouseDown += (s, e) => { if (e.Button == MouseButtons.Right) { ContextNode = treeView.GetNodeAt(e.X, e.Y); } }; }
public override void ViewDidLoad() { base.ViewDidLoad(); var updatedGistObservable = ViewModel.WhenAnyValue(x => x.Gist).Where(x => x != null); var headerSection = new Section(HeaderView); var filesSection = new Section("Files"); var split = new SplitButtonElement(); var files = split.AddButton("Files", "-"); var comments = split.AddButton("Comments", "-"); var forks = split.AddButton("Forks", "-"); headerSection.Add(split); var commentsSection = new Section("Comments"); var commentsElement = new WebElement("comments"); commentsElement.UrlRequested = ViewModel.GoToUrlCommand.ExecuteIfCan; commentsSection.Add(commentsElement); var detailsSection = new Section(); var splitElement1 = new SplitElement(); splitElement1.Button1 = new SplitElement.SplitButton(Images.Locked, string.Empty); splitElement1.Button2 = new SplitElement.SplitButton(Images.Language, string.Empty); detailsSection.Add(splitElement1); var splitElement2 = new SplitElement(); splitElement2.Button1 = new SplitElement.SplitButton(Images.Update, string.Empty); splitElement2.Button2 = new SplitElement.SplitButton(Images.Star2, string.Empty); detailsSection.Add(splitElement2); var owner = new StyledStringElement("Owner", string.Empty) { Image = Images.Person }; owner.Tapped += () => ViewModel.GoToUserCommand.ExecuteIfCan(); detailsSection.Add(owner); updatedGistObservable.SubscribeSafe(x => { var publicGist = x.Public.HasValue && x.Public.Value; var revisionCount = x.History == null ? 0 : x.History.Count; splitElement1.Button1.Text = publicGist ? "Public" : "Private"; splitElement1.Button1.Image = publicGist ? Images.Unlocked : Images.Locked; splitElement1.Button2.Text = revisionCount + " Revisions"; splitElement2.Button1.Text = x.UpdatedAt.ToLocalTime().ToString("MM/dd/yy"); }); updatedGistObservable.SubscribeSafe(x => { if (x.Owner == null) { owner.Value = "Anonymous"; owner.Accessory = UITableViewCellAccessory.None; } else { owner.Value = x.Owner.Login; owner.Accessory = UITableViewCellAccessory.DisclosureIndicator; } Root.Reload(owner); }); ViewModel.WhenAnyValue(x => x.IsStarred).Where(x => x.HasValue).Subscribe(x => { splitElement2.Button2.Text = x.Value ? "Starred!" : "Unstarred"; splitElement2.Button2.Image = x.Value ? Images.Star : Images.Star2; }); Root.Reset(headerSection, detailsSection, filesSection); updatedGistObservable.SubscribeSafe(x => { HeaderView.SubText = x.Description; if (x.Owner != null) { HeaderView.ImageUri = x.Owner.AvatarUrl; } Root.Reload(headerSection); }); updatedGistObservable.Select(x => x.Files == null ? 0 : x.Files.Count()).SubscribeSafe(x => files.Text = x.ToString()); updatedGistObservable.SubscribeSafe(x => comments.Text = x.Comments.ToString()); updatedGistObservable.Select(x => x.Forks == null ? 0 : x.Forks.Count()).SubscribeSafe(x => forks.Text = x.ToString()); updatedGistObservable.Subscribe(x => { var elements = new List <Element>(); foreach (var file in x.Files.Keys) { var sse = new StyledStringElement(file, x.Files[file].Size + " bytes", UITableViewCellStyle.Subtitle) { Accessory = UITableViewCellAccessory.DisclosureIndicator, LineBreakMode = UILineBreakMode.TailTruncation, Lines = 1 }; var fileSaved = file; var gistFileModel = x.Files[fileSaved]; // if (string.Equals(gistFileModel.Language, "markdown", StringComparison.OrdinalIgnoreCase)) // sse.Tapped += () => ViewModel.GoToViewableFileCommand.Execute(gistFileModel); // else sse.Tapped += () => ViewModel.GoToFileSourceCommand.Execute(gistFileModel); elements.Add(sse); } filesSection.Reset(elements); }); // // updatedGistObservable.Take(1).Subscribe(_ => Root.Add(filesSection)); ViewModel.Comments.Changed.Subscribe(_ => { var commentModels = ViewModel.Comments.Select(x => new Comment(x.User.AvatarUrl, x.User.Login, x.BodyHtml, x.CreatedAt.ToDaysAgo())); var razorView = new CommentsView { Model = commentModels }; var html = razorView.GenerateString(); commentsElement.Value = html; }); ViewModel.Comments.Changed.Take(1).Select(x => ViewModel.Comments).Where(x => x.Count > 0) .Subscribe(_ => Root.Insert(Root.Count, commentsSection)); ViewModel.WhenAnyValue(x => x.Gist).Where(x => x != null).Subscribe(gist => { if (string.Equals(_applicationService.Account.Username, ViewModel.Gist.Owner.Login, StringComparison.OrdinalIgnoreCase)) { NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Compose, (s, e) => { }); // try // { // var data = await this.DoWorkAsync("Loading...", () => app.Client.ExecuteAsync(app.Client.Gists[ViewModel.Id].Get())); // var gistController = new EditGistController(data.Data); // gistController.Created = editedGist => ViewModel.Gist = editedGist; // var navController = new UINavigationController(gistController); // PresentViewController(navController, true, null); // // } // catch (Exception ex) // { // MonoTouch.Utilities.ShowAlert("Error", ex.Message); // } } else { NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.ForkButton, UIBarButtonItemStyle.Plain, (s, e) => ViewModel.ForkCommand.ExecuteIfCan()); NavigationItem.RightBarButtonItem.EnableIfExecutable(ViewModel.ForkCommand.CanExecuteObservable); } }); ViewModel.ForkCommand.IsExecuting.Subscribe(x => { if (x) { _statusIndicatorService.Show("Forking..."); } else { _statusIndicatorService.Hide(); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = ViewModel.Username; HeaderView.SetImage(null, Images.Avatar); HeaderView.Text = ViewModel.RepositoryName; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.35f)).Take(1)) .Switch() .Select(_ => ViewModel.Bind(x => x.IsStarred, true).Where(x => x.HasValue)) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => HeaderView.SetSubImage(x.Value ? Octicon.Star.ToImage() : null)); var actionButton = NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action) { Enabled = false }; _split = new SplitButtonElement(); _stargazers = _split.AddButton("Stargazers", "-"); _watchers = _split.AddButton("Watchers", "-"); _forks = _split.AddButton("Forks", "-"); OnActivation(d => { d(_watchers.Clicked .Select(_ => ViewModel) .Select(x => UsersViewController.CreateWatchersViewController(x.Username, x.RepositoryName)) .Subscribe(x => NavigationController.PushViewController(x, true))); d(_stargazers.Clicked .Select(_ => ViewModel) .Select(x => UsersViewController.CreateStargazersViewController(x.Username, x.RepositoryName)) .Subscribe(x => NavigationController.PushViewController(x, true))); d(actionButton.GetClickedObservable().Subscribe(_ => ShowExtraMenu())); d(_forks.Clicked.Subscribe(_ => { var vc = RepositoriesViewController.CreateForkedViewController(ViewModel.Username, ViewModel.RepositoryName); NavigationController?.PushViewController(vc, true); })); d(_eventsElement.Clicked.BindCommand(ViewModel.GoToEventsCommand)); d(_ownerElement.Clicked.BindCommand(ViewModel.GoToOwnerCommand)); d(_commitsElement.Clicked.BindCommand(ViewModel.GoToCommitsCommand)); d(_pullRequestsElement.Clicked.BindCommand(ViewModel.GoToPullRequestsCommand)); d(_sourceElement.Clicked.BindCommand(ViewModel.GoToSourceCommand)); d(ViewModel.Bind(x => x.Branches, true).Subscribe(_ => Render())); d(ViewModel.Bind(x => x.Readme, true).Subscribe(_ => Render())); d(_forkElement.Value.Clicked.Select(x => ViewModel.Repository.Parent).BindCommand(ViewModel.GoToForkParentCommand)); d(_issuesElement.Value.Clicked.BindCommand(ViewModel.GoToIssuesCommand)); d(_readmeElement.Value.Clicked.BindCommand(ViewModel.GoToReadmeCommand)); d(_websiteElement.Value.Clicked.Select(x => ViewModel.Repository.Homepage).BindCommand(ViewModel.GoToUrlCommand)); d(HeaderView.Clicked.BindCommand(ViewModel.GoToOwnerCommand)); d(ViewModel.Bind(x => x.Repository, true).Where(x => x != null).Subscribe(x => { if (x.Private && !_featuresService.IsProEnabled) { if (_privateView == null) { _privateView = this.ShowPrivateView(); } actionButton.Enabled = false; } else { actionButton.Enabled = true; _privateView?.Dispose(); } ViewModel.ImageUrl = x.Owner?.AvatarUrl; HeaderView.SubText = Emojis.FindAndReplace(x.Description); HeaderView.SetImage(x.Owner?.AvatarUrl, Images.Avatar); Render(); RefreshHeaderView(); })); }); }
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; var root = new RootElement(Title) { UnevenRows = Root.UnevenRows }; 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) { CaptionColor = Theme.CurrentTheme.MainTextColor, ValueColor = Theme.CurrentTheme.MainTextColor, BackgroundColor = UIColor.White }); if (ViewModel.ShowRepository) { var repo = new StyledStringElement(ViewModel.Repository) { Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator, Lines = 1, Font = StyledStringElement.DefaultDetailFont, TextColor = StyledStringElement.DefaultDetailColor, Image = AtlassianIcon.Devtoolsrepository.ToImage() }; repo.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(null); 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.Tapped += () => ViewModel.GoToFileCommand.Execute(y); 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 imgUri = new Avatar(comment.User.Links?.Avatar?.Href); commentSection.Add(new NameTimeStringElement(name, comment.Content.Raw, comment.CreatedOn, imgUri.ToUrl(), Images.Avatar)); } if (commentSection.Elements.Count > 0) { root.Add(commentSection); } var addComment = new StyledStringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() }; addComment.Tapped += 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 el = new UserElement(l.User.DisplayName, string.Empty, string.Empty, l.User.Links.Avatar.Href); el.Tapped += () => ViewModel.GoToUserCommand.Execute(l.User.Username); return(el); })); if (likeSection.Elements.Count > 0) { root.Add(likeSection); } StyledStringElement approveButton; if (ViewModel.Commit.Participants.Any(x => x.User.Username.Equals(ViewModel.GetApplication().Account.Username) && x.Approved)) { approveButton = new StyledStringElement("Unapprove") { Image = AtlassianIcon.Approve.ToImage() }; approveButton.Tapped += () => this.DoWorkAsync("Unapproving...", ViewModel.Unapprove); } else { approveButton = new StyledStringElement("Approve") { Image = AtlassianIcon.Approve.ToImage() }; approveButton.Tapped += () => this.DoWorkAsync("Approving...", ViewModel.Approve); } root.Add(new Section { approveButton }); } Root = root; }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Gist"; var editButton = NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action); HeaderView.SetImage(null, Images.Avatar); HeaderView.Text = "Gist #" + ViewModel.Id; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.35f)).Take(1)) .Switch() .Select(_ => ViewModel.Bind(x => x.IsStarred, true)) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => HeaderView.SetSubImage(x ? Octicon.Star.ToImage() : null)); TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 44f; _split = new SplitButtonElement(); var files = _split.AddButton("Files", "-"); var comments = _split.AddButton("Comments", "-"); var forks = _split.AddButton("Forks", "-"); _splitRow1 = new SplitViewElement(Octicon.Lock.ToImage(), Octicon.Package.ToImage()); _splitRow2 = new SplitViewElement(Octicon.Calendar.ToImage(), Octicon.Star.ToImage()); _ownerElement = new StringElement("Owner", string.Empty, UITableViewCellStyle.Value1) { Image = Octicon.Person.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; OnActivation(d => { d(editButton.GetClickedObservable().Subscribe(_ => ShareButtonTap(editButton))); d(_ownerElement.Clicked.BindCommand(ViewModel.GoToUserCommand)); d(ViewModel.Bind(x => x.IsStarred, true).Subscribe(isStarred => _splitRow2.Button2.Text = isStarred ? "Starred" : "Not Starred")); d(ViewModel.BindCollection(x => x.Comments, true).Subscribe(_ => RenderGist())); d(HeaderView.Clicked.BindCommand(ViewModel.GoToUserCommand)); d(ViewModel.Bind(x => x.Gist, true).Where(x => x != null).Subscribe(gist => { var daysOld = gist.CreatedAt.TotalDaysAgo(); _splitRow1.Button1.Text = gist.Public ? "Public" : "Private"; _splitRow1.Button2.Text = (gist.History?.Count ?? 0) + " Revisions"; _splitRow2.Button1.Text = daysOld == 0 ? "Created today" : "day".ToQuantity(daysOld) + " old"; _ownerElement.Value = gist.Owner?.Login ?? "Unknown"; files.Text = gist.Files?.Count.ToString() ?? "-"; comments.Text = gist.Comments.ToString(); forks.Text = gist.Forks?.Count.ToString() ?? "-"; HeaderView.SubText = gist.Description; HeaderView.Text = gist.Files?.Select(x => x.Key).FirstOrDefault() ?? HeaderView.Text; HeaderView.SetImage(gist.Owner?.AvatarUrl, Images.Avatar); RenderGist(); RefreshHeaderView(); })); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.Image = Images.LoginUserUnknown; var split = new SplitButtonElement(); var headerSection = new Section { split }; var descriptionElement = new MultilinedElement(); var detailsSection = new Section(); var footerButton = new TableFooterButton("Add Comment"); var commentsSection = new Section(null, footerButton); var diffButton = new StringElement(Octicon.DiffAdded.ToImage()); var removedButton = new StringElement(Octicon.DiffRemoved.ToImage()); var modifiedButton = new StringElement(Octicon.DiffModified.ToImage()); var allChangesButton = new StringElement("All Changes", Octicon.Diff.ToImage()); detailsSection.Add(new [] { diffButton, removedButton, modifiedButton, allChangesButton }); var additions = split.AddButton("Additions"); var deletions = split.AddButton("Deletions"); var parents = split.AddButton("Parents"); var commentsElement = new HtmlElement("comments"); ViewModel.Comments.Changed .Select(_ => new Unit()) .StartWith(new Unit()) .Subscribe(x => { var comments = ViewModel.Comments.Select(c => new Comment(c.Avatar.ToUri(), c.Actor, c.Body, c.UtcCreatedAt.Humanize())).ToList(); var commentModel = new CommentModel(comments, (int)UIFont.PreferredSubheadline.PointSize); var razorView = new CommentsView { Model = commentModel }; var html = razorView.GenerateString(); commentsElement.Value = html; if (commentsElement.GetRootElement() == null && ViewModel.Comments.Count > 0) { commentsSection.Add(commentsElement); } TableView.ReloadData(); }); this.WhenAnyValue(x => x.ViewModel.Commit) .IsNotNull() .Take(1) .Subscribe(_ => Root.Reset(headerSection, detailsSection, commentsSection)); Appeared .Take(1) .Select(_ => this.WhenAnyValue(x => x.ViewModel.CommitMessage, y => y.ViewModel.CommiterName)) .Switch() .Where(x => x.Item1 != null && x.Item2 != null) .Take(1) .Subscribe(_ => detailsSection.Insert(0, UITableViewRowAnimation.Automatic, descriptionElement)); OnActivation(d => { d(allChangesButton.BindCommand(ViewModel.GoToAllFiles)); d(footerButton.Clicked.InvokeCommand(ViewModel.AddCommentCommand)); d(this.WhenAnyValue(x => x.ViewModel.Avatar) .Subscribe(x => HeaderView.SetImage(x?.ToUri(128), Images.LoginUserUnknown))); d(this.WhenAnyValue(x => x.ViewModel.CommitMessage) .Subscribe(x => descriptionElement.Details = x ?? string.Empty)); d(descriptionElement.BindCaption(this.WhenAnyValue(x => x.ViewModel.CommiterName))); d(diffButton.BindCommand(ViewModel.GoToAddedFiles)); d(diffButton.BindDisclosure(this.WhenAnyValue(x => x.ViewModel.DiffAdditions).Select(x => x > 0))); d(diffButton.BindCaption(this.WhenAnyValue(x => x.ViewModel.DiffAdditions).StartWith(0).Select(x => string.Format("{0} added", x)))); d(removedButton.BindCommand(ViewModel.GoToRemovedFiles)); d(removedButton.BindDisclosure(this.WhenAnyValue(x => x.ViewModel.DiffDeletions).Select(x => x > 0))); d(removedButton.BindCaption(this.WhenAnyValue(x => x.ViewModel.DiffDeletions).StartWith(0).Select(x => string.Format("{0} removed", x)))); d(modifiedButton.BindCommand(ViewModel.GoToModifiedFiles)); d(modifiedButton.BindDisclosure(this.WhenAnyValue(x => x.ViewModel.DiffModifications).Select(x => x > 0))); d(modifiedButton.BindCaption(this.WhenAnyValue(x => x.ViewModel.DiffModifications).StartWith(0).Select(x => string.Format("{0} modified", x)))); d(allChangesButton.BindDisclosure(this.WhenAnyValue(x => x.ViewModel.DiffAdditions, x => x.ViewModel.DiffDeletions, x => x.ViewModel.DiffModifications) .Select(x => x.Item1 + x.Item2 + x.Item3 > 0))); d(commentsElement.UrlRequested.InvokeCommand(ViewModel.GoToUrlCommand)); d(this.WhenAnyValue(x => x.ViewModel.ShowMenuCommand) .ToBarButtonItem(UIBarButtonSystemItem.Action, x => NavigationItem.RightBarButtonItem = x)); d(this.WhenAnyValue(x => x.ViewModel.CommitMessageSummary).Subscribe(x => RefreshHeaderView(x))); d(this.WhenAnyValue(x => x.ViewModel.Commit).IsNotNull() .Select(x => "Commited " + x.Commit.Committer.Date.LocalDateTime.Humanize()) .Subscribe(x => RefreshHeaderView(subtext: x))); var statsObs = this.WhenAnyValue(x => x.ViewModel.Commit.Stats); d(additions.BindText(statsObs.Select(x => x != null ? x.Additions.ToString() : "-"))); d(deletions.BindText(statsObs.Select(x => x != null ? x.Deletions.ToString() : "-"))); d(this.WhenAnyValue(x => x.ViewModel.Commit.Parents) .Subscribe(x => parents.Text = x != null ? x.Count.ToString() : "-")); }); }
private void Render() { //Wait for the issue to load if (ViewModel.PullRequest == null) { return; } var additions = ViewModel.PullRequest?.Additions ?? 0; var deletions = ViewModel.PullRequest?.Deletions ?? 0; var changes = ViewModel.PullRequest?.ChangedFiles ?? 0; var split = new SplitButtonElement(); split.AddButton("Additions", additions.ToString()); split.AddButton("Deletions", deletions.ToString()); split.AddButton("Changes", changes.ToString()); ICollection <Section> sections = new LinkedList <Section>(); sections.Add(new Section { split }); var secDetails = new Section(); if (_descriptionElement.HasValue) { secDetails.Add(_descriptionElement); } secDetails.Add(_split1); secDetails.Add(_split2); foreach (var i in new [] { _assigneeElement, _milestoneElement, _labelsElement }) { i.Accessory = ViewModel.IsCollaborator ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; } secDetails.Add(_assigneeElement); secDetails.Add(_milestoneElement); secDetails.Add(_labelsElement); sections.Add(secDetails); var commits = new StringElement("Commits", Octicon.GitCommit.ToImage()); commits.Clicked.Subscribe(_ => ViewModel.GoToCommitsCommand.Execute(null)); var files = new StringElement("Files", Octicon.FileCode.ToImage()); files.Clicked.Subscribe(_ => ViewModel.GoToFilesCommand.Execute(null)); sections.Add(new Section { commits, files }); var isClosed = string.Equals(ViewModel.PullRequest.State, "closed", StringComparison.OrdinalIgnoreCase); var isMerged = ViewModel.PullRequest.Merged.GetValueOrDefault(); if (ViewModel.CanPush && !isClosed && !isMerged) { Action mergeAction = async() => { try { await this.DoWorkAsync("Merging...", ViewModel.Merge); } catch (Exception e) { AlertDialogService.ShowAlert("Unable to Merge", e.Message); } }; StringElement el; if (!ViewModel.PullRequest.Mergeable.HasValue || ViewModel.PullRequest.Mergeable.Value) { el = new StringElement("Merge This Pull Request!", Octicon.GitMerge.ToImage()); el.Clicked.Subscribe(_ => mergeAction()); } else { el = new StringElement("Merge Conflicted!", Octicon.GitMerge.ToImage()); el.Accessory = UITableViewCellAccessory.None; } sections.Add(new Section { el }); } var commentsSection = new Section(); if (_commentsElement.HasValue) { commentsSection.Add(_commentsElement); } commentsSection.Add(_addCommentElement); sections.Add(commentsSection); Root.Reset(sections); }
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; }
public override void ViewDidLoad() { base.ViewDidLoad(); var split = new SplitButtonElement(); var contributors = split.AddButton("Contributors", "-"); var lastCommit = split.AddButton("Last Commit", "-"); var addFeatureButton = new BigButtonElement("Suggest a feature", Octicon.LightBulb); var addBugButton = new BigButtonElement("Report a bug", Octicon.Bug); var featuresButton = new BigButtonElement("Submitted Work Items", Octicon.Clippy); HeaderView.SubText = "This app is the product of hard work and great suggestions! Thank you to all whom provide feedback!"; HeaderView.Image = UIImage.FromBundle("AppIcons60x60"); NavigationItem.BackBarButtonItem = new UIBarButtonItem { Title = "" }; Root.Reset( new Section { split }, new Section { addFeatureButton, addBugButton }, new Section { featuresButton }); OnActivation(d => { d(addFeatureButton.Clicked .Select(_ => FeedbackComposerViewController.CreateAsFeature()) .Select(viewCtrl => new ThemedNavigationController(viewCtrl)) .Subscribe(viewCtrl => PresentViewController(viewCtrl, true, null))); d(addBugButton.Clicked .Select(_ => FeedbackComposerViewController.CreateAsBug()) .Select(viewCtrl => new ThemedNavigationController(viewCtrl)) .Subscribe(viewCtrl => PresentViewController(viewCtrl, true, null))); d(this.WhenAnyValue(x => x.ViewModel.Title) .Subscribe(title => Title = title)); d(featuresButton.Clicked .Subscribe(_ => this.PushViewController(new FeedbackViewController()))); d(HeaderView.Clicked.Subscribe(_ => GoToRepository())); d(this.WhenAnyValue(x => x.ViewModel.Contributors) .Where(x => x.HasValue) .Subscribe(x => contributors.Text = (x.Value >= 100 ? "100+" : x.Value.ToString()))); d(this.WhenAnyValue(x => x.ViewModel.LastCommit) .Where(x => x.HasValue) .Subscribe(x => lastCommit.Text = x.Value.UtcDateTime.Humanize())); }); Appearing .Take(1) .Select(_ => Unit.Default) .InvokeReactiveCommand(ViewModel.LoadCommand); }
public override void ViewDidLoad() { base.ViewDidLoad(); var split = new SplitButtonElement(); var contributors = split.AddButton("Contributors", "-"); var lastCommit = split.AddButton("Last Commit", "-"); var openIssue = new BigButtonElement("Open an Issue on GitHub", Octicon.Bug); var sendEmail = new BigButtonElement("Email Support", Octicon.Mail); var openIssues = new BigButtonElement("Existing Issues", Octicon.IssueOpened); HeaderView.SubText = "This app is the product of hard work and great suggestions! Thank you to all whom provide feedback!"; HeaderView.Image = UIImage.FromBundle("AppIcons60x60"); NavigationItem.BackBarButtonItem = new UIBarButtonItem { Title = "" }; Root.Reset( new Section { split }, new Section(null, "Opening an issue on the GitHub project page is the fastest way to get a response.") { openIssue, openIssues }, new Section(), new Section(null, "Emails are answered as quickly as possible but there is only one person answering them so expect a delay.") { sendEmail }); OnActivation(d => { d(openIssue.Clicked .Select(_ => new FeedbackComposerViewController()) .Select(viewCtrl => new ThemedNavigationController(viewCtrl)) .Subscribe(viewCtrl => PresentViewController(viewCtrl, true, null))); d(sendEmail.Clicked.Subscribe(_ => SendEmail())); d(this.WhenAnyValue(x => x.ViewModel.Title) .Subscribe(title => Title = title)); d(openIssues.Clicked .Subscribe(_ => this.PushViewController(new FeedbackViewController()))); d(HeaderView.Clicked.Subscribe(_ => GoToRepository())); d(this.WhenAnyValue(x => x.ViewModel.Contributors) .Where(x => x.HasValue) .Subscribe(x => contributors.Text = (x.Value >= 100 ? "100+" : x.Value.ToString()))); d(this.WhenAnyValue(x => x.ViewModel.LastCommit) .Where(x => x.HasValue) .Subscribe(x => lastCommit.Text = x.Value.UtcDateTime.Humanize())); }); Appearing .Take(1) .Select(_ => Unit.Default) .InvokeReactiveCommand(ViewModel.LoadCommand); }
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(RepositoryDetailedModel model) { if (model == null) return; Title = model.Name; var avatar = new Avatar(model.Logo).ToUrl(128); var root = new RootElement(Title) { UnevenRows = true }; HeaderView.SubText = string.IsNullOrWhiteSpace(model.Description) ? "Updated " + model.UtcLastUpdated.Humanize() : model.Description; HeaderView.SetImage(avatar, Images.RepoPlaceholder); RefreshHeaderView(); var stargazersCommand = ViewModel.GoToStargazersCommand; var split = new SplitButtonElement(); split.AddButton("Watchers", model.FollowersCount.ToString(), () => stargazersCommand.Execute(null)); split.AddButton("Forks", model.ForkCount.ToString()); split.AddButton("Branches", ViewModel.Branches?.Count.ToString() ?? "-"); 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 StyledStringElement("Owner", model.Owner) { Image = AtlassianIcon.User.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; owner.Tapped += () => ViewModel.GoToOwnerCommand.Execute(null); sec1.Add(owner); if (model.ForkOf != null) { var parent = new StyledStringElement("Forked From", model.ForkOf.Name) { Image = AtlassianIcon.Devtoolsfork.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; parent.Tapped += () => ViewModel.GoToForkParentCommand.Execute(model.ForkOf); sec1.Add(parent); } var events = new StyledStringElement("Events", () => ViewModel.GoToEventsCommand.Execute(null), AtlassianIcon.Blogroll.ToImage()); var sec2 = new Section { events }; if (model.HasWiki) sec2.Add(new StyledStringElement("Wiki", () => ViewModel.GoToWikiCommand.Execute(null), AtlassianIcon.Edit.ToImage())); if (model.HasIssues) sec2.Add(new StyledStringElement("Issues", () => ViewModel.GoToIssuesCommand.Execute(null), AtlassianIcon.Flag.ToImage())); if (ViewModel.HasReadme) sec2.Add(new StyledStringElement("Readme", () => ViewModel.GoToReadmeCommand.Execute(null), AtlassianIcon.Pagedefault.ToImage())); var sec3 = new Section { new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), AtlassianIcon.Devtoolscommit.ToImage()), new StyledStringElement("Pull Requests", () => ViewModel.GoToPullRequestsCommand.Execute(null), AtlassianIcon.Devtoolspullrequest.ToImage()), new StyledStringElement("Source", () => ViewModel.GoToSourceCommand.Execute(null), AtlassianIcon.Filecode.ToImage()), }; root.Add(new[] { new Section { split }, sec1, sec2, sec3 }); if (!String.IsNullOrEmpty(ViewModel.Repository.Website)) { root.Add(new Section { new StyledStringElement("Website", () => ViewModel.GoToUrlCommand.Execute(ViewModel.Repository.Website), AtlassianIcon.Homepage.ToImage()) }); } Root = root; }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowExtraMenu()); NavigationItem.RightBarButtonItem.EnableIfExecutable(ViewModel.WhenAnyValue(x => x.Commit).Select(x => x != null)); _split = new SplitButtonElement(); var additions = _split.AddButton("Additions", "-"); var deletions = _split.AddButton("Deletions", "-"); var parents = _split.AddButton("Parents", "-"); var commentsElement = new WebElement("comments"); commentsElement.UrlRequested = ViewModel.GoToUrlCommand.ExecuteIfCan; //commentsSection.Add(commentsElement); var headerSection = new Section(HeaderView) { _split }; Root.Reset(headerSection); ViewModel.WhenAnyValue(x => x.Commit).IsNotNull().SubscribeSafe(x => { HeaderView.Image = Images.LoginUserUnknown; if (x.Author != null) { HeaderView.ImageUri = x.Author.AvatarUrl; } var msg = x.Commit.Message ?? string.Empty; var firstLine = msg.IndexOf("\n", StringComparison.Ordinal); HeaderView.Text = firstLine > 0 ? msg.Substring(0, firstLine) : msg; HeaderView.SubText = "Commited " + (x.Commit.Committer.Date).ToDaysAgo(); additions.Text = x.Stats.Additions.ToString(); deletions.Text = x.Stats.Deletions.ToString(); parents.Text = x.Parents.Count.ToString(); ReloadData(); }); ViewModel.WhenAnyValue(x => x.Commit).Where(x => x != null).Subscribe(Render); ViewModel.Comments.Changed .Select(_ => new Unit()) .StartWith(new Unit()) .Subscribe(x => { var commentModels = ViewModel.Comments.Select(c => new Comment(c.User.AvatarUrl, c.User.Login, c.BodyHtml, c.CreatedAt.ToDaysAgo())); var razorView = new CommentsView { Model = commentModels }; var html = razorView.GenerateString(); commentsElement.Value = html; if (commentsElement.GetRootElement() == null && ViewModel.Comments.Count > 0) { _commentSection.Add(commentsElement); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowMenu()); NavigationItem.RightBarButtonItem.EnableIfExecutable( ViewModel.WhenAnyValue(x => x.Repository, x => x.IsStarred, x => x.IsWatched) .Select(x => x.Item1 != null && x.Item2 != null && x.Item3 != null)); _split = new SplitButtonElement(); var stargazers = _split.AddButton("Stargazers", "-", () => ViewModel.GoToStargazersCommand.ExecuteIfCan()); var watchers = _split.AddButton("Watchers", "-", () => ViewModel.GoToWatchersCommand.ExecuteIfCan()); var forks = _split.AddButton("Forks", "-", () => ViewModel.GoToForksCommand.ExecuteIfCan()); Root.Reset(new Section(HeaderView) { _split }); // Not very efficient but it'll work for now. ViewModel.WhenAnyValue(x => x.Readme).IsNotNull() .Select(_ => ViewModel.Repository).IsNotNull().Subscribe(_ => Render()); _splitElements[0] = new SplitElement(); _splitElements[0].Button1 = new SplitElement.SplitButton(Images.Locked, string.Empty); _splitElements[0].Button2 = new SplitElement.SplitButton(Images.Language, string.Empty); _splitElements[1] = new SplitElement(); _splitElements[1].Button1 = new SplitElement.SplitButton(Images.Flag, string.Empty, () => ViewModel.GoToIssuesCommand.ExecuteIfCan()); _splitElements[1].Button2 = new SplitElement.SplitButton(Images.Team, string.Empty, () => ViewModel.GoToContributors.ExecuteIfCan()); _splitElements[2] = new SplitElement(); _splitElements[2].Button1 = new SplitElement.SplitButton(Images.Tag, string.Empty, () => ViewModel.GoToReleasesCommand.ExecuteIfCan()); _splitElements[2].Button2 = new SplitElement.SplitButton(Images.Branch, string.Empty, () => ViewModel.GoToBranchesCommand.ExecuteIfCan()); ViewModel.WhenAnyValue(x => x.Repository).Where(x => x != null).Subscribe(x => { HeaderView.ImageUri = x.Owner.AvatarUrl; HeaderView.SubText = x.Description; stargazers.Text = x.StargazersCount.ToString(); watchers.Text = x.SubscribersCount.ToString(); forks.Text = x.ForksCount.ToString(); _splitElements[0].Button1.Image = x.Private ? Images.Locked : Images.Unlocked; _splitElements[0].Button1.Text = x.Private ? "Private" : "Public"; _splitElements[0].Button2.Text = x.Language ?? "N/A"; _splitElements[1].Button1.Text = x.OpenIssues + (x.OpenIssues == 1 ? " Issue" : " Issues"); Render(); }); ViewModel.WhenAnyValue(x => x.Contributors).Where(x => x.HasValue).SubscribeSafe(x => _splitElements[1].Button2.Text = (x >= 100 ? "100+" : x.ToString()) + (x == 1 ? " Contributor" : " Contributors")); ViewModel.WhenAnyValue(x => x.Branches).Where(x => x != null).SubscribeSafe(x => _splitElements[2].Button2.Text = (x.Count >= 100 ? "100+" : x.Count.ToString()) + (x.Count == 1 ? " Branch" : " Branches")); ViewModel.WhenAnyValue(x => x.Releases).Where(x => x.HasValue).SubscribeSafe(x => _splitElements[2].Button1.Text = (x >= 100 ? "100+" : x.ToString()) + (x == 1 ? " Release" : " Releases")); ViewModel.WhenAnyValue(x => x.RepositoryName).Subscribe(x => HeaderView.Text = x); }
public override void ViewDidLoad() { base.ViewDidLoad(); var headerSection = new Section(); var filesSection = new Section("Files"); var split = new SplitButtonElement(); var files = split.AddButton("Files", "-"); var comments = split.AddButton("Comments", "-"); var forks = split.AddButton("Forks", "-"); headerSection.Add(split); var commentsSection = new Section("Comments") { FooterView = new TableFooterButton("Add Comment", ViewModel.AddCommentCommand.ExecuteIfCan) }; var commentsElement = new HtmlElement("comments"); commentsElement.UrlRequested = ViewModel.GoToUrlCommand.ExecuteIfCan; commentsSection.Add(commentsElement); var detailsSection = new Section { _splitRow1, _splitRow2 }; Root.Reset(headerSection, detailsSection, filesSection, commentsSection); var updatedGistObservable = ViewModel.WhenAnyValue(x => x.Gist).Where(x => x != null); ViewModel.WhenAnyValue(x => x.Gist) .IsNotNull() .Select(x => x.Owner) .Subscribe(x => { if (x == null) { detailsSection.Remove(_ownerElement); } else if (x != null && !detailsSection.Contains(_ownerElement)) { detailsSection.Add(_ownerElement); } }); updatedGistObservable.SubscribeSafe(x => { if (x.Owner == null) { _ownerElement.Value = "Anonymous"; _ownerElement.Accessory = UITableViewCellAccessory.None; } else { _ownerElement.Value = x.Owner.Login; _ownerElement.Accessory = UITableViewCellAccessory.DisclosureIndicator; } Root.Reload(_ownerElement); }); updatedGistObservable.SubscribeSafe(x => { HeaderView.SubText = x.Description; if (x.Owner != null) { HeaderView.ImageUri = x.Owner.AvatarUrl; } else { HeaderView.Image = Images.LoginUserUnknown; } TableView.ReloadData(); }); updatedGistObservable.Select(x => x.Files == null ? 0 : x.Files.Count()).SubscribeSafe(x => files.Text = x.ToString()); updatedGistObservable.SubscribeSafe(x => comments.Text = x.Comments.ToString()); updatedGistObservable.Select(x => x.Forks == null ? 0 : x.Forks.Count()).SubscribeSafe(x => forks.Text = x.ToString()); updatedGistObservable.Subscribe(x => { var elements = new List <Element>(); foreach (var file in x.Files.Keys) { var sse = new StyledStringElement(file, x.Files[file].Size + " bytes", UITableViewCellStyle.Subtitle) { Accessory = UITableViewCellAccessory.DisclosureIndicator, LineBreakMode = UILineBreakMode.TailTruncation, Lines = 1 }; sse.Tapped += () => ViewModel.GoToFileSourceCommand.Execute(x.Files[file]); elements.Add(sse); } filesSection.Reset(elements); }); ViewModel.Comments.Changed.Subscribe(_ => { var commentModels = ViewModel.Comments .Select(x => new Comment(x.User.AvatarUrl, x.User.Login, x.BodyHtml, x.CreatedAt.UtcDateTime.Humanize())) .ToList(); if (commentModels.Count > 0) { var razorView = new CommentsView { Model = commentModels }; var html = razorView.GenerateString(); commentsElement.Value = html; if (!commentsSection.Contains(commentsElement)) { commentsSection.Insert(0, UITableViewRowAnimation.Fade, commentsElement); } } else { commentsSection.Remove(commentsElement); } }); }