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

refactor: commits screen type

This commit is contained in:
Rongjian Zhang 2019-12-13 23:44:49 +08:00
parent b32a0e7739
commit 6b08ceae9e
5 changed files with 1211 additions and 61 deletions

View File

@ -49,6 +49,13 @@ targets:
queries_glob: lib/graphql/github_users.graphql queries_glob: lib/graphql/github_users.graphql
resolve_type_field: __typename resolve_type_field: __typename
add_query_prefix: true add_query_prefix: true
- schema: lib/github.schema.json
output: lib/graphql/github_commits.dart
queries_glob: lib/graphql/github_commits.graphql
resolve_type_field: __typename
add_query_prefix: true
scalar_mapping: scalar_mapping:
- graphql_type: URI - graphql_type: URI
dart_type: String dart_type: String
- graphql_type: GitObjectID
dart_type: String

View File

@ -0,0 +1,765 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
import 'package:artemis/artemis.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
import 'package:gql/ast.dart';
part 'github_commits.g.dart';
mixin TMixin {
GithubCommitsGitObject target;
}
@JsonSerializable(explicitToJson: true)
class GithubCommits with EquatableMixin {
GithubCommits();
factory GithubCommits.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsFromJson(json);
GithubCommitsRepository repository;
@override
List<Object> get props => [repository];
Map<String, dynamic> toJson() => _$GithubCommitsToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsRepository extends GithubCommitsPinnableItem
with EquatableMixin
implements
GithubCommitsNode,
GithubCommitsProjectOwner,
GithubCommitsRegistryPackageOwner,
GithubCommitsRegistryPackageSearch,
GithubCommitsSubscribable,
GithubCommitsStarrable,
GithubCommitsUniformResourceLocatable,
GithubCommitsRepositoryInfo {
GithubCommitsRepository();
factory GithubCommitsRepository.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsRepositoryFromJson(json);
GithubCommitsRef defaultBranchRef;
GithubCommitsRef ref;
@override
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [defaultBranchRef, ref, resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsRepositoryToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsRef
with EquatableMixin, TMixin
implements GithubCommitsNode {
GithubCommitsRef();
factory GithubCommitsRef.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsRefFromJson(json);
@override
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [target, resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsRefToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsGitObject with EquatableMixin {
GithubCommitsGitObject();
factory GithubCommitsGitObject.fromJson(Map<String, dynamic> json) {
switch (json['__typename'].toString()) {
case 'Commit':
return GithubCommitsCommit.fromJson(json);
default:
}
return _$GithubCommitsGitObjectFromJson(json);
}
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() {
switch (resolveType) {
case 'Commit':
return (this as GithubCommitsCommit).toJson();
default:
}
return _$GithubCommitsGitObjectToJson(this);
}
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsCommit extends GithubCommitsPullRequestTimelineItem
with EquatableMixin
implements
GithubCommitsNode,
GithubCommitsGitObject,
GithubCommitsSubscribable,
GithubCommitsUniformResourceLocatable {
GithubCommitsCommit();
factory GithubCommitsCommit.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsCommitFromJson(json);
String oid;
String url;
String messageHeadline;
DateTime committedDate;
GithubCommitsGitActor author;
GithubCommitsCommitHistoryConnection history;
@override
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props =>
[oid, url, messageHeadline, committedDate, author, history, resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsCommitToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsGitActor with EquatableMixin {
GithubCommitsGitActor();
factory GithubCommitsGitActor.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsGitActorFromJson(json);
String name;
String avatarUrl;
GithubCommitsUser user;
@override
List<Object> get props => [name, avatarUrl, user];
Map<String, dynamic> toJson() => _$GithubCommitsGitActorToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsUser extends GithubCommitsAuditEntryActor
with EquatableMixin
implements
GithubCommitsNode,
GithubCommitsActor,
GithubCommitsRegistryPackageOwner,
GithubCommitsRegistryPackageSearch,
GithubCommitsProjectOwner,
GithubCommitsRepositoryOwner,
GithubCommitsUniformResourceLocatable,
GithubCommitsProfileOwner,
GithubCommitsSponsorable {
GithubCommitsUser();
factory GithubCommitsUser.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsUserFromJson(json);
@override
String login;
@override
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [login, resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsUserToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsAuditEntryActor with EquatableMixin {
GithubCommitsAuditEntryActor();
factory GithubCommitsAuditEntryActor.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsAuditEntryActorFromJson(json);
@override
List<Object> get props => [];
Map<String, dynamic> toJson() => _$GithubCommitsAuditEntryActorToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsNode with EquatableMixin {
GithubCommitsNode();
factory GithubCommitsNode.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsNodeFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsNodeToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsActor with EquatableMixin {
GithubCommitsActor();
factory GithubCommitsActor.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsActorFromJson(json);
String login;
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [login, resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsActorToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsRegistryPackageOwner with EquatableMixin {
GithubCommitsRegistryPackageOwner();
factory GithubCommitsRegistryPackageOwner.fromJson(
Map<String, dynamic> json) =>
_$GithubCommitsRegistryPackageOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GithubCommitsRegistryPackageOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsRegistryPackageSearch with EquatableMixin {
GithubCommitsRegistryPackageSearch();
factory GithubCommitsRegistryPackageSearch.fromJson(
Map<String, dynamic> json) =>
_$GithubCommitsRegistryPackageSearchFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GithubCommitsRegistryPackageSearchToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsProjectOwner with EquatableMixin {
GithubCommitsProjectOwner();
factory GithubCommitsProjectOwner.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsProjectOwnerFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsProjectOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsRepositoryOwner with EquatableMixin {
GithubCommitsRepositoryOwner();
factory GithubCommitsRepositoryOwner.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsRepositoryOwnerFromJson(json);
String login;
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [login, resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsRepositoryOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsUniformResourceLocatable with EquatableMixin {
GithubCommitsUniformResourceLocatable();
factory GithubCommitsUniformResourceLocatable.fromJson(
Map<String, dynamic> json) =>
_$GithubCommitsUniformResourceLocatableFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() =>
_$GithubCommitsUniformResourceLocatableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsProfileOwner with EquatableMixin {
GithubCommitsProfileOwner();
factory GithubCommitsProfileOwner.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsProfileOwnerFromJson(json);
String login;
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [login, resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsProfileOwnerToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsSponsorable with EquatableMixin {
GithubCommitsSponsorable();
factory GithubCommitsSponsorable.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsSponsorableFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsSponsorableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsCommitHistoryConnection with EquatableMixin {
GithubCommitsCommitHistoryConnection();
factory GithubCommitsCommitHistoryConnection.fromJson(
Map<String, dynamic> json) =>
_$GithubCommitsCommitHistoryConnectionFromJson(json);
GithubCommitsPageInfo pageInfo;
List<GithubCommitsCommit> nodes;
@override
List<Object> get props => [pageInfo, nodes];
Map<String, dynamic> toJson() =>
_$GithubCommitsCommitHistoryConnectionToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsPageInfo with EquatableMixin {
GithubCommitsPageInfo();
factory GithubCommitsPageInfo.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsPageInfoFromJson(json);
bool hasNextPage;
String endCursor;
@override
List<Object> get props => [hasNextPage, endCursor];
Map<String, dynamic> toJson() => _$GithubCommitsPageInfoToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsPullRequestTimelineItem with EquatableMixin {
GithubCommitsPullRequestTimelineItem();
factory GithubCommitsPullRequestTimelineItem.fromJson(
Map<String, dynamic> json) =>
_$GithubCommitsPullRequestTimelineItemFromJson(json);
@override
List<Object> get props => [];
Map<String, dynamic> toJson() =>
_$GithubCommitsPullRequestTimelineItemToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsSubscribable with EquatableMixin {
GithubCommitsSubscribable();
factory GithubCommitsSubscribable.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsSubscribableFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsSubscribableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsPinnableItem with EquatableMixin {
GithubCommitsPinnableItem();
factory GithubCommitsPinnableItem.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsPinnableItemFromJson(json);
@override
List<Object> get props => [];
Map<String, dynamic> toJson() => _$GithubCommitsPinnableItemToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsStarrable with EquatableMixin {
GithubCommitsStarrable();
factory GithubCommitsStarrable.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsStarrableFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsStarrableToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsRepositoryInfo with EquatableMixin {
GithubCommitsRepositoryInfo();
factory GithubCommitsRepositoryInfo.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsRepositoryInfoFromJson(json);
@JsonKey(name: '__typename')
String resolveType;
@override
List<Object> get props => [resolveType];
Map<String, dynamic> toJson() => _$GithubCommitsRepositoryInfoToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GithubCommitsArguments extends JsonSerializable with EquatableMixin {
GithubCommitsArguments(
{this.owner, this.name, this.ref, this.hasRef, this.after});
factory GithubCommitsArguments.fromJson(Map<String, dynamic> json) =>
_$GithubCommitsArgumentsFromJson(json);
final String owner;
final String name;
final String ref;
final bool hasRef;
final String after;
@override
List<Object> get props => [owner, name, ref, hasRef, after];
Map<String, dynamic> toJson() => _$GithubCommitsArgumentsToJson(this);
}
class GithubCommitsQuery
extends GraphQLQuery<GithubCommits, GithubCommitsArguments> {
GithubCommitsQuery({this.variables});
@override
final DocumentNode document = DocumentNode(definitions: [
FragmentDefinitionNode(
name: NameNode(value: 'T'),
typeCondition: TypeConditionNode(
on: NamedTypeNode(name: NameNode(value: 'Ref'), isNonNull: false)),
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'target'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
InlineFragmentNode(
typeCondition: TypeConditionNode(
on: NamedTypeNode(
name: NameNode(value: 'Commit'), isNonNull: false)),
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'oid'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'url'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'messageHeadline'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'committedDate'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'author'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'name'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'avatarUrl'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'user'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'login'),
alias: null,
arguments: [],
directives: [],
selectionSet: null)
]))
])),
FieldNode(
name: NameNode(value: '__typename'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'history'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'first'),
value: IntValueNode(value: '30')),
ArgumentNode(
name: NameNode(value: 'after'),
value: VariableNode(
name: NameNode(value: 'after')))
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'pageInfo'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'hasNextPage'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'endCursor'),
alias: null,
arguments: [],
directives: [],
selectionSet: null)
])),
FieldNode(
name: NameNode(value: 'nodes'),
alias: null,
arguments: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'oid'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'url'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'messageHeadline'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'committedDate'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'author'),
alias: null,
arguments: [],
directives: [],
selectionSet:
SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'name'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'avatarUrl'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'user'),
alias: null,
arguments: [],
directives: [],
selectionSet:
SelectionSetNode(selections: [
FieldNode(
name:
NameNode(value: 'login'),
alias: null,
arguments: [],
directives: [],
selectionSet: null)
]))
]))
]))
]))
]))
]))
])),
OperationDefinitionNode(
type: OperationType.query,
name: null,
variableDefinitions: [
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'owner')),
type: NamedTypeNode(
name: NameNode(value: 'String'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: []),
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'name')),
type: NamedTypeNode(
name: NameNode(value: 'String'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: []),
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'ref')),
type: NamedTypeNode(
name: NameNode(value: 'String'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: []),
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'hasRef')),
type: NamedTypeNode(
name: NameNode(value: 'Boolean'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: []),
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'after')),
type: NamedTypeNode(
name: NameNode(value: 'String'), isNonNull: false),
defaultValue: DefaultValueNode(value: null),
directives: [])
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'repository'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'owner'),
value: VariableNode(name: NameNode(value: 'owner'))),
ArgumentNode(
name: NameNode(value: 'name'),
value: VariableNode(name: NameNode(value: 'name')))
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'defaultBranchRef'),
alias: null,
arguments: [],
directives: [
DirectiveNode(name: NameNode(value: 'skip'), arguments: [
ArgumentNode(
name: NameNode(value: 'if'),
value:
VariableNode(name: NameNode(value: 'hasRef')))
])
],
selectionSet: SelectionSetNode(selections: [
FragmentSpreadNode(
name: NameNode(value: 'T'), directives: [])
])),
FieldNode(
name: NameNode(value: 'ref'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'qualifiedName'),
value: VariableNode(name: NameNode(value: 'ref')))
],
directives: [
DirectiveNode(
name: NameNode(value: 'include'),
arguments: [
ArgumentNode(
name: NameNode(value: 'if'),
value: VariableNode(
name: NameNode(value: 'hasRef')))
])
],
selectionSet: SelectionSetNode(selections: [
FragmentSpreadNode(
name: NameNode(value: 'T'), directives: [])
]))
]))
]))
]);
@override
final String operationName = 'github_commits';
@override
final GithubCommitsArguments variables;
@override
List<Object> get props => [document, operationName, variables];
@override
GithubCommits parse(Map<String, dynamic> json) =>
GithubCommits.fromJson(json);
}

View File

@ -0,0 +1,353 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'github_commits.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
GithubCommits _$GithubCommitsFromJson(Map<String, dynamic> json) {
return GithubCommits()
..repository = json['repository'] == null
? null
: GithubCommitsRepository.fromJson(
json['repository'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GithubCommitsToJson(GithubCommits instance) =>
<String, dynamic>{
'repository': instance.repository?.toJson(),
};
GithubCommitsRepository _$GithubCommitsRepositoryFromJson(
Map<String, dynamic> json) {
return GithubCommitsRepository()
..defaultBranchRef = json['defaultBranchRef'] == null
? null
: GithubCommitsRef.fromJson(
json['defaultBranchRef'] as Map<String, dynamic>)
..ref = json['ref'] == null
? null
: GithubCommitsRef.fromJson(json['ref'] as Map<String, dynamic>)
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsRepositoryToJson(
GithubCommitsRepository instance) =>
<String, dynamic>{
'defaultBranchRef': instance.defaultBranchRef?.toJson(),
'ref': instance.ref?.toJson(),
'__typename': instance.resolveType,
};
GithubCommitsRef _$GithubCommitsRefFromJson(Map<String, dynamic> json) {
return GithubCommitsRef()
..target = json['target'] == null
? null
: GithubCommitsGitObject.fromJson(
json['target'] as Map<String, dynamic>)
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsRefToJson(GithubCommitsRef instance) =>
<String, dynamic>{
'target': instance.target?.toJson(),
'__typename': instance.resolveType,
};
GithubCommitsGitObject _$GithubCommitsGitObjectFromJson(
Map<String, dynamic> json) {
return GithubCommitsGitObject()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsGitObjectToJson(
GithubCommitsGitObject instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsCommit _$GithubCommitsCommitFromJson(Map<String, dynamic> json) {
return GithubCommitsCommit()
..oid = json['oid'] as String
..url = json['url'] as String
..messageHeadline = json['messageHeadline'] as String
..committedDate = json['committedDate'] == null
? null
: DateTime.parse(json['committedDate'] as String)
..author = json['author'] == null
? null
: GithubCommitsGitActor.fromJson(json['author'] as Map<String, dynamic>)
..history = json['history'] == null
? null
: GithubCommitsCommitHistoryConnection.fromJson(
json['history'] as Map<String, dynamic>)
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsCommitToJson(
GithubCommitsCommit instance) =>
<String, dynamic>{
'oid': instance.oid,
'url': instance.url,
'messageHeadline': instance.messageHeadline,
'committedDate': instance.committedDate?.toIso8601String(),
'author': instance.author?.toJson(),
'history': instance.history?.toJson(),
'__typename': instance.resolveType,
};
GithubCommitsGitActor _$GithubCommitsGitActorFromJson(
Map<String, dynamic> json) {
return GithubCommitsGitActor()
..name = json['name'] as String
..avatarUrl = json['avatarUrl'] as String
..user = json['user'] == null
? null
: GithubCommitsUser.fromJson(json['user'] as Map<String, dynamic>);
}
Map<String, dynamic> _$GithubCommitsGitActorToJson(
GithubCommitsGitActor instance) =>
<String, dynamic>{
'name': instance.name,
'avatarUrl': instance.avatarUrl,
'user': instance.user?.toJson(),
};
GithubCommitsUser _$GithubCommitsUserFromJson(Map<String, dynamic> json) {
return GithubCommitsUser()
..login = json['login'] as String
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsUserToJson(GithubCommitsUser instance) =>
<String, dynamic>{
'login': instance.login,
'__typename': instance.resolveType,
};
GithubCommitsAuditEntryActor _$GithubCommitsAuditEntryActorFromJson(
Map<String, dynamic> json) {
return GithubCommitsAuditEntryActor();
}
Map<String, dynamic> _$GithubCommitsAuditEntryActorToJson(
GithubCommitsAuditEntryActor instance) =>
<String, dynamic>{};
GithubCommitsNode _$GithubCommitsNodeFromJson(Map<String, dynamic> json) {
return GithubCommitsNode()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsNodeToJson(GithubCommitsNode instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsActor _$GithubCommitsActorFromJson(Map<String, dynamic> json) {
return GithubCommitsActor()
..login = json['login'] as String
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsActorToJson(GithubCommitsActor instance) =>
<String, dynamic>{
'login': instance.login,
'__typename': instance.resolveType,
};
GithubCommitsRegistryPackageOwner _$GithubCommitsRegistryPackageOwnerFromJson(
Map<String, dynamic> json) {
return GithubCommitsRegistryPackageOwner()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsRegistryPackageOwnerToJson(
GithubCommitsRegistryPackageOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsRegistryPackageSearch _$GithubCommitsRegistryPackageSearchFromJson(
Map<String, dynamic> json) {
return GithubCommitsRegistryPackageSearch()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsRegistryPackageSearchToJson(
GithubCommitsRegistryPackageSearch instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsProjectOwner _$GithubCommitsProjectOwnerFromJson(
Map<String, dynamic> json) {
return GithubCommitsProjectOwner()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsProjectOwnerToJson(
GithubCommitsProjectOwner instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsRepositoryOwner _$GithubCommitsRepositoryOwnerFromJson(
Map<String, dynamic> json) {
return GithubCommitsRepositoryOwner()
..login = json['login'] as String
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsRepositoryOwnerToJson(
GithubCommitsRepositoryOwner instance) =>
<String, dynamic>{
'login': instance.login,
'__typename': instance.resolveType,
};
GithubCommitsUniformResourceLocatable
_$GithubCommitsUniformResourceLocatableFromJson(Map<String, dynamic> json) {
return GithubCommitsUniformResourceLocatable()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsUniformResourceLocatableToJson(
GithubCommitsUniformResourceLocatable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsProfileOwner _$GithubCommitsProfileOwnerFromJson(
Map<String, dynamic> json) {
return GithubCommitsProfileOwner()
..login = json['login'] as String
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsProfileOwnerToJson(
GithubCommitsProfileOwner instance) =>
<String, dynamic>{
'login': instance.login,
'__typename': instance.resolveType,
};
GithubCommitsSponsorable _$GithubCommitsSponsorableFromJson(
Map<String, dynamic> json) {
return GithubCommitsSponsorable()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsSponsorableToJson(
GithubCommitsSponsorable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsCommitHistoryConnection
_$GithubCommitsCommitHistoryConnectionFromJson(Map<String, dynamic> json) {
return GithubCommitsCommitHistoryConnection()
..pageInfo = json['pageInfo'] == null
? null
: GithubCommitsPageInfo.fromJson(
json['pageInfo'] as Map<String, dynamic>)
..nodes = (json['nodes'] as List)
?.map((e) => e == null
? null
: GithubCommitsCommit.fromJson(e as Map<String, dynamic>))
?.toList();
}
Map<String, dynamic> _$GithubCommitsCommitHistoryConnectionToJson(
GithubCommitsCommitHistoryConnection instance) =>
<String, dynamic>{
'pageInfo': instance.pageInfo?.toJson(),
'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(),
};
GithubCommitsPageInfo _$GithubCommitsPageInfoFromJson(
Map<String, dynamic> json) {
return GithubCommitsPageInfo()
..hasNextPage = json['hasNextPage'] as bool
..endCursor = json['endCursor'] as String;
}
Map<String, dynamic> _$GithubCommitsPageInfoToJson(
GithubCommitsPageInfo instance) =>
<String, dynamic>{
'hasNextPage': instance.hasNextPage,
'endCursor': instance.endCursor,
};
GithubCommitsPullRequestTimelineItem
_$GithubCommitsPullRequestTimelineItemFromJson(Map<String, dynamic> json) {
return GithubCommitsPullRequestTimelineItem();
}
Map<String, dynamic> _$GithubCommitsPullRequestTimelineItemToJson(
GithubCommitsPullRequestTimelineItem instance) =>
<String, dynamic>{};
GithubCommitsSubscribable _$GithubCommitsSubscribableFromJson(
Map<String, dynamic> json) {
return GithubCommitsSubscribable()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsSubscribableToJson(
GithubCommitsSubscribable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsPinnableItem _$GithubCommitsPinnableItemFromJson(
Map<String, dynamic> json) {
return GithubCommitsPinnableItem();
}
Map<String, dynamic> _$GithubCommitsPinnableItemToJson(
GithubCommitsPinnableItem instance) =>
<String, dynamic>{};
GithubCommitsStarrable _$GithubCommitsStarrableFromJson(
Map<String, dynamic> json) {
return GithubCommitsStarrable()..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsStarrableToJson(
GithubCommitsStarrable instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsRepositoryInfo _$GithubCommitsRepositoryInfoFromJson(
Map<String, dynamic> json) {
return GithubCommitsRepositoryInfo()
..resolveType = json['__typename'] as String;
}
Map<String, dynamic> _$GithubCommitsRepositoryInfoToJson(
GithubCommitsRepositoryInfo instance) =>
<String, dynamic>{
'__typename': instance.resolveType,
};
GithubCommitsArguments _$GithubCommitsArgumentsFromJson(
Map<String, dynamic> json) {
return GithubCommitsArguments(
owner: json['owner'] as String,
name: json['name'] as String,
ref: json['ref'] as String,
hasRef: json['hasRef'] as bool,
after: json['after'] as String,
);
}
Map<String, dynamic> _$GithubCommitsArgumentsToJson(
GithubCommitsArguments instance) =>
<String, dynamic>{
'owner': instance.owner,
'name': instance.name,
'ref': instance.ref,
'hasRef': instance.hasRef,
'after': instance.after,
};

View File

@ -0,0 +1,60 @@
fragment T on Ref {
target {
... on Commit {
oid
url
messageHeadline
committedDate
author {
name
avatarUrl
user {
login
}
}
# status {
# state
# }
__typename
history(first: 30, after: $after) {
pageInfo {
hasNextPage
endCursor
}
nodes {
oid
url
messageHeadline
committedDate
author {
name
avatarUrl
user {
login
}
}
# status {
# state
# }
}
}
}
}
}
query(
$owner: String!
$name: String!
$ref: String!
$hasRef: Boolean!
$after: String
) {
repository(owner: $owner, name: $name) {
defaultBranchRef @skip(if: $hasRef) {
...T
}
ref(qualifiedName: $ref) @include(if: $hasRef) {
...T
}
}
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; 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/auth.dart';
import 'package:git_touch/scaffolds/list_stateful.dart'; import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/utils/utils.dart'; import 'package:git_touch/utils/utils.dart';
@ -21,55 +22,22 @@ class CommitsScreen extends StatelessWidget {
CommitsScreen(this.owner, this.name, {this.branch}); CommitsScreen(this.owner, this.name, {this.branch});
Future<ListPayload> _query(BuildContext context, [String cursor]) async { Future<ListPayload<GithubCommitsCommit, String>> _query(BuildContext context,
var params = 'first: 30'; [String cursor]) async {
if (cursor != null) { final res = await Provider.of<AuthModel>(context).gqlClient.execute(
params += ', after: "$cursor"'; GithubCommitsQuery(
} variables: GithubCommitsArguments(
var key = getBranchQueryKey(branch, withParams: true); owner: owner,
var data = await Provider.of<AuthModel>(context).query(''' name: name,
{ hasRef: branch != null,
repository(owner: "$owner", name: "$name") { ref: branch ?? '',
$key { after: cursor)));
target { final ref = res.data.repository.defaultBranchRef ?? res.data.repository.ref;
... on Commit { final history = (ref.target as GithubCommitsCommit).history;
history($params) {
pageInfo {
hasNextPage
endCursor
}
nodes {
oid
url
messageHeadline
committedDate
author {
name
email
avatarUrl
user {
login
}
}
status {
state
}
}
}
}
}
}
}
}
''');
var history =
data["repository"][getBranchQueryKey(branch)]['target']['history'];
return ListPayload( return ListPayload(
cursor: history["pageInfo"]["endCursor"], cursor: history.pageInfo.endCursor,
hasMore: history['pageInfo']['hasNextPage'], hasMore: history.pageInfo.hasNextPage,
items: history["nodes"], items: history.nodes,
); );
} }
@ -87,46 +55,43 @@ class CommitsScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListStatefulScaffold( return ListStatefulScaffold<GithubCommitsCommit, String>(
title: AppBarTitle('Commits'), title: AppBarTitle('Commits'),
onRefresh: () => _query(context), onRefresh: () => _query(context),
onLoadMore: (cursor) => _query(context, cursor), onLoadMore: (cursor) => _query(context, cursor),
itemBuilder: (payload) { itemBuilder: (payload) {
return Link( return Link(
url: payload['url'], url: payload.url,
child: Container( child: Container(
padding: CommonStyle.padding, padding: CommonStyle.padding,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Avatar.medium(url: payload['author']['avatarUrl']), Avatar.medium(url: payload.author.avatarUrl),
SizedBox(width: 8), SizedBox(width: 8),
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text(payload['messageHeadline'], Text(payload.messageHeadline,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 14)), fontWeight: FontWeight.w500, fontSize: 14)),
SizedBox(height: 4), SizedBox(height: 4),
Wrap( Wrap(
children: <Widget>[ children: <Widget>[
Text( Text(
payload['author']['user'] == null payload.author.user?.login ?? payload.author.name,
? payload['author']['name']
: payload['author']['user']['login'],
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 14)), fontWeight: FontWeight.w500, fontSize: 14)),
Text( Text(
' committed ' + ' committed ' +
timeago.format( timeago.format(payload.committedDate),
DateTime.parse(payload['committedDate'])),
style: TextStyle( style: TextStyle(
color: PrimerColors.gray600, fontSize: 14)), color: PrimerColors.gray600, fontSize: 14)),
if (payload['status'] != null) ...[ // if (payload['status'] != null) ...[
SizedBox(width: 4), // SizedBox(width: 4),
_buildStatus(payload['status']['state']) // _buildStatus(payload['status']['state'])
], // ], TODO:
], ],
) )
], ],