2021-05-16 09:16:35 +02:00
|
|
|
import 'package:ferry/ferry.dart';
|
2020-01-28 16:19:05 +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';
|
2021-05-16 09:16:35 +02:00
|
|
|
import 'package:git_touch/graphql/github.var.gql.dart';
|
2020-01-28 16:19:05 +01:00
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/scaffolds/list_stateful.dart';
|
|
|
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
|
|
|
import 'package:git_touch/widgets/issue_item.dart';
|
|
|
|
import 'package:git_touch/widgets/label.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2021-02-03 05:04:41 +01:00
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2020-01-28 16:19:05 +01:00
|
|
|
|
2020-02-07 07:17:05 +01:00
|
|
|
class GhPullsScreen extends StatelessWidget {
|
2020-01-28 16:19:05 +01:00
|
|
|
final String owner;
|
|
|
|
final String name;
|
2020-02-07 07:17:05 +01:00
|
|
|
GhPullsScreen(this.owner, this.name);
|
2020-01-28 16:19:05 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-01-17 15:08:32 +01:00
|
|
|
return ListStatefulScaffold<GPullsData_repository_pullRequests_nodes,
|
2021-05-16 09:16:35 +02:00
|
|
|
String?>(
|
|
|
|
title: AppBarTitle(AppLocalizations.of(context)!.pullRequests),
|
2020-10-06 14:52:40 +02:00
|
|
|
fetch: (cursor) async {
|
2021-01-17 15:08:32 +01:00
|
|
|
final req = GPullsReq((b) {
|
|
|
|
b.vars.owner = owner;
|
|
|
|
b.vars.name = name;
|
|
|
|
b.vars.cursor = cursor;
|
|
|
|
});
|
2021-05-16 09:16:35 +02:00
|
|
|
final OperationResponse<GPullsData, GPullsVars?> res =
|
|
|
|
await context.read<AuthModel>().gqlClient!.request(req).first;
|
|
|
|
final pulls = res.data!.repository!.pullRequests;
|
2020-10-04 16:10:05 +02:00
|
|
|
return ListPayload(
|
|
|
|
cursor: pulls.pageInfo.endCursor,
|
|
|
|
hasMore: pulls.pageInfo.hasNextPage,
|
2021-05-16 09:16:35 +02:00
|
|
|
items: pulls.nodes!.toList(),
|
2020-10-04 16:10:05 +02:00
|
|
|
);
|
|
|
|
},
|
2020-01-28 16:19:05 +01:00
|
|
|
itemBuilder: (p) => IssueItem(
|
|
|
|
isPr: true,
|
|
|
|
author: p.author?.login,
|
|
|
|
avatarUrl: p.author?.avatarUrl,
|
|
|
|
commentCount: p.comments.totalCount,
|
2021-01-06 05:52:58 +01:00
|
|
|
subtitle: '#' + p.number.toString(),
|
2020-01-28 16:19:05 +01:00
|
|
|
title: p.title,
|
|
|
|
updatedAt: p.updatedAt,
|
2021-05-16 09:16:35 +02:00
|
|
|
labels: p.labels!.nodes!.isEmpty
|
2020-01-28 16:19:05 +01:00
|
|
|
? null
|
|
|
|
: Wrap(spacing: 4, runSpacing: 4, children: [
|
2021-05-16 09:16:35 +02:00
|
|
|
for (var label in p.labels!.nodes!)
|
2020-01-28 16:19:05 +01:00
|
|
|
MyLabel(name: label.name, cssColor: label.color)
|
|
|
|
]),
|
2021-01-17 15:08:32 +01:00
|
|
|
url: '/github/$owner/$name/pull/${p.number}',
|
2020-01-28 16:19:05 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|