improvement: commit screen style

This commit is contained in:
Rongjian Zhang 2020-01-02 21:31:58 +08:00
parent 7689ac06c6
commit 1536ec47b8
4 changed files with 38 additions and 27 deletions

View File

@ -488,6 +488,12 @@ class GithubCommitsQuery
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: '__typename'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
InlineFragmentNode(
typeCondition: TypeConditionNode(
on: NamedTypeNode(
@ -550,12 +556,6 @@ class GithubCommitsQuery
selectionSet: null)
]))
])),
FieldNode(
name: NameNode(value: '__typename'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'history'),
alias: null,

View File

@ -1,5 +1,6 @@
fragment T on Ref {
target {
__typename
... on Commit {
oid
url
@ -15,7 +16,6 @@ fragment T on Ref {
# status {
# state
# }
__typename
history(first: 30, after: $after) {
pageInfo {
hasNextPage

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:git_touch/graphql/github_commits.dart';
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
@ -8,7 +9,6 @@ import 'package:git_touch/widgets/link.dart';
import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago;
import 'package:git_touch/widgets/avatar.dart';
import 'package:primer/primer.dart';
final commitsRouter = RouterScreen(
'/:owner/:name/commits',
@ -55,6 +55,8 @@ class CommitsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
return ListStatefulScaffold<GithubCommitsCommit, String>(
title: AppBarTitle('Commits'),
onRefresh: () => _query(context),
@ -67,27 +69,34 @@ class CommitsScreen extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Avatar(url: payload.author.avatarUrl),
SizedBox(width: 8),
Avatar(url: payload.author?.avatarUrl),
SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(payload.messageHeadline,
style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 14)),
Text(
payload.messageHeadline,
style: TextStyle(
fontSize: 17,
color: theme.palette.text,
),
overflow: TextOverflow.ellipsis,
),
SizedBox(height: 4),
Wrap(
children: <Widget>[
Text(
payload.author.user?.login ?? payload.author.name,
style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 14)),
payload.author?.user?.login ??
payload.author.name,
style: TextStyle(fontSize: 15)),
Text(
' committed ' +
timeago.format(payload.committedDate),
style: TextStyle(
color: PrimerColors.gray600, fontSize: 14)),
' committed ${timeago.format(payload.committedDate)}',
style: TextStyle(
color: theme.palette.secondaryText,
fontSize: 15,
),
),
// if (payload['status'] != null) ...[
// SizedBox(width: 4),
// _buildStatus(payload['status']['state'])

View File

@ -72,8 +72,6 @@ class RepositoryScreen extends StatelessWidget {
},
actionBuilder: (data, setState) {
final repo = data.item1;
final ref = branch == null ? repo.defaultBranchRef : repo.ref;
return ActionButton(
title: 'Repository Actions',
items: [
@ -95,11 +93,6 @@ class RepositoryScreen extends StatelessWidget {
// setState(() {});
// },
// ),
ActionItem(
text:
'Commits (${(ref.target as GithubRepositoryCommit).history?.totalCount})',
url: '/$owner/$name/commits',
),
ActionItem(
text: 'Projects (${repo.projects.totalCount})',
url: repo.projectsUrl,
@ -336,6 +329,15 @@ class RepositoryScreen extends StatelessWidget {
Text(numberFormat.format(repo.pullRequests.totalCount)),
url: '/$owner/$name/pulls',
),
TableViewItem(
leftIconData: Octicons.history,
text: Text('Commits'),
rightWidget: Text((ref.target as GithubRepositoryCommit)
.history
?.totalCount
.toString()),
url: '/$owner/$name/commits',
),
if (ref != null) ...[
if (repo.refs != null)
TableViewItem(