2020-05-17 06:20:11 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/bitbucket.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:provider/provider.dart';
|
2021-01-05 10:25:19 +01:00
|
|
|
import '../generated/l10n.dart';
|
2020-05-17 06:20:11 +02:00
|
|
|
|
|
|
|
class BbPullsScreen extends StatelessWidget {
|
|
|
|
final String owner;
|
|
|
|
final String name;
|
2021-01-06 14:17:49 +01:00
|
|
|
BbPullsScreen(this.owner, this.name);
|
2020-05-17 06:20:11 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final auth = Provider.of<AuthModel>(context);
|
|
|
|
return ListStatefulScaffold<BbPulls, String>(
|
2021-01-05 10:25:19 +01:00
|
|
|
title: AppBarTitle(S.of(context).pullRequests),
|
2020-10-06 14:52:40 +02:00
|
|
|
fetch: (nextUrl) async {
|
2020-10-04 16:10:05 +02:00
|
|
|
final res = await context.read<AuthModel>().fetchBbWithPage(
|
|
|
|
nextUrl ?? '/repositories/$owner/$name/pullrequests');
|
|
|
|
return ListPayload(
|
|
|
|
cursor: res.cursor,
|
|
|
|
hasMore: res.hasMore,
|
|
|
|
items: <BbPulls>[
|
|
|
|
for (var v in res.data) BbPulls.fromJson(v),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
2020-05-17 06:20:11 +02:00
|
|
|
itemBuilder: (v) {
|
|
|
|
int pullNumber =
|
|
|
|
int.parse(v.pullRequestLink.replaceFirst(RegExp(r'.*\/'), ''));
|
|
|
|
return IssueItem(
|
|
|
|
avatarUrl: v.author.avatarUrl,
|
|
|
|
author: v.author.displayName,
|
|
|
|
title: v.title,
|
2021-01-06 05:52:58 +01:00
|
|
|
subtitle: '#' + pullNumber.toString(),
|
2020-05-17 06:20:11 +02:00
|
|
|
commentCount: 0,
|
|
|
|
updatedAt: v.createdOn,
|
|
|
|
url: '${auth.activeAccount.domain}/$owner/$name/issues/$pullNumber',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|