chore: style tweaks

This commit is contained in:
Rongjian Zhang 2022-10-02 12:49:55 +08:00
parent 0e952a6ef7
commit 26b78a31a6
18 changed files with 78 additions and 89 deletions

View File

@ -4,7 +4,7 @@ import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/bitbucket.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:provider/provider.dart';
class BbExploreScreen extends StatelessWidget {
@ -24,7 +24,7 @@ class BbExploreScreen extends StatelessWidget {
);
},
itemBuilder: (v) {
return RepositoryItem.bb(payload: v);
return RepoItem.bb(payload: v);
},
);
}

View File

@ -4,7 +4,7 @@ import 'package:git_touch/models/bitbucket.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_header.dart';
import 'package:provider/provider.dart';
import 'package:tuple/tuple.dart';
@ -58,9 +58,7 @@ class BbUserScreen extends StatelessWidget {
),
CommonStyle.border,
Column(
children: <Widget>[
for (var v in repos) RepositoryItem.bb(payload: v)
],
children: <Widget>[for (var v in repos) RepoItem.bb(payload: v)],
)
],
);

View File

@ -3,12 +3,11 @@ import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/gitee.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
class GeReposScreen extends StatelessWidget {
const GeReposScreen(String owner)
: api = '/users/$owner/repos',
title = 'Repositories';
@ -35,7 +34,7 @@ class GeReposScreen extends StatelessWidget {
);
},
itemBuilder: (v) {
return RepositoryItem(
return RepoItem(
owner: v.namespace!.path,
avatarUrl: v.owner!.avatarUrl,
name: v.path,

View File

@ -8,7 +8,7 @@ import 'package:git_touch/scaffolds/common.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/issue_item.dart';
import 'package:git_touch/widgets/loading.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_item.dart';
import 'package:primer/primer.dart';
import 'package:provider/provider.dart';
@ -85,7 +85,7 @@ class _GeSearchScreenState extends State<GeSearchScreen> {
Widget _buildItem(p) {
switch (_activeTab) {
case 0:
return RepositoryItem(
return RepoItem(
owner: p.namespace.path,
avatarUrl: p.owner.avatarUrl,
name: p.path,

View File

@ -8,7 +8,7 @@ import 'package:git_touch/widgets/action_button.dart';
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/entry_item.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_header.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
@ -99,7 +99,7 @@ class GeUserScreen extends StatelessWidget {
Column(
children: <Widget>[
for (var v in repos)
RepositoryItem(
RepoItem(
owner: v.namespace!.path,
avatarUrl: v.owner!.avatarUrl,
name: v.path,

View File

@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:gql_github/repos.data.gql.dart';
import 'package:gql_github/repos.req.gql.dart';
import 'package:provider/provider.dart';
@ -31,8 +31,7 @@ class GhRepos extends StatelessWidget {
);
},
itemBuilder: (p) {
return RepositoryItem.gql(p,
note: 'Updated ${timeago.format(p.updatedAt)}');
return RepoItem.gql(p, note: 'Updated ${timeago.format(p.updatedAt)}');
},
);
}
@ -61,8 +60,7 @@ class GhStars extends StatelessWidget {
);
},
itemBuilder: (p) {
return RepositoryItem.gql(p,
note: 'Updated ${timeago.format(p.updatedAt)}');
return RepoItem.gql(p, note: 'Updated ${timeago.format(p.updatedAt)}');
},
);
}

View File

@ -7,7 +7,7 @@ import 'package:git_touch/scaffolds/common.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/issue_item.dart';
import 'package:git_touch/widgets/loading.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_item.dart';
import 'package:primer/primer.dart';
import 'package:provider/provider.dart';
@ -138,7 +138,7 @@ class _GhSearchScreenState extends State<GhSearchScreen> {
switch (_activeTab) {
case 0:
final updatedAt = timeago.format(DateTime.parse(p['updatedAt']));
return RepositoryItem.gh(
return RepoItem.gh(
owner: p['owner']['login'],
avatarUrl: p['owner']['avatarUrl'],
name: p['name'],

View File

@ -6,7 +6,7 @@ import 'package:git_touch/scaffolds/tab_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/link.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_item.dart';
import 'package:github_trending/github_trending.dart';
import 'package:provider/provider.dart';
@ -38,7 +38,7 @@ class GhTrendingScreen extends StatelessWidget {
activeTab == 0
? [
for (var v in payload.cast<GithubTrendingRepository>())
RepositoryItem.gh(
RepoItem.gh(
owner: v.author,
avatarUrl: v.avatar,
name: v.name,

View File

@ -12,7 +12,7 @@ import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/contribution.dart';
import 'package:git_touch/widgets/entry_item.dart';
import 'package:git_touch/widgets/mutation_button.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/text_with_at.dart';
import 'package:git_touch/widgets/user_header.dart';
import 'package:go_router/go_router.dart';
@ -33,10 +33,9 @@ class _Repos extends StatelessWidget {
Widget build(BuildContext context) {
return AntList(
header: Text(title),
mode: AntListMode.card,
children: [
for (final v in repos!)
RepositoryItem.gh(
RepoItem.gh(
owner: v.owner.login,
avatarUrl: v.owner.avatarUrl,
name: v.name,
@ -109,7 +108,6 @@ class _User extends StatelessWidget {
),
CommonStyle.border,
AntList(
mode: AntListMode.card,
children: [
if (isNotNullOrEmpty(p.company))
AntListItem(
@ -154,7 +152,6 @@ class _User extends StatelessWidget {
),
CommonStyle.verticalGap,
AntList(
mode: AntListMode.card,
children: [
AntListItem(
prefix: const Icon(Octicons.organization),
@ -327,39 +324,41 @@ class GhUserScreen extends StatelessWidget {
),
],
),
AntList(mode: AntListMode.card, children: [
if (isNotNullOrEmpty(p.location))
AntListItem(
prefix: const Icon(Octicons.location),
child: Text(p.location!),
onClick: () {
launchStringUrl(
'https://www.google.com/maps/place/${p.location!.replaceAll(RegExp(r'\s+'), '')}');
},
),
if (isNotNullOrEmpty(p.email))
AntListItem(
prefix: const Icon(Octicons.mail),
child: Text(p.email!),
onClick: () {
launchStringUrl('mailto:${p.email!}');
},
),
if (isNotNullOrEmpty(p.websiteUrl))
AntListItem(
prefix: const Icon(Octicons.link),
child: Text(p.websiteUrl!),
onClick: () {
var url = p.websiteUrl!;
if (!url.startsWith('http')) {
url = 'http://$url';
}
launchStringUrl(url);
},
),
]),
AntList(
mode: AntListMode.card,
children: [
if (isNotNullOrEmpty(p.location))
AntListItem(
prefix: const Icon(Octicons.location),
child: Text(p.location!),
onClick: () {
launchStringUrl(
'https://www.google.com/maps/place/${p.location!.replaceAll(RegExp(r'\s+'), '')}');
},
),
if (isNotNullOrEmpty(p.email))
AntListItem(
prefix: const Icon(Octicons.mail),
child: Text(p.email!),
onClick: () {
launchStringUrl('mailto:${p.email!}');
},
),
if (isNotNullOrEmpty(p.websiteUrl))
AntListItem(
prefix: const Icon(Octicons.link),
child: Text(p.websiteUrl!),
onClick: () {
var url = p.websiteUrl!;
if (!url.startsWith('http')) {
url = 'http://$url';
}
launchStringUrl(url);
},
),
],
),
CommonStyle.verticalGap,
AntList(
children: [
AntListItem(
prefix: const Icon(Octicons.repo),

View File

@ -4,7 +4,7 @@ import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/gitlab.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
@ -27,7 +27,7 @@ class GlExploreScreen extends StatelessWidget {
);
},
itemBuilder: (v) {
return RepositoryItem.gl(
return RepoItem.gl(
payload: v,
note: 'Updated ${timeago.format(v.lastActivityAt!)}',
);

View File

@ -5,7 +5,7 @@ import 'package:git_touch/models/gitlab.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/entry_item.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_header.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
@ -53,7 +53,7 @@ class GlGroupScreen extends StatelessWidget {
Column(
children: <Widget>[
for (var v in p.projects!)
RepositoryItem.gl(
RepoItem.gl(
payload: v,
note: 'Updated ${timeago.format(v.lastActivityAt!)}',
)

View File

@ -7,7 +7,7 @@ import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/common.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/loading.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_item.dart';
import 'package:primer/primer.dart';
import 'package:provider/provider.dart';
@ -77,7 +77,7 @@ class _GlSearchScreenState extends State<GlSearchScreen> {
if (_activeTab == 0) {
final p = project as GitlabProject;
final updatedAt = timeago.format(p.lastActivityAt!);
return RepositoryItem.gl(
return RepoItem.gl(
payload: p,
note: 'Updated $updatedAt',
);

View File

@ -5,7 +5,7 @@ import 'package:git_touch/models/gitlab.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_header.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
@ -58,7 +58,7 @@ class GlUserScreen extends StatelessWidget {
Column(
children: <Widget>[
for (var v in projects)
RepositoryItem.gl(
RepoItem.gl(
payload: v,
note: 'Updated ${timeago.format(v.lastActivityAt!)}',
)

View File

@ -3,11 +3,10 @@ import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/gogs.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:provider/provider.dart';
class GoReposScreen extends StatelessWidget {
const GoReposScreen(String owner, {this.isViewer = false})
: api = isViewer ? '/users/$owner/repos' : '/user/repos',
title = 'Repositories';
@ -33,7 +32,7 @@ class GoReposScreen extends StatelessWidget {
);
},
itemBuilder: (v) {
return RepositoryItem.go(
return RepoItem.go(
payload: v,
name: v.fullName!.split('/')[1],
owner: v.owner!.username,

View File

@ -6,7 +6,7 @@ import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/entry_item.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_header.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
@ -87,7 +87,7 @@ class GoUserScreen extends StatelessWidget {
Column(
children: <Widget>[
for (var v in repos) ...[
RepositoryItem.go(
RepoItem.go(
payload: v,
name: v.fullName!.split('/')[1],
owner: v.owner!.username,

View File

@ -3,12 +3,11 @@ import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/gitea.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
class GtReposScreen extends StatelessWidget {
const GtReposScreen(String owner)
: api = '/users/$owner/repos',
title = 'Repositories';
@ -38,7 +37,7 @@ class GtReposScreen extends StatelessWidget {
);
},
itemBuilder: (v) {
return RepositoryItem(
return RepoItem(
owner: v.owner!.login,
avatarUrl: v.owner!.avatarUrl,
name: v.name,

View File

@ -7,7 +7,7 @@ import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/contribution.dart';
import 'package:git_touch/widgets/entry_item.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/repo_item.dart';
import 'package:git_touch/widgets/user_header.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
@ -145,7 +145,7 @@ class GtUserScreen extends StatelessWidget {
Column(
children: <Widget>[
for (var v in p.userRepos)
RepositoryItem(
RepoItem(
owner: v.owner!.login,
avatarUrl: v.owner!.avatarUrl,
name: v.name,
@ -187,7 +187,7 @@ class GtUserScreen extends StatelessWidget {
Column(
children: <Widget>[
for (var v in p.orgRepos)
RepositoryItem(
RepoItem(
owner: v.owner!.login,
avatarUrl: v.owner!.avatarUrl,
name: v.name,

View File

@ -5,16 +5,14 @@ import 'package:from_css_color/from_css_color.dart';
import 'package:git_touch/models/bitbucket.dart';
import 'package:git_touch/models/gitlab.dart';
import 'package:git_touch/models/gogs.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/avatar.dart';
import 'package:github/github.dart' as github;
import 'package:gql_github/repos.data.gql.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
class RepositoryItem extends StatelessWidget {
const RepositoryItem({
class RepoItem extends StatelessWidget {
const RepoItem({
required this.owner,
required this.avatarUrl,
required this.name,
@ -29,7 +27,7 @@ class RepositoryItem extends StatelessWidget {
required this.avatarLink,
});
RepositoryItem.go({
RepoItem.go({
required GogsRepository payload,
this.primaryLanguageName,
this.primaryLanguageColor,
@ -44,7 +42,7 @@ class RepositoryItem extends StatelessWidget {
starCount = payload.starsCount,
iconData = payload.private! ? Octicons.lock : null;
RepositoryItem.bb({
RepoItem.bb({
required BbRepo payload,
this.primaryLanguageName,
this.primaryLanguageColor,
@ -59,7 +57,7 @@ class RepositoryItem extends StatelessWidget {
starCount = 0,
iconData = payload.isPrivate! ? Octicons.lock : null;
RepositoryItem.gl({
RepoItem.gl({
required GitlabProject payload,
this.primaryLanguageName,
this.primaryLanguageColor,
@ -76,7 +74,7 @@ class RepositoryItem extends StatelessWidget {
: '/gitlab/user/${payload.namespace!.id}',
iconData = _buildGlIconData(payload.visibility);
RepositoryItem.gh({
RepoItem.gh({
required this.owner,
required this.avatarUrl,
required this.name,
@ -92,8 +90,8 @@ class RepositoryItem extends StatelessWidget {
avatarLink = '/github/$owner',
url = '/github/$owner/$name';
factory RepositoryItem.gql(GRepoParts v, {String? note}) {
return RepositoryItem.gh(
factory RepoItem.gql(GRepoParts v, {String? note}) {
return RepoItem.gh(
owner: v.owner.login,
avatarUrl: v.owner.avatarUrl,
name: v.name,
@ -141,7 +139,6 @@ class RepositoryItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
return AntListItem(
arrow: null,
onClick: () {