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

improvement: add avatar link url

This commit is contained in:
Rongjian Zhang 2019-12-27 15:06:45 +08:00
parent 5fe740f450
commit 2bc130b91a
6 changed files with 51 additions and 19 deletions

View File

@ -56,7 +56,10 @@ class GitlabIssueScreen extends StatelessWidget {
Text(issue.title),
Row(
children: <Widget>[
Avatar(url: issue.author.avatarUrl),
Avatar(
url: issue.author.avatarUrl,
linkUrl: '/user/${issue.author}',
),
Expanded(
child: Text(issue.description),
),

View File

@ -12,12 +12,13 @@ class AvatarSize {
class Avatar extends StatelessWidget {
final String url;
final double size;
final String linkUrl;
Avatar.large({
Avatar({
@required this.url,
}) : size = 48;
Avatar({this.url, this.size = AvatarSize.medium});
this.size = AvatarSize.medium,
this.linkUrl,
});
@override
Widget build(BuildContext context) {
@ -34,9 +35,43 @@ class Avatar extends StatelessWidget {
),
),
onTap: () {
// Provider.of<ThemeModel>(context).push(
// context, '/$login');
if (linkUrl != null)
Provider.of<ThemeModel>(context).push(context, linkUrl);
},
);
}
}
class GithubAvatar extends StatelessWidget {
final String url;
final double size;
final String login;
GithubAvatar({
@required this.url,
this.size = AvatarSize.medium,
this.login,
});
@override
Widget build(BuildContext context) {
return Avatar(url: url, size: size, linkUrl: '/$login');
}
}
class GitlabAvatar extends StatelessWidget {
final String url;
final double size;
final String login;
GitlabAvatar({
@required this.url,
this.size = AvatarSize.medium,
this.login,
});
@override
Widget build(BuildContext context) {
return Avatar(url: url, size: size, linkUrl: '/$login');
}
}

View File

@ -45,9 +45,9 @@ class CommentItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Link(
url: '/' + payload['author']['login'],
child: Avatar(url: payload['author']['avatarUrl']),
Avatar(
url: payload['author']['avatarUrl'],
linkUrl: '/' + payload['author']['login'],
),
SizedBox(width: 8),
Expanded(

View File

@ -52,10 +52,7 @@ class EventItem extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Link(
url: '/' + e.actor.login,
child: Avatar(url: e.actor.avatarUrl),
),
Avatar(url: e.actor.avatarUrl, linkUrl: '/' + e.actor.login),
SizedBox(width: 10),
Expanded(
child: Column(

View File

@ -148,7 +148,7 @@ class RepositoryItem extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Avatar(url: avatarUrl, size: AvatarSize.small),
Avatar(url: avatarUrl, size: AvatarSize.small, linkUrl: '/$owner'),
SizedBox(width: 8),
Expanded(
child: Column(

View File

@ -88,10 +88,7 @@ class UserItem extends StatelessWidget {
if (inUserScreen) {
return widget;
} else {
return Link(
url: '/$login',
child: widget,
);
return Link(url: '/$login', child: widget);
}
}
}