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

refactor: avatar size

This commit is contained in:
Rongjian Zhang 2019-10-02 15:23:33 +08:00
parent 378f8d10d8
commit ae5660061c
8 changed files with 29 additions and 13 deletions

View File

@ -94,7 +94,7 @@ class CommitsScreen extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Avatar(url: payload['author']['avatarUrl'], size: 16),
Avatar.medium(url: payload['author']['avatarUrl']),
SizedBox(width: 8),
Expanded(
child: Column(

View File

@ -30,7 +30,7 @@ class _LoginScreenState extends State<LoginScreen> {
),
child: Row(
children: <Widget>[
Avatar(url: account.avatarUrl, size: 24),
Avatar.large(url: account.avatarUrl),
Padding(padding: EdgeInsets.only(left: 10)),
Expanded(
child: Column(

View File

@ -10,9 +10,25 @@ class Avatar extends StatelessWidget {
Avatar({
@required this.url,
this.size = 18,
this.login,
@required this.size,
});
Avatar.extraSmall({
@required this.url,
this.login,
}) : size = 16;
Avatar.small({
@required this.url,
this.login,
}) : size = 24;
Avatar.medium({
@required this.url,
this.login,
}) : size = 36;
Avatar.large({
@required this.url,
this.login,
}) : size = 48;
@override
Widget build(BuildContext context) {
@ -21,8 +37,8 @@ class Avatar extends StatelessWidget {
child: FadeInImage.assetNetwork(
placeholder: 'images/octoface.png',
image: url,
width: 2 * size,
height: 2 * size,
width: size,
height: size,
fadeInDuration: Duration(milliseconds: 200),
fadeOutDuration: Duration(milliseconds: 100),
),

View File

@ -43,9 +43,8 @@ class CommentItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Avatar(
Avatar.medium(
url: payload['author']['avatarUrl'],
size: 16,
login: payload['author']['login'],
),
SizedBox(width: 8),

View File

@ -79,10 +79,9 @@ class EventItem extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Avatar(
Avatar.medium(
url: event.actorAvatarUrl,
login: event.actorLogin,
size: 20,
),
SizedBox(width: 10),
Expanded(

View File

@ -120,10 +120,9 @@ class IssueItem extends StatelessWidget {
children: <Widget>[
// FIXME: Deleted user
if (payload['author'] != null) ...[
Avatar(
Avatar.extraSmall(
login: payload['author']['login'],
url: payload['author']['avatarUrl'],
size: 8,
),
SizedBox(width: 4),
Text(

View File

@ -130,7 +130,10 @@ class RepositoryItem extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Avatar(url: payload['owner']['avatarUrl'], size: 12),
Avatar.small(
url: payload['owner']['avatarUrl'],
login: payload['owner']['login'],
),
SizedBox(width: 8),
Expanded(
child: Column(

View File

@ -50,7 +50,7 @@ class UserItem extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Avatar(url: avatarUrl, size: 24),
Avatar.large(url: avatarUrl),
SizedBox(width: 10),
Expanded(
child: Column(