parent
c2f05da96e
commit
edb9b56637
@ -47,7 +47,7 @@ class _ChatInfoState extends State<ChatInfo> {
|
|||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: UserAvatar(
|
child: UserAvatar(
|
||||||
username: widget.room.name,
|
id: isGroup ? widget.room.token : widget.room.name,
|
||||||
isGroup: isGroup,
|
isGroup: isGroup,
|
||||||
size: 80,
|
size: 80,
|
||||||
),
|
),
|
||||||
|
@ -21,7 +21,7 @@ class _ParticipantsListViewState extends State<ParticipantsListView> {
|
|||||||
body: ListView(
|
body: ListView(
|
||||||
children: widget.participantsResponse.data.map((participant) {
|
children: widget.participantsResponse.data.map((participant) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: UserAvatar(username: participant.actorId),
|
leading: UserAvatar(id: participant.actorId),
|
||||||
title: Text(participant.displayName),
|
title: Text(participant.displayName),
|
||||||
subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null,
|
subtitle: participant.statusMessage != null ? Text(participant.statusMessage!) : null,
|
||||||
);
|
);
|
||||||
|
@ -31,6 +31,7 @@ class ChatTile extends StatefulWidget {
|
|||||||
|
|
||||||
class _ChatTileState extends State<ChatTile> {
|
class _ChatTileState extends State<ChatTile> {
|
||||||
late String username;
|
late String username;
|
||||||
|
late UserAvatar circleAvatar;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -38,6 +39,9 @@ class _ChatTileState extends State<ChatTile> {
|
|||||||
SharedPreferences.getInstance().then((value) => {
|
SharedPreferences.getInstance().then((value) => {
|
||||||
username = value.getString("username")!
|
username = value.getString("username")!
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bool isGroup = widget.data.type != GetRoomResponseObjectConversationType.oneToOne;
|
||||||
|
circleAvatar = UserAvatar(id: isGroup ? widget.data.token : widget.data.name, isGroup: isGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentAsRead() {
|
void setCurrentAsRead() {
|
||||||
@ -50,10 +54,9 @@ class _ChatTileState extends State<ChatTile> {
|
|||||||
).run().then((value) => widget.query(renew: true));
|
).run().then((value) => widget.query(renew: true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool isGroup = widget.data.type != GetRoomResponseObjectConversationType.oneToOne;
|
|
||||||
UserAvatar circleAvatar = UserAvatar(username: widget.data.name, isGroup: isGroup);
|
|
||||||
|
|
||||||
return Consumer<ChatProps>(builder: (context, chatData, child) {
|
return Consumer<ChatProps>(builder: (context, chatData, child) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
@ -55,7 +55,7 @@ class _MessageReactionsState extends State<MessageReactions> {
|
|||||||
children: entry.value.map((e) {
|
children: entry.value.map((e) {
|
||||||
bool isSelf = AccountData().getUsername() == e.actorId;
|
bool isSelf = AccountData().getUsername() == e.actorId;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: UserAvatar(username: e.actorId, isGroup: false),
|
leading: UserAvatar(id: e.actorId, isGroup: false),
|
||||||
title: Text(e.actorDisplayName),
|
title: Text(e.actorDisplayName),
|
||||||
subtitle: isSelf
|
subtitle: isSelf
|
||||||
? const Text("Du")
|
? const Text("Du")
|
||||||
|
@ -1,23 +1,45 @@
|
|||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../model/accountData.dart';
|
||||||
import '../model/endpointData.dart';
|
import '../model/endpointData.dart';
|
||||||
|
|
||||||
class UserAvatar extends StatelessWidget {
|
class UserAvatar extends StatelessWidget {
|
||||||
final String username;
|
final String id;
|
||||||
final bool isGroup;
|
final bool isGroup;
|
||||||
final int size;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CircleAvatar(
|
if(isGroup) {
|
||||||
foregroundImage: !isGroup ? Image.network("https://${EndpointData().nextcloud().full()}/avatar/$username/$size").image : null,
|
return CircleAvatar(
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
foregroundImage: Image(
|
||||||
foregroundColor: Colors.white,
|
image: CachedNetworkImageProvider(
|
||||||
onForegroundImageError: !isGroup ? (o, t) {} : null,
|
"https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/ocs/v2.php/apps/spreed/api/v1/room/$id/avatar",
|
||||||
radius: size.toDouble(),
|
errorListener: (p0) {}
|
||||||
child: isGroup ? Icon(Icons.group, size: size.toDouble()) : Icon(Icons.person, size: size.toDouble()),
|
)
|
||||||
);
|
).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()),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user