2020-04-15 10:04:19 +00:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:comunic/models/group.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
/// Custom group icon
|
|
|
|
///
|
|
|
|
/// @author Pierre Hubert
|
|
|
|
class GroupIcon extends StatelessWidget {
|
|
|
|
final Group group;
|
|
|
|
final double width;
|
|
|
|
|
|
|
|
const GroupIcon({
|
2022-03-10 18:39:57 +00:00
|
|
|
Key? key,
|
|
|
|
required this.group,
|
2020-04-15 10:04:19 +00:00
|
|
|
this.width = 50,
|
2022-03-11 15:40:56 +00:00
|
|
|
}) : super(key: key);
|
2020-04-15 10:04:19 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Material(
|
2020-04-16 06:58:56 +00:00
|
|
|
color: Colors.transparent,
|
2020-04-15 10:04:19 +00:00
|
|
|
child: CachedNetworkImage(
|
|
|
|
imageUrl: group.iconURL,
|
|
|
|
width: width,
|
|
|
|
height: width,
|
|
|
|
placeholder: (c, s) => Container(
|
|
|
|
color: Colors.grey,
|
|
|
|
width: width,
|
|
|
|
height: width,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
strokeWidth: 4.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
errorWidget: (c, s, o) => Container(
|
|
|
|
color: Colors.red,
|
|
|
|
width: width,
|
|
|
|
height: width,
|
|
|
|
child: Icon(
|
|
|
|
Icons.error,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|