@ -1,23 +1,45 @@
|
||||
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 username;
|
||||
final String id;
|
||||
final bool isGroup;
|
||||
final int size;
|
||||
const UserAvatar({required this.username, this.isGroup = false, this.size = 20, super.key});
|
||||
const UserAvatar({required this.id, this.isGroup = false, this.size = 20, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CircleAvatar(
|
||||
foregroundImage: !isGroup ? Image.network("https://${EndpointData().nextcloud().full()}/avatar/$username/$size").image : null,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
onForegroundImageError: !isGroup ? (o, t) {} : null,
|
||||
radius: size.toDouble(),
|
||||
child: isGroup ? Icon(Icons.group, size: size.toDouble()) : Icon(Icons.person, size: size.toDouble()),
|
||||
);
|
||||
|
||||
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()),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user