2019-12-22 13:00:58 +08:00
import ' package:flutter/gestures.dart ' ;
2018-07-05 22:08:19 +08:00
import ' package:flutter/material.dart ' ;
2019-02-03 00:28:51 +08:00
import ' package:flutter/cupertino.dart ' ;
2019-12-12 14:02:48 +08:00
import ' package:git_touch/models/github.dart ' ;
2019-11-03 23:33:24 +08:00
import ' package:git_touch/models/theme.dart ' ;
2019-12-20 22:41:38 +08:00
import ' package:git_touch/widgets/issue_icon.dart ' ;
2019-11-03 23:33:24 +08:00
import ' package:provider/provider.dart ' ;
2019-08-31 21:37:29 +08:00
import ' package:timeago/timeago.dart ' as timeago ;
2019-02-07 14:35:19 +08:00
import ' avatar.dart ' ;
2019-03-13 22:51:48 +08:00
import ' ../widgets/link.dart ' ;
2019-02-07 19:17:29 +08:00
import ' ../utils/utils.dart ' ;
2018-07-05 22:08:19 +08:00
class EventItem extends StatelessWidget {
2019-12-20 22:41:38 +08:00
final GithubEvent e ;
2019-02-09 13:29:44 +08:00
2019-12-20 22:41:38 +08:00
EventItem ( this . e ) ;
2018-07-05 22:08:19 +08:00
2019-12-22 13:00:58 +08:00
InlineSpan _buildLinkSpan ( BuildContext context , String text , String url ) {
final theme = Provider . of < ThemeModel > ( context ) ;
2019-11-05 21:22:41 +08:00
return TextSpan (
text: text ,
2020-01-27 15:11:51 +08:00
style: TextStyle ( color: theme . palette . primary ) ,
2019-12-22 13:00:58 +08:00
recognizer: TapGestureRecognizer ( )
. . onTap = ( ) {
theme . push ( context , url ) ;
} ,
2019-11-05 21:22:41 +08:00
) ;
}
2018-07-05 22:08:19 +08:00
2019-12-22 13:00:58 +08:00
InlineSpan _buildRepo ( BuildContext context , [ String fullName ] ) {
final name = fullName ? ? e . repo . name ;
2020-05-12 21:01:30 +05:30
return _buildLinkSpan ( context , name , ' /github/ $ name ' ) ;
2019-12-22 13:00:58 +08:00
}
InlineSpan _buildIssue ( BuildContext context , int number ,
{ bool isPullRequest = false } ) {
return _buildLinkSpan ( context , ' # $ number ' ,
2020-05-12 21:01:30 +05:30
' /github/ ${ e . repoOwner } / ${ e . repoName } / ${ isPullRequest ? ' pull ' : ' issues ' } / $ number ' ) ;
2019-12-22 13:00:58 +08:00
}
2019-01-26 22:10:18 +08:00
2019-02-07 17:19:08 +08:00
Widget _buildItem ( {
@ required BuildContext context ,
2019-09-25 13:34:13 +08:00
@ required List < InlineSpan > spans ,
2019-12-20 22:41:38 +08:00
Widget card ,
2019-02-07 17:19:08 +08:00
} ) {
2019-11-05 21:22:41 +08:00
final theme = Provider . of < ThemeModel > ( context ) ;
2019-12-20 20:52:49 +08:00
return Container (
padding: CommonStyle . padding ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: < Widget > [
Row (
crossAxisAlignment: CrossAxisAlignment . start ,
children: < Widget > [
2020-05-12 21:01:30 +05:30
Avatar (
url: e . actor . avatarUrl , linkUrl: ' /github/ ' + e . actor . login ) ,
2019-12-20 20:52:49 +08:00
SizedBox ( width: 10 ) ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
2019-12-25 11:05:25 +08:00
children: join ( SizedBox ( height: 6 ) , [
2020-01-26 23:44:45 +08:00
Text . rich (
TextSpan (
2019-12-20 20:52:49 +08:00
style: TextStyle (
2019-12-20 23:19:41 +08:00
fontSize: 17 ,
2020-01-27 15:11:51 +08:00
color: theme . palette . text ,
2019-08-31 21:37:29 +08:00
) ,
2019-12-20 20:52:49 +08:00
children: [
2020-05-12 21:01:30 +05:30
_buildLinkSpan ( context , e . actor . login ,
' /github/ ${ e . actor . login } ' ) ,
2019-12-20 20:52:49 +08:00
. . . spans ,
] ,
2019-09-07 17:08:24 +08:00
) ,
2019-12-20 20:52:49 +08:00
) ,
Row (
crossAxisAlignment: CrossAxisAlignment . start ,
children: < Widget > [
2019-12-20 22:41:38 +08:00
Text ( timeago . format ( e . createdAt ) ,
2019-12-20 20:52:49 +08:00
style: TextStyle (
2019-12-20 23:19:41 +08:00
fontSize: 14 ,
2020-01-27 15:11:51 +08:00
color: theme . palette . tertiaryText ,
2019-12-20 20:52:49 +08:00
) ) ,
] ,
) ,
2019-12-20 22:41:38 +08:00
if ( card ! = null ) card
2019-12-20 20:52:49 +08:00
] ) ,
2019-01-31 14:37:25 +08:00
) ,
2019-12-20 20:52:49 +08:00
) ,
] ,
) ,
] ,
2018-07-05 22:08:19 +08:00
) ,
) ;
}
2019-02-07 17:19:08 +08:00
2019-12-12 14:02:48 +08:00
Widget _buildDefaultItem ( BuildContext context ) {
2019-11-05 21:22:41 +08:00
final theme = Provider . of < ThemeModel > ( context ) ;
2019-12-12 14:02:48 +08:00
return _buildItem (
2019-02-07 17:39:27 +08:00
context: context ,
2019-02-10 12:54:48 +08:00
spans: [
TextSpan (
2019-12-20 22:41:38 +08:00
text: ' ' + e . type ,
2020-01-27 15:11:51 +08:00
style: TextStyle ( color: theme . palette . primary ) ,
2019-02-10 12:54:48 +08:00
)
] ,
2019-12-22 13:00:58 +08:00
card: Text ( ' Woops, ${ e . type } not implemented yet ' ) ,
2019-12-20 22:41:38 +08:00
) ;
}
Widget _buildCommitsCard ( BuildContext context ) {
final theme = Provider . of < ThemeModel > ( context ) ;
return Link (
url:
2020-05-12 21:01:30 +05:30
' /github/ ${ e . repoOwner } / ${ e . repoName } /compare/ ${ e . payload . before } / ${ e . payload . head } ' ,
2019-12-20 22:41:38 +08:00
child: Container (
padding: EdgeInsets . all ( 12 ) ,
decoration: BoxDecoration (
2020-01-27 15:11:51 +08:00
color: theme . palette . grayBackground ,
2019-12-20 22:41:38 +08:00
borderRadius: BorderRadius . all ( Radius . circular ( 4 ) ) ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
2020-01-26 23:44:45 +08:00
Text . rich (
TextSpan (
2020-01-27 15:11:51 +08:00
style: TextStyle ( color: theme . palette . text , fontSize: 15 ) ,
2019-12-20 22:41:38 +08:00
children: [
TextSpan (
text:
e . payload . commits . length . toString ( ) + ' commits to ' ) ,
WidgetSpan (
child: PrimerBranchName (
e . payload . ref . replaceFirst ( ' refs/heads/ ' , ' ' ) ) ,
) ,
] ,
) ,
) ,
2019-12-20 23:19:41 +08:00
SizedBox ( height: 8 ) ,
2019-12-20 22:41:38 +08:00
. . . e . payload . commits . map ( ( commit ) {
return Row (
children: < Widget > [
Text (
commit . sha . substring ( 0 , 7 ) ,
style: TextStyle (
2020-01-27 15:11:51 +08:00
color: theme . palette . primary ,
2019-12-20 23:19:41 +08:00
fontSize: 15 ,
2019-12-20 22:41:38 +08:00
fontFamily: CommonStyle . monospace ,
) ,
) ,
SizedBox ( width: 6 ) ,
Expanded (
child: Text (
commit . message ,
overflow: TextOverflow . ellipsis ,
maxLines: 1 ,
2020-01-27 15:11:51 +08:00
style: TextStyle ( color: theme . palette . text , fontSize: 15 ) ,
2019-12-20 22:41:38 +08:00
) ,
)
] ,
) ;
} ) . toList ( )
] ,
) ,
) ,
2019-02-07 17:39:27 +08:00
) ;
2019-12-12 14:02:48 +08:00
}
2020-05-17 09:48:47 +05:30
// 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 ) ,
) ,
)
] ,
) ,
] ,
) ,
) ,
) ;
}
2019-12-20 22:41:38 +08:00
Widget _buildIssueCard (
BuildContext context , GithubEventIssue issue , String body ,
{ isPullRequest = false } ) {
final theme = Provider . of < ThemeModel > ( context ) ;
IssueIconState state ;
if ( isPullRequest ) {
if ( issue . merged = = true ) {
state = IssueIconState . prMerged ;
} else if ( issue . state = = ' open ' ) {
state = IssueIconState . prOpen ;
} else {
state = IssueIconState . prClosed ;
}
} else {
if ( issue . state = = ' open ' ) {
state = IssueIconState . open ;
} else {
state = IssueIconState . closed ;
}
}
return Link (
url:
2020-05-12 21:01:30 +05:30
' /github/ ${ e . repoOwner } / ${ e . repoName } / ${ isPullRequest ? ' pull ' : ' issues ' } / ${ issue . number } ' ,
2019-12-20 22:41:38 +08:00
child: Container (
padding: EdgeInsets . all ( 12 ) ,
decoration: BoxDecoration (
2020-01-27 15:11:51 +08:00
color: theme . palette . grayBackground ,
2019-12-20 22:41:38 +08:00
borderRadius: BorderRadius . all ( Radius . circular ( 4 ) ) ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
2019-12-25 11:05:25 +08:00
children: join ( SizedBox ( height: 6 ) , [
2019-12-20 22:41:38 +08:00
Row (
children: < Widget > [
IssueIcon ( state , size: 20 ) ,
SizedBox ( width: 4 ) ,
Expanded (
child: Text (
' # ' + issue . number . toString ( ) + ' ' + issue . title ,
style: TextStyle (
fontWeight: FontWeight . w500 ,
2019-12-20 23:19:41 +08:00
fontSize: 17 ,
2020-01-27 15:11:51 +08:00
color: theme . palette . text ,
2019-12-20 22:41:38 +08:00
) ,
overflow: TextOverflow . ellipsis ,
) ,
) ,
] ,
) ,
2019-12-20 23:19:41 +08:00
if ( body ! = null & & body . isNotEmpty )
2019-12-20 22:41:38 +08:00
Text (
body ,
overflow: TextOverflow . ellipsis ,
maxLines: 3 ,
2020-01-27 15:11:51 +08:00
style:
TextStyle ( color: theme . palette . secondaryText , fontSize: 15 ) ,
2019-12-20 22:41:38 +08:00
) ,
2019-12-20 23:19:41 +08:00
Row (
children: < Widget > [
2019-12-22 11:11:13 +08:00
Avatar ( url: issue . user . avatarUrl , size: AvatarSize . extraSmall ) ,
2019-12-20 23:19:41 +08:00
SizedBox ( width: 8 ) ,
Text ( issue . user . login ,
style: TextStyle (
fontSize: 14 ,
2020-01-27 15:11:51 +08:00
color: theme . palette . tertiaryText ,
2019-12-20 23:19:41 +08:00
) ) ,
Expanded ( child: Container ( ) ) ,
2019-12-25 11:05:25 +08:00
if ( issue . comments ! = null ) . . . [
Icon (
Octicons . comment ,
size: 14 ,
2020-01-27 15:11:51 +08:00
color: theme . palette . tertiaryText ,
2019-12-25 11:05:25 +08:00
) ,
SizedBox ( width: 4 ) ,
Text ( issue . comments . toString ( ) ,
style: TextStyle (
fontSize: 14 ,
2020-01-27 15:11:51 +08:00
color: theme . palette . tertiaryText ,
2019-12-25 11:05:25 +08:00
) ) ,
]
2019-12-20 23:19:41 +08:00
] ,
)
] ) ,
2019-12-20 20:52:49 +08:00
) ,
2019-12-20 22:41:38 +08:00
) ,
2019-12-20 20:52:49 +08:00
) ;
}
2019-12-12 14:02:48 +08:00
@ override
build ( BuildContext context ) {
2019-02-07 17:39:27 +08:00
// all events types here:
// https://developer.github.com/v3/activity/events/types/#event-types--payloads
2019-12-20 22:41:38 +08:00
switch ( e . type ) {
2019-02-07 17:39:27 +08:00
case ' CheckRunEvent ' :
2020-04-16 11:36:48 +08:00
return _buildItem ( context: context , spans: [
TextSpan (
text:
' ${ e . payload . action } a check run for ${ e . payload . checkRun . name } ' ) ,
] ) ;
2019-02-07 17:39:27 +08:00
case ' CheckSuiteEvent ' :
2020-04-16 11:36:48 +08:00
// Needs checks permission
2020-04-08 08:21:04 +05:30
String conclusion = " " ;
2020-04-16 11:36:48 +08:00
switch ( e . payload . checkSuite . conclusion ) {
2020-04-08 08:21:04 +05:30
case ' success ' :
case ' failure ' :
conclusion = ' it is a ' + e . payload . checkSuite . conclusion ;
break ;
case ' neutral ' :
case ' cancelled ' :
case ' timed_out ' :
case ' stale ' :
conclusion = ' it is ' + e . payload . checkSuite . conclusion ;
break ;
case ' action_required ' :
conclusion = ' it requires more action ' ;
break ;
}
2020-04-16 11:36:48 +08:00
return _buildItem (
2020-04-08 08:21:04 +05:30
context: context ,
spans: [
2020-04-16 11:36:48 +08:00
TextSpan (
text:
' ${ e . payload . action } the check suite and the conclusion is that $ conclusion ' ) ,
2020-04-08 08:21:04 +05:30
] ,
) ;
2019-02-07 17:39:27 +08:00
case ' CommitCommentEvent ' :
2020-04-16 11:36:48 +08:00
return _buildItem (
2020-04-08 08:21:04 +05:30
context: context ,
spans: [
2020-05-17 09:48:47 +05:30
TextSpan ( text: ' commented on a commit ' ) ,
TextSpan ( text: ' at ' ) ,
2020-04-08 08:21:04 +05:30
_buildRepo ( context ) ,
] ,
2020-05-17 09:48:47 +05:30
card: _buildCommitCommentCard ( context ) ,
2020-04-08 08:21:04 +05:30
) ;
2019-02-07 17:39:27 +08:00
case ' ContentReferenceEvent ' :
2020-04-16 11:36:48 +08:00
return _buildItem ( context: context , spans: [
TextSpan ( text: ' ${ e . payload . action } a content reference at ' ) ,
_buildLinkSpan ( context , e . payload . contentReference . reference ,
e . payload . contentReference . reference ) ,
] ) ;
2019-02-07 17:39:27 +08:00
case ' CreateEvent ' :
2019-12-25 10:56:30 +08:00
return _buildItem (
context: context ,
spans: < InlineSpan > [
2020-04-28 22:29:01 +05:30
TextSpan ( text: ' created a ${ e . payload . refType } ' ) ,
TextSpan (
text:
' ${ e . payload . ref = = null ? ' ' : ' ' + e . payload . ref + ' at ' } ' ) ,
2019-12-25 10:56:30 +08:00
_buildRepo ( context ) ,
] ,
) ;
2019-02-07 17:39:27 +08:00
case ' DeleteEvent ' :
2020-02-08 20:53:06 +05:30
return _buildItem (
context: context ,
spans: < InlineSpan > [
2020-04-28 22:29:01 +05:30
TextSpan ( text: ' deleted the ${ e . payload . refType } ' ) ,
TextSpan (
text:
' ${ e . payload . ref = = null ? ' ' : ' ' + e . payload . ref + ' at ' } ' ) ,
2020-02-08 20:53:06 +05:30
_buildRepo ( context ) ,
] ,
) ;
2019-02-07 17:39:27 +08:00
case ' ForkEvent ' :
2019-12-20 22:41:38 +08:00
final forkeeOwner = e . payload . forkee [ ' owner ' ] [ ' login ' ] as String ;
final forkeeName = e . payload . forkee [ ' name ' ] as String ;
2019-02-07 17:19:08 +08:00
return _buildItem (
context: context ,
spans: [
2019-02-07 17:39:27 +08:00
TextSpan ( text: ' forked ' ) ,
2019-12-22 13:00:58 +08:00
_buildRepo ( context , ' $ forkeeOwner / $ forkeeName ' ) ,
2019-02-07 17:39:27 +08:00
TextSpan ( text: ' from ' ) ,
2019-12-22 13:00:58 +08:00
_buildRepo ( context ) ,
2019-02-07 17:39:27 +08:00
] ,
) ;
case ' GollumEvent ' :
2020-04-08 08:21:04 +05:30
String pageNamesCreated = " " ;
String pageNamesEdited = " " ;
2020-04-16 11:36:48 +08:00
for ( GithubPagesItem page in e . payload . pages ) {
if ( page . action = = " edited " ) {
2020-04-08 08:21:04 +05:30
pageNamesEdited + = " , " + page . pageName ;
} else {
pageNamesCreated + = " , " + page . pageName ;
}
}
2020-04-16 11:36:48 +08:00
if ( pageNamesCreated . length > 0 ) {
2020-04-08 08:21:04 +05:30
pageNamesCreated = " created the pages: \n " + pageNamesCreated + " \n " ;
}
2020-04-16 11:36:48 +08:00
if ( pageNamesEdited . length > 0 ) {
2020-04-08 08:21:04 +05:30
pageNamesEdited = " edited the pages: \n " + pageNamesEdited + " \n " ;
}
2020-04-16 11:36:48 +08:00
return _buildItem (
context: context ,
spans: [ TextSpan ( text: ' $ pageNamesCreated \n $ pageNamesEdited ' ) ] ) ;
2019-02-07 17:39:27 +08:00
case ' InstallationEvent ' :
2020-04-08 08:21:04 +05:30
String action = e . payload . action ;
2020-04-16 11:36:48 +08:00
if ( action = = ' new_permissions_accepted ' ) {
2020-04-08 08:21:04 +05:30
action = " new permission were accepted for " ;
}
return _buildItem (
context: context ,
spans: [
2020-04-16 11:36:48 +08:00
TextSpan (
text:
' $ action for the Github App with id ${ e . payload . installation . id } ' ) ,
2020-04-08 08:21:04 +05:30
] ,
) ;
2019-02-07 17:39:27 +08:00
case ' InstallationRepositoriesEvent ' :
2020-04-16 11:36:48 +08:00
List < GithubNotificationItemRepo > repositoriesAdded =
e . payload . installation . repositoriesAdded ;
List < GithubNotificationItemRepo > repositoriesRemoved =
e . payload . installation . repositoriesRemoved ;
2020-04-08 08:21:04 +05:30
String addedRepos = " " ;
String removedRepos = " " ;
2020-04-16 11:36:48 +08:00
for ( GithubNotificationItemRepo repo in repositoriesAdded ) {
2020-04-08 08:21:04 +05:30
addedRepos + = repo . fullName + " , " ;
}
2020-04-16 11:36:48 +08:00
for ( GithubNotificationItemRepo repo in repositoriesRemoved ) {
2020-04-08 08:21:04 +05:30
removedRepos + = repo . fullName + " , " ;
}
String finalListOfRepos = " " ;
2020-04-16 11:36:48 +08:00
if ( addedRepos ! = " " ) {
2020-04-08 08:21:04 +05:30
finalListOfRepos + = addedRepos + " were added to \n " ;
2020-04-16 11:36:48 +08:00
}
if ( removedRepos ! = " " ) {
2020-04-08 08:21:04 +05:30
finalListOfRepos + = removedRepos + " were removed from " ;
}
2020-04-16 11:36:48 +08:00
return _buildItem (
2020-04-08 08:21:04 +05:30
context: context ,
spans: [
2020-04-16 11:36:48 +08:00
TextSpan (
text:
' $ finalListOfRepos the installation id ${ e . payload . installation . id } ' ) ,
2020-04-08 08:21:04 +05:30
] ,
) ;
2019-02-07 17:39:27 +08:00
case ' IssueCommentEvent ' :
return _buildItem (
context: context ,
spans: [
2019-12-20 20:52:49 +08:00
TextSpan (
text:
2019-12-20 22:41:38 +08:00
' commented on ${ e . payload . issue . isPullRequestComment ? ' pull request ' : ' issue ' } ' ) ,
2020-01-06 12:50:31 +08:00
_buildIssue (
context ,
e . payload . issue . number ,
isPullRequest: e . payload . issue . isPullRequestComment ,
) ,
2019-02-07 17:19:08 +08:00
TextSpan ( text: ' at ' ) ,
2019-12-22 13:00:58 +08:00
_buildRepo ( context ) ,
2019-02-07 17:19:08 +08:00
] ,
2019-12-20 22:41:38 +08:00
card: _buildIssueCard (
context ,
e . payload . issue ,
e . payload . comment . body ,
isPullRequest: e . payload . issue . isPullRequestComment ,
) ,
2019-02-07 17:19:08 +08:00
) ;
2019-02-07 17:39:27 +08:00
case ' IssuesEvent ' :
2019-12-20 22:41:38 +08:00
final issue = e . payload . issue ;
2019-02-07 17:19:08 +08:00
return _buildItem (
context: context ,
spans: [
2019-12-20 22:41:38 +08:00
TextSpan ( text: ' ${ e . payload . action } issue ' ) ,
2019-12-22 13:00:58 +08:00
_buildIssue ( context , issue . number ) ,
2019-02-07 17:19:08 +08:00
TextSpan ( text: ' at ' ) ,
2019-12-22 13:00:58 +08:00
_buildRepo ( context ) ,
2019-02-07 17:19:08 +08:00
] ,
2019-12-20 22:41:38 +08:00
card: _buildIssueCard ( context , issue , issue . body ) ,
2019-02-07 17:19:08 +08:00
) ;
2019-02-07 17:39:27 +08:00
case ' MarketplacePurchaseEvent ' :
2020-02-08 20:53:06 +05:30
final action = e . payload . action ;
var messageToDisplay ;
2020-04-16 11:36:48 +08:00
switch ( action ) {
case " purchased " :
2020-02-08 20:53:06 +05:30
messageToDisplay = " purchased a Marketplace Plan " ;
2020-04-16 11:36:48 +08:00
break ;
2020-02-08 20:53:06 +05:30
case " cancelled " :
messageToDisplay = " cancelled their Marketplace Plan " ;
2020-04-16 11:36:48 +08:00
break ;
2020-02-08 20:53:06 +05:30
case " pending_change " :
messageToDisplay = " Marketplace Plan is pending change " ;
2020-04-16 11:36:48 +08:00
break ;
2020-02-08 20:53:06 +05:30
case " pending_change_cancelled " :
messageToDisplay = " Pending Marketplace Plan was cancelled " ;
2020-04-16 11:36:48 +08:00
break ;
2020-02-08 20:53:06 +05:30
case " changed " :
messageToDisplay = " changed their Marketplace Plan " ;
2020-04-16 11:36:48 +08:00
break ;
2020-02-08 20:53:06 +05:30
}
return _buildItem (
context: context ,
spans: [
TextSpan (
text: ' $ messageToDisplay ' ,
) ,
_buildRepo ( context ) ,
] ,
) ;
2019-02-07 17:39:27 +08:00
case ' MemberEvent ' :
2020-02-08 20:53:06 +05:30
final action = e . payload . action ;
return _buildItem (
context: context ,
spans: [
TextSpan (
2020-04-16 11:36:48 +08:00
text:
' was ${ e . payload . action } ${ action = = ' added ' ? ' to ' : ' from ' } ' ) ,
2020-02-08 20:53:06 +05:30
_buildRepo ( context ) ,
] ,
) ;
2019-02-07 17:39:27 +08:00
case ' ProjectCardEvent ' :
2020-04-08 08:21:04 +05:30
String action = e . payload . action ;
2020-04-16 11:36:48 +08:00
if ( action = = ' converted ' ) {
2020-04-08 08:21:04 +05:30
action = ' converted the project card into an issue ' ;
} else {
action = action + ' the project card ' ;
}
2020-04-16 11:36:48 +08:00
return _buildItem (
2020-04-08 08:21:04 +05:30
context: context ,
spans: [
TextSpan ( text: ' $ action at ' ) ,
_buildRepo ( context ) ,
] ,
) ;
2019-02-07 17:39:27 +08:00
case ' ProjectColumnEvent ' :
2020-04-16 11:36:48 +08:00
return _buildItem ( context: context , spans: [
TextSpan (
text:
' ${ e . payload . action } the project column ${ e . payload . projectColumn . name } at ' ) ,
_buildRepo ( context ) ,
] ) ;
2019-02-07 17:39:27 +08:00
case ' ProjectEvent ' :
2020-04-16 11:36:48 +08:00
return _buildItem ( context: context , spans: [
TextSpan (
text:
' ${ e . payload . action } the project ${ e . payload . project . name } ' ) ,
] ) ;
2019-02-07 17:39:27 +08:00
case ' PublicEvent ' :
2020-02-08 20:53:06 +05:30
return _buildItem (
2020-04-08 08:21:04 +05:30
context: context ,
spans: [
TextSpan ( text: ' made ' ) ,
_buildRepo ( context ) ,
TextSpan ( text: ' public ' ) ,
] ,
2020-02-08 20:53:06 +05:30
) ;
2019-02-07 17:19:08 +08:00
case ' PullRequestEvent ' :
2019-12-20 22:41:38 +08:00
final pr = e . payload . pullRequest ;
2019-02-07 17:19:08 +08:00
return _buildItem (
context: context ,
spans: [
2019-12-20 22:41:38 +08:00
TextSpan ( text: ' ${ e . payload . action } pull request ' ) ,
2019-12-22 13:00:58 +08:00
_buildIssue ( context , pr . number , isPullRequest: true ) ,
2019-02-07 17:19:08 +08:00
TextSpan ( text: ' at ' ) ,
2019-12-22 13:00:58 +08:00
_buildRepo ( context ) ,
2019-02-07 17:19:08 +08:00
] ,
2019-12-20 22:41:38 +08:00
card: _buildIssueCard ( context , pr , pr . body , isPullRequest: true ) ,
2019-02-07 17:19:08 +08:00
) ;
2019-02-07 17:39:27 +08:00
case ' PullRequestReviewEvent ' :
2020-04-08 08:21:04 +05:30
final pr = e . payload . pullRequest ;
2020-04-16 11:36:48 +08:00
return _buildItem ( context: context , spans: [
TextSpan ( text: ' ${ e . payload . action } the pull request review ' ) ,
_buildIssue ( context , pr . number , isPullRequest: true ) ,
TextSpan ( text: ' at ' ) ,
_buildRepo ( context ) ,
] ) ;
2019-02-07 17:19:08 +08:00
case ' PullRequestReviewCommentEvent ' :
2019-12-20 22:41:38 +08:00
final pr = e . payload . pullRequest ;
2019-02-07 17:19:08 +08:00
return _buildItem (
context: context ,
spans: [
TextSpan ( text: ' reviewed pull request ' ) ,
2019-12-22 13:00:58 +08:00
_buildIssue ( context , pr . number , isPullRequest: true ) ,
2019-02-07 17:19:08 +08:00
TextSpan ( text: ' at ' ) ,
2019-12-22 13:00:58 +08:00
_buildRepo ( context ) ,
2019-02-07 17:19:08 +08:00
] ,
2019-12-25 11:05:25 +08:00
card: _buildIssueCard ( context , pr , e . payload . comment . body ,
isPullRequest: true ) ,
2019-02-07 17:19:08 +08:00
) ;
2019-02-07 17:39:27 +08:00
case ' PushEvent ' :
2019-02-07 17:19:08 +08:00
return _buildItem (
context: context ,
2019-12-22 13:00:58 +08:00
spans: [ TextSpan ( text: ' pushed to ' ) , _buildRepo ( context ) ] ,
2019-12-20 22:41:38 +08:00
card: _buildCommitsCard ( context ) ,
2019-02-07 17:19:08 +08:00
) ;
2019-02-07 17:39:27 +08:00
case ' ReleaseEvent ' :
2019-12-25 10:46:56 +08:00
return _buildItem (
context: context ,
spans: [
TextSpan ( text: ' released ' ) ,
_buildLinkSpan (
context , e . payload . release . tagName , e . payload . release . htmlUrl ) ,
TextSpan ( text: ' at ' ) ,
_buildRepo ( context )
] ,
) ;
2020-04-08 08:21:04 +05:30
// case 'RepositoryImportEvent':
// // Uses Source Imports API
2019-02-07 17:39:27 +08:00
case ' RepositoryVulnerabilityAlertEvent ' :
2020-04-16 11:36:48 +08:00
return _buildItem ( context: context , spans: [
TextSpan (
text:
' Security alert involving the package ${ e . payload . alert . affectedPackageName } between versions ${ e . payload . alert . affectedRange } was {e.payload.action}ed ' ,
)
] ) ;
2019-02-07 17:39:27 +08:00
case ' SecurityAdvisoryEvent ' :
2020-04-16 11:36:48 +08:00
return _buildItem ( context: context , spans: [
TextSpan (
text:
' Security advisory regarding ${ e . payload . securityAdvisory . summary } was ${ e . payload . action } ' ,
)
] ) ;
2019-02-07 17:39:27 +08:00
case ' WatchEvent ' :
2019-02-07 17:19:08 +08:00
return _buildItem (
context: context ,
2019-12-22 13:00:58 +08:00
spans: [ TextSpan ( text: ' starred ' ) , _buildRepo ( context ) ] ,
2019-02-07 17:19:08 +08:00
) ;
default :
2019-12-12 14:02:48 +08:00
return _buildDefaultItem ( context ) ;
2019-02-07 17:19:08 +08:00
}
}
2018-07-05 22:08:19 +08:00
}