1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-18 11:19:28 +01:00

refactor: url action items

This commit is contained in:
Rongjian Zhang 2020-01-27 13:41:17 +08:00
parent e97befd412
commit 4ea5a03431
5 changed files with 19 additions and 22 deletions

View File

@ -41,8 +41,7 @@ class GitlabProjectScreen extends StatelessWidget {
return ActionButton(
title: 'Project Actions',
items: [
ActionItem.share(data.webUrl),
ActionItem.launch(data.webUrl),
...ActionItem.getUrlActions(data.webUrl),
],
);
},

View File

@ -401,8 +401,7 @@ mutation {
});
},
),
ActionItem.share(payload['url']),
ActionItem.launch(payload['url']),
...ActionItem.getUrlActions(payload['url'] as String),
],
],
);

View File

@ -130,8 +130,7 @@ class RepositoryScreen extends StatelessWidget {
text: 'Releases(${repo.releases.totalCount})',
url: 'https://github.com/$owner/$name/releases',
),
ActionItem.share(repo.url),
ActionItem.launch(repo.url),
...ActionItem.getUrlActions(repo.url),
],
);
},

View File

@ -402,20 +402,14 @@ class UserScreen extends StatelessWidget {
final user = payload as GhUserUser;
return ActionButton(
title: 'User Actions',
items: [
ActionItem.share(user.url),
ActionItem.launch(user.url),
],
items: [...ActionItem.getUrlActions(user.url)],
);
case 'Organization':
final organization = payload as GhUserOrganization;
return ActionButton(
title: 'Organization Actions',
items: [
if (payload != null) ...[
ActionItem.share(organization.url),
ActionItem.launch(organization.url),
],
...ActionItem.getUrlActions(organization.url),
],
);
default:

View File

@ -18,16 +18,22 @@ class ActionItem {
this.iconData,
});
ActionItem.share(String url)
: text = 'Share',
onTap = ((_) {
static List<ActionItem> getUrlActions(String url) {
return [
ActionItem(
text: 'Share',
onTap: (_) {
Share.share(url);
});
ActionItem.launch(String url)
: text = 'Open in Browser',
onTap = ((_) {
},
),
ActionItem(
text: 'Open in Browser',
onTap: (_) {
launchUrl(url);
});
},
),
];
}
}
class ActionButton extends StatelessWidget {