2020-01-28 16:43:47 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-12 05:46:42 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2020-01-28 16:43:47 +01:00
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/gitlab.dart';
|
|
|
|
import 'package:git_touch/scaffolds/list_stateful.dart';
|
|
|
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
2022-09-12 05:46:42 +02:00
|
|
|
import 'package:git_touch/widgets/hex_color_tag.dart';
|
2020-01-28 16:43:47 +01:00
|
|
|
import 'package:git_touch/widgets/issue_item.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
2020-02-07 15:26:37 +01:00
|
|
|
class GlMergeRequestsScreen extends StatelessWidget {
|
2020-01-28 16:43:47 +01:00
|
|
|
final String id;
|
2021-05-16 09:16:35 +02:00
|
|
|
final String? prefix;
|
2022-09-06 18:28:12 +02:00
|
|
|
const GlMergeRequestsScreen(this.id, {this.prefix});
|
2020-01-28 16:43:47 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListStatefulScaffold<GitlabIssue, int>(
|
2021-05-16 09:16:35 +02:00
|
|
|
title: AppBarTitle(AppLocalizations.of(context)!.mergeRequests),
|
2020-10-06 14:52:40 +02:00
|
|
|
fetch: (page) async {
|
2020-10-04 16:10:05 +02:00
|
|
|
page = page ?? 1;
|
|
|
|
final res = await context.read<AuthModel>().fetchGitlabWithPage(
|
|
|
|
'/projects/$id/merge_requests?state=opened&page=$page');
|
|
|
|
return ListPayload(
|
|
|
|
cursor: res.cursor,
|
|
|
|
hasMore: res.hasMore,
|
|
|
|
items:
|
|
|
|
(res.data as List).map((v) => GitlabIssue.fromJson(v)).toList(),
|
|
|
|
);
|
|
|
|
},
|
2020-01-28 16:43:47 +01:00
|
|
|
itemBuilder: (p) => IssueItem(
|
|
|
|
isPr: true,
|
2021-05-16 09:16:35 +02:00
|
|
|
author: p.author!.username,
|
|
|
|
avatarUrl: p.author!.avatarUrl,
|
2020-01-28 16:43:47 +01:00
|
|
|
commentCount: p.userNotesCount,
|
2022-09-06 18:28:12 +02:00
|
|
|
subtitle: '#${p.iid}',
|
2020-01-28 16:43:47 +01:00
|
|
|
title: p.title,
|
|
|
|
updatedAt: p.updatedAt,
|
2021-05-16 09:16:35 +02:00
|
|
|
labels: p.labels!.isEmpty
|
2020-01-28 16:43:47 +01:00
|
|
|
? null
|
|
|
|
: Wrap(spacing: 4, runSpacing: 4, children: [
|
2021-05-16 09:16:35 +02:00
|
|
|
for (var label in p.labels!)
|
2022-09-12 05:46:42 +02:00
|
|
|
HexColorTag(name: label, color: '#428BCA')
|
2020-01-28 16:43:47 +01:00
|
|
|
]),
|
2020-02-01 05:35:56 +01:00
|
|
|
// url: '/gitlab/projects/${p.projectId}/merge_requests/${p.iid}',
|
|
|
|
url: '$prefix/merge_requests/${p.iid}', // TODO:
|
2020-01-28 16:43:47 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|