git-touch-android-ios-app/lib/screens/gh_users.dart

158 lines
4.3 KiB
Dart
Raw Normal View History

2019-02-04 14:38:29 +01:00
import 'package:flutter/material.dart';
2021-01-17 15:08:32 +01:00
import 'package:git_touch/graphql/github.data.gql.dart';
import 'package:git_touch/graphql/github.req.gql.dart';
2019-09-25 11:06:36 +02:00
import 'package:git_touch/scaffolds/list_stateful.dart';
2019-09-11 13:59:47 +02:00
import 'package:git_touch/widgets/app_bar_title.dart';
2019-09-14 11:19:33 +02:00
import 'package:git_touch/widgets/user_item.dart';
2019-09-27 14:52:38 +02:00
import 'package:git_touch/models/auth.dart';
2019-09-08 14:07:35 +02:00
import 'package:provider/provider.dart';
2019-12-07 16:10:30 +01:00
2021-01-17 15:08:32 +01:00
class GhFollowers extends StatelessWidget {
final String login;
GhFollowers(this.login);
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GUserItem, String>(
title: AppBarTitle('Followers'),
fetch: (cursor) async {
final auth = context.read<AuthModel>();
final req = GFollowersReq((b) {
b.vars.login = login;
b.vars.after = cursor;
});
final res = await auth.gqlClient.request(req).first;
final p = res.data.user.followers;
return ListPayload(
cursor: p.pageInfo.endCursor,
hasMore: p.pageInfo.hasNextPage,
items: p.nodes,
);
},
itemBuilder: (p) {
return UserItem.gql(p);
},
);
}
2019-12-07 16:10:30 +01:00
}
2019-02-04 14:38:29 +01:00
2021-01-17 15:08:32 +01:00
class GhFollowing extends StatelessWidget {
2019-12-07 16:10:30 +01:00
final String login;
2021-01-17 15:08:32 +01:00
GhFollowing(this.login);
2021-01-17 15:08:32 +01:00
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GUserItem, String>(
title: AppBarTitle('Following'),
fetch: (cursor) async {
final auth = context.read<AuthModel>();
final req = GFollowingReq((b) {
b.vars.login = login;
b.vars.after = cursor;
});
final res = await auth.gqlClient.request(req).first;
final p = res.data.user.following;
return ListPayload(
cursor: p.pageInfo.endCursor,
hasMore: p.pageInfo.hasNextPage,
items: p.nodes,
);
},
itemBuilder: (p) {
return UserItem.gql(p);
},
);
}
2021-01-17 15:08:32 +01:00
}
class GhMembers extends StatelessWidget {
final String login;
GhMembers(this.login);
2021-01-17 15:08:32 +01:00
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GUserItem, String>(
title: AppBarTitle('Members'),
fetch: (cursor) async {
final auth = context.read<AuthModel>();
final req = GMembersReq((b) {
b.vars.login = login;
b.vars.after = cursor;
});
final res = await auth.gqlClient.request(req).first;
final p = res.data.organization.membersWithRole;
return ListPayload(
cursor: p.pageInfo.endCursor,
hasMore: p.pageInfo.hasNextPage,
items: p.nodes,
);
},
itemBuilder: (p) {
return UserItem.gql(p);
},
);
}
2021-01-17 15:08:32 +01:00
}
class GhWachers extends StatelessWidget {
final String owner;
final String name;
GhWachers(this.owner, this.name);
2019-02-04 14:38:29 +01:00
@override
Widget build(BuildContext context) {
2021-01-17 15:08:32 +01:00
return ListStatefulScaffold<GUserItem, String>(
title: AppBarTitle('Wachers'),
fetch: (cursor) async {
2020-10-04 16:10:05 +02:00
final auth = context.read<AuthModel>();
2021-01-17 15:08:32 +01:00
final req = GWatchersReq((b) {
b.vars.owner = owner;
b.vars.name = name;
b.vars.after = cursor;
});
final res = await auth.gqlClient.request(req).first;
final p = res.data.repository.watchers;
return ListPayload(
cursor: p.pageInfo.endCursor,
hasMore: p.pageInfo.hasNextPage,
items: p.nodes,
);
2020-10-04 16:10:05 +02:00
},
2021-01-17 15:08:32 +01:00
itemBuilder: (p) {
return UserItem.gql(p);
},
);
}
}
class GhStargazers extends StatelessWidget {
final String owner;
final String name;
GhStargazers(this.owner, this.name);
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GUserItem, String>(
title: AppBarTitle('Stargazers'),
fetch: (cursor) async {
final auth = context.read<AuthModel>();
final req = GStargazersReq((b) {
b.vars.owner = owner;
b.vars.name = name;
b.vars.after = cursor;
});
final res = await auth.gqlClient.request(req).first;
final p = res.data.repository.stargazers;
return ListPayload(
cursor: p.pageInfo.endCursor,
hasMore: p.pageInfo.hasNextPage,
items: p.nodes,
2019-12-07 16:10:30 +01:00
);
},
2021-01-17 15:08:32 +01:00
itemBuilder: (p) {
return UserItem.gql(p);
},
);
2019-02-04 14:38:29 +01:00
}
}