Ejemplo n.º 1
0
        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);
     }
 }
Ejemplo n.º 3
0
        private void GoToFile(Octokit.RepositoryContent content)
        {
            var viewController = new FileSourceViewController(
                _username, _repository, content.Path, _sha, _shaType)
            {
                Content = content
            };

            this.PushViewController(viewController);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
 private void GoToSourceTree(Octokit.RepositoryContent content)
 {
     this.PushViewController(new SourceTreeViewController(
                                 _username, _repository, content.Path, _sha, _shaType));
 }
Ejemplo n.º 6
0
        public void Update(Octokit.RepositoryContent content)
        {
            label.Text = DownloadResult.ToCleanName(content.Name);

            ShowLoading();
        }