1
0
mirror of https://github.com/git-touch/git-touch synced 2025-02-13 01:50:43 +01:00

159 lines
5.0 KiB
Dart
Raw Normal View History

2019-09-25 20:51:23 +08:00
import 'package:flutter/material.dart';
2019-11-08 18:29:08 +08:00
import 'package:git_touch/models/theme.dart';
2019-09-25 20:51:23 +08:00
import 'package:git_touch/widgets/avatar.dart';
2019-11-08 18:29:08 +08:00
import 'package:provider/provider.dart';
2019-09-25 20:51:23 +08:00
import 'package:timeago/timeago.dart' as timeago;
import '../utils/utils.dart';
import '../widgets/link.dart';
const issueGqlChunk = '''
2020-01-28 23:19:05 +08:00
url
2019-09-25 20:51:23 +08: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 23:19:05 +08:00
final String url;
final String subtitle;
2020-01-28 23:19:05 +08: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 20:51:23 +08:00
2020-01-28 23:19:05 +08:00
IssueItem({
@required this.url,
@required this.subtitle,
2020-01-28 23:19:05 +08:00
@required this.title,
@required this.commentCount,
@required this.updatedAt,
@required this.avatarUrl,
@required this.author,
this.labels,
this.isPr = false,
});
2019-09-25 20:51:23 +08:00
@override
Widget build(BuildContext context) {
2019-11-08 18:29:08 +08:00
final theme = Provider.of<ThemeModel>(context);
2019-09-25 20:51:23 +08:00
return Link(
2020-01-28 23:19:05 +08:00
url: url,
2019-09-25 20:51:23 +08:00
child: Container(
2019-10-02 16:09:54 +08:00
padding: CommonStyle.padding,
2019-09-25 20:51:23 +08:00
// color: payload.unread ? Colors.white : Colors.black12,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
2020-01-28 23:19:05 +08:00
Icon(isPr ? Octicons.git_pull_request : Octicons.issue_opened,
color: GithubPalette.open, size: 20),
2019-09-25 20:51:23 +08:00
SizedBox(width: 6),
Expanded(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: join(SizedBox(height: 8), [
2019-10-03 11:00:59 +08:00
Text.rich(
2020-01-12 15:44:07 +08:00
TextSpan(
children: [
2020-01-28 23:19:05 +08:00
TextSpan(text: '$title '),
2020-01-12 15:44:07 +08:00
TextSpan(
text: '$subtitle',
2020-01-12 15:44:07 +08:00
style: TextStyle(
2020-01-27 15:11:51 +08:00
color: theme.palette.tertiaryText,
2020-01-14 13:33:02 +08:00
fontWeight: FontWeight.normal,
2020-01-12 15:44:07 +08:00
),
),
],
),
2019-09-25 20:51:23 +08:00
style: TextStyle(
2020-01-12 15:44:07 +08:00
fontSize: 17,
2020-01-27 15:11:51 +08:00
color: theme.palette.text,
2019-09-25 20:51:23 +08:00
fontWeight: FontWeight.w600,
),
),
2020-01-28 23:19:05 +08:00
if (labels != null) labels,
2019-09-25 20:51:23 +08:00
DefaultTextStyle(
style: TextStyle(
2020-01-12 15:44:07 +08:00
fontSize: 14,
2020-01-27 15:11:51 +08:00
color: theme.palette.secondaryText,
2020-01-12 15:44:07 +08:00
),
2019-09-25 20:51:23 +08:00
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// FIXME: Deleted user
2020-01-28 23:19:05 +08:00
if (avatarUrl != null) ...[
2020-01-14 13:33:02 +08:00
Avatar(
size: AvatarSize.extraSmall,
2020-01-28 23:19:05 +08:00
url: avatarUrl,
2019-09-25 20:51:23 +08:00
),
SizedBox(width: 4),
Text(
2020-01-28 23:19:05 +08:00
author,
2020-01-12 15:44:07 +08:00
style: TextStyle(fontWeight: FontWeight.w600),
2019-09-25 20:51:23 +08:00
),
],
2021-01-06 12:27:31 +05:30
Expanded(
child: Text(
' opened ' + timeago.format(updatedAt),
style: TextStyle(
fontSize: 17,
color: theme.palette.secondaryText,
),
overflow: TextOverflow.ellipsis,
)),
2020-01-28 23:19:05 +08:00
if (commentCount > 0) ...[
2019-09-25 20:51:23 +08:00
Expanded(child: SizedBox()),
Icon(Octicons.comment,
2020-01-12 15:44:07 +08:00
size: 14,
2020-01-27 15:11:51 +08:00
color: theme.palette.secondaryText),
2020-01-12 15:44:07 +08:00
SizedBox(width: 3),
2020-01-28 23:19:05 +08:00
Text(numberFormat.format(commentCount))
2019-09-25 20:51:23 +08:00
],
],
),
)
]),
),
),
),
// Column(
// children: <Widget>[
// Icon(Octicons.check, color: Colors.black45),
// Icon(Octicons.unmute, color: Colors.black45)
// ],
// ),
],
),
],
),
),
);
}
}