2019-01-27 17:37:44 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
2019-02-07 07:35:19 +01:00
|
|
|
import '../screens/user.dart';
|
2019-01-31 07:37:25 +01:00
|
|
|
import 'link.dart';
|
2019-01-27 17:37:44 +01:00
|
|
|
|
|
|
|
class Avatar extends StatelessWidget {
|
|
|
|
final String url;
|
2019-03-09 10:03:33 +01:00
|
|
|
final String login;
|
2019-02-03 08:50:17 +01:00
|
|
|
final double size;
|
2019-01-27 17:37:44 +01:00
|
|
|
|
2019-02-03 08:50:17 +01:00
|
|
|
Avatar({
|
|
|
|
@required this.url,
|
|
|
|
this.size = 18,
|
2019-03-09 10:03:33 +01:00
|
|
|
this.login,
|
2019-02-03 08:50:17 +01:00
|
|
|
});
|
2019-01-27 17:37:44 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-03-09 10:03:33 +01:00
|
|
|
var avatar = ClipRRect(
|
2019-09-04 16:59:33 +02:00
|
|
|
borderRadius: BorderRadius.circular(4),
|
2019-03-09 10:03:33 +01:00
|
|
|
child: FadeInImage.assetNetwork(
|
|
|
|
placeholder: 'images/octoface.png',
|
|
|
|
image: url,
|
|
|
|
width: 2 * size,
|
|
|
|
height: 2 * size,
|
|
|
|
fadeInDuration: Duration(milliseconds: 200),
|
|
|
|
fadeOutDuration: Duration(milliseconds: 100),
|
2019-01-27 17:37:44 +01:00
|
|
|
),
|
|
|
|
);
|
2019-03-09 10:03:33 +01:00
|
|
|
|
|
|
|
if (login == null) {
|
|
|
|
return avatar;
|
|
|
|
} else {
|
|
|
|
return Link(
|
|
|
|
screenBuilder: (_) => UserScreen(login),
|
|
|
|
child: avatar,
|
|
|
|
);
|
|
|
|
}
|
2019-01-27 17:37:44 +01:00
|
|
|
}
|
|
|
|
}
|