From cd38d96a91d2a2c835adff1d253f90437bbc54fd Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sun, 12 Jan 2020 21:39:03 +0800 Subject: [PATCH] fix: avatar click --- lib/screens/repository.dart | 9 +++++---- lib/screens/user.dart | 2 +- lib/widgets/avatar.dart | 28 ++++++++++++++-------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/screens/repository.dart b/lib/screens/repository.dart index c904ab9..338e5bf 100644 --- a/lib/screens/repository.dart +++ b/lib/screens/repository.dart @@ -133,10 +133,11 @@ class RepositoryScreen extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - GithubAvatar( - url: repo.owner.avatarUrl, - size: AvatarSize.small, - login: owner), + Avatar( + url: repo.owner.avatarUrl, + size: AvatarSize.small, + linkUrl: '/$owner', + ), SizedBox(width: 8), Text( '$owner / $name', diff --git a/lib/screens/user.dart b/lib/screens/user.dart index 33330b7..95145c6 100644 --- a/lib/screens/user.dart +++ b/lib/screens/user.dart @@ -256,7 +256,7 @@ class UserScreen extends StatelessWidget { leftIconData: Octicons.organization, text: TextContainsOrganization( p.company, - style: TextStyle(fontSize: 16, color: theme.palette.text), + style: TextStyle(fontSize: 17, color: theme.palette.text), oneLine: true, ), ), diff --git a/lib/widgets/avatar.dart b/lib/widgets/avatar.dart index 35a4384..dea339e 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -25,21 +25,22 @@ class Avatar extends StatelessWidget { @override Widget build(BuildContext context) { - return GestureDetector( - child: ClipRRect( - borderRadius: borderRadius ?? BorderRadius.circular(size / 2), - child: FadeInImage.assetNetwork( - placeholder: 'images/avatar.png', - image: url ?? 'images/avatar.png', - width: size, - height: size, - fadeInDuration: Duration(milliseconds: 200), - fadeOutDuration: Duration(milliseconds: 100), - ), + final widget = ClipRRect( + borderRadius: borderRadius ?? BorderRadius.circular(size / 2), + child: FadeInImage.assetNetwork( + placeholder: 'images/avatar.png', + image: url ?? 'images/avatar.png', + width: size, + height: size, + fadeInDuration: Duration(milliseconds: 200), + fadeOutDuration: Duration(milliseconds: 100), ), + ); + if (linkUrl == null) return widget; + return GestureDetector( + child: widget, onTap: () { - if (linkUrl != null) - Provider.of(context).push(context, linkUrl); + Provider.of(context).push(context, linkUrl); }, ); } @@ -79,7 +80,6 @@ class GitlabAvatar extends StatelessWidget { url: url, size: size, linkUrl: '/user/$id', - borderRadius: BorderRadius.circular(size / 2), ); } }