diff --git a/lib/view/pages/talk/chatBubble.dart b/lib/view/pages/talk/chatBubble.dart index 24ce608..805e4d8 100644 --- a/lib/view/pages/talk/chatBubble.dart +++ b/lib/view/pages/talk/chatBubble.dart @@ -176,12 +176,12 @@ class _ChatBubbleState extends State<ChatBubble> { ), onLongPress: () { showDialog(context: context, builder: (context) { - List<String> commonReactions = ["👍", "👎", "😆", "❤️", "💔", "😍"]; - bool reactable = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment; + List<String> commonReactions = ["👍", "👎", "😆", "❤️", "👀", "🤔"]; + bool canReact = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment; return SimpleDialog( children: [ Visibility( - visible: reactable, + visible: canReact, child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -211,7 +211,7 @@ class _ChatBubbleState extends State<ChatBubble> { ) ), Visibility( - visible: reactable, + visible: canReact, child: ListTile( leading: const Icon(Icons.add_reaction_outlined), title: const Text("Reaktionen"), diff --git a/lib/view/pages/talk/chatList.dart b/lib/view/pages/talk/chatList.dart index 473d0a6..dacee98 100644 --- a/lib/view/pages/talk/chatList.dart +++ b/lib/view/pages/talk/chatList.dart @@ -62,8 +62,6 @@ class _ChatListState extends State<ChatList> { ).asDialog(context); } }); - - } void _query({bool renew = false}) { diff --git a/lib/view/pages/talk/chatTile.dart b/lib/view/pages/talk/chatTile.dart index afc8de5..cb219a9 100644 --- a/lib/view/pages/talk/chatTile.dart +++ b/lib/view/pages/talk/chatTile.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:jiffy/jiffy.dart'; +import 'package:marianum_mobile/widget/userAvatar.dart'; import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -9,7 +10,6 @@ import '../../../api/marianumcloud/talk/room/getRoomResponse.dart'; import '../../../api/marianumcloud/talk/setFavorite/setFavorite.dart'; import '../../../api/marianumcloud/talk/setReadMarker/setReadMarker.dart'; import '../../../api/marianumcloud/talk/setReadMarker/setReadMarkerParams.dart'; -import '../../../model/endpointData.dart'; import '../../../widget/confirmDialog.dart'; import '../../../widget/debug/debugTile.dart'; import 'chatView.dart'; @@ -49,14 +49,8 @@ class _ChatTileState extends State<ChatTile> { @override Widget build(BuildContext context) { - bool useRemotePicture = widget.data.type == GetRoomResponseObjectConversationType.oneToOne; - CircleAvatar circleAvatar = CircleAvatar( - foregroundImage: useRemotePicture ? Image.network("https://${EndpointData().nextcloud().full()}/avatar/${widget.data.name}/128").image : null, - backgroundColor: Theme.of(context).primaryColor, - foregroundColor: Colors.white, - onForegroundImageError: useRemotePicture ? (o, t) {} : null, - child: widget.data.type == GetRoomResponseObjectConversationType.group ? const Icon(Icons.group) : const Icon(Icons.person), - ); + bool isGroup = widget.data.type == GetRoomResponseObjectConversationType.oneToOne; + UserAvatar circleAvatar = UserAvatar(username: widget.data.name, isGroup: isGroup); return ListTile( leading: Stack( diff --git a/lib/view/pages/talk/chatView.dart b/lib/view/pages/talk/chatView.dart index 9f37d91..9acf6d7 100644 --- a/lib/view/pages/talk/chatView.dart +++ b/lib/view/pages/talk/chatView.dart @@ -8,13 +8,14 @@ import '../../../api/marianumcloud/talk/room/getRoomResponse.dart'; import '../../../theming/appTheme.dart'; import '../../../model/chatList/chatProps.dart'; import '../../../widget/loadingSpinner.dart'; +import '../../../widget/userAvatar.dart'; import 'chatBubble.dart'; import 'chatTextfield.dart'; class ChatView extends StatefulWidget { final GetRoomResponseObject room; final String selfId; - final CircleAvatar avatar; + final UserAvatar avatar; const ChatView({Key? key, required this.room, required this.selfId, required this.avatar}) : super(key: key); diff --git a/lib/view/pages/talk/messageReactions.dart b/lib/view/pages/talk/messageReactions.dart index f7b3086..0001844 100644 --- a/lib/view/pages/talk/messageReactions.dart +++ b/lib/view/pages/talk/messageReactions.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:marianum_mobile/widget/userAvatar.dart'; import '../../../api/marianumcloud/talk/getReactions/getReactions.dart'; import '../../../api/marianumcloud/talk/getReactions/getReactionsResponse.dart'; @@ -54,16 +55,20 @@ class _MessageReactionsState extends State<MessageReactions> { children: entry.value.map((e) { bool isSelf = AccountData().getUsername() == e.actorId; return ListTile( - leading: const CenteredLeading(Icon(Icons.person)), + leading: UserAvatar(username: e.actorId, isGroup: false), title: Text(e.actorDisplayName), - subtitle: isSelf ? const Text("Du") : e.actorType == GetReactionsResponseObjectActorType.guests ? const Text("Gast") : null, - trailing: isSelf ? null : Visibility( - visible: kReleaseMode, - child: IconButton( - onPressed: () => UnimplementedDialog.show(context), - icon: const Icon(Icons.textsms_outlined), + subtitle: isSelf + ? const Text("Du") + : e.actorType == GetReactionsResponseObjectActorType.guests ? const Text("Gast") : null, + trailing: isSelf + ? null + : Visibility( + visible: kReleaseMode, + child: IconButton( + onPressed: () => UnimplementedDialog.show(context), + icon: const Icon(Icons.textsms_outlined), + ), ), - ), ); }).toList(), ); diff --git a/lib/widget/userAvatar.dart b/lib/widget/userAvatar.dart new file mode 100644 index 0000000..1afdb55 --- /dev/null +++ b/lib/widget/userAvatar.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +import '../model/endpointData.dart'; + +class UserAvatar extends StatelessWidget { + final String username; + final bool isGroup; + const UserAvatar({required this.username, this.isGroup = false, super.key}); + + @override + Widget build(BuildContext context) { + return CircleAvatar( + foregroundImage: !isGroup ? Image.network("https://${EndpointData().nextcloud().full()}/avatar/$username/128").image : null, + backgroundColor: Theme.of(context).primaryColor, + foregroundColor: Colors.white, + onForegroundImageError: !isGroup ? (o, t) {} : null, + child: isGroup ? const Icon(Icons.group) : const Icon(Icons.person), + ); + } +}