import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import '../model/accountData.dart'; import '../model/endpointData.dart'; class UserAvatar extends StatelessWidget { final String id; final bool isGroup; final int size; const UserAvatar({required this.id, this.isGroup = false, this.size = 20, super.key}); @override Widget build(BuildContext context) { if(isGroup) { return CircleAvatar( foregroundImage: Image( image: CachedNetworkImageProvider( "https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/ocs/v2.php/apps/spreed/api/v1/room/$id/avatar", errorListener: (p0) {} ) ).image, backgroundColor: Theme.of(context).primaryColor, foregroundColor: Colors.white, onForegroundImageError: (o, t) {}, radius: size.toDouble(), child: Icon(Icons.group, size: size.toDouble()), ); } else { return CircleAvatar( foregroundImage: Image( image: CachedNetworkImageProvider( "https://${EndpointData().nextcloud().full()}/avatar/$id/$size", errorListener: (p0) {} ), ).image, backgroundColor: Theme.of(context).primaryColor, foregroundColor: Colors.white, onForegroundImageError: (o, t) {}, radius: size.toDouble(), child: Icon(Icons.person, size: size.toDouble()), ); } } }