mirror of
https://github.com/git-touch/git-touch
synced 2025-03-26 08:00:05 +01:00
refactor: object screen types
This commit is contained in:
parent
50cfd48e51
commit
bd56d64972
@ -34,6 +34,11 @@ targets:
|
|||||||
queries_glob: lib/graphql/github_repository.graphql
|
queries_glob: lib/graphql/github_repository.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_object.dart
|
||||||
|
queries_glob: lib/graphql/github_object.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
|
||||||
|
412
lib/graphql/github_object.dart
Normal file
412
lib/graphql/github_object.dart
Normal file
@ -0,0 +1,412 @@
|
|||||||
|
// 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_object.g.dart';
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObject with EquatableMixin {
|
||||||
|
GithubObject();
|
||||||
|
|
||||||
|
factory GithubObject.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectFromJson(json);
|
||||||
|
|
||||||
|
GithubObjectRepository repository;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [repository];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectRepository extends GithubObjectPinnableItem
|
||||||
|
with EquatableMixin
|
||||||
|
implements
|
||||||
|
GithubObjectNode,
|
||||||
|
GithubObjectProjectOwner,
|
||||||
|
GithubObjectRegistryPackageOwner,
|
||||||
|
GithubObjectRegistryPackageSearch,
|
||||||
|
GithubObjectSubscribable,
|
||||||
|
GithubObjectStarrable,
|
||||||
|
GithubObjectUniformResourceLocatable,
|
||||||
|
GithubObjectRepositoryInfo {
|
||||||
|
GithubObjectRepository();
|
||||||
|
|
||||||
|
factory GithubObjectRepository.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectRepositoryFromJson(json);
|
||||||
|
|
||||||
|
GithubObjectGitObject object;
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [object, resolveType];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectRepositoryToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectGitObject with EquatableMixin {
|
||||||
|
GithubObjectGitObject();
|
||||||
|
|
||||||
|
factory GithubObjectGitObject.fromJson(Map<String, dynamic> json) {
|
||||||
|
switch (json['__typename'].toString()) {
|
||||||
|
case 'Tree':
|
||||||
|
return GithubObjectTree.fromJson(json);
|
||||||
|
case 'Blob':
|
||||||
|
return GithubObjectBlob.fromJson(json);
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return _$GithubObjectGitObjectFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
switch (resolveType) {
|
||||||
|
case 'Tree':
|
||||||
|
return (this as GithubObjectTree).toJson();
|
||||||
|
case 'Blob':
|
||||||
|
return (this as GithubObjectBlob).toJson();
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return _$GithubObjectGitObjectToJson(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectTree
|
||||||
|
with EquatableMixin
|
||||||
|
implements GithubObjectNode, GithubObjectGitObject {
|
||||||
|
GithubObjectTree();
|
||||||
|
|
||||||
|
factory GithubObjectTree.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectTreeFromJson(json);
|
||||||
|
|
||||||
|
List<GithubObjectTreeEntry> entries;
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [entries, resolveType];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectTreeToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectTreeEntry with EquatableMixin {
|
||||||
|
GithubObjectTreeEntry();
|
||||||
|
|
||||||
|
factory GithubObjectTreeEntry.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectTreeEntryFromJson(json);
|
||||||
|
|
||||||
|
String type;
|
||||||
|
|
||||||
|
String name;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [type, name];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectTreeEntryToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectNode with EquatableMixin {
|
||||||
|
GithubObjectNode();
|
||||||
|
|
||||||
|
factory GithubObjectNode.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectNodeFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectNodeToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectBlob
|
||||||
|
with EquatableMixin
|
||||||
|
implements GithubObjectNode, GithubObjectGitObject {
|
||||||
|
GithubObjectBlob();
|
||||||
|
|
||||||
|
factory GithubObjectBlob.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectBlobFromJson(json);
|
||||||
|
|
||||||
|
String text;
|
||||||
|
|
||||||
|
@override
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [text, resolveType];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectBlobToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectPinnableItem with EquatableMixin {
|
||||||
|
GithubObjectPinnableItem();
|
||||||
|
|
||||||
|
factory GithubObjectPinnableItem.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectPinnableItemFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectPinnableItemToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectProjectOwner with EquatableMixin {
|
||||||
|
GithubObjectProjectOwner();
|
||||||
|
|
||||||
|
factory GithubObjectProjectOwner.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectProjectOwnerFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectProjectOwnerToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectRegistryPackageOwner with EquatableMixin {
|
||||||
|
GithubObjectRegistryPackageOwner();
|
||||||
|
|
||||||
|
factory GithubObjectRegistryPackageOwner.fromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectRegistryPackageOwnerFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() =>
|
||||||
|
_$GithubObjectRegistryPackageOwnerToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectRegistryPackageSearch with EquatableMixin {
|
||||||
|
GithubObjectRegistryPackageSearch();
|
||||||
|
|
||||||
|
factory GithubObjectRegistryPackageSearch.fromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectRegistryPackageSearchFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() =>
|
||||||
|
_$GithubObjectRegistryPackageSearchToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectSubscribable with EquatableMixin {
|
||||||
|
GithubObjectSubscribable();
|
||||||
|
|
||||||
|
factory GithubObjectSubscribable.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectSubscribableFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectSubscribableToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectStarrable with EquatableMixin {
|
||||||
|
GithubObjectStarrable();
|
||||||
|
|
||||||
|
factory GithubObjectStarrable.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectStarrableFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectStarrableToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectUniformResourceLocatable with EquatableMixin {
|
||||||
|
GithubObjectUniformResourceLocatable();
|
||||||
|
|
||||||
|
factory GithubObjectUniformResourceLocatable.fromJson(
|
||||||
|
Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectUniformResourceLocatableFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() =>
|
||||||
|
_$GithubObjectUniformResourceLocatableToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectRepositoryInfo with EquatableMixin {
|
||||||
|
GithubObjectRepositoryInfo();
|
||||||
|
|
||||||
|
factory GithubObjectRepositoryInfo.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectRepositoryInfoFromJson(json);
|
||||||
|
|
||||||
|
@JsonKey(name: '__typename')
|
||||||
|
String resolveType;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [resolveType];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectRepositoryInfoToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonSerializable(explicitToJson: true)
|
||||||
|
class GithubObjectArguments extends JsonSerializable with EquatableMixin {
|
||||||
|
GithubObjectArguments({this.owner, this.name, this.expression});
|
||||||
|
|
||||||
|
factory GithubObjectArguments.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$GithubObjectArgumentsFromJson(json);
|
||||||
|
|
||||||
|
final String owner;
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
final String expression;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [owner, name, expression];
|
||||||
|
Map<String, dynamic> toJson() => _$GithubObjectArgumentsToJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
class GithubObjectQuery
|
||||||
|
extends GraphQLQuery<GithubObject, GithubObjectArguments> {
|
||||||
|
GithubObjectQuery({this.variables});
|
||||||
|
|
||||||
|
@override
|
||||||
|
final DocumentNode document = DocumentNode(definitions: [
|
||||||
|
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: 'expression')),
|
||||||
|
type: NamedTypeNode(
|
||||||
|
name: NameNode(value: 'String'), isNonNull: true),
|
||||||
|
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: 'object'),
|
||||||
|
alias: null,
|
||||||
|
arguments: [
|
||||||
|
ArgumentNode(
|
||||||
|
name: NameNode(value: 'expression'),
|
||||||
|
value:
|
||||||
|
VariableNode(name: NameNode(value: 'expression')))
|
||||||
|
],
|
||||||
|
directives: [],
|
||||||
|
selectionSet: SelectionSetNode(selections: [
|
||||||
|
FieldNode(
|
||||||
|
name: NameNode(value: '__typename'),
|
||||||
|
alias: null,
|
||||||
|
arguments: [],
|
||||||
|
directives: [],
|
||||||
|
selectionSet: null),
|
||||||
|
InlineFragmentNode(
|
||||||
|
typeCondition: TypeConditionNode(
|
||||||
|
on: NamedTypeNode(
|
||||||
|
name: NameNode(value: 'Tree'),
|
||||||
|
isNonNull: false)),
|
||||||
|
directives: [],
|
||||||
|
selectionSet: SelectionSetNode(selections: [
|
||||||
|
FieldNode(
|
||||||
|
name: NameNode(value: 'entries'),
|
||||||
|
alias: null,
|
||||||
|
arguments: [],
|
||||||
|
directives: [],
|
||||||
|
selectionSet: SelectionSetNode(selections: [
|
||||||
|
FieldNode(
|
||||||
|
name: NameNode(value: 'type'),
|
||||||
|
alias: null,
|
||||||
|
arguments: [],
|
||||||
|
directives: [],
|
||||||
|
selectionSet: null),
|
||||||
|
FieldNode(
|
||||||
|
name: NameNode(value: 'name'),
|
||||||
|
alias: null,
|
||||||
|
arguments: [],
|
||||||
|
directives: [],
|
||||||
|
selectionSet: null)
|
||||||
|
]))
|
||||||
|
])),
|
||||||
|
InlineFragmentNode(
|
||||||
|
typeCondition: TypeConditionNode(
|
||||||
|
on: NamedTypeNode(
|
||||||
|
name: NameNode(value: 'Blob'),
|
||||||
|
isNonNull: false)),
|
||||||
|
directives: [],
|
||||||
|
selectionSet: SelectionSetNode(selections: [
|
||||||
|
FieldNode(
|
||||||
|
name: NameNode(value: 'text'),
|
||||||
|
alias: null,
|
||||||
|
arguments: [],
|
||||||
|
directives: [],
|
||||||
|
selectionSet: null)
|
||||||
|
]))
|
||||||
|
]))
|
||||||
|
]))
|
||||||
|
]))
|
||||||
|
]);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String operationName = 'github_object';
|
||||||
|
|
||||||
|
@override
|
||||||
|
final GithubObjectArguments variables;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [document, operationName, variables];
|
||||||
|
@override
|
||||||
|
GithubObject parse(Map<String, dynamic> json) => GithubObject.fromJson(json);
|
||||||
|
}
|
205
lib/graphql/github_object.g.dart
Normal file
205
lib/graphql/github_object.g.dart
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'github_object.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
GithubObject _$GithubObjectFromJson(Map<String, dynamic> json) {
|
||||||
|
return GithubObject()
|
||||||
|
..repository = json['repository'] == null
|
||||||
|
? null
|
||||||
|
: GithubObjectRepository.fromJson(
|
||||||
|
json['repository'] as Map<String, dynamic>);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectToJson(GithubObject instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'repository': instance.repository?.toJson(),
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectRepository _$GithubObjectRepositoryFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectRepository()
|
||||||
|
..object = json['object'] == null
|
||||||
|
? null
|
||||||
|
: GithubObjectGitObject.fromJson(json['object'] as Map<String, dynamic>)
|
||||||
|
..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectRepositoryToJson(
|
||||||
|
GithubObjectRepository instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'object': instance.object?.toJson(),
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectGitObject _$GithubObjectGitObjectFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectGitObject()..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectGitObjectToJson(
|
||||||
|
GithubObjectGitObject instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectTree _$GithubObjectTreeFromJson(Map<String, dynamic> json) {
|
||||||
|
return GithubObjectTree()
|
||||||
|
..entries = (json['entries'] as List)
|
||||||
|
?.map((e) => e == null
|
||||||
|
? null
|
||||||
|
: GithubObjectTreeEntry.fromJson(e as Map<String, dynamic>))
|
||||||
|
?.toList()
|
||||||
|
..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectTreeToJson(GithubObjectTree instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'entries': instance.entries?.map((e) => e?.toJson())?.toList(),
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectTreeEntry _$GithubObjectTreeEntryFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectTreeEntry()
|
||||||
|
..type = json['type'] as String
|
||||||
|
..name = json['name'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectTreeEntryToJson(
|
||||||
|
GithubObjectTreeEntry instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'type': instance.type,
|
||||||
|
'name': instance.name,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectNode _$GithubObjectNodeFromJson(Map<String, dynamic> json) {
|
||||||
|
return GithubObjectNode()..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectNodeToJson(GithubObjectNode instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectBlob _$GithubObjectBlobFromJson(Map<String, dynamic> json) {
|
||||||
|
return GithubObjectBlob()
|
||||||
|
..text = json['text'] as String
|
||||||
|
..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectBlobToJson(GithubObjectBlob instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'text': instance.text,
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectPinnableItem _$GithubObjectPinnableItemFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectPinnableItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectPinnableItemToJson(
|
||||||
|
GithubObjectPinnableItem instance) =>
|
||||||
|
<String, dynamic>{};
|
||||||
|
|
||||||
|
GithubObjectProjectOwner _$GithubObjectProjectOwnerFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectProjectOwner()..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectProjectOwnerToJson(
|
||||||
|
GithubObjectProjectOwner instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectRegistryPackageOwner _$GithubObjectRegistryPackageOwnerFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectRegistryPackageOwner()
|
||||||
|
..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectRegistryPackageOwnerToJson(
|
||||||
|
GithubObjectRegistryPackageOwner instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectRegistryPackageSearch _$GithubObjectRegistryPackageSearchFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectRegistryPackageSearch()
|
||||||
|
..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectRegistryPackageSearchToJson(
|
||||||
|
GithubObjectRegistryPackageSearch instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectSubscribable _$GithubObjectSubscribableFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectSubscribable()..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectSubscribableToJson(
|
||||||
|
GithubObjectSubscribable instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectStarrable _$GithubObjectStarrableFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectStarrable()..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectStarrableToJson(
|
||||||
|
GithubObjectStarrable instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectUniformResourceLocatable
|
||||||
|
_$GithubObjectUniformResourceLocatableFromJson(Map<String, dynamic> json) {
|
||||||
|
return GithubObjectUniformResourceLocatable()
|
||||||
|
..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectUniformResourceLocatableToJson(
|
||||||
|
GithubObjectUniformResourceLocatable instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectRepositoryInfo _$GithubObjectRepositoryInfoFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectRepositoryInfo()
|
||||||
|
..resolveType = json['__typename'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectRepositoryInfoToJson(
|
||||||
|
GithubObjectRepositoryInfo instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'__typename': instance.resolveType,
|
||||||
|
};
|
||||||
|
|
||||||
|
GithubObjectArguments _$GithubObjectArgumentsFromJson(
|
||||||
|
Map<String, dynamic> json) {
|
||||||
|
return GithubObjectArguments(
|
||||||
|
owner: json['owner'] as String,
|
||||||
|
name: json['name'] as String,
|
||||||
|
expression: json['expression'] as String,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> _$GithubObjectArgumentsToJson(
|
||||||
|
GithubObjectArguments instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'owner': instance.owner,
|
||||||
|
'name': instance.name,
|
||||||
|
'expression': instance.expression,
|
||||||
|
};
|
16
lib/graphql/github_object.graphql
Normal file
16
lib/graphql/github_object.graphql
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
query($owner: String!, $name: String!, $expression: String!) {
|
||||||
|
repository(owner: $owner, name: $name) {
|
||||||
|
object(expression: $expression) {
|
||||||
|
__typename
|
||||||
|
... on Tree {
|
||||||
|
entries {
|
||||||
|
type
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
... on Blob {
|
||||||
|
text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_highlight/theme_map.dart';
|
import 'package:flutter_highlight/theme_map.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:git_touch/graphql/github_object.dart';
|
||||||
import 'package:git_touch/models/code.dart';
|
import 'package:git_touch/models/code.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||||
@ -45,93 +46,21 @@ class ObjectScreen extends StatelessWidget {
|
|||||||
|
|
||||||
static const _iconDefaultColor = PrimerColors.blue300;
|
static const _iconDefaultColor = PrimerColors.blue300;
|
||||||
|
|
||||||
Widget _buildIcon(item) {
|
Widget _buildIcon(GithubObjectTreeEntry item) {
|
||||||
switch (item['type']) {
|
switch (item.type) {
|
||||||
case 'blob':
|
case 'blob':
|
||||||
return SetiIcon(item['name'], size: 36);
|
return SetiIcon(item.name, size: 36);
|
||||||
case 'tree':
|
case 'tree':
|
||||||
case 'commit':
|
case 'commit':
|
||||||
return Icon(
|
return Icon(
|
||||||
item['type'] == 'tree'
|
item.type == 'tree'
|
||||||
? Octicons.file_directory
|
? Octicons.file_directory
|
||||||
: Octicons.file_submodule,
|
: Octicons.file_submodule,
|
||||||
color: _iconDefaultColor,
|
color: _iconDefaultColor,
|
||||||
size: 24,
|
size: 24,
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
throw 'Should not be here';
|
return null;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String get _subQuery {
|
|
||||||
switch (type) {
|
|
||||||
case 'tree':
|
|
||||||
return '''
|
|
||||||
... on Tree {
|
|
||||||
entries {
|
|
||||||
type
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
case 'blob':
|
|
||||||
default:
|
|
||||||
return '''
|
|
||||||
... on Blob {
|
|
||||||
text
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildTree(payload) {
|
|
||||||
var entries = payload['entries'] as List;
|
|
||||||
return TableView(
|
|
||||||
hasIcon: true,
|
|
||||||
items: entries.map((item) {
|
|
||||||
return TableViewItem(
|
|
||||||
leftWidget: _buildIcon(item),
|
|
||||||
text: Text(item['name']),
|
|
||||||
screenBuilder: (_) {
|
|
||||||
if (item['type'] == 'commit') return null;
|
|
||||||
return ObjectScreen(
|
|
||||||
owner,
|
|
||||||
name,
|
|
||||||
branch,
|
|
||||||
paths: [...paths, item['name']],
|
|
||||||
type: item['type'],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildBlob(BuildContext context, payload) {
|
|
||||||
var codeProvider = Provider.of<CodeModel>(context);
|
|
||||||
switch (_extname) {
|
|
||||||
case 'md':
|
|
||||||
case 'markdown':
|
|
||||||
return Padding(
|
|
||||||
padding: CommonStyle.padding,
|
|
||||||
child: MarkdownView(payload['text'],
|
|
||||||
basePaths: [owner, name, branch, ...paths]),
|
|
||||||
);
|
|
||||||
case 'svg':
|
|
||||||
return SvgPicture.network(rawUrl);
|
|
||||||
default:
|
|
||||||
return SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: HighlightView(
|
|
||||||
payload['text'],
|
|
||||||
language: _language,
|
|
||||||
theme: themeMap[codeProvider.theme],
|
|
||||||
padding: CommonStyle.padding,
|
|
||||||
textStyle: TextStyle(
|
|
||||||
fontSize: codeProvider.fontSize.toDouble(),
|
|
||||||
fontFamily: codeProvider.fontFamilyUsed),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,41 +72,46 @@ class ObjectScreen extends StatelessWidget {
|
|||||||
return ImageViewScreen(rawUrl, title: Text(paths.last));
|
return ImageViewScreen(rawUrl, title: Text(paths.last));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RefreshStatefulScaffold(
|
return RefreshStatefulScaffold<GithubObjectGitObject>(
|
||||||
title: AppBarTitle(_path.isEmpty ? 'Files' : _path),
|
title: AppBarTitle(_path.isEmpty ? 'Files' : _path),
|
||||||
fetchData: () async {
|
fetchData: () async {
|
||||||
var data = await Provider.of<AuthModel>(context).query('''{
|
final res = await Provider.of<AuthModel>(context)
|
||||||
repository(owner: "$owner", name: "$name") {
|
.gqlClient
|
||||||
object(expression: "$_expression") {
|
.execute(GithubObjectQuery(
|
||||||
$_subQuery
|
variables: GithubObjectArguments(
|
||||||
}
|
owner: owner,
|
||||||
}
|
name: name,
|
||||||
}''');
|
expression: _expression,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
return res.data.repository.object;
|
||||||
|
|
||||||
if (type == 'tree') {
|
// if (type == 'tree') {
|
||||||
var entries = data['repository']['object']['entries'] as List;
|
// var entries = data['repository']['object']['entries'] as List;
|
||||||
entries.sort((a, b) {
|
// entries.sort((a, b) {
|
||||||
if (a['type'] == 'tree' && b['type'] == 'blob') {
|
// if (a['type'] == 'tree' && b['type'] == 'blob') {
|
||||||
return -1;
|
// return -1;
|
||||||
}
|
// }
|
||||||
if (a['type'] == 'blob' && b['type'] == 'tree') {
|
// if (a['type'] == 'blob' && b['type'] == 'tree') {
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
return 0;
|
// return 0;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
return data['repository']['object'];
|
// return data['repository']['object'];
|
||||||
},
|
},
|
||||||
actionBuilder: (data, _) {
|
actionBuilder: (data, _) {
|
||||||
switch (type) {
|
if (data == null) return null;
|
||||||
case 'blob':
|
switch (data.resolveType) {
|
||||||
|
case 'Blob':
|
||||||
|
final blob = data as GithubObjectBlob;
|
||||||
return ActionEntry(
|
return ActionEntry(
|
||||||
iconData: Octicons.settings,
|
iconData: Octicons.settings,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
Provider.of<ThemeModel>(context).pushRoute(
|
Provider.of<ThemeModel>(context).pushRoute(
|
||||||
context, (_) => CodeThemeScreen(data['text'], _language));
|
context, (_) => CodeThemeScreen(blob.text, _language));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -186,11 +120,56 @@ class ObjectScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
bodyBuilder: (data, _) {
|
bodyBuilder: (data, _) {
|
||||||
switch (type) {
|
switch (data.resolveType) {
|
||||||
case 'tree':
|
case 'Tree':
|
||||||
return _buildTree(data);
|
final tree = data as GithubObjectTree;
|
||||||
case 'blob':
|
return TableView(
|
||||||
return _buildBlob(context, data);
|
hasIcon: true,
|
||||||
|
items: tree.entries.map((item) {
|
||||||
|
return TableViewItem(
|
||||||
|
leftWidget: _buildIcon(item),
|
||||||
|
text: Text(item.name),
|
||||||
|
screenBuilder: (_) {
|
||||||
|
if (item.type == 'commit') return null;
|
||||||
|
return ObjectScreen(
|
||||||
|
owner,
|
||||||
|
name,
|
||||||
|
branch,
|
||||||
|
paths: [...paths, item.name],
|
||||||
|
type: item.type,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
case 'Blob':
|
||||||
|
final codeProvider = Provider.of<CodeModel>(context);
|
||||||
|
final text = (data as GithubObjectBlob).text;
|
||||||
|
switch (_extname) {
|
||||||
|
case 'md':
|
||||||
|
case 'markdown':
|
||||||
|
return Padding(
|
||||||
|
padding: CommonStyle.padding,
|
||||||
|
child: MarkdownView(text,
|
||||||
|
basePaths: [owner, name, branch, ...paths]),
|
||||||
|
);
|
||||||
|
case 'svg':
|
||||||
|
return SvgPicture.network(rawUrl);
|
||||||
|
default:
|
||||||
|
return SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: HighlightView(
|
||||||
|
text,
|
||||||
|
language: _language,
|
||||||
|
theme: themeMap[codeProvider.theme],
|
||||||
|
padding: CommonStyle.padding,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: codeProvider.fontSize.toDouble(),
|
||||||
|
fontFamily: codeProvider.fontFamilyUsed),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user