1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-17 02:38:39 +01:00

feat(gitlab): mrs screen

This commit is contained in:
Rongjian Zhang 2020-01-28 23:43:47 +08:00
parent 2c9951be7b
commit 4bf049a2e4
2 changed files with 57 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import 'package:git_touch/screens/gitlab_blob.dart';
import 'package:git_touch/screens/gitlab_commits.dart';
import 'package:git_touch/screens/gitlab_issue.dart';
import 'package:git_touch/screens/gitlab_issues.dart';
import 'package:git_touch/screens/gitlab_merge_requests.dart';
import 'package:git_touch/screens/gitlab_project.dart';
import 'package:git_touch/screens/gitlab_tree.dart';
import 'package:git_touch/screens/gitlab_user.dart';
@ -71,6 +72,7 @@ void main() async {
gitlabProjectRouter,
gitlabIssueRouter,
gitlabIssuesRouter,
gitlabMergeRequestsRouter,
gitlabCommitsRouter,
loginRouter,
settingsRouter,

View File

@ -0,0 +1,55 @@
import 'package:flutter/material.dart';
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/utils/utils.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';
final gitlabMergeRequestsRouter = RouterScreen(
'/gitlab/projects/:id/merge_requests',
(context, params) => GitlabMergeRequestsScreen(params['id'].first));
class GitlabMergeRequestsScreen extends StatelessWidget {
final String id;
GitlabMergeRequestsScreen(this.id);
Future<ListPayload<GitlabIssue, int>> _query(BuildContext context,
[int page = 1]) async {
final res = await Provider.of<AuthModel>(context)
.fetchGitlab('/projects/$id/merge_requests?page=$page');
return ListPayload(
cursor: page + 1,
hasMore: true, // TODO:
items: (res as List).map((v) => GitlabIssue.fromJson(v)).toList(),
);
}
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GitlabIssue, int>(
title: AppBarTitle('Merge Requests'),
onRefresh: () => _query(context),
onLoadMore: (cursor) => _query(context, cursor),
itemBuilder: (p) => IssueItem(
isPr: true,
author: p.author.username,
avatarUrl: p.author.avatarUrl,
commentCount: p.userNotesCount,
number: p.iid,
title: p.title,
updatedAt: p.updatedAt,
labels: p.labels.isEmpty
? null
: Wrap(spacing: 4, runSpacing: 4, children: [
for (var label in p.labels)
MyLabel(name: label, cssColor: '#428BCA')
]),
url: '/gitlab/projects/${p.projectId}/merge_requests/${p.iid}',
),
);
}
}