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

48 lines
1.6 KiB
Dart
Raw Normal View History

2022-09-17 14:35:45 +02:00
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/S.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';
class BbPullsScreen extends StatelessWidget {
final String owner;
final String name;
2022-09-06 18:28:12 +02:00
const BbPullsScreen(this.owner, this.name);
@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),
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
],
);
},
itemBuilder: (v) {
int pullNumber =
2021-05-16 09:16:35 +02:00
int.parse(v.pullRequestLink!.replaceFirst(RegExp(r'.*\/'), ''));
return IssueItem(
2021-05-16 09:16:35 +02:00
avatarUrl: v.author!.avatarUrl,
author: v.author!.displayName,
title: v.title,
2022-09-06 18:28:12 +02:00
subtitle: '#$pullNumber',
commentCount: 0,
updatedAt: v.createdOn,
url:
2021-05-16 09:16:35 +02:00
'${auth.activeAccount!.domain}/$owner/$name/pull-requests/$pullNumber',
);
},
);
}
}