mirror of
https://github.com/git-touch/git-touch
synced 2024-12-18 19:22:54 +01:00
refactor: url action items
This commit is contained in:
parent
e97befd412
commit
4ea5a03431
@ -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),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -401,8 +401,7 @@ mutation {
|
||||
});
|
||||
},
|
||||
),
|
||||
ActionItem.share(payload['url']),
|
||||
ActionItem.launch(payload['url']),
|
||||
...ActionItem.getUrlActions(payload['url'] as String),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
@ -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),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -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:
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user