fromRxChat static method
Creates an AvatarWidget from the specified RxChat.
Implementation
static Widget fromRxChat(
RxChat? chat, {
Key? key,
AvatarRadius? radius,
double opacity = 1,
FutureOr<void> Function()? onForbidden,
BoxShape shape = BoxShape.circle,
}) {
if (chat == null) {
return AvatarWidget(key: key, radius: radius, opacity: opacity);
}
return Obx(() {
if (chat.chat.value.isMonolog) {
return AvatarWidget.fromMonolog(
chat.chat.value,
chat.me,
radius: radius,
opacity: opacity,
shape: shape,
);
}
final RxUser? user =
chat.members.values
.firstWhereOrNull((e) => e.user.id != chat.me)
?.user;
return AvatarWidget(
key: key,
isOnline: chat.chat.value.isDialog && user?.user.value.online == true,
isAway:
chat.chat.value.isDialog &&
user?.user.value.presence == Presence.away,
avatar: chat.avatar.value,
title: chat.title,
color: chat.chat.value.colorDiscriminant(chat.me).sum(),
radius: radius,
opacity: opacity,
onForbidden: onForbidden,
shape: shape,
);
});
}