1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-24 23:01:18 +01:00
git-touch-android-ios-app/lib/widgets/issue_item.dart

155 lines
5.5 KiB
Dart
Raw Normal View History

2019-09-25 14:51:23 +02:00
import 'package:flutter/material.dart';
2019-11-08 11:29:08 +01:00
import 'package:git_touch/models/theme.dart';
2019-09-25 14:51:23 +02:00
import 'package:git_touch/widgets/avatar.dart';
2020-01-12 08:44:07 +01:00
import 'package:git_touch/widgets/label.dart';
2019-11-08 11:29:08 +01:00
import 'package:provider/provider.dart';
2019-09-25 14:51:23 +02:00
import 'package:timeago/timeago.dart' as timeago;
import '../utils/utils.dart';
import '../widgets/link.dart';
const issueGqlChunk = '''
number
title
updatedAt
author {
login
avatarUrl
}
repository {
owner {
login
}
name
}
labels(first: 10) {
nodes {
name
color
}
}
comments {
totalCount
}
''';
class IssueItem extends StatelessWidget {
final payload;
final bool isPullRequest;
IssueItem({this.payload, this.isPullRequest = false});
@override
Widget build(BuildContext context) {
2019-11-08 11:29:08 +01:00
final theme = Provider.of<ThemeModel>(context);
2019-09-25 14:51:23 +02:00
return Link(
2019-12-12 15:02:58 +01:00
url:
'/${payload['repository']['owner']['login']}/${payload['repository']['name']}/${isPullRequest ? 'pulls' : 'issues'}/${payload['number']}',
2019-09-25 14:51:23 +02:00
child: Container(
2019-10-02 10:09:54 +02:00
padding: CommonStyle.padding,
2019-09-25 14:51:23 +02:00
// color: payload.unread ? Colors.white : Colors.black12,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Icon(
isPullRequest
? Octicons.git_pull_request
: Octicons.issue_opened,
2019-11-08 13:23:09 +01:00
color: GithubPalette.open,
2020-01-12 08:44:07 +01:00
size: 20),
2019-09-25 14:51:23 +02:00
SizedBox(width: 6),
Expanded(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: join(SizedBox(height: 8), [
2019-10-03 05:00:59 +02:00
Text.rich(
2020-01-12 08:44:07 +01:00
TextSpan(
children: [
TextSpan(text: payload['title'] + ' '),
TextSpan(
text: '#${payload['number']}',
style: TextStyle(
2020-01-14 11:13:07 +01:00
color: theme.paletteOf(context).tertiaryText,
2020-01-14 06:33:02 +01:00
fontWeight: FontWeight.normal,
2020-01-12 08:44:07 +01:00
),
),
],
),
2019-09-25 14:51:23 +02:00
style: TextStyle(
2020-01-12 08:44:07 +01:00
fontSize: 17,
2020-01-14 11:13:07 +01:00
color: theme.paletteOf(context).text,
2019-09-25 14:51:23 +02:00
fontWeight: FontWeight.w600,
),
),
if ((payload['labels']['nodes'] as List).isNotEmpty)
Wrap(
2020-01-12 08:44:07 +01:00
spacing: 4,
runSpacing: 4,
2019-09-25 14:51:23 +02:00
children: (payload['labels']['nodes'] as List)
.map((label) {
2020-01-14 06:51:53 +01:00
return MyLabel(
2020-01-12 08:44:07 +01:00
name: label['name'],
cssColor: label['color'],
2019-09-25 14:51:23 +02:00
);
}).toList(),
),
DefaultTextStyle(
style: TextStyle(
2020-01-12 08:44:07 +01:00
fontSize: 14,
2020-01-14 11:13:07 +01:00
color: theme.paletteOf(context).secondaryText,
2020-01-12 08:44:07 +01:00
),
2019-09-25 14:51:23 +02:00
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// FIXME: Deleted user
if (payload['author'] != null) ...[
2020-01-14 06:33:02 +01:00
Avatar(
size: AvatarSize.extraSmall,
url: payload['author']['avatarUrl'],
linkUrl: '/' + payload['author']['login'],
2019-09-25 14:51:23 +02:00
),
SizedBox(width: 4),
Text(
payload['author']['login'],
2020-01-12 08:44:07 +01:00
style: TextStyle(fontWeight: FontWeight.w600),
2019-09-25 14:51:23 +02:00
),
],
Text(' opened ' +
timeago.format(
DateTime.parse(payload['updatedAt']))),
if (payload['comments']['totalCount'] > 0) ...[
Expanded(child: SizedBox()),
Icon(Octicons.comment,
2020-01-12 08:44:07 +01:00
size: 14,
2020-01-14 11:13:07 +01:00
color:
theme.paletteOf(context).secondaryText),
2020-01-12 08:44:07 +01:00
SizedBox(width: 3),
2019-09-25 14:51:23 +02:00
Text(numberFormat
.format(payload['comments']['totalCount']))
],
],
),
)
]),
),
),
),
// Column(
// children: <Widget>[
// Icon(Octicons.check, color: Colors.black45),
// Icon(Octicons.unmute, color: Colors.black45)
// ],
// ),
],
),
],
),
),
);
}
}