1
0
mirror of https://github.com/git-touch/git-touch synced 2025-01-31 08:04:51 +01:00

feat: review comment

This commit is contained in:
Rongjian Zhang 2019-12-01 00:22:19 +08:00
parent 9f1eb49089
commit c84a503299
2 changed files with 54 additions and 25 deletions

View File

@ -9,7 +9,7 @@ import '../scaffolds/long_list.dart';
import '../widgets/timeline_item.dart'; import '../widgets/timeline_item.dart';
import '../widgets/comment_item.dart'; import '../widgets/comment_item.dart';
var reactionChunk = emojiMap.entries.map((entry) { final reactionChunk = emojiMap.entries.map((entry) {
var key = entry.key; var key = entry.key;
return ''' return '''
$key: reactions(content: $key) { $key: reactions(content: $key) {
@ -41,17 +41,11 @@ class _IssueScreenState extends State<IssueScreen> {
String get issueChunk { String get issueChunk {
var base = ''' var base = '''
id title
title closed
createdAt url
body ...CommentParts
author { ...ReactableParts
login
avatarUrl
}
closed
url
$reactionChunk
'''; ''';
if (isPullRequest) { if (isPullRequest) {
@ -71,14 +65,8 @@ commits {
var base = ''' var base = '''
__typename __typename
... on IssueComment { ... on IssueComment {
id ...CommentParts
createdAt ...ReactableParts
body
author {
login
avatarUrl
}
$reactionChunk
} }
... on Commit { ... on Commit {
committedDate committedDate
@ -240,6 +228,12 @@ __typename
author { author {
login login
} }
comments(first: 10) {
nodes {
...CommentParts
...ReactableParts
}
}
} }
... on MergedEvent { ... on MergedEvent {
createdAt createdAt
@ -277,6 +271,20 @@ __typename
} }
var data = await Provider.of<AuthModel>(context).query(''' var data = await Provider.of<AuthModel>(context).query('''
fragment CommentParts on Comment {
id
createdAt
body
author {
login
avatarUrl
}
}
fragment ReactableParts on Reactable {
$reactionChunk
}
{ {
repository(owner: "$owner", name: "$name") { repository(owner: "$owner", name: "$name") {
$resource(number: $number) { $resource(number: $number) {

View File

@ -60,7 +60,7 @@ class TimelineItem extends StatelessWidget {
case 'APPROVED': case 'APPROVED':
return TextSpan(text: ' approved these changes'); return TextSpan(text: ' approved these changes');
case 'COMMENTED': case 'COMMENTED':
return TextSpan(text: ' commented '); return TextSpan(text: ' reviewed ');
default: default:
return warningSpan; return warningSpan;
} }
@ -81,9 +81,8 @@ class TimelineItem extends StatelessWidget {
); );
} }
Widget _buildByType(BuildContext context) { Widget _buildByType(BuildContext context, String type) {
final theme = Provider.of<ThemeModel>(context); final theme = Provider.of<ThemeModel>(context);
final type = payload['__typename'] as String;
var defaultItem = TimelineEventItem( var defaultItem = TimelineEventItem(
actor: '', actor: '',
@ -330,9 +329,31 @@ class TimelineItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( final type = payload['__typename'] as String;
Widget widget = Container(
padding: CommonStyle.padding, padding: CommonStyle.padding,
child: _buildByType(context), child: _buildByType(context, type),
); );
if (type == 'PullRequestReview') {
final comments = payload['comments']['nodes'] as List;
if (comments.isNotEmpty) {
widget = Column(
children: <Widget>[
widget,
Container(
padding: CommonStyle.padding.copyWith(left: 50),
child: Column(
children: comments.map((v) {
return CommentItem(v, onReaction: (_, __) {});
}).toList()),
),
],
);
}
}
return widget;
} }
} }