mirror of
https://github.com/git-touch/git-touch
synced 2025-02-20 13:30:38 +01:00
refactor: repository item
This commit is contained in:
parent
df09ee4c17
commit
6ffef6eaf6
@ -40,19 +40,17 @@ class GiteaUserScreen extends StatelessWidget {
|
||||
),
|
||||
CommonStyle.border,
|
||||
Column(
|
||||
children: repos.map((v) {
|
||||
return RepositoryItem(
|
||||
v.owner.login,
|
||||
v.owner.avatarUrl,
|
||||
v.name,
|
||||
v.description,
|
||||
v.starsCount,
|
||||
v.forksCount,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
}).toList(),
|
||||
children: <Widget>[
|
||||
for (var v in repos)
|
||||
RepositoryItem(
|
||||
owner: v.owner.login,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.starsCount,
|
||||
forkCount: v.forksCount,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
|
@ -60,19 +60,17 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
),
|
||||
CommonStyle.border,
|
||||
Column(
|
||||
children: projects.map((v) {
|
||||
return RepositoryItem(
|
||||
v.owner.name,
|
||||
v.owner.avatarUrl,
|
||||
v.name,
|
||||
v.description,
|
||||
v.starCount,
|
||||
v.forksCount,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
);
|
||||
}).toList(),
|
||||
children: <Widget>[
|
||||
for (var v in projects)
|
||||
RepositoryItem(
|
||||
owner: v.owner.username,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.starCount,
|
||||
forkCount: v.forksCount,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
|
@ -64,15 +64,15 @@ class RepositoriesScreen extends StatelessWidget {
|
||||
onLoadMore: (cursor) => _query(context, cursor),
|
||||
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)}',
|
||||
owner: v.owner.login,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.stargazers.totalCount,
|
||||
forkCount: v.forks.totalCount,
|
||||
primaryLanguageName: v.primaryLanguage?.name,
|
||||
primaryLanguageColor: v.primaryLanguage?.color,
|
||||
note: 'Updated ${timeago.format(v.updatedAt)}',
|
||||
isPrivate: v.isPrivate,
|
||||
isFork: v.isFork,
|
||||
);
|
||||
|
@ -166,15 +166,19 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
case 0:
|
||||
final updatedAt = timeago.format(DateTime.parse(p['updatedAt']));
|
||||
return RepositoryItem.gh(
|
||||
p['owner']['login'],
|
||||
p['owner']['avatarUrl'],
|
||||
p['name'],
|
||||
p['description'],
|
||||
p['stargazers']['totalCount'],
|
||||
p['forks']['totalCount'],
|
||||
p['primaryLanguage'] == null ? null : p['primaryLanguage']['name'],
|
||||
p['primaryLanguage'] == null ? null : p['primaryLanguage']['color'],
|
||||
'Updated $updatedAt',
|
||||
owner: p['owner']['login'],
|
||||
avatarUrl: p['owner']['avatarUrl'],
|
||||
name: p['name'],
|
||||
description: p['description'],
|
||||
starCount: p['stargazers']['totalCount'],
|
||||
forkCount: p['forks']['totalCount'],
|
||||
primaryLanguageName: p['primaryLanguage'] == null
|
||||
? null
|
||||
: p['primaryLanguage']['name'],
|
||||
primaryLanguageColor: p['primaryLanguage'] == null
|
||||
? null
|
||||
: p['primaryLanguage']['color'],
|
||||
note: 'Updated $updatedAt',
|
||||
isPrivate: p['isPrivate'],
|
||||
isFork: p['isFork'],
|
||||
);
|
||||
|
@ -32,15 +32,17 @@ class TrendingScreen extends StatelessWidget {
|
||||
case 0:
|
||||
final item = GithubTrendingItem.fromJson(v);
|
||||
return RepositoryItem.gh(
|
||||
item.author,
|
||||
item.avatar,
|
||||
item.name,
|
||||
item.description,
|
||||
item.stars ?? 0,
|
||||
item.forks ?? 0,
|
||||
item.language,
|
||||
item.languageColor,
|
||||
'${item.currentPeriodStars} stars today',
|
||||
owner: item.author,
|
||||
avatarUrl: item.avatar,
|
||||
name: item.name,
|
||||
description: item.description,
|
||||
starCount: item.stars ?? 0,
|
||||
forkCount: item.forks ?? 0,
|
||||
primaryLanguageName: item.language,
|
||||
primaryLanguageColor: item.languageColor,
|
||||
note: '${item.currentPeriodStars} stars today',
|
||||
isPrivate: false,
|
||||
isFork: false, // TODO:
|
||||
);
|
||||
case 1:
|
||||
final item = GithubTrendingUser.fromJson(v);
|
||||
|
@ -67,15 +67,14 @@ class UserScreen extends StatelessWidget {
|
||||
CommonStyle.border,
|
||||
items.map((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,
|
||||
null,
|
||||
owner: v.owner.login,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.stargazers.totalCount,
|
||||
forkCount: v.forks.totalCount,
|
||||
primaryLanguageName: v.primaryLanguage?.name,
|
||||
primaryLanguageColor: v.primaryLanguage?.color,
|
||||
isPrivate: v.isPrivate,
|
||||
isFork: v.isFork,
|
||||
);
|
||||
|
@ -18,31 +18,31 @@ class RepositoryItem extends StatelessWidget {
|
||||
final String primaryLanguageColor;
|
||||
final String note;
|
||||
|
||||
RepositoryItem(
|
||||
this.owner,
|
||||
this.avatarUrl,
|
||||
this.name,
|
||||
this.description,
|
||||
this.starCount,
|
||||
this.forkCount,
|
||||
RepositoryItem({
|
||||
@required this.owner,
|
||||
@required this.avatarUrl,
|
||||
@required this.name,
|
||||
@required this.description,
|
||||
@required this.starCount,
|
||||
@required 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,
|
||||
RepositoryItem.gh({
|
||||
@required this.owner,
|
||||
@required this.avatarUrl,
|
||||
@required this.name,
|
||||
@required this.description,
|
||||
@required this.starCount,
|
||||
@required this.forkCount,
|
||||
this.primaryLanguageName,
|
||||
this.primaryLanguageColor,
|
||||
this.note, {
|
||||
bool isPrivate,
|
||||
bool isFork,
|
||||
this.note,
|
||||
@required bool isPrivate,
|
||||
@required bool isFork,
|
||||
}) : this.iconData = _buildIconData(isPrivate, isFork);
|
||||
|
||||
static IconData _buildIconData(bool isPrivate, bool isFork) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user