private Element CreateElement(Octokit.RepositoryContent content) { var weakRef = new WeakReference <SourceTreeViewController>(this); if (content.Type == Octokit.ContentType.Dir) { var e = new StringElement(content.Name, Octicon.FileDirectory.ToImage()); e.Clicked.Subscribe(_ => weakRef.Get()?.GoToSourceTree(content)); return(e); } if (content.Type == Octokit.ContentType.File) { if (content.DownloadUrl != null) { var e = new StringElement(content.Name, Octicon.FileCode.ToImage()); e.Style = UITableViewCellStyle.Subtitle; e.Value = content.Size.Bytes().ToString("#.#"); e.Clicked.Subscribe(_ => weakRef.Get()?.GoToFile(content)); return(e); } else { var e = new StringElement(content.Name, Octicon.FileSubmodule.ToImage()); e.Clicked.Subscribe(_ => weakRef.Get()?.GoToSubModule(content)); return(e); } } return(new StringElement(content.Name) { Image = Octicon.FileMedia.ToImage() }); }
private static void IncludeCommunityFile(Octokit.RepositoryContent content, List <string> files) { if (content.Type.Value == Octokit.ContentType.File && IsCommunityFile(content.Path)) { files.Add(content.Path); } }
private void GoToFile(Octokit.RepositoryContent content) { var viewController = new FileSourceViewController( _username, _repository, content.Path, _sha, _shaType) { Content = content }; this.PushViewController(viewController); }
private void GoToSubModule(Octokit.RepositoryContent content) { var gitUrl = content.GitUrl; var nameAndSlug = gitUrl.Substring(gitUrl.IndexOf("/repos/", StringComparison.Ordinal) + 7); var indexOfGit = nameAndSlug.LastIndexOf("/git", StringComparison.Ordinal); indexOfGit = indexOfGit < 0 ? 0 : indexOfGit; var repoId = RepositoryIdentifier.FromFullName(nameAndSlug.Substring(0, indexOfGit)); if (repoId == null) { return; } var sha = gitUrl.Substring(gitUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); this.PushViewController(new SourceTreeViewController( repoId.Owner, repoId.Name, null, sha, ShaType.Hash)); }
private void GoToSourceTree(Octokit.RepositoryContent content) { this.PushViewController(new SourceTreeViewController( _username, _repository, content.Path, _sha, _shaType)); }
public void Update(Octokit.RepositoryContent content) { label.Text = DownloadResult.ToCleanName(content.Name); ShowLoading(); }