mirror of
https://github.com/git-touch/git-touch
synced 2025-01-27 14:19:24 +01:00
feat: users' star repos
This commit is contained in:
parent
ab755005b7
commit
813a95666e
@ -7,8 +7,9 @@ import '../widgets/repo_item.dart';
|
||||
/// Repos of user
|
||||
class ReposScreen extends StatefulWidget {
|
||||
final String login;
|
||||
final bool star;
|
||||
|
||||
ReposScreen(this.login);
|
||||
ReposScreen({this.login, this.star = false});
|
||||
|
||||
@override
|
||||
_ReposScreenState createState() => _ReposScreenState();
|
||||
@ -19,10 +20,13 @@ class _ReposScreenState extends State<ReposScreen> {
|
||||
|
||||
Future<ListPayload> _queryRepos([String cursor]) async {
|
||||
var cursorChunk = cursor == null ? '' : ', after: "$cursor"';
|
||||
var resouce = widget.star ? 'starredRepositories' : 'repositories';
|
||||
var fieldOrderBy = widget.star ? 'STARRED_AT' : 'UPDATED_AT';
|
||||
|
||||
var data = await SettingsProvider.of(context).query('''
|
||||
{
|
||||
user(login: "$login") {
|
||||
repositories(first: $pageSize$cursorChunk, orderBy: {field: UPDATED_AT, direction: DESC}) {
|
||||
$resouce(first: $pageSize$cursorChunk, orderBy: {field: $fieldOrderBy, direction: DESC}) {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
@ -34,7 +38,7 @@ class _ReposScreenState extends State<ReposScreen> {
|
||||
}
|
||||
}
|
||||
''');
|
||||
var repo = data["user"]["repositories"];
|
||||
var repo = data["user"][resouce];
|
||||
|
||||
return ListPayload(
|
||||
cursor: repo["pageInfo"]["endCursor"],
|
||||
|
@ -185,12 +185,14 @@ class _UserScreenState extends State<UserScreen> {
|
||||
EntryItem(
|
||||
count: payload['repositories']['totalCount'],
|
||||
text: 'Repositories',
|
||||
screenBuilder: (context) => ReposScreen(widget.login),
|
||||
screenBuilder: (context) =>
|
||||
ReposScreen(login: widget.login),
|
||||
),
|
||||
EntryItem(
|
||||
count: payload['starredRepositories']['totalCount'],
|
||||
text: 'Stars',
|
||||
screenBuilder: (context) => ReposScreen(widget.login),
|
||||
screenBuilder: (context) =>
|
||||
ReposScreen(login: widget.login, star: true),
|
||||
),
|
||||
EntryItem(
|
||||
count: payload['followers']['totalCount'],
|
||||
|
@ -33,7 +33,7 @@ class RepoItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
item['name'],
|
||||
item['owner']['login'] + '/' + item['name'],
|
||||
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 15),
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(top: 6)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user