2019-01-27 17:37:44 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2019-11-02 14:44:26 +01:00
|
|
|
import 'package:git_touch/models/theme.dart';
|
2019-11-02 15:30:26 +01:00
|
|
|
import 'package:git_touch/screens/image_view.dart';
|
2019-11-02 14:44:26 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2019-01-27 17:37:44 +01:00
|
|
|
|
|
|
|
class Avatar extends StatelessWidget {
|
|
|
|
final String url;
|
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,
|
2019-10-02 09:23:33 +02:00
|
|
|
@required this.size,
|
2019-02-03 08:50:17 +01:00
|
|
|
});
|
2019-10-02 09:23:33 +02:00
|
|
|
Avatar.extraSmall({
|
|
|
|
@required this.url,
|
|
|
|
}) : size = 16;
|
2019-10-03 04:12:22 +02:00
|
|
|
Avatar.small({@required this.url}) : size = 24;
|
2019-10-02 09:23:33 +02:00
|
|
|
Avatar.medium({
|
|
|
|
@required this.url,
|
|
|
|
}) : size = 36;
|
|
|
|
Avatar.large({
|
|
|
|
@required this.url,
|
|
|
|
}) : size = 48;
|
2019-01-27 17:37:44 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-11-02 14:44:26 +01:00
|
|
|
return GestureDetector(
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(4),
|
|
|
|
child: FadeInImage.assetNetwork(
|
|
|
|
placeholder: 'images/octoface.png',
|
|
|
|
image: url,
|
|
|
|
width: size,
|
|
|
|
height: size,
|
|
|
|
fadeInDuration: Duration(milliseconds: 200),
|
|
|
|
fadeOutDuration: Duration(milliseconds: 100),
|
|
|
|
),
|
2019-01-27 17:37:44 +01:00
|
|
|
),
|
2019-11-02 14:44:26 +01:00
|
|
|
onTap: () {
|
2019-11-02 15:30:26 +01:00
|
|
|
Provider.of<ThemeModel>(context).pushRoute(
|
|
|
|
context, (_) => ImageViewScreen(url),
|
|
|
|
fullscreenDialog: true);
|
2019-11-02 14:44:26 +01:00
|
|
|
},
|
2019-01-27 17:37:44 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|