diff --git a/lib/graphql/github_commits.dart b/lib/graphql/github_commits.dart index 69a7c22..d6e953b 100644 --- a/lib/graphql/github_commits.dart +++ b/lib/graphql/github_commits.dart @@ -123,6 +123,8 @@ class GithubCommitsCommit extends GithubCommitsPullRequestTimelineItem GithubCommitsGitActor author; + GithubCommitsStatus status; + GithubCommitsCommitHistoryConnection history; @override @@ -130,8 +132,16 @@ class GithubCommitsCommit extends GithubCommitsPullRequestTimelineItem String resolveType; @override - List get props => - [oid, url, messageHeadline, committedDate, author, history, resolveType]; + List get props => [ + oid, + url, + messageHeadline, + committedDate, + author, + status, + history, + resolveType + ]; Map toJson() => _$GithubCommitsCommitToJson(this); } @@ -342,6 +352,24 @@ class GithubCommitsSponsorable with EquatableMixin { Map toJson() => _$GithubCommitsSponsorableToJson(this); } +@JsonSerializable(explicitToJson: true) +class GithubCommitsStatus with EquatableMixin implements GithubCommitsNode { + GithubCommitsStatus(); + + factory GithubCommitsStatus.fromJson(Map json) => + _$GithubCommitsStatusFromJson(json); + + GithubCommitsStatusState state; + + @override + @JsonKey(name: '__typename') + String resolveType; + + @override + List get props => [state, resolveType]; + Map toJson() => _$GithubCommitsStatusToJson(this); +} + @JsonSerializable(explicitToJson: true) class GithubCommitsCommitHistoryConnection with EquatableMixin { GithubCommitsCommitHistoryConnection(); @@ -447,6 +475,14 @@ class GithubCommitsRepositoryInfo with EquatableMixin { Map toJson() => _$GithubCommitsRepositoryInfoToJson(this); } +enum GithubCommitsStatusState { + EXPECTED, + ERROR, + FAILURE, + PENDING, + SUCCESS, +} + @JsonSerializable(explicitToJson: true) class GithubCommitsArguments extends JsonSerializable with EquatableMixin { GithubCommitsArguments( @@ -556,6 +592,19 @@ class GithubCommitsQuery selectionSet: null) ])) ])), + FieldNode( + name: NameNode(value: 'status'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'state'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), FieldNode( name: NameNode(value: 'history'), alias: null, @@ -653,6 +702,20 @@ class GithubCommitsQuery directives: [], selectionSet: null) ])) + ])), + FieldNode( + name: NameNode(value: 'status'), + alias: null, + arguments: [], + directives: [], + selectionSet: + SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'state'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) ])) ])) ])) diff --git a/lib/graphql/github_commits.g.dart b/lib/graphql/github_commits.g.dart index 1fff11f..df13043 100644 --- a/lib/graphql/github_commits.g.dart +++ b/lib/graphql/github_commits.g.dart @@ -77,6 +77,9 @@ GithubCommitsCommit _$GithubCommitsCommitFromJson(Map json) { ..author = json['author'] == null ? null : GithubCommitsGitActor.fromJson(json['author'] as Map) + ..status = json['status'] == null + ? null + : GithubCommitsStatus.fromJson(json['status'] as Map) ..history = json['history'] == null ? null : GithubCommitsCommitHistoryConnection.fromJson( @@ -92,6 +95,7 @@ Map _$GithubCommitsCommitToJson( 'messageHeadline': instance.messageHeadline, 'committedDate': instance.committedDate?.toIso8601String(), 'author': instance.author?.toJson(), + 'status': instance.status?.toJson(), 'history': instance.history?.toJson(), '__typename': instance.resolveType, }; @@ -243,6 +247,60 @@ Map _$GithubCommitsSponsorableToJson( '__typename': instance.resolveType, }; +GithubCommitsStatus _$GithubCommitsStatusFromJson(Map json) { + return GithubCommitsStatus() + ..state = + _$enumDecodeNullable(_$GithubCommitsStatusStateEnumMap, json['state']) + ..resolveType = json['__typename'] as String; +} + +Map _$GithubCommitsStatusToJson( + GithubCommitsStatus instance) => + { + 'state': _$GithubCommitsStatusStateEnumMap[instance.state], + '__typename': instance.resolveType, + }; + +T _$enumDecode( + Map enumValues, + dynamic source, { + T unknownValue, +}) { + if (source == null) { + throw ArgumentError('A value must be provided. Supported values: ' + '${enumValues.values.join(', ')}'); + } + + final value = enumValues.entries + .singleWhere((e) => e.value == source, orElse: () => null) + ?.key; + + if (value == null && unknownValue == null) { + throw ArgumentError('`$source` is not one of the supported values: ' + '${enumValues.values.join(', ')}'); + } + return value ?? unknownValue; +} + +T _$enumDecodeNullable( + Map enumValues, + dynamic source, { + T unknownValue, +}) { + if (source == null) { + return null; + } + return _$enumDecode(enumValues, source, unknownValue: unknownValue); +} + +const _$GithubCommitsStatusStateEnumMap = { + GithubCommitsStatusState.EXPECTED: 'EXPECTED', + GithubCommitsStatusState.ERROR: 'ERROR', + GithubCommitsStatusState.FAILURE: 'FAILURE', + GithubCommitsStatusState.PENDING: 'PENDING', + GithubCommitsStatusState.SUCCESS: 'SUCCESS', +}; + GithubCommitsCommitHistoryConnection _$GithubCommitsCommitHistoryConnectionFromJson(Map json) { return GithubCommitsCommitHistoryConnection() diff --git a/lib/graphql/github_commits.graphql b/lib/graphql/github_commits.graphql index 18e54a7..742bcd3 100644 --- a/lib/graphql/github_commits.graphql +++ b/lib/graphql/github_commits.graphql @@ -13,9 +13,9 @@ fragment T on Ref { login } } - # status { - # state - # } + status { + state + } history(first: 30, after: $after) { pageInfo { hasNextPage @@ -33,9 +33,9 @@ fragment T on Ref { login } } - # status { - # state - # } + status { + state + } } } } diff --git a/lib/screens/commits.dart b/lib/screens/commits.dart index d2dd5f0..f412070 100644 --- a/lib/screens/commits.dart +++ b/lib/screens/commits.dart @@ -41,12 +41,12 @@ class CommitsScreen extends StatelessWidget { ); } - Widget _buildStatus(String state) { - var size = 18.0; + Widget _buildStatus(GithubCommitsStatusState state) { + const size = 18.0; switch (state) { - case 'SUCCESS': + case GithubCommitsStatusState.SUCCESS: return Icon(Octicons.check, color: GithubPalette.open, size: size); - case 'FAILURE': + case GithubCommitsStatusState.FAILURE: return Icon(Octicons.x, color: GithubPalette.closed, size: size); default: return Container(); @@ -97,10 +97,10 @@ class CommitsScreen extends StatelessWidget { fontSize: 15, ), ), - // if (payload['status'] != null) ...[ - // SizedBox(width: 4), - // _buildStatus(payload['status']['state']) - // ], TODO: + if (payload.status != null) ...[ + SizedBox(width: 4), + _buildStatus(payload.status.state), + ], ], ) ], diff --git a/pubspec.yaml b/pubspec.yaml index a97abc0..22710d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,7 +36,11 @@ dependencies: uri: ^0.11.3 fimber: ^0.3.2 photo_view: ^0.7.0 - artemis: ^2.1.2 + artemis: #^2.1.2 + # path: ../../github/artemis + git: + url: git://github.com/pd4d10/artemis.git + ref: patch-1 gql_link: ^0.2.0 fluro: ^1.5.1 charts_flutter: ^0.8.1