1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-24 06:42:07 +01:00

refactor: drop unused actions

This commit is contained in:
Rongjian Zhang 2019-12-22 13:03:57 +08:00
parent 6544e93e6b
commit ad54108855

View File

@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:git_touch/models/github.dart'; import 'package:git_touch/models/github.dart';
import 'package:git_touch/models/theme.dart'; import 'package:git_touch/models/theme.dart';
import 'package:git_touch/widgets/action_button.dart';
import 'package:git_touch/widgets/issue_icon.dart'; import 'package:git_touch/widgets/issue_icon.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:timeago/timeago.dart' as timeago; import 'package:timeago/timeago.dart' as timeago;
@ -39,19 +38,10 @@ class EventItem extends StatelessWidget {
'/${e.repoOwner}/${e.repoName}/${isPullRequest ? 'pulls' : 'issues'}/$number'); '/${e.repoOwner}/${e.repoName}/${isPullRequest ? 'pulls' : 'issues'}/$number');
} }
Iterable<ActionItem> _getUserActions(List<String> users) {
// Remove duplicates
return users.toSet().map((user) {
return ActionItem.user(user);
});
}
Widget _buildItem({ Widget _buildItem({
@required BuildContext context, @required BuildContext context,
@required List<InlineSpan> spans, @required List<InlineSpan> spans,
Widget card, Widget card,
String url,
List<ActionItem> actionItems,
}) { }) {
final theme = Provider.of<ThemeModel>(context); final theme = Provider.of<ThemeModel>(context);
return Container( return Container(
@ -92,13 +82,6 @@ class EventItem extends StatelessWidget {
fontSize: 14, fontSize: 14,
color: theme.palette.tertiaryText, color: theme.palette.tertiaryText,
)), )),
// Expanded(child: Container()),
// GestureDetector(
// child: Icon(Icons.more_horiz),
// onTap: () {
// theme.showActions(context, actionItems);
// },
// ),
], ],
), ),
if (card != null) card if (card != null) card
@ -271,8 +254,6 @@ class EventItem extends StatelessWidget {
@override @override
build(BuildContext context) { build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
// all events types here: // all events types here:
// https://developer.github.com/v3/activity/events/types/#event-types--payloads // https://developer.github.com/v3/activity/events/types/#event-types--payloads
switch (e.type) { switch (e.type) {
@ -299,12 +280,6 @@ class EventItem extends StatelessWidget {
TextSpan(text: ' from '), TextSpan(text: ' from '),
_buildRepo(context), _buildRepo(context),
], ],
url: '/$forkeeOwner/$forkeeName',
actionItems: [
..._getUserActions([e.actor.login, forkeeOwner]),
ActionItem.repository(forkeeOwner, forkeeName),
ActionItem.repository(e.repoOwner, e.repoName),
],
); );
case 'ForkApplyEvent': case 'ForkApplyEvent':
case 'GitHubAppAuthorizationEvent': case 'GitHubAppAuthorizationEvent':
@ -331,11 +306,6 @@ class EventItem extends StatelessWidget {
e.payload.comment.body, e.payload.comment.body,
isPullRequest: e.payload.issue.isPullRequestComment, isPullRequest: e.payload.issue.isPullRequestComment,
), ),
actionItems: [
..._getUserActions([e.actor.login, e.repoOwner]),
ActionItem.pullRequest(
e.repoOwner, e.repoName, e.payload.issue.number),
],
); );
case 'IssuesEvent': case 'IssuesEvent':
final issue = e.payload.issue; final issue = e.payload.issue;
@ -348,12 +318,6 @@ class EventItem extends StatelessWidget {
_buildRepo(context), _buildRepo(context),
], ],
card: _buildIssueCard(context, issue, issue.body), card: _buildIssueCard(context, issue, issue.body),
url: '/${e.repoOwner}/${e.repoName}/issues/${issue.number}',
actionItems: [
..._getUserActions([e.actor.login, e.repoOwner]),
ActionItem.repository(e.repoOwner, e.repoName),
ActionItem.issue(e.repoOwner, e.repoName, issue.number),
],
); );
case 'LabelEvent': case 'LabelEvent':
case 'MarketplacePurchaseEvent': case 'MarketplacePurchaseEvent':
@ -380,12 +344,6 @@ class EventItem extends StatelessWidget {
_buildRepo(context), _buildRepo(context),
], ],
card: _buildIssueCard(context, pr, pr.body, isPullRequest: true), card: _buildIssueCard(context, pr, pr.body, isPullRequest: true),
url: '/${e.repoOwner}/${e.repoName}/pulls/${pr.number}',
actionItems: [
..._getUserActions([e.actor.login, e.repoOwner]),
ActionItem.repository(e.repoOwner, e.repoName),
ActionItem.pullRequest(e.repoOwner, e.repoName, pr.number),
],
); );
case 'PullRequestReviewEvent': case 'PullRequestReviewEvent':
// TODO: // TODO:
@ -401,22 +359,12 @@ class EventItem extends StatelessWidget {
_buildRepo(context), _buildRepo(context),
], ],
card: _buildIssueCard(context, pr, pr.body), card: _buildIssueCard(context, pr, pr.body),
url: '/${e.repoOwner}/${e.repoName}/pulls/${pr.number}',
actionItems: [
..._getUserActions([e.actor.login, e.repoOwner]),
ActionItem.repository(e.repoOwner, e.repoName),
ActionItem.pullRequest(e.repoOwner, e.repoName, pr.number),
],
); );
case 'PushEvent': case 'PushEvent':
return _buildItem( return _buildItem(
context: context, context: context,
spans: [TextSpan(text: ' pushed to '), _buildRepo(context)], spans: [TextSpan(text: ' pushed to '), _buildRepo(context)],
card: _buildCommitsCard(context), card: _buildCommitsCard(context),
actionItems: [
..._getUserActions([e.actor.login, e.repoOwner]),
ActionItem.repository(e.repoOwner, e.repoName),
],
); );
case 'ReleaseEvent': case 'ReleaseEvent':
case 'RepositoryEvent': case 'RepositoryEvent':
@ -432,11 +380,6 @@ class EventItem extends StatelessWidget {
return _buildItem( return _buildItem(
context: context, context: context,
spans: [TextSpan(text: ' starred '), _buildRepo(context)], spans: [TextSpan(text: ' starred '), _buildRepo(context)],
url: '/${e.repoOwner}/${e.repoName}',
actionItems: [
..._getUserActions([e.actor.login, e.repoOwner]),
ActionItem.repository(e.repoOwner, e.repoName),
],
); );
default: default:
return _buildDefaultItem(context); return _buildDefaultItem(context);