diff --git a/lib/screens/gitea_user.dart b/lib/screens/gitea_user.dart index ea4abfd..421c6c1 100644 --- a/lib/screens/gitea_user.dart +++ b/lib/screens/gitea_user.dart @@ -47,7 +47,6 @@ class GiteaUserScreen extends StatelessWidget { v.owner.avatarUrl, v.name, v.description, - Octicons.repo, v.starsCount, v.forksCount, null, diff --git a/lib/screens/gitlab_project.dart b/lib/screens/gitlab_project.dart index 1875105..18457e2 100644 --- a/lib/screens/gitlab_project.dart +++ b/lib/screens/gitlab_project.dart @@ -63,11 +63,11 @@ class GitlabProjectScreen extends StatelessWidget { data.avatarUrl, data.name, data.description, - Octicons.repo, // TODO: data.starCount, data.forksCount, data.languages.keys.first, - null, null, + null, + null, ), CommonStyle.border, Row( diff --git a/lib/screens/gitlab_user.dart b/lib/screens/gitlab_user.dart index 1368551..5d3583d 100644 --- a/lib/screens/gitlab_user.dart +++ b/lib/screens/gitlab_user.dart @@ -67,7 +67,6 @@ class GitlabUserScreen extends StatelessWidget { v.owner.avatarUrl, v.name, v.description, - _getGitlabIcon(v.visibility), v.starCount, v.forksCount, null, diff --git a/lib/screens/repositories.dart b/lib/screens/repositories.dart index f97b74a..547658c 100644 --- a/lib/screens/repositories.dart +++ b/lib/screens/repositories.dart @@ -62,18 +62,19 @@ class RepositoriesScreen extends StatelessWidget { title: AppBarTitle(title), onRefresh: () => _query(context), onLoadMore: (cursor) => _query(context, cursor), - itemBuilder: (item) { - return RepositoryItem( - item.owner.login, - item.owner.avatarUrl, - item.name, - item.description, - Octicons.repo, - item.stargazers.totalCount, - item.forks.totalCount, - item.primaryLanguage?.name, - item.primaryLanguage?.color, - 'Updated ${timeago.format(item.updatedAt)}', + itemBuilder: (v) { + return RepositoryItem.gh( + v.owner.login, + v.owner.avatarUrl, + v.name, + v.description, + v.stargazers.totalCount, + v.forks.totalCount, + v.primaryLanguage?.name, + v.primaryLanguage?.color, + 'Updated ${timeago.format(v.updatedAt)}', + isPrivate: v.isPrivate, + isFork: v.isFork, ); }); } diff --git a/lib/screens/search.dart b/lib/screens/search.dart index d042e8b..c658c9f 100644 --- a/lib/screens/search.dart +++ b/lib/screens/search.dart @@ -165,17 +165,18 @@ class _SearchScreenState extends State { switch (_activeTab) { case 0: final updatedAt = timeago.format(DateTime.parse(p['updatedAt'])); - return RepositoryItem( + return RepositoryItem.gh( p['owner']['login'], p['owner']['avatarUrl'], p['name'], p['description'], - _buildIconData(p), p['stargazers']['totalCount'], p['forks']['totalCount'], p['primaryLanguage'] == null ? null : p['primaryLanguage']['name'], p['primaryLanguage'] == null ? null : p['primaryLanguage']['color'], 'Updated $updatedAt', + isPrivate: p['isPrivate'], + isFork: p['isFork'], ); case 1: return UserItem( diff --git a/lib/screens/trending.dart b/lib/screens/trending.dart index e2ed594..f562eb1 100644 --- a/lib/screens/trending.dart +++ b/lib/screens/trending.dart @@ -28,12 +28,11 @@ class TrendingScreen extends StatelessWidget { switch (activeTab) { case 0: final item = GithubTrendingItem.fromJson(v); - return RepositoryItem( + return RepositoryItem.gh( item.author, item.avatar, item.name, item.description, - Octicons.repo, item.stars ?? 0, item.forks ?? 0, item.language, diff --git a/lib/screens/user.dart b/lib/screens/user.dart index 03bf604..434c4c4 100644 --- a/lib/screens/user.dart +++ b/lib/screens/user.dart @@ -65,17 +65,18 @@ class UserScreen extends StatelessWidget { ...join( CommonStyle.border, items.map((v) { - return RepositoryItem( + return RepositoryItem.gh( v.owner.login, v.owner.avatarUrl, v.name, v.description, - Octicons.repo, // TODO: v.stargazers.totalCount, v.forks.totalCount, v.primaryLanguage?.name, v.primaryLanguage?.color, null, + isPrivate: v.isPrivate, + isFork: v.isFork, ); }).toList(), ), diff --git a/lib/widgets/repository_item.dart b/lib/widgets/repository_item.dart index 30b9050..f9b8b0d 100644 --- a/lib/widgets/repository_item.dart +++ b/lib/widgets/repository_item.dart @@ -23,13 +23,33 @@ class RepositoryItem extends StatelessWidget { this.avatarUrl, this.name, this.description, - this.iconData, this.starCount, this.forkCount, this.primaryLanguageName, this.primaryLanguageColor, - this.note, - ); + this.note, { + this.iconData, + }); + + RepositoryItem.gh( + this.owner, + this.avatarUrl, + this.name, + this.description, + this.starCount, + this.forkCount, + this.primaryLanguageName, + this.primaryLanguageColor, + this.note, { + bool isPrivate, + bool isFork, + }) : this.iconData = _buildIconData(isPrivate, isFork); + + static IconData _buildIconData(bool isPrivate, bool isFork) { + if (isPrivate == true) return Octicons.lock; + if (isFork == true) return Octicons.repo_forked; + return null; + } @override Widget build(BuildContext context) { @@ -53,32 +73,34 @@ class RepositoryItem extends StatelessWidget { linkUrl: '/$owner', ), SizedBox(width: 8), - Expanded( - child: Row( - children: [ - Text( - owner + ' / ', - style: TextStyle( - fontSize: 18, - color: theme.palette.primary, - ), + Row( + children: [ + Text( + owner + ' / ', + style: TextStyle( + fontSize: 18, + color: theme.palette.primary, ), - Expanded( - child: Text( - name, - style: TextStyle( - fontSize: 18, - color: theme.palette.primary, - fontWeight: FontWeight.w600, - ), - overflow: TextOverflow.ellipsis, - ), + ), + Text( + name, + style: TextStyle( + fontSize: 18, + color: theme.palette.primary, + fontWeight: FontWeight.w600, ), - ], - ), + overflow: TextOverflow.ellipsis, + ), + ], ), - // Icon(iconData, - // size: 17, color: theme.palette.tertiaryText), + if (iconData != null) ...[ + SizedBox(width: 6), + DefaultTextStyle( + child: Icon(iconData, + size: 16, color: theme.palette.secondaryText), + style: TextStyle(color: theme.palette.secondaryText), + ), + ] ], ), SizedBox(height: 8),