2020-01-28 16:19:05 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:git_touch/graphql/gh.dart';
|
|
|
|
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-01-05 10:25:19 +01:00
|
|
|
import '../generated/l10n.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) {
|
|
|
|
return ListStatefulScaffold<GhPullsPullRequest, String>(
|
2021-01-05 10:25:19 +01:00
|
|
|
title: AppBarTitle(S.of(context).pullRequests),
|
2020-10-06 14:52:40 +02:00
|
|
|
fetch: (cursor) async {
|
2020-10-04 16:10:05 +02:00
|
|
|
final res =
|
|
|
|
await context.read<AuthModel>().gqlClient.execute(GhPullsQuery(
|
|
|
|
variables: GhPullsArguments(
|
|
|
|
owner: owner,
|
|
|
|
name: name,
|
|
|
|
cursor: cursor,
|
|
|
|
)));
|
|
|
|
final pulls = res.data.repository.pullRequests;
|
|
|
|
return ListPayload(
|
|
|
|
cursor: pulls.pageInfo.endCursor,
|
|
|
|
hasMore: pulls.pageInfo.hasNextPage,
|
|
|
|
items: pulls.nodes,
|
|
|
|
);
|
|
|
|
},
|
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,
|
|
|
|
labels: p.labels.nodes.isEmpty
|
|
|
|
? null
|
|
|
|
: Wrap(spacing: 4, runSpacing: 4, children: [
|
|
|
|
for (var label in p.labels.nodes)
|
|
|
|
MyLabel(name: label.name, cssColor: label.color)
|
|
|
|
]),
|
|
|
|
url:
|
2020-05-12 17:31:30 +02:00
|
|
|
'/github/${p.repository.owner.login}/${p.repository.name}/pull/${p.number}',
|
2020-01-28 16:19:05 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|