1
0
mirror of https://github.com/git-touch/git-touch synced 2025-01-18 18:29:59 +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/comment_item.dart';
var reactionChunk = emojiMap.entries.map((entry) {
final reactionChunk = emojiMap.entries.map((entry) {
var key = entry.key;
return '''
$key: reactions(content: $key) {
@ -41,17 +41,11 @@ class _IssueScreenState extends State<IssueScreen> {
String get issueChunk {
var base = '''
id
title
createdAt
body
author {
login
avatarUrl
}
closed
url
$reactionChunk
title
closed
url
...CommentParts
...ReactableParts
''';
if (isPullRequest) {
@ -71,14 +65,8 @@ commits {
var base = '''
__typename
... on IssueComment {
id
createdAt
body
author {
login
avatarUrl
}
$reactionChunk
...CommentParts
...ReactableParts
}
... on Commit {
committedDate
@ -240,6 +228,12 @@ __typename
author {
login
}
comments(first: 10) {
nodes {
...CommentParts
...ReactableParts
}
}
}
... on MergedEvent {
createdAt
@ -277,6 +271,20 @@ __typename
}
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") {
$resource(number: $number) {

View File

@ -60,7 +60,7 @@ class TimelineItem extends StatelessWidget {
case 'APPROVED':
return TextSpan(text: ' approved these changes');
case 'COMMENTED':
return TextSpan(text: ' commented ');
return TextSpan(text: ' reviewed ');
default:
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 type = payload['__typename'] as String;
var defaultItem = TimelineEventItem(
actor: '',
@ -330,9 +329,31 @@ class TimelineItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
final type = payload['__typename'] as String;
Widget widget = Container(
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;
}
}