1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-16 10:20:55 +01:00

improvement: private and fork

This commit is contained in:
Rongjian Zhang 2020-01-11 19:52:17 +08:00
parent 22fe55d9e0
commit 3074040935
8 changed files with 70 additions and 48 deletions

View File

@ -47,7 +47,6 @@ class GiteaUserScreen extends StatelessWidget {
v.owner.avatarUrl,
v.name,
v.description,
Octicons.repo,
v.starsCount,
v.forksCount,
null,

View File

@ -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(

View File

@ -67,7 +67,6 @@ class GitlabUserScreen extends StatelessWidget {
v.owner.avatarUrl,
v.name,
v.description,
_getGitlabIcon(v.visibility),
v.starCount,
v.forksCount,
null,

View File

@ -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,
);
});
}

View File

@ -165,17 +165,18 @@ class _SearchScreenState extends State<SearchScreen> {
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(

View File

@ -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,

View File

@ -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(),
),

View File

@ -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: <Widget>[
Text(
owner + ' / ',
style: TextStyle(
fontSize: 18,
color: theme.palette.primary,
),
Row(
children: <Widget>[
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),