git-touch-android-ios-app/lib/widgets/avatar.dart

43 lines
1.0 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2019-11-02 14:44:26 +01:00
import 'package:git_touch/models/theme.dart';
import 'package:provider/provider.dart';
2019-12-22 04:11:13 +01:00
class AvatarSize {
static const double extraSmall = 20;
static const double small = 24;
static const double medium = 36;
static const double large = 48;
}
class Avatar extends StatelessWidget {
final String url;
2019-02-03 08:50:17 +01:00
final double size;
2019-10-02 09:23:33 +02:00
Avatar.large({
@required this.url,
}) : size = 48;
2019-12-22 04:11:13 +01:00
Avatar({this.url, this.size = AvatarSize.medium});
@override
Widget build(BuildContext context) {
2019-11-02 14:44:26 +01:00
return GestureDetector(
child: ClipRRect(
borderRadius: BorderRadius.circular(4),
child: FadeInImage.assetNetwork(
2019-12-22 04:05:55 +01:00
placeholder: 'images/avatar.png',
image: url ?? 'images/avatar.png',
2019-11-02 14:44:26 +01:00
width: size,
height: size,
fadeInDuration: Duration(milliseconds: 200),
fadeOutDuration: Duration(milliseconds: 100),
),
),
2019-11-02 14:44:26 +01:00
onTap: () {
2019-12-22 04:05:55 +01:00
// Provider.of<ThemeModel>(context).push(
// context, '/$login');
2019-11-02 14:44:26 +01:00
},
);
}
}