git-touch-android-ios-app/lib/widgets/issue_item.dart

159 lines
5.0 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';
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 = '''
2020-01-28 16:19:05 +01:00
url
2019-09-25 14:51:23 +02:00
number
title
updatedAt
author {
login
avatarUrl
}
repository {
owner {
login
}
name
}
labels(first: 10) {
nodes {
name
color
}
}
comments {
totalCount
}
''';
class IssueItem extends StatelessWidget {
2020-01-28 16:19:05 +01:00
final String url;
final String subtitle;
2020-01-28 16:19:05 +01:00
final String title;
final int commentCount;
final DateTime updatedAt;
final String avatarUrl;
final String author;
final Widget labels;
final bool isPr;
2019-09-25 14:51:23 +02:00
2020-01-28 16:19:05 +01:00
IssueItem({
@required this.url,
@required this.subtitle,
2020-01-28 16:19:05 +01:00
@required this.title,
@required this.commentCount,
@required this.updatedAt,
@required this.avatarUrl,
@required this.author,
this.labels,
this.isPr = false,
});
2019-09-25 14:51:23 +02:00
@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(
2020-01-28 16:19:05 +01:00
url: url,
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>[
2020-01-28 16:19:05 +01:00
Icon(isPr ? Octicons.git_pull_request : Octicons.issue_opened,
color: GithubPalette.open, 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: [
2020-01-28 16:19:05 +01:00
TextSpan(text: '$title '),
2020-01-12 08:44:07 +01:00
TextSpan(
text: '$subtitle',
2020-01-12 08:44:07 +01:00
style: TextStyle(
2020-01-27 08:11:51 +01:00
color: theme.palette.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-27 08:11:51 +01:00
color: theme.palette.text,
2019-09-25 14:51:23 +02:00
fontWeight: FontWeight.w600,
),
),
2020-01-28 16:19:05 +01:00
if (labels != null) labels,
2019-09-25 14:51:23 +02:00
DefaultTextStyle(
style: TextStyle(
2020-01-12 08:44:07 +01:00
fontSize: 14,
2020-01-27 08:11:51 +01:00
color: theme.palette.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
2020-01-28 16:19:05 +01:00
if (avatarUrl != null) ...[
2020-01-14 06:33:02 +01:00
Avatar(
size: AvatarSize.extraSmall,
2020-01-28 16:19:05 +01:00
url: avatarUrl,
2019-09-25 14:51:23 +02:00
),
SizedBox(width: 4),
Text(
2020-01-28 16:19:05 +01:00
author,
2020-01-12 08:44:07 +01:00
style: TextStyle(fontWeight: FontWeight.w600),
2019-09-25 14:51:23 +02:00
),
],
2021-01-06 07:57:31 +01:00
Expanded(
child: Text(
' opened ' + timeago.format(updatedAt),
style: TextStyle(
fontSize: 17,
color: theme.palette.secondaryText,
),
overflow: TextOverflow.ellipsis,
)),
2020-01-28 16:19:05 +01:00
if (commentCount > 0) ...[
2019-09-25 14:51:23 +02:00
Expanded(child: SizedBox()),
Icon(Octicons.comment,
2020-01-12 08:44:07 +01:00
size: 14,
2020-01-27 08:11:51 +01:00
color: theme.palette.secondaryText),
2020-01-12 08:44:07 +01:00
SizedBox(width: 3),
2020-01-28 16:19:05 +01:00
Text(numberFormat.format(commentCount))
2019-09-25 14:51:23 +02:00
],
],
),
)
]),
),
),
),
// Column(
// children: <Widget>[
// Icon(Octicons.check, color: Colors.black45),
// Icon(Octicons.unmute, color: Colors.black45)
// ],
// ),
],
),
],
),
),
);
}
}