diff --git a/lib/gql_github/commits.graphql b/lib/gql_github/commits.graphql index f7633e9..4932f17 100644 --- a/lib/gql_github/commits.graphql +++ b/lib/gql_github/commits.graphql @@ -1,9 +1,8 @@ -# import './fragments.graphql' - fragment CommitsRefCommit on Commit { history(first: 30, after: $after) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { url diff --git a/lib/gql_github/fragments.graphql b/lib/gql_github/fragments.graphql deleted file mode 100644 index e725af6..0000000 --- a/lib/gql_github/fragments.graphql +++ /dev/null @@ -1,41 +0,0 @@ -fragment PageInfoParts on PageInfo { - hasNextPage - endCursor -} - -fragment RepoParts on Repository { - owner { - login - avatarUrl - } - name - description - isPrivate - isFork - stargazers { - totalCount - } - forks { - totalCount - } - primaryLanguage { - color - name - } -} - -fragment UserParts on User { - login - name - avatarUrl - location - createdAt -} - -fragment OrgParts on Organization { - login - name - avatarUrl - location - createdAt -} diff --git a/lib/gql_github/gists.graphql b/lib/gql_github/gists.graphql index 993bd23..224fe93 100644 --- a/lib/gql_github/gists.graphql +++ b/lib/gql_github/gists.graphql @@ -1,10 +1,9 @@ -# import './fragments.graphql' - query Gists($login: String!, $after: String) { user(login: $login) { gists(first: 30, after: $after) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { name diff --git a/lib/gql_github/issues.graphql b/lib/gql_github/issues.graphql index 27d73c1..9225374 100644 --- a/lib/gql_github/issues.graphql +++ b/lib/gql_github/issues.graphql @@ -1,5 +1,3 @@ -# import './fragments.graphql' - query Issues($owner: String!, $name: String!, $cursor: String) { repository(owner: $owner, name: $name) { issues( @@ -9,7 +7,8 @@ query Issues($owner: String!, $name: String!, $cursor: String) { after: $cursor ) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { number @@ -43,7 +42,8 @@ query Pulls($owner: String!, $name: String!, $cursor: String) { after: $cursor ) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { number diff --git a/lib/gql_github/releases.graphql b/lib/gql_github/releases.graphql index 8f97343..5ae899e 100644 --- a/lib/gql_github/releases.graphql +++ b/lib/gql_github/releases.graphql @@ -1,5 +1,3 @@ -# import './fragments.graphql' - query Releases($name: String!, $owner: String!, $cursor: String) { repository(name: $name, owner: $owner) { releases( @@ -8,7 +6,8 @@ query Releases($name: String!, $owner: String!, $cursor: String) { orderBy: { field: CREATED_AT, direction: DESC } ) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { tagName diff --git a/lib/gql_github/repos.graphql b/lib/gql_github/repos.graphql index f733c67..f9fef77 100644 --- a/lib/gql_github/repos.graphql +++ b/lib/gql_github/repos.graphql @@ -1,9 +1,25 @@ -# import './fragments.graphql' - -fragment RepoPartsWithTime on Repository { - ...RepoParts +fragment RepoParts on Repository { + owner { + login + avatarUrl + } + name + description + isPrivate + isFork + stargazers { + totalCount + } + forks { + totalCount + } + primaryLanguage { + color + name + } updatedAt } + query Repos($login: String!, $after: String) { repositoryOwner(login: $login) { repositories( @@ -12,14 +28,16 @@ query Repos($login: String!, $after: String) { orderBy: { field: UPDATED_AT, direction: DESC } ) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { - ...RepoPartsWithTime + ...RepoParts } } } } + query Stars($login: String!, $after: String) { user(login: $login) { starredRepositories( @@ -28,10 +46,11 @@ query Stars($login: String!, $after: String) { orderBy: { field: STARRED_AT, direction: DESC } ) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { - ...RepoPartsWithTime + ...RepoParts } } } diff --git a/lib/gql_github/user.graphql b/lib/gql_github/user.graphql index f9ac8e8..7ac1316 100644 --- a/lib/gql_github/user.graphql +++ b/lib/gql_github/user.graphql @@ -1,7 +1,30 @@ -# import './fragments.graphql' +fragment RepoParts on Repository { + owner { + login + avatarUrl + } + name + description + isPrivate + isFork + stargazers { + totalCount + } + forks { + totalCount + } + primaryLanguage { + color + name + } +} -fragment UserPartsFull on User { - ...UserParts +fragment UserParts on User { + login + name + avatarUrl + location + createdAt company bio url @@ -57,13 +80,13 @@ fragment UserPartsFull on User { query Viewer { viewer { - ...UserPartsFull + ...UserParts } } query User($login: String!) { user(login: $login) { - ...UserPartsFull + ...UserParts } organization(login: $login) { login diff --git a/lib/gql_github/users.graphql b/lib/gql_github/users.graphql index cdc7187..b713116 100644 --- a/lib/gql_github/users.graphql +++ b/lib/gql_github/users.graphql @@ -1,10 +1,25 @@ -# import './fragments.graphql' +fragment UserParts on User { + login + name + avatarUrl + location + createdAt +} + +fragment OrgParts on Organization { + login + name + avatarUrl + location + createdAt +} query Followers($login: String!, $after: String) { user(login: $login) { followers(first: 30, after: $after) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { ...UserParts @@ -17,7 +32,8 @@ query Following($login: String!, $after: String) { user(login: $login) { following(first: 30, after: $after) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { ...UserParts @@ -30,7 +46,8 @@ query Orgs($login: String!, $after: String) { user(login: $login) { organizations(first: 30, after: $after) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { ...OrgParts @@ -43,7 +60,8 @@ query Members($login: String!, $after: String) { organization(login: $login) { membersWithRole(first: 30, after: $after) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { ...UserParts @@ -56,7 +74,8 @@ query Watchers($owner: String!, $name: String!, $after: String) { repository(owner: $owner, name: $name) { watchers(first: 30, after: $after) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { ...UserParts @@ -73,7 +92,8 @@ query Stargazers($owner: String!, $name: String!, $after: String) { orderBy: { field: STARRED_AT, direction: DESC } ) { pageInfo { - ...PageInfoParts + hasNextPage + endCursor } nodes { ...UserParts diff --git a/lib/screens/gh_repos.dart b/lib/screens/gh_repos.dart index 469b3c7..f3312d8 100644 --- a/lib/screens/gh_repos.dart +++ b/lib/screens/gh_repos.dart @@ -14,7 +14,7 @@ class GhRepos extends StatelessWidget { @override Widget build(BuildContext context) { - return ListStatefulScaffold( + return ListStatefulScaffold( title: const AppBarTitle('Repositories'), fetch: (cursor) async { final auth = context.read(); @@ -44,7 +44,7 @@ class GhStars extends StatelessWidget { @override Widget build(BuildContext context) { - return ListStatefulScaffold( + return ListStatefulScaffold( title: const AppBarTitle('Stars'), fetch: (cursor) async { final auth = context.read(); diff --git a/lib/screens/gh_user.dart b/lib/screens/gh_user.dart index abce911..7490070 100644 --- a/lib/screens/gh_user.dart +++ b/lib/screens/gh_user.dart @@ -2,7 +2,6 @@ import 'package:antd_mobile/antd_mobile.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/S.dart'; -import 'package:git_touch/gql_github/__generated__/fragments.data.gql.dart'; import 'package:git_touch/gql_github/__generated__/user.data.gql.dart'; import 'package:git_touch/gql_github/__generated__/user.req.gql.dart'; import 'package:git_touch/models/auth.dart'; @@ -35,7 +34,19 @@ class _Repos extends StatelessWidget { header: Text(title), mode: AntListMode.card, children: [ - for (final v in repos!) RepositoryItem.gql(v), + for (final v in repos!) + RepositoryItem.gh( + owner: v.owner.login, + avatarUrl: v.owner.avatarUrl, + name: v.name, + description: v.description, + starCount: v.stargazers.totalCount, + forkCount: v.forks.totalCount, + primaryLanguageName: v.primaryLanguage?.name, + primaryLanguageColor: v.primaryLanguage?.color, + isPrivate: v.isPrivate, + isFork: v.isFork, + ), ], ); } @@ -43,7 +54,7 @@ class _Repos extends StatelessWidget { class _User extends StatelessWidget { const _User(this.p, {this.isViewer = false, this.rightWidgets = const []}); - final GUserPartsFull p; + final GUserParts p; final bool isViewer; final List rightWidgets; @@ -203,7 +214,7 @@ class GhViewerScreen extends StatelessWidget { @override Widget build(BuildContext context) { final auth = Provider.of(context); - return RefreshStatefulScaffold( + return RefreshStatefulScaffold( fetch: () async { final req = GViewerReq(); final res = await auth.gqlClient.request(req).first; diff --git a/lib/screens/gh_users.dart b/lib/screens/gh_users.dart index c426bd5..4117bdd 100644 --- a/lib/screens/gh_users.dart +++ b/lib/screens/gh_users.dart @@ -1,5 +1,5 @@ import 'package:flutter/widgets.dart'; -import 'package:git_touch/gql_github/__generated__/fragments.data.gql.dart'; +import 'package:git_touch/gql_github/__generated__/users.data.gql.dart'; import 'package:git_touch/gql_github/__generated__/users.req.gql.dart'; import 'package:git_touch/models/auth.dart'; import 'package:git_touch/scaffolds/list_stateful.dart'; diff --git a/lib/widgets/repository_item.dart b/lib/widgets/repository_item.dart index ca3254b..6ca532d 100644 --- a/lib/widgets/repository_item.dart +++ b/lib/widgets/repository_item.dart @@ -2,7 +2,7 @@ import 'package:antd_mobile/antd_mobile.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/widgets.dart'; import 'package:from_css_color/from_css_color.dart'; -import 'package:git_touch/gql_github/__generated__/fragments.data.gql.dart'; +import 'package:git_touch/gql_github/__generated__/repos.data.gql.dart'; import 'package:git_touch/models/bitbucket.dart'; import 'package:git_touch/models/gitlab.dart'; import 'package:git_touch/models/gogs.dart'; diff --git a/lib/widgets/user_item.dart b/lib/widgets/user_item.dart index adaa6f4..1af55ea 100644 --- a/lib/widgets/user_item.dart +++ b/lib/widgets/user_item.dart @@ -1,6 +1,6 @@ import 'package:antd_mobile/antd_mobile.dart'; import 'package:flutter/widgets.dart'; -import 'package:git_touch/gql_github/__generated__/fragments.data.gql.dart'; +import 'package:git_touch/gql_github/__generated__/users.data.gql.dart'; import 'package:git_touch/models/theme.dart'; import 'package:git_touch/utils/utils.dart'; import 'package:git_touch/widgets/avatar.dart';