From 8012ea6544bd0de7243d8d100beb29055d114e4e Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Tue, 28 Jan 2020 23:19:05 +0800 Subject: [PATCH] refactor: issue and pull item --- lib/graphql/gh.dart | 1545 +++++++++++++++++++++++++++++++++ lib/graphql/gh.g.dart | 819 +++++++++++++++++ lib/graphql/gh_issues.graphql | 43 + lib/graphql/gh_pulls.graphql | 43 + lib/main.dart | 1 + lib/screens/issue.dart | 2 +- lib/screens/issues.dart | 71 +- lib/screens/pulls.dart | 64 ++ lib/screens/search.dart | 10 +- lib/widgets/issue_item.dart | 68 +- 10 files changed, 2592 insertions(+), 74 deletions(-) create mode 100644 lib/graphql/gh_issues.graphql create mode 100644 lib/graphql/gh_pulls.graphql create mode 100644 lib/screens/pulls.dart diff --git a/lib/graphql/gh.dart b/lib/graphql/gh.dart index 0a90bc5..8cb67d9 100644 --- a/lib/graphql/gh.dart +++ b/lib/graphql/gh.dart @@ -8748,3 +8748,1548 @@ class GhRepoIdQuery extends GraphQLQuery { @override GhRepoId parse(Map json) => GhRepoId.fromJson(json); } + +@JsonSerializable(explicitToJson: true) +class GhIssues with EquatableMixin { + GhIssues({this.repository}); + + factory GhIssues.fromJson(Map json) => + _$GhIssuesFromJson(json); + + GhIssuesRepository repository; + + @override + List get props => [repository]; + Map toJson() => _$GhIssuesToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesRepository extends GhIssuesPinnableItem + with EquatableMixin + implements + GhIssuesNode, + GhIssuesProjectOwner, + GhIssuesRegistryPackageOwner, + GhIssuesRegistryPackageSearch, + GhIssuesSubscribable, + GhIssuesStarrable, + GhIssuesUniformResourceLocatable, + GhIssuesRepositoryInfo { + GhIssuesRepository({this.issues}); + + factory GhIssuesRepository.fromJson(Map json) => + _$GhIssuesRepositoryFromJson(json); + + @override + GhIssuesRepositoryOwner owner; + + @override + String name; + + GhIssuesIssueConnection issues; + + @override + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [owner, name, issues, resolveType]; + Map toJson() => _$GhIssuesRepositoryToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesRepositoryOwner with EquatableMixin { + GhIssuesRepositoryOwner({this.login}); + + factory GhIssuesRepositoryOwner.fromJson(Map json) => + _$GhIssuesRepositoryOwnerFromJson(json); + + String login; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [login, resolveType]; + Map toJson() => _$GhIssuesRepositoryOwnerToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesIssueConnection with EquatableMixin { + GhIssuesIssueConnection({this.pageInfo, this.nodes}); + + factory GhIssuesIssueConnection.fromJson(Map json) => + _$GhIssuesIssueConnectionFromJson(json); + + GhIssuesPageInfo pageInfo; + + List nodes; + + @override + List get props => [pageInfo, nodes]; + Map toJson() => _$GhIssuesIssueConnectionToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesPageInfo with EquatableMixin { + GhIssuesPageInfo({this.hasNextPage, this.endCursor}); + + factory GhIssuesPageInfo.fromJson(Map json) => + _$GhIssuesPageInfoFromJson(json); + + bool hasNextPage; + + String endCursor; + + @override + List get props => [hasNextPage, endCursor]; + Map toJson() => _$GhIssuesPageInfoToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesIssue extends GhIssuesProjectCardItem + with EquatableMixin + implements + GhIssuesNode, + GhIssuesAssignable, + GhIssuesClosable, + GhIssuesComment, + GhIssuesUpdatable, + GhIssuesUpdatableComment, + GhIssuesLabelable, + GhIssuesLockable, + GhIssuesReactable, + GhIssuesRepositoryNode, + GhIssuesSubscribable, + GhIssuesUniformResourceLocatable { + GhIssuesIssue({this.number, this.title, this.comments}); + + factory GhIssuesIssue.fromJson(Map json) => + _$GhIssuesIssueFromJson(json); + + @override + GhIssuesRepository repository; + + int number; + + String title; + + @override + DateTime updatedAt; + + @override + GhIssuesActor author; + + @override + GhIssuesLabelConnection labels; + + GhIssuesIssueCommentConnection comments; + + @override + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [ + repository, + number, + title, + updatedAt, + author, + labels, + comments, + resolveType + ]; + Map toJson() => _$GhIssuesIssueToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesPinnableItem with EquatableMixin { + GhIssuesPinnableItem(); + + factory GhIssuesPinnableItem.fromJson(Map json) => + _$GhIssuesPinnableItemFromJson(json); + + @override + List get props => []; + Map toJson() => _$GhIssuesPinnableItemToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesNode with EquatableMixin { + GhIssuesNode(); + + factory GhIssuesNode.fromJson(Map json) => + _$GhIssuesNodeFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesNodeToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesProjectOwner with EquatableMixin { + GhIssuesProjectOwner(); + + factory GhIssuesProjectOwner.fromJson(Map json) => + _$GhIssuesProjectOwnerFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesProjectOwnerToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesRegistryPackageOwner with EquatableMixin { + GhIssuesRegistryPackageOwner(); + + factory GhIssuesRegistryPackageOwner.fromJson(Map json) => + _$GhIssuesRegistryPackageOwnerFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesRegistryPackageOwnerToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesRegistryPackageSearch with EquatableMixin { + GhIssuesRegistryPackageSearch(); + + factory GhIssuesRegistryPackageSearch.fromJson(Map json) => + _$GhIssuesRegistryPackageSearchFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesRegistryPackageSearchToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesSubscribable with EquatableMixin { + GhIssuesSubscribable(); + + factory GhIssuesSubscribable.fromJson(Map json) => + _$GhIssuesSubscribableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesSubscribableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesStarrable with EquatableMixin { + GhIssuesStarrable(); + + factory GhIssuesStarrable.fromJson(Map json) => + _$GhIssuesStarrableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesStarrableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesUniformResourceLocatable with EquatableMixin { + GhIssuesUniformResourceLocatable(); + + factory GhIssuesUniformResourceLocatable.fromJson( + Map json) => + _$GhIssuesUniformResourceLocatableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => + _$GhIssuesUniformResourceLocatableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesRepositoryInfo with EquatableMixin { + GhIssuesRepositoryInfo({this.owner, this.name}); + + factory GhIssuesRepositoryInfo.fromJson(Map json) => + _$GhIssuesRepositoryInfoFromJson(json); + + GhIssuesRepositoryOwner owner; + + String name; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [owner, name, resolveType]; + Map toJson() => _$GhIssuesRepositoryInfoToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesActor with EquatableMixin { + GhIssuesActor({this.login, this.avatarUrl}); + + factory GhIssuesActor.fromJson(Map json) => + _$GhIssuesActorFromJson(json); + + String login; + + String avatarUrl; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [login, avatarUrl, resolveType]; + Map toJson() => _$GhIssuesActorToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesLabelConnection with EquatableMixin { + GhIssuesLabelConnection({this.nodes}); + + factory GhIssuesLabelConnection.fromJson(Map json) => + _$GhIssuesLabelConnectionFromJson(json); + + List nodes; + + @override + List get props => [nodes]; + Map toJson() => _$GhIssuesLabelConnectionToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesLabel with EquatableMixin implements GhIssuesNode { + GhIssuesLabel({this.name, this.color}); + + factory GhIssuesLabel.fromJson(Map json) => + _$GhIssuesLabelFromJson(json); + + String name; + + String color; + + @override + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [name, color, resolveType]; + Map toJson() => _$GhIssuesLabelToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesIssueCommentConnection with EquatableMixin { + GhIssuesIssueCommentConnection({this.totalCount}); + + factory GhIssuesIssueCommentConnection.fromJson(Map json) => + _$GhIssuesIssueCommentConnectionFromJson(json); + + int totalCount; + + @override + List get props => [totalCount]; + Map toJson() => _$GhIssuesIssueCommentConnectionToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesProjectCardItem with EquatableMixin { + GhIssuesProjectCardItem(); + + factory GhIssuesProjectCardItem.fromJson(Map json) => + _$GhIssuesProjectCardItemFromJson(json); + + @override + List get props => []; + Map toJson() => _$GhIssuesProjectCardItemToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesAssignable with EquatableMixin { + GhIssuesAssignable(); + + factory GhIssuesAssignable.fromJson(Map json) => + _$GhIssuesAssignableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesAssignableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesClosable with EquatableMixin { + GhIssuesClosable(); + + factory GhIssuesClosable.fromJson(Map json) => + _$GhIssuesClosableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesClosableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesComment with EquatableMixin { + GhIssuesComment({this.updatedAt, this.author}); + + factory GhIssuesComment.fromJson(Map json) => + _$GhIssuesCommentFromJson(json); + + DateTime updatedAt; + + GhIssuesActor author; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [updatedAt, author, resolveType]; + Map toJson() => _$GhIssuesCommentToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesUpdatable with EquatableMixin { + GhIssuesUpdatable(); + + factory GhIssuesUpdatable.fromJson(Map json) => + _$GhIssuesUpdatableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesUpdatableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesUpdatableComment with EquatableMixin { + GhIssuesUpdatableComment(); + + factory GhIssuesUpdatableComment.fromJson(Map json) => + _$GhIssuesUpdatableCommentFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesUpdatableCommentToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesLabelable with EquatableMixin { + GhIssuesLabelable({this.labels}); + + factory GhIssuesLabelable.fromJson(Map json) => + _$GhIssuesLabelableFromJson(json); + + GhIssuesLabelConnection labels; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [labels, resolveType]; + Map toJson() => _$GhIssuesLabelableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesLockable with EquatableMixin { + GhIssuesLockable(); + + factory GhIssuesLockable.fromJson(Map json) => + _$GhIssuesLockableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesLockableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesReactable with EquatableMixin { + GhIssuesReactable(); + + factory GhIssuesReactable.fromJson(Map json) => + _$GhIssuesReactableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhIssuesReactableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesRepositoryNode with EquatableMixin { + GhIssuesRepositoryNode({this.repository}); + + factory GhIssuesRepositoryNode.fromJson(Map json) => + _$GhIssuesRepositoryNodeFromJson(json); + + GhIssuesRepository repository; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [repository, resolveType]; + Map toJson() => _$GhIssuesRepositoryNodeToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhIssuesArguments extends JsonSerializable with EquatableMixin { + GhIssuesArguments({@required this.owner, @required this.name, this.cursor}); + + factory GhIssuesArguments.fromJson(Map json) => + _$GhIssuesArgumentsFromJson(json); + + final String owner; + + final String name; + + final String cursor; + + @override + List get props => [owner, name, cursor]; + Map toJson() => _$GhIssuesArgumentsToJson(this); +} + +class GhIssuesQuery extends GraphQLQuery { + GhIssuesQuery({this.variables}); + + @override + final DocumentNode document = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'GhIssues'), + 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: 'cursor')), + 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: 'owner'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'login'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'issues'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'states'), + value: EnumValueNode(name: NameNode(value: 'OPEN'))), + ArgumentNode( + name: NameNode(value: 'orderBy'), + value: ObjectValueNode(fields: [ + ObjectFieldNode( + name: NameNode(value: 'field'), + value: EnumValueNode( + name: NameNode(value: 'CREATED_AT'))), + ObjectFieldNode( + name: NameNode(value: 'direction'), + value: EnumValueNode( + name: NameNode(value: 'DESC'))) + ])), + ArgumentNode( + name: NameNode(value: 'first'), + value: IntValueNode(value: '30')), + ArgumentNode( + name: NameNode(value: 'after'), + value: VariableNode(name: NameNode(value: 'cursor'))) + ], + 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: 'repository'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'owner'), + alias: null, + arguments: [], + directives: [], + selectionSet: + SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'login'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: 'number'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'title'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'updatedAt'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'author'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'login'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'avatarUrl'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: 'labels'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'first'), + value: IntValueNode(value: '10')) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'nodes'), + alias: null, + arguments: [], + directives: [], + selectionSet: + SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'color'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])) + ])), + FieldNode( + name: NameNode(value: 'comments'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'totalCount'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])) + ])) + ])) + ])) + ])) + ]); + + @override + final String operationName = 'GhIssues'; + + @override + final GhIssuesArguments variables; + + @override + List get props => [document, operationName, variables]; + @override + GhIssues parse(Map json) => GhIssues.fromJson(json); +} + +@JsonSerializable(explicitToJson: true) +class GhPulls with EquatableMixin { + GhPulls({this.repository}); + + factory GhPulls.fromJson(Map json) => + _$GhPullsFromJson(json); + + GhPullsRepository repository; + + @override + List get props => [repository]; + Map toJson() => _$GhPullsToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsRepository extends GhPullsPinnableItem + with EquatableMixin + implements + GhPullsNode, + GhPullsProjectOwner, + GhPullsRegistryPackageOwner, + GhPullsRegistryPackageSearch, + GhPullsSubscribable, + GhPullsStarrable, + GhPullsUniformResourceLocatable, + GhPullsRepositoryInfo { + GhPullsRepository({this.pullRequests}); + + factory GhPullsRepository.fromJson(Map json) => + _$GhPullsRepositoryFromJson(json); + + @override + GhPullsRepositoryOwner owner; + + @override + String name; + + GhPullsPullRequestConnection pullRequests; + + @override + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [owner, name, pullRequests, resolveType]; + Map toJson() => _$GhPullsRepositoryToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsRepositoryOwner with EquatableMixin { + GhPullsRepositoryOwner({this.login}); + + factory GhPullsRepositoryOwner.fromJson(Map json) => + _$GhPullsRepositoryOwnerFromJson(json); + + String login; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [login, resolveType]; + Map toJson() => _$GhPullsRepositoryOwnerToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsPullRequestConnection with EquatableMixin { + GhPullsPullRequestConnection({this.pageInfo, this.nodes}); + + factory GhPullsPullRequestConnection.fromJson(Map json) => + _$GhPullsPullRequestConnectionFromJson(json); + + GhPullsPageInfo pageInfo; + + List nodes; + + @override + List get props => [pageInfo, nodes]; + Map toJson() => _$GhPullsPullRequestConnectionToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsPageInfo with EquatableMixin { + GhPullsPageInfo({this.hasNextPage, this.endCursor}); + + factory GhPullsPageInfo.fromJson(Map json) => + _$GhPullsPageInfoFromJson(json); + + bool hasNextPage; + + String endCursor; + + @override + List get props => [hasNextPage, endCursor]; + Map toJson() => _$GhPullsPageInfoToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsPullRequest extends GhPullsProjectCardItem + with EquatableMixin + implements + GhPullsNode, + GhPullsAssignable, + GhPullsClosable, + GhPullsComment, + GhPullsUpdatable, + GhPullsUpdatableComment, + GhPullsLabelable, + GhPullsLockable, + GhPullsReactable, + GhPullsRepositoryNode, + GhPullsSubscribable, + GhPullsUniformResourceLocatable { + GhPullsPullRequest({this.number, this.title, this.comments}); + + factory GhPullsPullRequest.fromJson(Map json) => + _$GhPullsPullRequestFromJson(json); + + @override + GhPullsRepository repository; + + int number; + + String title; + + @override + DateTime updatedAt; + + @override + GhPullsActor author; + + @override + GhPullsLabelConnection labels; + + GhPullsIssueCommentConnection comments; + + @override + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [ + repository, + number, + title, + updatedAt, + author, + labels, + comments, + resolveType + ]; + Map toJson() => _$GhPullsPullRequestToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsPinnableItem with EquatableMixin { + GhPullsPinnableItem(); + + factory GhPullsPinnableItem.fromJson(Map json) => + _$GhPullsPinnableItemFromJson(json); + + @override + List get props => []; + Map toJson() => _$GhPullsPinnableItemToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsNode with EquatableMixin { + GhPullsNode(); + + factory GhPullsNode.fromJson(Map json) => + _$GhPullsNodeFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsNodeToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsProjectOwner with EquatableMixin { + GhPullsProjectOwner(); + + factory GhPullsProjectOwner.fromJson(Map json) => + _$GhPullsProjectOwnerFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsProjectOwnerToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsRegistryPackageOwner with EquatableMixin { + GhPullsRegistryPackageOwner(); + + factory GhPullsRegistryPackageOwner.fromJson(Map json) => + _$GhPullsRegistryPackageOwnerFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsRegistryPackageOwnerToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsRegistryPackageSearch with EquatableMixin { + GhPullsRegistryPackageSearch(); + + factory GhPullsRegistryPackageSearch.fromJson(Map json) => + _$GhPullsRegistryPackageSearchFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsRegistryPackageSearchToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsSubscribable with EquatableMixin { + GhPullsSubscribable(); + + factory GhPullsSubscribable.fromJson(Map json) => + _$GhPullsSubscribableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsSubscribableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsStarrable with EquatableMixin { + GhPullsStarrable(); + + factory GhPullsStarrable.fromJson(Map json) => + _$GhPullsStarrableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsStarrableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsUniformResourceLocatable with EquatableMixin { + GhPullsUniformResourceLocatable(); + + factory GhPullsUniformResourceLocatable.fromJson(Map json) => + _$GhPullsUniformResourceLocatableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => + _$GhPullsUniformResourceLocatableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsRepositoryInfo with EquatableMixin { + GhPullsRepositoryInfo({this.owner, this.name}); + + factory GhPullsRepositoryInfo.fromJson(Map json) => + _$GhPullsRepositoryInfoFromJson(json); + + GhPullsRepositoryOwner owner; + + String name; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [owner, name, resolveType]; + Map toJson() => _$GhPullsRepositoryInfoToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsActor with EquatableMixin { + GhPullsActor({this.login, this.avatarUrl}); + + factory GhPullsActor.fromJson(Map json) => + _$GhPullsActorFromJson(json); + + String login; + + String avatarUrl; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [login, avatarUrl, resolveType]; + Map toJson() => _$GhPullsActorToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsLabelConnection with EquatableMixin { + GhPullsLabelConnection({this.nodes}); + + factory GhPullsLabelConnection.fromJson(Map json) => + _$GhPullsLabelConnectionFromJson(json); + + List nodes; + + @override + List get props => [nodes]; + Map toJson() => _$GhPullsLabelConnectionToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsLabel with EquatableMixin implements GhPullsNode { + GhPullsLabel({this.name, this.color}); + + factory GhPullsLabel.fromJson(Map json) => + _$GhPullsLabelFromJson(json); + + String name; + + String color; + + @override + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [name, color, resolveType]; + Map toJson() => _$GhPullsLabelToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsIssueCommentConnection with EquatableMixin { + GhPullsIssueCommentConnection({this.totalCount}); + + factory GhPullsIssueCommentConnection.fromJson(Map json) => + _$GhPullsIssueCommentConnectionFromJson(json); + + int totalCount; + + @override + List get props => [totalCount]; + Map toJson() => _$GhPullsIssueCommentConnectionToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsProjectCardItem with EquatableMixin { + GhPullsProjectCardItem(); + + factory GhPullsProjectCardItem.fromJson(Map json) => + _$GhPullsProjectCardItemFromJson(json); + + @override + List get props => []; + Map toJson() => _$GhPullsProjectCardItemToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsAssignable with EquatableMixin { + GhPullsAssignable(); + + factory GhPullsAssignable.fromJson(Map json) => + _$GhPullsAssignableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsAssignableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsClosable with EquatableMixin { + GhPullsClosable(); + + factory GhPullsClosable.fromJson(Map json) => + _$GhPullsClosableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsClosableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsComment with EquatableMixin { + GhPullsComment({this.updatedAt, this.author}); + + factory GhPullsComment.fromJson(Map json) => + _$GhPullsCommentFromJson(json); + + DateTime updatedAt; + + GhPullsActor author; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [updatedAt, author, resolveType]; + Map toJson() => _$GhPullsCommentToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsUpdatable with EquatableMixin { + GhPullsUpdatable(); + + factory GhPullsUpdatable.fromJson(Map json) => + _$GhPullsUpdatableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsUpdatableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsUpdatableComment with EquatableMixin { + GhPullsUpdatableComment(); + + factory GhPullsUpdatableComment.fromJson(Map json) => + _$GhPullsUpdatableCommentFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsUpdatableCommentToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsLabelable with EquatableMixin { + GhPullsLabelable({this.labels}); + + factory GhPullsLabelable.fromJson(Map json) => + _$GhPullsLabelableFromJson(json); + + GhPullsLabelConnection labels; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [labels, resolveType]; + Map toJson() => _$GhPullsLabelableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsLockable with EquatableMixin { + GhPullsLockable(); + + factory GhPullsLockable.fromJson(Map json) => + _$GhPullsLockableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsLockableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsReactable with EquatableMixin { + GhPullsReactable(); + + factory GhPullsReactable.fromJson(Map json) => + _$GhPullsReactableFromJson(json); + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [resolveType]; + Map toJson() => _$GhPullsReactableToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsRepositoryNode with EquatableMixin { + GhPullsRepositoryNode({this.repository}); + + factory GhPullsRepositoryNode.fromJson(Map json) => + _$GhPullsRepositoryNodeFromJson(json); + + GhPullsRepository repository; + + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [repository, resolveType]; + Map toJson() => _$GhPullsRepositoryNodeToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class GhPullsArguments extends JsonSerializable with EquatableMixin { + GhPullsArguments({@required this.owner, @required this.name, this.cursor}); + + factory GhPullsArguments.fromJson(Map json) => + _$GhPullsArgumentsFromJson(json); + + final String owner; + + final String name; + + final String cursor; + + @override + List get props => [owner, name, cursor]; + Map toJson() => _$GhPullsArgumentsToJson(this); +} + +class GhPullsQuery extends GraphQLQuery { + GhPullsQuery({this.variables}); + + @override + final DocumentNode document = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'GhPulls'), + 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: 'cursor')), + 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: 'owner'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'login'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'pullRequests'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'states'), + value: EnumValueNode(name: NameNode(value: 'OPEN'))), + ArgumentNode( + name: NameNode(value: 'orderBy'), + value: ObjectValueNode(fields: [ + ObjectFieldNode( + name: NameNode(value: 'field'), + value: EnumValueNode( + name: NameNode(value: 'CREATED_AT'))), + ObjectFieldNode( + name: NameNode(value: 'direction'), + value: EnumValueNode( + name: NameNode(value: 'DESC'))) + ])), + ArgumentNode( + name: NameNode(value: 'first'), + value: IntValueNode(value: '30')), + ArgumentNode( + name: NameNode(value: 'after'), + value: VariableNode(name: NameNode(value: 'cursor'))) + ], + 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: 'repository'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'owner'), + alias: null, + arguments: [], + directives: [], + selectionSet: + SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'login'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: 'number'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'title'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'updatedAt'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'author'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'login'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'avatarUrl'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: 'labels'), + alias: null, + arguments: [ + ArgumentNode( + name: NameNode(value: 'first'), + value: IntValueNode(value: '10')) + ], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'nodes'), + alias: null, + arguments: [], + directives: [], + selectionSet: + SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'color'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])) + ])), + FieldNode( + name: NameNode(value: 'comments'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'totalCount'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])) + ])) + ])) + ])) + ])) + ]); + + @override + final String operationName = 'GhPulls'; + + @override + final GhPullsArguments variables; + + @override + List get props => [document, operationName, variables]; + @override + GhPulls parse(Map json) => GhPulls.fromJson(json); +} diff --git a/lib/graphql/gh.g.dart b/lib/graphql/gh.g.dart index 9188017..e73cf2c 100644 --- a/lib/graphql/gh.g.dart +++ b/lib/graphql/gh.g.dart @@ -3597,3 +3597,822 @@ Map _$GhRepoIdArgumentsToJson(GhRepoIdArguments instance) => 'owner': instance.owner, 'name': instance.name, }; + +GhIssues _$GhIssuesFromJson(Map json) { + return GhIssues( + repository: json['repository'] == null + ? null + : GhIssuesRepository.fromJson( + json['repository'] as Map), + ); +} + +Map _$GhIssuesToJson(GhIssues instance) => { + 'repository': instance.repository?.toJson(), + }; + +GhIssuesRepository _$GhIssuesRepositoryFromJson(Map json) { + return GhIssuesRepository( + issues: json['issues'] == null + ? null + : GhIssuesIssueConnection.fromJson( + json['issues'] as Map), + ) + ..owner = json['owner'] == null + ? null + : GhIssuesRepositoryOwner.fromJson( + json['owner'] as Map) + ..name = json['name'] as String + ..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesRepositoryToJson(GhIssuesRepository instance) => + { + 'owner': instance.owner?.toJson(), + 'name': instance.name, + 'issues': instance.issues?.toJson(), + '__typename': instance.resolveType, + }; + +GhIssuesRepositoryOwner _$GhIssuesRepositoryOwnerFromJson( + Map json) { + return GhIssuesRepositoryOwner( + login: json['login'] as String, + )..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesRepositoryOwnerToJson( + GhIssuesRepositoryOwner instance) => + { + 'login': instance.login, + '__typename': instance.resolveType, + }; + +GhIssuesIssueConnection _$GhIssuesIssueConnectionFromJson( + Map json) { + return GhIssuesIssueConnection( + pageInfo: json['pageInfo'] == null + ? null + : GhIssuesPageInfo.fromJson(json['pageInfo'] as Map), + nodes: (json['nodes'] as List) + ?.map((e) => e == null + ? null + : GhIssuesIssue.fromJson(e as Map)) + ?.toList(), + ); +} + +Map _$GhIssuesIssueConnectionToJson( + GhIssuesIssueConnection instance) => + { + 'pageInfo': instance.pageInfo?.toJson(), + 'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(), + }; + +GhIssuesPageInfo _$GhIssuesPageInfoFromJson(Map json) { + return GhIssuesPageInfo( + hasNextPage: json['hasNextPage'] as bool, + endCursor: json['endCursor'] as String, + ); +} + +Map _$GhIssuesPageInfoToJson(GhIssuesPageInfo instance) => + { + 'hasNextPage': instance.hasNextPage, + 'endCursor': instance.endCursor, + }; + +GhIssuesIssue _$GhIssuesIssueFromJson(Map json) { + return GhIssuesIssue( + number: json['number'] as int, + title: json['title'] as String, + comments: json['comments'] == null + ? null + : GhIssuesIssueCommentConnection.fromJson( + json['comments'] as Map), + ) + ..repository = json['repository'] == null + ? null + : GhIssuesRepository.fromJson( + json['repository'] as Map) + ..updatedAt = json['updatedAt'] == null + ? null + : DateTime.parse(json['updatedAt'] as String) + ..author = json['author'] == null + ? null + : GhIssuesActor.fromJson(json['author'] as Map) + ..labels = json['labels'] == null + ? null + : GhIssuesLabelConnection.fromJson( + json['labels'] as Map) + ..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesIssueToJson(GhIssuesIssue instance) => + { + 'repository': instance.repository?.toJson(), + 'number': instance.number, + 'title': instance.title, + 'updatedAt': instance.updatedAt?.toIso8601String(), + 'author': instance.author?.toJson(), + 'labels': instance.labels?.toJson(), + 'comments': instance.comments?.toJson(), + '__typename': instance.resolveType, + }; + +GhIssuesPinnableItem _$GhIssuesPinnableItemFromJson(Map json) { + return GhIssuesPinnableItem(); +} + +Map _$GhIssuesPinnableItemToJson( + GhIssuesPinnableItem instance) => + {}; + +GhIssuesNode _$GhIssuesNodeFromJson(Map json) { + return GhIssuesNode()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesNodeToJson(GhIssuesNode instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesProjectOwner _$GhIssuesProjectOwnerFromJson(Map json) { + return GhIssuesProjectOwner()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesProjectOwnerToJson( + GhIssuesProjectOwner instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesRegistryPackageOwner _$GhIssuesRegistryPackageOwnerFromJson( + Map json) { + return GhIssuesRegistryPackageOwner() + ..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesRegistryPackageOwnerToJson( + GhIssuesRegistryPackageOwner instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesRegistryPackageSearch _$GhIssuesRegistryPackageSearchFromJson( + Map json) { + return GhIssuesRegistryPackageSearch() + ..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesRegistryPackageSearchToJson( + GhIssuesRegistryPackageSearch instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesSubscribable _$GhIssuesSubscribableFromJson(Map json) { + return GhIssuesSubscribable()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesSubscribableToJson( + GhIssuesSubscribable instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesStarrable _$GhIssuesStarrableFromJson(Map json) { + return GhIssuesStarrable()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesStarrableToJson(GhIssuesStarrable instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesUniformResourceLocatable _$GhIssuesUniformResourceLocatableFromJson( + Map json) { + return GhIssuesUniformResourceLocatable() + ..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesUniformResourceLocatableToJson( + GhIssuesUniformResourceLocatable instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesRepositoryInfo _$GhIssuesRepositoryInfoFromJson( + Map json) { + return GhIssuesRepositoryInfo( + owner: json['owner'] == null + ? null + : GhIssuesRepositoryOwner.fromJson( + json['owner'] as Map), + name: json['name'] as String, + )..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesRepositoryInfoToJson( + GhIssuesRepositoryInfo instance) => + { + 'owner': instance.owner?.toJson(), + 'name': instance.name, + '__typename': instance.resolveType, + }; + +GhIssuesActor _$GhIssuesActorFromJson(Map json) { + return GhIssuesActor( + login: json['login'] as String, + avatarUrl: json['avatarUrl'] as String, + )..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesActorToJson(GhIssuesActor instance) => + { + 'login': instance.login, + 'avatarUrl': instance.avatarUrl, + '__typename': instance.resolveType, + }; + +GhIssuesLabelConnection _$GhIssuesLabelConnectionFromJson( + Map json) { + return GhIssuesLabelConnection( + nodes: (json['nodes'] as List) + ?.map((e) => e == null + ? null + : GhIssuesLabel.fromJson(e as Map)) + ?.toList(), + ); +} + +Map _$GhIssuesLabelConnectionToJson( + GhIssuesLabelConnection instance) => + { + 'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(), + }; + +GhIssuesLabel _$GhIssuesLabelFromJson(Map json) { + return GhIssuesLabel( + name: json['name'] as String, + color: json['color'] as String, + )..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesLabelToJson(GhIssuesLabel instance) => + { + 'name': instance.name, + 'color': instance.color, + '__typename': instance.resolveType, + }; + +GhIssuesIssueCommentConnection _$GhIssuesIssueCommentConnectionFromJson( + Map json) { + return GhIssuesIssueCommentConnection( + totalCount: json['totalCount'] as int, + ); +} + +Map _$GhIssuesIssueCommentConnectionToJson( + GhIssuesIssueCommentConnection instance) => + { + 'totalCount': instance.totalCount, + }; + +GhIssuesProjectCardItem _$GhIssuesProjectCardItemFromJson( + Map json) { + return GhIssuesProjectCardItem(); +} + +Map _$GhIssuesProjectCardItemToJson( + GhIssuesProjectCardItem instance) => + {}; + +GhIssuesAssignable _$GhIssuesAssignableFromJson(Map json) { + return GhIssuesAssignable()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesAssignableToJson(GhIssuesAssignable instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesClosable _$GhIssuesClosableFromJson(Map json) { + return GhIssuesClosable()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesClosableToJson(GhIssuesClosable instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesComment _$GhIssuesCommentFromJson(Map json) { + return GhIssuesComment( + updatedAt: json['updatedAt'] == null + ? null + : DateTime.parse(json['updatedAt'] as String), + author: json['author'] == null + ? null + : GhIssuesActor.fromJson(json['author'] as Map), + )..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesCommentToJson(GhIssuesComment instance) => + { + 'updatedAt': instance.updatedAt?.toIso8601String(), + 'author': instance.author?.toJson(), + '__typename': instance.resolveType, + }; + +GhIssuesUpdatable _$GhIssuesUpdatableFromJson(Map json) { + return GhIssuesUpdatable()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesUpdatableToJson(GhIssuesUpdatable instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesUpdatableComment _$GhIssuesUpdatableCommentFromJson( + Map json) { + return GhIssuesUpdatableComment()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesUpdatableCommentToJson( + GhIssuesUpdatableComment instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesLabelable _$GhIssuesLabelableFromJson(Map json) { + return GhIssuesLabelable( + labels: json['labels'] == null + ? null + : GhIssuesLabelConnection.fromJson( + json['labels'] as Map), + )..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesLabelableToJson(GhIssuesLabelable instance) => + { + 'labels': instance.labels?.toJson(), + '__typename': instance.resolveType, + }; + +GhIssuesLockable _$GhIssuesLockableFromJson(Map json) { + return GhIssuesLockable()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesLockableToJson(GhIssuesLockable instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesReactable _$GhIssuesReactableFromJson(Map json) { + return GhIssuesReactable()..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesReactableToJson(GhIssuesReactable instance) => + { + '__typename': instance.resolveType, + }; + +GhIssuesRepositoryNode _$GhIssuesRepositoryNodeFromJson( + Map json) { + return GhIssuesRepositoryNode( + repository: json['repository'] == null + ? null + : GhIssuesRepository.fromJson( + json['repository'] as Map), + )..resolveType = json['__typename'] as String; +} + +Map _$GhIssuesRepositoryNodeToJson( + GhIssuesRepositoryNode instance) => + { + 'repository': instance.repository?.toJson(), + '__typename': instance.resolveType, + }; + +GhIssuesArguments _$GhIssuesArgumentsFromJson(Map json) { + return GhIssuesArguments( + owner: json['owner'] as String, + name: json['name'] as String, + cursor: json['cursor'] as String, + ); +} + +Map _$GhIssuesArgumentsToJson(GhIssuesArguments instance) => + { + 'owner': instance.owner, + 'name': instance.name, + 'cursor': instance.cursor, + }; + +GhPulls _$GhPullsFromJson(Map json) { + return GhPulls( + repository: json['repository'] == null + ? null + : GhPullsRepository.fromJson( + json['repository'] as Map), + ); +} + +Map _$GhPullsToJson(GhPulls instance) => { + 'repository': instance.repository?.toJson(), + }; + +GhPullsRepository _$GhPullsRepositoryFromJson(Map json) { + return GhPullsRepository( + pullRequests: json['pullRequests'] == null + ? null + : GhPullsPullRequestConnection.fromJson( + json['pullRequests'] as Map), + ) + ..owner = json['owner'] == null + ? null + : GhPullsRepositoryOwner.fromJson(json['owner'] as Map) + ..name = json['name'] as String + ..resolveType = json['__typename'] as String; +} + +Map _$GhPullsRepositoryToJson(GhPullsRepository instance) => + { + 'owner': instance.owner?.toJson(), + 'name': instance.name, + 'pullRequests': instance.pullRequests?.toJson(), + '__typename': instance.resolveType, + }; + +GhPullsRepositoryOwner _$GhPullsRepositoryOwnerFromJson( + Map json) { + return GhPullsRepositoryOwner( + login: json['login'] as String, + )..resolveType = json['__typename'] as String; +} + +Map _$GhPullsRepositoryOwnerToJson( + GhPullsRepositoryOwner instance) => + { + 'login': instance.login, + '__typename': instance.resolveType, + }; + +GhPullsPullRequestConnection _$GhPullsPullRequestConnectionFromJson( + Map json) { + return GhPullsPullRequestConnection( + pageInfo: json['pageInfo'] == null + ? null + : GhPullsPageInfo.fromJson(json['pageInfo'] as Map), + nodes: (json['nodes'] as List) + ?.map((e) => e == null + ? null + : GhPullsPullRequest.fromJson(e as Map)) + ?.toList(), + ); +} + +Map _$GhPullsPullRequestConnectionToJson( + GhPullsPullRequestConnection instance) => + { + 'pageInfo': instance.pageInfo?.toJson(), + 'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(), + }; + +GhPullsPageInfo _$GhPullsPageInfoFromJson(Map json) { + return GhPullsPageInfo( + hasNextPage: json['hasNextPage'] as bool, + endCursor: json['endCursor'] as String, + ); +} + +Map _$GhPullsPageInfoToJson(GhPullsPageInfo instance) => + { + 'hasNextPage': instance.hasNextPage, + 'endCursor': instance.endCursor, + }; + +GhPullsPullRequest _$GhPullsPullRequestFromJson(Map json) { + return GhPullsPullRequest( + number: json['number'] as int, + title: json['title'] as String, + comments: json['comments'] == null + ? null + : GhPullsIssueCommentConnection.fromJson( + json['comments'] as Map), + ) + ..repository = json['repository'] == null + ? null + : GhPullsRepository.fromJson(json['repository'] as Map) + ..updatedAt = json['updatedAt'] == null + ? null + : DateTime.parse(json['updatedAt'] as String) + ..author = json['author'] == null + ? null + : GhPullsActor.fromJson(json['author'] as Map) + ..labels = json['labels'] == null + ? null + : GhPullsLabelConnection.fromJson( + json['labels'] as Map) + ..resolveType = json['__typename'] as String; +} + +Map _$GhPullsPullRequestToJson(GhPullsPullRequest instance) => + { + 'repository': instance.repository?.toJson(), + 'number': instance.number, + 'title': instance.title, + 'updatedAt': instance.updatedAt?.toIso8601String(), + 'author': instance.author?.toJson(), + 'labels': instance.labels?.toJson(), + 'comments': instance.comments?.toJson(), + '__typename': instance.resolveType, + }; + +GhPullsPinnableItem _$GhPullsPinnableItemFromJson(Map json) { + return GhPullsPinnableItem(); +} + +Map _$GhPullsPinnableItemToJson( + GhPullsPinnableItem instance) => + {}; + +GhPullsNode _$GhPullsNodeFromJson(Map json) { + return GhPullsNode()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsNodeToJson(GhPullsNode instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsProjectOwner _$GhPullsProjectOwnerFromJson(Map json) { + return GhPullsProjectOwner()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsProjectOwnerToJson( + GhPullsProjectOwner instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsRegistryPackageOwner _$GhPullsRegistryPackageOwnerFromJson( + Map json) { + return GhPullsRegistryPackageOwner() + ..resolveType = json['__typename'] as String; +} + +Map _$GhPullsRegistryPackageOwnerToJson( + GhPullsRegistryPackageOwner instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsRegistryPackageSearch _$GhPullsRegistryPackageSearchFromJson( + Map json) { + return GhPullsRegistryPackageSearch() + ..resolveType = json['__typename'] as String; +} + +Map _$GhPullsRegistryPackageSearchToJson( + GhPullsRegistryPackageSearch instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsSubscribable _$GhPullsSubscribableFromJson(Map json) { + return GhPullsSubscribable()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsSubscribableToJson( + GhPullsSubscribable instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsStarrable _$GhPullsStarrableFromJson(Map json) { + return GhPullsStarrable()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsStarrableToJson(GhPullsStarrable instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsUniformResourceLocatable _$GhPullsUniformResourceLocatableFromJson( + Map json) { + return GhPullsUniformResourceLocatable() + ..resolveType = json['__typename'] as String; +} + +Map _$GhPullsUniformResourceLocatableToJson( + GhPullsUniformResourceLocatable instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsRepositoryInfo _$GhPullsRepositoryInfoFromJson( + Map json) { + return GhPullsRepositoryInfo( + owner: json['owner'] == null + ? null + : GhPullsRepositoryOwner.fromJson( + json['owner'] as Map), + name: json['name'] as String, + )..resolveType = json['__typename'] as String; +} + +Map _$GhPullsRepositoryInfoToJson( + GhPullsRepositoryInfo instance) => + { + 'owner': instance.owner?.toJson(), + 'name': instance.name, + '__typename': instance.resolveType, + }; + +GhPullsActor _$GhPullsActorFromJson(Map json) { + return GhPullsActor( + login: json['login'] as String, + avatarUrl: json['avatarUrl'] as String, + )..resolveType = json['__typename'] as String; +} + +Map _$GhPullsActorToJson(GhPullsActor instance) => + { + 'login': instance.login, + 'avatarUrl': instance.avatarUrl, + '__typename': instance.resolveType, + }; + +GhPullsLabelConnection _$GhPullsLabelConnectionFromJson( + Map json) { + return GhPullsLabelConnection( + nodes: (json['nodes'] as List) + ?.map((e) => + e == null ? null : GhPullsLabel.fromJson(e as Map)) + ?.toList(), + ); +} + +Map _$GhPullsLabelConnectionToJson( + GhPullsLabelConnection instance) => + { + 'nodes': instance.nodes?.map((e) => e?.toJson())?.toList(), + }; + +GhPullsLabel _$GhPullsLabelFromJson(Map json) { + return GhPullsLabel( + name: json['name'] as String, + color: json['color'] as String, + )..resolveType = json['__typename'] as String; +} + +Map _$GhPullsLabelToJson(GhPullsLabel instance) => + { + 'name': instance.name, + 'color': instance.color, + '__typename': instance.resolveType, + }; + +GhPullsIssueCommentConnection _$GhPullsIssueCommentConnectionFromJson( + Map json) { + return GhPullsIssueCommentConnection( + totalCount: json['totalCount'] as int, + ); +} + +Map _$GhPullsIssueCommentConnectionToJson( + GhPullsIssueCommentConnection instance) => + { + 'totalCount': instance.totalCount, + }; + +GhPullsProjectCardItem _$GhPullsProjectCardItemFromJson( + Map json) { + return GhPullsProjectCardItem(); +} + +Map _$GhPullsProjectCardItemToJson( + GhPullsProjectCardItem instance) => + {}; + +GhPullsAssignable _$GhPullsAssignableFromJson(Map json) { + return GhPullsAssignable()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsAssignableToJson(GhPullsAssignable instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsClosable _$GhPullsClosableFromJson(Map json) { + return GhPullsClosable()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsClosableToJson(GhPullsClosable instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsComment _$GhPullsCommentFromJson(Map json) { + return GhPullsComment( + updatedAt: json['updatedAt'] == null + ? null + : DateTime.parse(json['updatedAt'] as String), + author: json['author'] == null + ? null + : GhPullsActor.fromJson(json['author'] as Map), + )..resolveType = json['__typename'] as String; +} + +Map _$GhPullsCommentToJson(GhPullsComment instance) => + { + 'updatedAt': instance.updatedAt?.toIso8601String(), + 'author': instance.author?.toJson(), + '__typename': instance.resolveType, + }; + +GhPullsUpdatable _$GhPullsUpdatableFromJson(Map json) { + return GhPullsUpdatable()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsUpdatableToJson(GhPullsUpdatable instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsUpdatableComment _$GhPullsUpdatableCommentFromJson( + Map json) { + return GhPullsUpdatableComment()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsUpdatableCommentToJson( + GhPullsUpdatableComment instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsLabelable _$GhPullsLabelableFromJson(Map json) { + return GhPullsLabelable( + labels: json['labels'] == null + ? null + : GhPullsLabelConnection.fromJson( + json['labels'] as Map), + )..resolveType = json['__typename'] as String; +} + +Map _$GhPullsLabelableToJson(GhPullsLabelable instance) => + { + 'labels': instance.labels?.toJson(), + '__typename': instance.resolveType, + }; + +GhPullsLockable _$GhPullsLockableFromJson(Map json) { + return GhPullsLockable()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsLockableToJson(GhPullsLockable instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsReactable _$GhPullsReactableFromJson(Map json) { + return GhPullsReactable()..resolveType = json['__typename'] as String; +} + +Map _$GhPullsReactableToJson(GhPullsReactable instance) => + { + '__typename': instance.resolveType, + }; + +GhPullsRepositoryNode _$GhPullsRepositoryNodeFromJson( + Map json) { + return GhPullsRepositoryNode( + repository: json['repository'] == null + ? null + : GhPullsRepository.fromJson( + json['repository'] as Map), + )..resolveType = json['__typename'] as String; +} + +Map _$GhPullsRepositoryNodeToJson( + GhPullsRepositoryNode instance) => + { + 'repository': instance.repository?.toJson(), + '__typename': instance.resolveType, + }; + +GhPullsArguments _$GhPullsArgumentsFromJson(Map json) { + return GhPullsArguments( + owner: json['owner'] as String, + name: json['name'] as String, + cursor: json['cursor'] as String, + ); +} + +Map _$GhPullsArgumentsToJson(GhPullsArguments instance) => + { + 'owner': instance.owner, + 'name': instance.name, + 'cursor': instance.cursor, + }; diff --git a/lib/graphql/gh_issues.graphql b/lib/graphql/gh_issues.graphql new file mode 100644 index 0000000..84669f2 --- /dev/null +++ b/lib/graphql/gh_issues.graphql @@ -0,0 +1,43 @@ +query GhIssues($owner: String!, $name: String!, $cursor: String) { + repository(owner: $owner, name: $name) { + owner { + login + } + name + issues( + states: OPEN + orderBy: { field: CREATED_AT, direction: DESC } + first: 30 + after: $cursor + ) { + pageInfo { + hasNextPage + endCursor + } + nodes { + repository { + owner { + login + } + name + } + number + title + updatedAt + author { + login + avatarUrl + } + labels(first: 10) { + nodes { + name + color + } + } + comments { + totalCount + } + } + } + } +} diff --git a/lib/graphql/gh_pulls.graphql b/lib/graphql/gh_pulls.graphql new file mode 100644 index 0000000..e08df9f --- /dev/null +++ b/lib/graphql/gh_pulls.graphql @@ -0,0 +1,43 @@ +query GhPulls($owner: String!, $name: String!, $cursor: String) { + repository(owner: $owner, name: $name) { + owner { + login + } + name + pullRequests( + states: OPEN + orderBy: { field: CREATED_AT, direction: DESC } + first: 30 + after: $cursor + ) { + pageInfo { + hasNextPage + endCursor + } + nodes { + repository { + owner { + login + } + name + } + number + title + updatedAt + author { + login + avatarUrl + } + labels(first: 10) { + nodes { + name + color + } + } + comments { + totalCount + } + } + } + } +} diff --git a/lib/main.dart b/lib/main.dart index 3bd2fa9..9d2849e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,6 +16,7 @@ import 'package:git_touch/screens/gitlab_user.dart'; import 'package:git_touch/screens/issue_form.dart'; import 'package:git_touch/screens/issues.dart'; import 'package:git_touch/screens/object.dart'; +import 'package:git_touch/screens/pulls.dart'; import 'package:git_touch/screens/repository.dart'; import 'package:git_touch/screens/settings.dart'; import 'package:git_touch/screens/stargazers.dart'; diff --git a/lib/screens/issue.dart b/lib/screens/issue.dart index 4d195e6..dc79ac5 100644 --- a/lib/screens/issue.dart +++ b/lib/screens/issue.dart @@ -19,7 +19,7 @@ final issueRouter = RouterScreen( params['name'].first, int.parse(params['number'].first))); final pullRouter = RouterScreen( - '/:owner/:name/pulls/:number', + '/:owner/:name/pull/:number', (context, params) => IssueScreen(params['owner'].first, params['name'].first, int.parse(params['number'].first), isPullRequest: true)); diff --git a/lib/screens/issues.dart b/lib/screens/issues.dart index 7a0b4e4..8bf1b19 100644 --- a/lib/screens/issues.dart +++ b/lib/screens/issues.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:git_touch/graphql/gh.dart'; import 'package:git_touch/models/auth.dart'; import 'package:git_touch/models/theme.dart'; import 'package:git_touch/scaffolds/list_stateful.dart'; @@ -6,6 +7,7 @@ import 'package:git_touch/utils/utils.dart'; import 'package:git_touch/widgets/action_entry.dart'; import 'package:git_touch/widgets/app_bar_title.dart'; import 'package:git_touch/widgets/issue_item.dart'; +import 'package:git_touch/widgets/label.dart'; import 'package:provider/provider.dart'; final issuesRouter = RouterScreen( @@ -13,52 +15,33 @@ final issuesRouter = RouterScreen( (context, params) => IssuesScreen(params['owner'].first, params['name'].first)); -final pullsRouter = RouterScreen( - '/:owner/:name/pulls', - (context, params) => IssuesScreen( - params['owner'].first, params['name'].first, - isPullRequest: true)); - class IssuesScreen extends StatelessWidget { final String owner; final String name; - final bool isPullRequest; - IssuesScreen(this.owner, this.name, {this.isPullRequest = false}); - - Future _query(BuildContext context, [String cursor]) async { - var cursorChunk = cursor == null ? '' : ', after: "$cursor"'; - var resource = isPullRequest ? 'pullRequests' : 'issues'; - - var data = await Provider.of(context).query(''' -{ - repository(owner: "$owner", name: "$name") { - $resource(states: OPEN, orderBy: {field: CREATED_AT, direction: DESC}, first: $pageSize$cursorChunk) { - pageInfo { - hasNextPage - endCursor - } - nodes { - $issueGqlChunk - } - } - } -} - '''); - - var repo = data["repository"][resource]; + IssuesScreen(this.owner, this.name); + Future> _query(BuildContext context, + [String cursor]) async { + final res = + await Provider.of(context).gqlClient.execute(GhIssuesQuery( + variables: GhIssuesArguments( + owner: owner, + name: name, + cursor: cursor, + ))); + final issues = res.data.repository.issues; return ListPayload( - cursor: repo["pageInfo"]["endCursor"], - hasMore: repo['pageInfo']['hasNextPage'], - items: repo["nodes"], + cursor: issues.pageInfo.endCursor, + hasMore: issues.pageInfo.hasNextPage, + items: issues.nodes, ); } @override Widget build(BuildContext context) { - return ListStatefulScaffold( - title: AppBarTitle((isPullRequest ? 'Pull requests' : 'Issues')), + return ListStatefulScaffold( + title: AppBarTitle('Issues'), actionBuilder: () => ActionEntry( iconData: Octicons.plus, onTap: () { @@ -67,8 +50,22 @@ class IssuesScreen extends StatelessWidget { }), onRefresh: () => _query(context), onLoadMore: (cursor) => _query(context, cursor), - itemBuilder: (payload) => - IssueItem(payload: payload, isPullRequest: isPullRequest), + itemBuilder: (p) => IssueItem( + author: p.author?.login, + avatarUrl: p.author?.avatarUrl, + commentCount: p.comments.totalCount, + number: p.number, + title: p.title, + updatedAt: p.updatedAt, + labels: p.labels.nodes.isEmpty + ? null + : Wrap(spacing: 4, runSpacing: 4, children: [ + for (var label in p.labels.nodes) + MyLabel(name: label.name, cssColor: label.color) + ]), + url: + '/${p.repository.owner.login}/${p.repository.name}/issues/${p.number}', + ), ); } } diff --git a/lib/screens/pulls.dart b/lib/screens/pulls.dart new file mode 100644 index 0000000..de857f8 --- /dev/null +++ b/lib/screens/pulls.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; +import 'package:git_touch/graphql/gh.dart'; +import 'package:git_touch/models/auth.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'; +import 'package:git_touch/widgets/issue_item.dart'; +import 'package:git_touch/widgets/label.dart'; +import 'package:provider/provider.dart'; + +final pullsRouter = RouterScreen( + '/:owner/:name/pulls', + (context, params) => + PullsScreen(params['owner'].first, params['name'].first)); + +class PullsScreen extends StatelessWidget { + final String owner; + final String name; + + PullsScreen(this.owner, this.name); + + Future> _query(BuildContext context, + [String cursor]) async { + final res = + await Provider.of(context).gqlClient.execute(GhPullsQuery( + variables: GhPullsArguments( + owner: owner, + name: name, + cursor: cursor, + ))); + final pulls = res.data.repository.pullRequests; + return ListPayload( + cursor: pulls.pageInfo.endCursor, + hasMore: pulls.pageInfo.hasNextPage, + items: pulls.nodes, + ); + } + + @override + Widget build(BuildContext context) { + return ListStatefulScaffold( + title: AppBarTitle('Pull requests'), + onRefresh: () => _query(context), + onLoadMore: (cursor) => _query(context, cursor), + itemBuilder: (p) => IssueItem( + isPr: true, + author: p.author?.login, + avatarUrl: p.author?.avatarUrl, + commentCount: p.comments.totalCount, + number: p.number, + title: p.title, + updatedAt: p.updatedAt, + labels: p.labels.nodes.isEmpty + ? null + : Wrap(spacing: 4, runSpacing: 4, children: [ + for (var label in p.labels.nodes) + MyLabel(name: label.name, cssColor: label.color) + ]), + url: + '/${p.repository.owner.login}/${p.repository.name}/pulls/${p.number}', + ), + ); + } +} diff --git a/lib/screens/search.dart b/lib/screens/search.dart index c658c9f..d522ad2 100644 --- a/lib/screens/search.dart +++ b/lib/screens/search.dart @@ -188,7 +188,15 @@ class _SearchScreenState extends State { case 2: default: return IssueItem( - payload: p, isPullRequest: p['__typename'] == 'PullRequest'); + author: p['author']['login'], + avatarUrl: p['author']['avatarUrl'], + commentCount: p['comments']['totalCount'], + number: p['number'], + title: p['title'], + updatedAt: DateTime.parse(p['updatedAt']), + url: Uri.parse(p['url']).path, + isPr: p['__typename'] == 'PullRequest', + ); } } diff --git a/lib/widgets/issue_item.dart b/lib/widgets/issue_item.dart index fa44847..8b762b4 100644 --- a/lib/widgets/issue_item.dart +++ b/lib/widgets/issue_item.dart @@ -8,6 +8,7 @@ import '../utils/utils.dart'; import '../widgets/link.dart'; const issueGqlChunk = ''' +url number title updatedAt @@ -33,18 +34,34 @@ comments { '''; class IssueItem extends StatelessWidget { - final payload; - final bool isPullRequest; + final String url; + final int number; + final String title; + final int commentCount; + final DateTime updatedAt; + final String avatarUrl; + final String author; + final Widget labels; + final bool isPr; - IssueItem({this.payload, this.isPullRequest = false}); + IssueItem({ + @required this.url, + @required this.number, + @required this.title, + @required this.commentCount, + @required this.updatedAt, + @required this.avatarUrl, + @required this.author, + this.labels, + this.isPr = false, + }); @override Widget build(BuildContext context) { final theme = Provider.of(context); return Link( - url: - '/${payload['repository']['owner']['login']}/${payload['repository']['name']}/${isPullRequest ? 'pulls' : 'issues'}/${payload['number']}', + url: url, child: Container( padding: CommonStyle.padding, // color: payload.unread ? Colors.white : Colors.black12, @@ -54,12 +71,8 @@ class IssueItem extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Icon( - isPullRequest - ? Octicons.git_pull_request - : Octicons.issue_opened, - color: GithubPalette.open, - size: 20), + Icon(isPr ? Octicons.git_pull_request : Octicons.issue_opened, + color: GithubPalette.open, size: 20), SizedBox(width: 6), Expanded( child: Container( @@ -69,9 +82,9 @@ class IssueItem extends StatelessWidget { Text.rich( TextSpan( children: [ - TextSpan(text: payload['title'] + ' '), + TextSpan(text: '$title '), TextSpan( - text: '#${payload['number']}', + text: '#$number', style: TextStyle( color: theme.palette.tertiaryText, fontWeight: FontWeight.normal, @@ -85,18 +98,7 @@ class IssueItem extends StatelessWidget { fontWeight: FontWeight.w600, ), ), - if ((payload['labels']['nodes'] as List).isNotEmpty) - Wrap( - spacing: 4, - runSpacing: 4, - children: (payload['labels']['nodes'] as List) - .map((label) { - return MyLabel( - name: label['name'], - cssColor: label['color'], - ); - }).toList(), - ), + if (labels != null) labels, DefaultTextStyle( style: TextStyle( fontSize: 14, @@ -106,29 +108,25 @@ class IssueItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ // FIXME: Deleted user - if (payload['author'] != null) ...[ + if (avatarUrl != null) ...[ Avatar( size: AvatarSize.extraSmall, - url: payload['author']['avatarUrl'], - linkUrl: '/' + payload['author']['login'], + url: avatarUrl, ), SizedBox(width: 4), Text( - payload['author']['login'], + author, style: TextStyle(fontWeight: FontWeight.w600), ), ], - Text(' opened ' + - timeago.format( - DateTime.parse(payload['updatedAt']))), - if (payload['comments']['totalCount'] > 0) ...[ + Text(' opened ' + timeago.format(updatedAt)), + if (commentCount > 0) ...[ Expanded(child: SizedBox()), Icon(Octicons.comment, size: 14, color: theme.palette.secondaryText), SizedBox(width: 3), - Text(numberFormat - .format(payload['comments']['totalCount'])) + Text(numberFormat.format(commentCount)) ], ], ),