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

51 lines
1.7 KiB
Dart
Raw Normal View History

2020-01-28 16:39:26 +01:00
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/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';
2020-02-07 15:26:37 +01:00
class GlIssuesScreen extends StatelessWidget {
2020-01-28 16:39:26 +01:00
final String id;
final String prefix;
2020-02-07 15:26:37 +01:00
GlIssuesScreen(this.id, {this.prefix});
2020-01-28 16:39:26 +01:00
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GitlabIssue, int>(
title: AppBarTitle('Issues'),
// TODO: create issue
fetch: (page) async {
2020-10-04 16:10:05 +02:00
page = page ?? 1;
final auth = context.read<AuthModel>();
final res = await auth.fetchGitlabWithPage(
'/projects/$id/issues?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:39:26 +01:00
itemBuilder: (p) => IssueItem(
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}/issues/${p.iid}',
url: '$prefix/issues/${p.iid}', // TODO:
2020-01-28 16:39:26 +01:00
),
);
}
}