1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-20 12:13:31 +01:00
git-touch-android-ios-app/lib/screens/gitlab/issue.dart

86 lines
2.8 KiB
Dart
Raw Normal View History

2019-11-01 18:12:17 +01:00
import 'package:flutter/material.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/avatar.dart';
import 'package:git_touch/widgets/markdown_view.dart';
import 'package:provider/provider.dart';
import 'package:git_touch/models/auth.dart';
import 'package:timeago/timeago.dart' as timeago;
class GitlabIssueScreen extends StatelessWidget {
final int projectId;
final int issueIid;
final bool isMr;
GitlabIssueScreen(this.projectId, this.issueIid, {this.isMr});
@override
Widget build(BuildContext context) {
return RefreshStatefulScaffold(
title: Text('Issue #$issueIid'),
fetchData: () async {
final type = isMr ? 'merge_requests' : 'issues';
final items = await Future.wait([
Provider.of<AuthModel>(context)
.fetchGitlab('/projects/$projectId/$type/$issueIid'),
Provider.of<AuthModel>(context)
.fetchGitlab('/projects/$projectId/$type/$issueIid/notes'),
Provider.of<AuthModel>(context)
.fetchGitlab('/projects/$projectId/$type/$issueIid/award_emoji'),
]);
return items;
},
2019-11-02 13:54:23 +01:00
bodyBuilder: (data, _) {
final issue = data[0];
final notes = data[1] as List;
final emoji = data[2];
2019-11-01 18:12:17 +01:00
return Column(
children: <Widget>[
Container(
padding: CommonStyle.padding,
child: Column(
children: <Widget>[
2019-11-02 13:54:23 +01:00
Text(issue['title']),
2019-11-01 18:12:17 +01:00
Row(
children: <Widget>[
2019-11-02 13:54:23 +01:00
Avatar.medium(url: issue['author']['avatar_url']),
2019-11-01 18:12:17 +01:00
Expanded(
2019-11-02 13:54:23 +01:00
child: Text(issue['description']),
2019-11-01 18:12:17 +01:00
),
],
),
2019-11-02 13:54:23 +01:00
Text(timeago.format(DateTime.parse(issue['created_at'])))
2019-11-01 18:12:17 +01:00
],
),
),
CommonStyle.border,
Column(
children: notes.map((note) {
return Container(
padding: CommonStyle.padding,
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Avatar.medium(url: note['author']['avatar_url']),
Expanded(
child: Column(
children: <Widget>[Text(note['author']['name'])],
),
)
],
),
MarkdownView(note['body']),
],
),
);
}).toList(),
)
],
);
},
);
}
}