2022-09-17 14:35:45 +02:00
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2020-05-17 06:20:11 +02:00
|
|
|
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';
|
|
|
|
|
|
|
|
class BbPullsScreen extends StatelessWidget {
|
|
|
|
final String owner;
|
|
|
|
final String name;
|
2022-09-06 18:28:12 +02:00
|
|
|
const BbPullsScreen(this.owner, this.name);
|
2020-05-17 06:20:11 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final auth = Provider.of<AuthModel>(context);
|
2021-05-16 09:16:35 +02:00
|
|
|
return ListStatefulScaffold<BbPulls, String?>(
|
|
|
|
title: AppBarTitle(AppLocalizations.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>[
|
2021-06-13 20:13:11 +02:00
|
|
|
for (var v in res.items) BbPulls.fromJson(v),
|
2020-10-04 16:10:05 +02:00
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
2020-05-17 06:20:11 +02:00
|
|
|
itemBuilder: (v) {
|
|
|
|
int pullNumber =
|
2021-05-16 09:16:35 +02:00
|
|
|
int.parse(v.pullRequestLink!.replaceFirst(RegExp(r'.*\/'), ''));
|
2020-05-17 06:20:11 +02:00
|
|
|
return IssueItem(
|
2021-05-16 09:16:35 +02:00
|
|
|
avatarUrl: v.author!.avatarUrl,
|
|
|
|
author: v.author!.displayName,
|
2020-05-17 06:20:11 +02:00
|
|
|
title: v.title,
|
2022-09-06 18:28:12 +02:00
|
|
|
subtitle: '#$pullNumber',
|
2020-05-17 06:20:11 +02:00
|
|
|
commentCount: 0,
|
|
|
|
updatedAt: v.createdOn,
|
2021-02-27 05:25:58 +01:00
|
|
|
url:
|
2021-05-16 09:16:35 +02:00
|
|
|
'${auth.activeAccount!.domain}/$owner/$name/pull-requests/$pullNumber',
|
2020-05-17 06:20:11 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|