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

653 lines
22 KiB
Dart
Raw Normal View History

2022-09-24 20:46:37 +02:00
import 'package:antd_mobile/antd_mobile.dart';
2019-02-02 17:28:51 +01:00
import 'package:flutter/cupertino.dart';
2022-09-17 14:35:45 +02:00
import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/S.dart';
2019-12-12 07:02:48 +01:00
import 'package:git_touch/models/github.dart';
2022-09-21 18:56:02 +02:00
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/avatar.dart';
import 'package:git_touch/widgets/branch_name.dart';
2019-12-20 15:41:38 +01:00
import 'package:git_touch/widgets/issue_icon.dart';
2022-09-21 18:56:02 +02:00
import 'package:git_touch/widgets/link.dart';
2019-08-31 15:37:29 +02:00
import 'package:timeago/timeago.dart' as timeago;
2022-09-17 14:35:45 +02:00
2018-07-05 16:08:19 +02:00
class EventItem extends StatelessWidget {
2022-09-06 18:28:12 +02:00
const EventItem(this.e);
2022-09-21 18:28:21 +02:00
final GithubEvent e;
2018-07-05 16:08:19 +02:00
2021-05-16 09:16:35 +02:00
InlineSpan _buildLinkSpan(BuildContext context, String? text, String? url) {
2019-11-05 14:22:41 +01:00
return TextSpan(
text: text,
2022-09-24 20:46:37 +02:00
style: TextStyle(color: AntTheme.of(context).colorPrimary),
2019-12-22 06:00:58 +01:00
recognizer: TapGestureRecognizer()
..onTap = () {
2022-09-22 19:50:45 +02:00
context.pushUrl(url!);
2019-12-22 06:00:58 +01:00
},
2019-11-05 14:22:41 +01:00
);
}
2018-07-05 16:08:19 +02:00
2021-05-16 09:16:35 +02:00
InlineSpan _buildRepo(BuildContext context, [String? fullName]) {
final name = fullName ?? e.repo!.name;
return _buildLinkSpan(context, name, '/github/$name');
2019-12-22 06:00:58 +01:00
}
2021-05-16 09:16:35 +02:00
InlineSpan _buildIssue(BuildContext context, int? number,
2019-12-22 06:00:58 +01:00
{bool isPullRequest = false}) {
return _buildLinkSpan(context, '#$number',
'/github/${e.repoOwner}/${e.repoName}/${isPullRequest ? 'pull' : 'issues'}/$number');
2019-12-22 06:00:58 +01:00
}
2019-02-07 10:19:08 +01:00
Widget _buildItem({
2021-05-16 09:16:35 +02:00
required BuildContext context,
required List<InlineSpan> spans,
Widget? card,
2019-02-07 10:19:08 +01:00
}) {
2022-10-03 07:27:11 +02:00
return AntListItem(
2019-12-20 13:52:49 +01:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Avatar(
2021-05-16 09:16:35 +02:00
url: e.actor!.avatarUrl,
2022-09-06 18:28:12 +02:00
linkUrl: '/github/${e.actor!.login!}'),
const SizedBox(width: 10),
2019-12-20 13:52:49 +01:00
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
2022-09-06 18:28:12 +02:00
children: join(const SizedBox(height: 6), [
2020-01-26 16:44:45 +01:00
Text.rich(
TextSpan(
2019-12-20 13:52:49 +01:00
style: TextStyle(
fontSize: 17,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorText,
2019-08-31 15:37:29 +02:00
),
2019-12-20 13:52:49 +01:00
children: [
2021-05-16 09:16:35 +02:00
_buildLinkSpan(context, e.actor!.login,
'/github/${e.actor!.login}'),
2019-12-20 13:52:49 +01:00
...spans,
],
2019-09-07 11:08:24 +02:00
),
2019-12-20 13:52:49 +01:00
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
2021-05-16 09:16:35 +02:00
Text(timeago.format(e.createdAt!),
2019-12-20 13:52:49 +01:00
style: TextStyle(
fontSize: 14,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorWeak,
2019-12-20 13:52:49 +01:00
)),
],
),
2019-12-20 15:41:38 +01:00
if (card != null) card
2019-12-20 13:52:49 +01:00
]),
2019-01-31 07:37:25 +01:00
),
2019-12-20 13:52:49 +01:00
),
],
),
],
2018-07-05 16:08:19 +02:00
),
);
}
2019-02-07 10:19:08 +01:00
2019-12-12 07:02:48 +01:00
Widget _buildDefaultItem(BuildContext context) {
return _buildItem(
context: context,
2019-02-10 05:54:48 +01:00
spans: [
TextSpan(
2022-09-06 18:28:12 +02:00
text: ' ${e.type!}',
2022-09-24 20:46:37 +02:00
style: TextStyle(color: AntTheme.of(context).colorPrimary),
2019-02-10 05:54:48 +01:00
)
],
card: Text(
'${e.type} ${AppLocalizations.of(context)!.timelineTypeNotImplemented}'),
2019-12-20 15:41:38 +01:00
);
}
Widget _buildCommitsCard(BuildContext context) {
2021-05-16 09:16:35 +02:00
return LinkWidget(
2019-12-20 15:41:38 +01:00
url:
2021-05-16 09:16:35 +02:00
'/github/${e.repoOwner}/${e.repoName}/compare/${e.payload!.before}/${e.payload!.head}',
2019-12-20 15:41:38 +01:00
child: Container(
2022-09-06 18:28:12 +02:00
padding: const EdgeInsets.all(12),
2022-09-24 20:46:37 +02:00
decoration: const BoxDecoration(
color: Color(0xffcccccc),
borderRadius: BorderRadius.all(Radius.circular(4))),
2019-12-20 15:41:38 +01:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
2020-01-26 16:44:45 +01:00
Text.rich(
TextSpan(
2022-09-24 20:46:37 +02:00
style: TextStyle(
color: AntTheme.of(context).colorText, fontSize: 15),
2019-12-20 15:41:38 +01:00
children: [
TextSpan(
text:
'${AppLocalizations.of(context)!.nCommitsTo(e.payload!.commits!.length)} '),
2019-12-20 15:41:38 +01:00
WidgetSpan(
2022-09-21 18:56:02 +02:00
child: BranchName(
2021-05-16 09:16:35 +02:00
e.payload!.ref!.replaceFirst('refs/heads/', '')),
2019-12-20 15:41:38 +01:00
),
],
),
),
2022-09-06 18:28:12 +02:00
const SizedBox(height: 8),
2021-05-16 09:16:35 +02:00
...e.payload!.commits!.map((commit) {
2019-12-20 15:41:38 +01:00
return Row(
children: <Widget>[
Text(
2021-05-16 09:16:35 +02:00
commit.sha!.substring(0, 7),
2019-12-20 15:41:38 +01:00
style: TextStyle(
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorPrimary,
fontSize: 15,
2019-12-20 15:41:38 +01:00
fontFamily: CommonStyle.monospace,
),
),
2022-09-06 18:28:12 +02:00
const SizedBox(width: 6),
2019-12-20 15:41:38 +01:00
Expanded(
child: Text(
2021-05-16 09:16:35 +02:00
commit.message!,
2019-12-20 15:41:38 +01:00
overflow: TextOverflow.ellipsis,
maxLines: 1,
2022-09-24 20:46:37 +02:00
style: TextStyle(
color: AntTheme.of(context).colorText, fontSize: 15),
2019-12-20 15:41:38 +01:00
),
)
],
);
}).toList()
],
),
),
);
2019-12-12 07:02:48 +01:00
}
// Todo: Add a screen for the url
Widget _buildCommitCommentCard(BuildContext context) {
2021-05-16 09:16:35 +02:00
return LinkWidget(
url: e.payload!.comment!.htmlUrl,
child: Container(
2022-09-06 18:28:12 +02:00
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorBox,
2022-09-06 18:28:12 +02:00
borderRadius: const BorderRadius.all(Radius.circular(4))),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: <Widget>[
Text(
2021-05-16 09:16:35 +02:00
e.payload!.comment!.commitId!.substring(0, 7),
style: TextStyle(
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorPrimary,
fontSize: 15,
fontFamily: CommonStyle.monospace,
),
),
2022-09-06 18:28:12 +02:00
const SizedBox(width: 6),
Expanded(
child: Text(
2021-05-16 09:16:35 +02:00
e.payload!.comment!.body!,
overflow: TextOverflow.ellipsis,
maxLines: 1,
2022-09-24 20:46:37 +02:00
style: TextStyle(
color: AntTheme.of(context).colorText, fontSize: 15),
),
)
],
),
],
),
),
);
}
2019-12-20 15:41:38 +01:00
Widget _buildIssueCard(
2021-05-16 09:16:35 +02:00
BuildContext context, GithubEventIssue issue, String? body,
2019-12-20 15:41:38 +01:00
{isPullRequest = false}) {
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;
}
}
2021-05-16 09:16:35 +02:00
return LinkWidget(
2019-12-20 15:41:38 +01:00
url:
'/github/${e.repoOwner}/${e.repoName}/${isPullRequest ? 'pull' : 'issues'}/${issue.number}',
2019-12-20 15:41:38 +01:00
child: Container(
2022-09-06 18:28:12 +02:00
padding: const EdgeInsets.all(12),
2019-12-20 15:41:38 +01:00
decoration: BoxDecoration(
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorBox,
2022-09-06 18:28:12 +02:00
borderRadius: const BorderRadius.all(Radius.circular(4))),
2019-12-20 15:41:38 +01:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
2022-09-06 18:28:12 +02:00
children: join(const SizedBox(height: 6), [
2019-12-20 15:41:38 +01:00
Row(
children: <Widget>[
IssueIcon(state, size: 20),
2022-09-06 18:28:12 +02:00
const SizedBox(width: 4),
2019-12-20 15:41:38 +01:00
Expanded(
child: Text(
2022-09-06 18:28:12 +02:00
'#${issue.number} ${issue.title!}',
2019-12-20 15:41:38 +01:00
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 17,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorText,
2019-12-20 15:41:38 +01:00
),
overflow: TextOverflow.ellipsis,
),
),
],
),
if (body != null && body.isNotEmpty)
2019-12-20 15:41:38 +01:00
Text(
body,
overflow: TextOverflow.ellipsis,
maxLines: 3,
2022-09-24 20:46:37 +02:00
style: TextStyle(
color: AntTheme.of(context).colorTextSecondary,
fontSize: 15),
2019-12-20 15:41:38 +01:00
),
Row(
children: <Widget>[
2021-05-16 09:16:35 +02:00
Avatar(url: issue.user!.avatarUrl, size: AvatarSize.extraSmall),
2022-09-06 18:28:12 +02:00
const SizedBox(width: 8),
2021-05-16 09:16:35 +02:00
Text(issue.user!.login!,
style: TextStyle(
fontSize: 14,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorWeak,
)),
Expanded(child: Container()),
2019-12-25 04:05:25 +01:00
if (issue.comments != null) ...[
Icon(
Octicons.comment,
size: 14,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorWeak,
2019-12-25 04:05:25 +01:00
),
2022-09-06 18:28:12 +02:00
const SizedBox(width: 4),
2019-12-25 04:05:25 +01:00
Text(issue.comments.toString(),
style: TextStyle(
fontSize: 14,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorWeak,
2019-12-25 04:05:25 +01:00
)),
]
],
)
]),
2019-12-20 13:52:49 +01:00
),
2019-12-20 15:41:38 +01:00
),
2019-12-20 13:52:49 +01:00
);
}
2019-12-12 07:02:48 +01:00
@override
build(BuildContext context) {
// all events types here:
// https://developer.github.com/v3/activity/events/types/#event-types--payloads
2019-12-20 15:41:38 +01:00
switch (e.type) {
case 'CheckRunEvent':
2020-04-16 05:36:48 +02:00
return _buildItem(context: context, spans: [
TextSpan(
text:
'${AppLocalizations.of(context)!.checkRunEventMessage(e.payload!.action!, e.payload!.checkRun!.name!)} '),
2020-04-16 05:36:48 +02:00
]);
case 'CheckSuiteEvent':
2020-04-16 05:36:48 +02:00
// Needs checks permission
2022-09-24 07:41:46 +02:00
var conclusion = '';
2021-05-16 09:16:35 +02:00
switch (e.payload!.checkSuite!.conclusion) {
case 'success':
case 'failure':
conclusion =
'${AppLocalizations.of(context)!.checkSuiteEventConclusionMessage(e.payload!.checkSuite!.conclusion!)} ';
break;
case 'neutral':
case 'cancelled':
case 'timed_out':
case 'stale':
conclusion =
'${AppLocalizations.of(context)!.checkSuiteEventConclusionMessage(e.payload!.checkSuite!.conclusion!)} ';
break;
case 'action_required':
conclusion =
' ${AppLocalizations.of(context)!.actionRequiredConclusion}';
break;
}
2020-04-16 05:36:48 +02:00
return _buildItem(
context: context,
spans: [
2020-04-16 05:36:48 +02:00
TextSpan(
text:
' ${AppLocalizations.of(context)!.checkSuiteEventMessage(e.payload!.action!)} $conclusion'),
],
);
case 'CommitCommentEvent':
2020-04-16 05:36:48 +02:00
return _buildItem(
context: context,
spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.commitCommentEventMessage} '),
_buildRepo(context),
],
card: _buildCommitCommentCard(context),
);
case 'ContentReferenceEvent':
2020-04-16 05:36:48 +02:00
return _buildItem(context: context, spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.contentReferenceEventMessage(e.payload!.action!)} '),
2021-05-16 09:16:35 +02:00
_buildLinkSpan(context, e.payload!.contentReference!.reference,
e.payload!.contentReference!.reference),
2020-04-16 05:36:48 +02:00
]);
case 'CreateEvent':
2019-12-25 03:56:30 +01:00
return _buildItem(
context: context,
spans: <InlineSpan>[
TextSpan(
text:
' ${AppLocalizations.of(context)!.createdEventMessage(e.payload!.refType!, e.payload!.ref ?? '')}'),
2019-12-25 03:56:30 +01:00
_buildRepo(context),
],
);
case 'DeleteEvent':
2020-02-08 16:23:06 +01:00
return _buildItem(
context: context,
spans: <InlineSpan>[
TextSpan(
text:
' ${AppLocalizations.of(context)!.deletedEventMessage(e.payload!.refType!, e.payload!.ref ?? '')}'),
2020-02-08 16:23:06 +01:00
_buildRepo(context),
],
);
case 'ForkEvent':
2021-05-16 09:16:35 +02:00
final forkeeOwner = e.payload!.forkee!['owner']['login'] as String?;
final forkeeName = e.payload!.forkee!['name'] as String?;
2019-02-07 10:19:08 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(text: ' ${AppLocalizations.of(context)!.forked} '),
2019-12-22 06:00:58 +01:00
_buildRepo(context, '$forkeeOwner/$forkeeName'),
TextSpan(text: ' ${AppLocalizations.of(context)!.from} '),
2019-12-22 06:00:58 +01:00
_buildRepo(context),
],
);
case 'GollumEvent':
2022-09-24 07:41:46 +02:00
var pageNamesCreated = '';
var pageNamesEdited = '';
for (final page in e.payload!.pages!) {
if (page.action == 'edited') {
pageNamesEdited += ', ${page.pageName!}';
} else {
pageNamesCreated += ', ${page.pageName!}';
}
}
2022-09-06 18:28:12 +02:00
if (pageNamesCreated.isNotEmpty) {
pageNamesCreated =
' ${AppLocalizations.of(context)!.createdPages(pageNamesCreated)}';
}
2022-09-06 18:28:12 +02:00
if (pageNamesEdited.isNotEmpty) {
pageNamesEdited =
' ${AppLocalizations.of(context)!.editedPages(pageNamesEdited)}';
}
2020-04-16 05:36:48 +02:00
return _buildItem(
context: context,
spans: [TextSpan(text: ' $pageNamesCreated\n$pageNamesEdited ')]);
case 'InstallationEvent':
2022-09-24 07:41:46 +02:00
var action = e.payload!.action;
2020-04-16 05:36:48 +02:00
if (action == 'new_permissions_accepted') {
2022-09-06 18:28:12 +02:00
action = AppLocalizations.of(context)!.newPermissionsAccepted;
}
return _buildItem(
context: context,
spans: [
2020-04-16 05:36:48 +02:00
TextSpan(
text:
' $action ${AppLocalizations.of(context)!.forGithubAppWithId(e.payload!.installation!.id.toString())}'),
],
);
case 'InstallationRepositoriesEvent':
2022-09-24 20:46:37 +02:00
final repositoriesAdded = e.payload!.installation!.repositoriesAdded!;
2022-09-24 07:41:46 +02:00
final repositoriesRemoved =
2021-05-16 09:16:35 +02:00
e.payload!.installation!.repositoriesRemoved!;
2022-09-24 07:41:46 +02:00
var addedRepos = '';
var removedRepos = '';
for (final repo in repositoriesAdded) {
addedRepos += '${repo.fullName!}, ';
}
2022-09-24 07:41:46 +02:00
for (final repo in repositoriesRemoved) {
removedRepos += '${repo.fullName!}, ';
}
2022-09-24 07:41:46 +02:00
var finalListOfRepos = '';
if (addedRepos != '') {
finalListOfRepos +=
'${AppLocalizations.of(context)!.wereAddedTo(addedRepos, e.payload!.installation!.id.toString())}\n ';
2020-04-16 05:36:48 +02:00
}
if (removedRepos != '') {
2022-09-17 14:35:45 +02:00
finalListOfRepos +=
'$removedRepos ${AppLocalizations.of(context)!.wereRemovedFrom(removedRepos, e.payload!.installation!.id.toString())}';
}
2020-04-16 05:36:48 +02:00
return _buildItem(
context: context,
spans: [
2022-09-06 18:28:12 +02:00
TextSpan(text: finalListOfRepos),
],
);
case 'IssueCommentEvent':
return _buildItem(
context: context,
spans: [
2019-12-20 13:52:49 +01:00
TextSpan(
text:
' ${AppLocalizations.of(context)!.commentedOn} ${e.payload!.issue!.isPullRequestComment ? 'pull request' : 'issue'} '),
2020-01-06 05:50:31 +01:00
_buildIssue(
context,
2021-05-16 09:16:35 +02:00
e.payload!.issue!.number,
isPullRequest: e.payload!.issue!.isPullRequestComment,
2020-01-06 05:50:31 +01:00
),
TextSpan(text: ' ${AppLocalizations.of(context)!.at} '),
2019-12-22 06:00:58 +01:00
_buildRepo(context),
2019-02-07 10:19:08 +01:00
],
2019-12-20 15:41:38 +01:00
card: _buildIssueCard(
context,
2021-05-16 09:16:35 +02:00
e.payload!.issue!,
e.payload!.comment!.body,
isPullRequest: e.payload!.issue!.isPullRequestComment,
2019-12-20 15:41:38 +01:00
),
2019-02-07 10:19:08 +01:00
);
case 'IssuesEvent':
2021-05-16 09:16:35 +02:00
final issue = e.payload!.issue!;
2019-02-07 10:19:08 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(
text:
' ${e.payload!.action} ${AppLocalizations.of(context)!.issue} '),
2019-12-22 06:00:58 +01:00
_buildIssue(context, issue.number),
TextSpan(text: ' ${AppLocalizations.of(context)!.at} '),
2019-12-22 06:00:58 +01:00
_buildRepo(context),
2019-02-07 10:19:08 +01:00
],
2019-12-20 15:41:38 +01:00
card: _buildIssueCard(context, issue, issue.body),
2019-02-07 10:19:08 +01:00
);
case 'MarketplacePurchaseEvent':
2021-05-16 09:16:35 +02:00
final action = e.payload!.action;
2022-10-03 19:05:29 +02:00
String? messageToDisplay;
2020-04-16 05:36:48 +02:00
switch (action) {
case 'purchased':
messageToDisplay =
AppLocalizations.of(context)!.purchasedMarketplacePlan;
2020-04-16 05:36:48 +02:00
break;
case 'cancelled':
messageToDisplay =
AppLocalizations.of(context)!.cancelledMarketplacePlan;
2020-04-16 05:36:48 +02:00
break;
case 'pending_change':
messageToDisplay =
AppLocalizations.of(context)!.pendingMarketplacePlan;
2020-04-16 05:36:48 +02:00
break;
case 'pending_change_cancelled':
messageToDisplay =
AppLocalizations.of(context)!.pendingChangeCancelled;
2020-04-16 05:36:48 +02:00
break;
case 'changed':
messageToDisplay =
AppLocalizations.of(context)!.changedMarketplacePlan;
2020-04-16 05:36:48 +02:00
break;
2020-02-08 16:23:06 +01:00
}
return _buildItem(
context: context,
spans: [
TextSpan(
text: ' $messageToDisplay ',
),
_buildRepo(context),
],
);
case 'MemberEvent':
2021-05-16 09:16:35 +02:00
final action = e.payload!.action;
2020-02-08 16:23:06 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(
2020-04-16 05:36:48 +02:00
text:
' ${AppLocalizations.of(context)!.was} ${e.payload!.action} ${action == 'added' ? AppLocalizations.of(context)!.to : AppLocalizations.of(context)!.from} '),
2020-02-08 16:23:06 +01:00
_buildRepo(context),
],
);
case 'ProjectCardEvent':
2022-09-24 07:41:46 +02:00
var action = e.payload!.action;
2020-04-16 05:36:48 +02:00
if (action == 'converted') {
action = ' ${AppLocalizations.of(context)!.convertProjectCard} ';
} else {
action =
2022-09-06 18:28:12 +02:00
'${action!} ${AppLocalizations.of(context)!.theProjectCard} ';
}
2020-04-16 05:36:48 +02:00
return _buildItem(
context: context,
spans: [
TextSpan(text: ' $action ${AppLocalizations.of(context)!.at} '),
_buildRepo(context),
],
);
case 'ProjectColumnEvent':
2020-04-16 05:36:48 +02:00
return _buildItem(context: context, spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.projectColumnEventMessage(e.payload!.action!, e.payload!.projectColumn!.name!)} '),
2020-04-16 05:36:48 +02:00
_buildRepo(context),
]);
case 'ProjectEvent':
2020-04-16 05:36:48 +02:00
return _buildItem(context: context, spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.projectEventMessage(e.payload!.action!, e.payload!.project!.name!)}} '),
2020-04-16 05:36:48 +02:00
]);
case 'PublicEvent':
2020-02-08 16:23:06 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(text: ' ${AppLocalizations.of(context)!.made} '),
_buildRepo(context),
TextSpan(text: ' ${AppLocalizations.of(context)!.public}'),
],
2020-02-08 16:23:06 +01:00
);
2019-02-07 10:19:08 +01:00
case 'PullRequestEvent':
2021-05-16 09:16:35 +02:00
final pr = e.payload!.pullRequest!;
2019-02-07 10:19:08 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.pullRequestEventMessage(e.payload!.action!)} '),
2019-12-22 06:00:58 +01:00
_buildIssue(context, pr.number, isPullRequest: true),
TextSpan(text: ' ${AppLocalizations.of(context)!.at} '),
2019-12-22 06:00:58 +01:00
_buildRepo(context),
2019-02-07 10:19:08 +01:00
],
2019-12-20 15:41:38 +01:00
card: _buildIssueCard(context, pr, pr.body, isPullRequest: true),
2019-02-07 10:19:08 +01:00
);
case 'PullRequestReviewEvent':
2021-05-16 09:16:35 +02:00
final pr = e.payload!.pullRequest!;
2020-04-16 05:36:48 +02:00
return _buildItem(context: context, spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.pullRequestReviewEventMessage(e.payload!.action!)} '),
2020-04-16 05:36:48 +02:00
_buildIssue(context, pr.number, isPullRequest: true),
TextSpan(text: ' ${AppLocalizations.of(context)!.at} '),
2020-04-16 05:36:48 +02:00
_buildRepo(context),
]);
2019-02-07 10:19:08 +01:00
case 'PullRequestReviewCommentEvent':
2021-05-16 09:16:35 +02:00
final pr = e.payload!.pullRequest!;
2019-02-07 10:19:08 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.pullRequestReviewCommentEventMessage} '),
2019-12-22 06:00:58 +01:00
_buildIssue(context, pr.number, isPullRequest: true),
TextSpan(text: ' ${AppLocalizations.of(context)!.at} '),
2019-12-22 06:00:58 +01:00
_buildRepo(context),
2019-02-07 10:19:08 +01:00
],
2021-05-16 09:16:35 +02:00
card: _buildIssueCard(context, pr, e.payload!.comment!.body,
2019-12-25 04:05:25 +01:00
isPullRequest: true),
2019-02-07 10:19:08 +01:00
);
case 'PushEvent':
2019-02-07 10:19:08 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(text: ' ${AppLocalizations.of(context)!.pushedTo} '),
_buildRepo(context)
],
2019-12-20 15:41:38 +01:00
card: _buildCommitsCard(context),
2019-02-07 10:19:08 +01:00
);
case 'ReleaseEvent':
2019-12-25 03:46:56 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(text: '${AppLocalizations.of(context)!.released} '),
2021-05-16 09:16:35 +02:00
_buildLinkSpan(context, e.payload!.release!.tagName,
e.payload!.release!.htmlUrl),
2022-09-06 18:28:12 +02:00
const TextSpan(text: ' at '),
2019-12-25 03:46:56 +01:00
_buildRepo(context)
],
);
// case 'RepositoryImportEvent':
// // Uses Source Imports API
case 'RepositoryVulnerabilityAlertEvent':
2020-04-16 05:36:48 +02:00
return _buildItem(context: context, spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.securityAlertInvolvingPackage(e.payload!.alert!.affectedPackageName!, e.payload!.alert!.affectedRange!, e.payload!.action!)}',
2020-04-16 05:36:48 +02:00
)
]);
case 'SecurityAdvisoryEvent':
2020-04-16 05:36:48 +02:00
return _buildItem(context: context, spans: [
TextSpan(
text:
' ${AppLocalizations.of(context)!.securityAdvisory(e.payload!.securityAdvisory!.summary!, e.payload!.action!)} ',
2020-04-16 05:36:48 +02:00
)
]);
case 'WatchEvent':
2019-02-07 10:19:08 +01:00
return _buildItem(
context: context,
spans: [
TextSpan(text: ' ${AppLocalizations.of(context)!.starred} '),
_buildRepo(context)
],
2019-02-07 10:19:08 +01:00
);
default:
2019-12-12 07:02:48 +01:00
return _buildDefaultItem(context);
2019-02-07 10:19:08 +01:00
}
}
2018-07-05 16:08:19 +02:00
}