fix: commit comment event render error (#93)

This commit is contained in:
Shreyas Thirumalai 2020-05-17 09:48:47 +05:30 committed by GitHub
parent 38bcb06f62
commit db624247ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 4 deletions

View File

@ -106,6 +106,8 @@ class GithubEventIssue {
class GithubEventComment {
String body;
GithubEventUser user;
String commitId;
String htmlUrl;
GithubEventComment();

View File

@ -174,13 +174,17 @@ GithubEventComment _$GithubEventCommentFromJson(Map<String, dynamic> json) {
..body = json['body'] as String
..user = json['user'] == null
? null
: GithubEventUser.fromJson(json['user'] as Map<String, dynamic>);
: GithubEventUser.fromJson(json['user'] as Map<String, dynamic>)
..commitId = json['commit_id'] as String
..htmlUrl = json['html_url'] as String;
}
Map<String, dynamic> _$GithubEventCommentToJson(GithubEventComment instance) =>
<String, dynamic>{
'body': instance.body,
'user': instance.user,
'commit_id': instance.commitId,
'html_url': instance.htmlUrl,
};
GithubEventCommit _$GithubEventCommitFromJson(Map<String, dynamic> json) {

View File

@ -164,6 +164,46 @@ class EventItem extends StatelessWidget {
);
}
// Todo: Add a screen for the url
Widget _buildCommitCommentCard(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
return Link(
url: e.payload.comment.htmlUrl,
child: Container(
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.palette.grayBackground,
borderRadius: BorderRadius.all(Radius.circular(4))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: <Widget>[
Text(
e.payload.comment.commitId.substring(0, 7),
style: TextStyle(
color: theme.palette.primary,
fontSize: 15,
fontFamily: CommonStyle.monospace,
),
),
SizedBox(width: 6),
Expanded(
child: Text(
e.payload.comment.body,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(color: theme.palette.text, fontSize: 15),
),
)
],
),
],
),
),
);
}
Widget _buildIssueCard(
BuildContext context, GithubEventIssue issue, String body,
{isPullRequest = false}) {
@ -293,11 +333,11 @@ class EventItem extends StatelessWidget {
return _buildItem(
context: context,
spans: [
TextSpan(text: ' ${e.payload.action} a comment on the commit at '),
TextSpan(text: ' commented on a commit '),
TextSpan(text: ' at '),
_buildRepo(context),
TextSpan(text: ' ${e.payload.comment.body} '),
],
card: _buildCommitsCard(context),
card: _buildCommitCommentCard(context),
);
case 'ContentReferenceEvent':
return _buildItem(context: context, spans: [