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

147 lines
4.2 KiB
Dart
Raw Normal View History

2022-09-23 20:22:17 +02:00
import 'package:antd_mobile/antd_mobile.dart';
2022-09-17 14:35:45 +02:00
import 'package:flutter/widgets.dart';
2022-10-07 18:55:47 +02:00
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
2022-09-23 20:22:17 +02:00
import 'package:git_touch/utils/utils.dart';
2019-09-25 14:51:23 +02:00
import 'package:git_touch/widgets/avatar.dart';
import 'package:timeago/timeago.dart' as timeago;
2022-09-17 14:35:45 +02:00
2019-09-25 14:51:23 +02:00
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 {
2022-09-06 18:28:12 +02:00
const IssueItem({
2021-05-16 09:16:35 +02:00
required this.url,
required this.subtitle,
required this.title,
required this.commentCount,
required this.updatedAt,
required this.avatarUrl,
required this.author,
2020-01-28 16:19:05 +01:00
this.labels,
this.isPr = false,
});
2022-09-21 18:28:21 +02:00
final String? url;
final String subtitle;
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
@override
Widget build(BuildContext context) {
2022-09-23 20:22:17 +02:00
return AntListItem(
arrow: null,
onClick: () {
context.pushUrl(url!);
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Icon(isPr ? Octicons.git_pull_request : Octicons.issue_opened,
color: GithubPalette.open, size: 20),
const SizedBox(width: 6),
Expanded(
child: Column(
2019-09-25 14:51:23 +02:00
crossAxisAlignment: CrossAxisAlignment.start,
2022-10-07 18:46:34 +02:00
children: [
2022-09-23 20:22:17 +02:00
Text.rich(
TextSpan(
children: [
TextSpan(text: '$title '),
TextSpan(
text: subtitle,
style: TextStyle(
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorWeak,
2022-09-23 20:22:17 +02:00
fontWeight: FontWeight.normal,
2019-09-25 14:51:23 +02:00
),
2022-09-23 20:22:17 +02:00
),
],
),
style: TextStyle(
fontSize: 17,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorText,
2022-09-23 20:22:17 +02:00
fontWeight: FontWeight.w600,
2019-09-25 14:51:23 +02:00
),
),
2022-09-23 20:22:17 +02:00
if (labels != null) labels!,
DefaultTextStyle(
style: TextStyle(
fontSize: 14,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorTextSecondary,
2022-09-23 20:22:17 +02:00
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// FIXME: Deleted user
if (avatarUrl != null) ...[
Avatar(
size: AvatarSize.extraSmall,
url: avatarUrl,
),
const SizedBox(width: 4),
Text(
author!,
style: const TextStyle(fontWeight: FontWeight.w600),
),
],
Expanded(
child: Text(
' opened ${timeago.format(updatedAt!)}',
style: TextStyle(
fontSize: 17,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorTextSecondary,
2022-09-23 20:22:17 +02:00
),
overflow: TextOverflow.ellipsis,
)),
if (commentCount! > 0) ...[
const Expanded(child: SizedBox()),
Icon(Octicons.comment,
2022-09-24 20:46:37 +02:00
size: 14,
color: AntTheme.of(context).colorTextSecondary),
2022-09-23 20:22:17 +02:00
const SizedBox(width: 3),
Text(numberFormat.format(commentCount))
],
],
),
)
2022-10-07 18:46:34 +02:00
].withSeparator(const SizedBox(height: 8)),
2019-09-25 14:51:23 +02:00
),
2022-09-23 20:22:17 +02:00
),
// Column(
// children: <Widget>[
// Icon(Octicons.check, color: Colors.black45),
// Icon(Octicons.unmute, color: Colors.black45)
// ],
// ),
],
2019-09-25 14:51:23 +02:00
),
);
}
}