diff --git a/lib/view/pages/talk/chatView.dart b/lib/view/pages/talk/chatView.dart index c66725f..34577bb 100644 --- a/lib/view/pages/talk/chatView.dart +++ b/lib/view/pages/talk/chatView.dart @@ -71,6 +71,7 @@ class _ChatViewState extends State { chatData: widget.room, refetch: _query, isRead: element.id <= commonRead, + selfId: widget.selfId, ) ); }); @@ -129,8 +130,8 @@ class _ChatViewState extends State { Container( color: Theme.of(context).colorScheme.background, child: TalkNavigator.isSecondaryVisible(context) - ? ChatTextfield(widget.room.token) - : SafeArea(child: ChatTextfield(widget.room.token) + ? ChatTextfield(widget.room.token, selfId: widget.selfId) + : SafeArea(child: ChatTextfield(widget.room.token, selfId: widget.selfId) ), ) ], diff --git a/lib/view/pages/talk/components/chatBubble.dart b/lib/view/pages/talk/components/chatBubble.dart index c2a63c2..428a168 100644 --- a/lib/view/pages/talk/components/chatBubble.dart +++ b/lib/view/pages/talk/components/chatBubble.dart @@ -30,6 +30,7 @@ class ChatBubble extends StatefulWidget { final GetChatResponseObject bubbleData; final GetRoomResponseObject chatData; final bool isRead; + final String? selfId; final double spacing = 3; final double timeIconSize = 11; @@ -44,6 +45,7 @@ class ChatBubble extends StatefulWidget { required this.chatData, required this.refetch, this.isRead = false, + this.selfId, super.key}); @override @@ -267,7 +269,14 @@ class _ChatBubbleState extends State { message = ChatMessage(originalMessage: widget.bubbleData.message, originalData: widget.bubbleData.messageParameters); var showActorDisplayName = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment && widget.chatData.type != GetRoomResponseObjectConversationType.oneToOne; var showBubbleTime = widget.bubbleData.messageType != GetRoomResponseObjectMessageType.system; + var parent = widget.bubbleData.parent; + var isSenderOfParent = parent != null && parent.actorId == widget.selfId; + var parentMessage = parent == null + ? '' + : ChatMessage(originalMessage: parent.message, originalData: parent.messageParameters).containsFile + ? 'Datei' + : parent.message; var actorText = Text( widget.bubbleData.actorDisplayName, @@ -347,37 +356,6 @@ class _ChatBubbleState extends State { style: getStyle(), child: Column( children: [ - Visibility( - visible: parent != null && parent.message.isNotEmpty, - child: Wrap( - alignment: WrapAlignment.start, - clipBehavior: Clip.hardEdge, - children: [ - DecoratedBox( - decoration: BoxDecoration( - color: Theme.of(context).secondaryHeaderColor, - ), - child: Text( - parent?.message ?? '', - maxLines: 2, - style: const TextStyle( - overflow: TextOverflow.ellipsis, - ), - ), - ), - ], - ), - // SizedBox( - // width: parentMessageWidth < MediaQuery.of(context).size.width * 0.9 - // ? parentMessageWidth.toDouble() - // : MediaQuery.of(context).size.width * 0.9, - // height: 20, - // child: Text( - // parentMessage?.message ?? 'Ranz', - // overflow: TextOverflow.clip, - // ), - // ), - ), Container( constraints: BoxConstraints( maxWidth: MediaQuery.of(context).size.width * 0.9, @@ -387,10 +365,6 @@ class _ChatBubbleState extends State { ), child: Stack( children: [ - Padding( - padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0), - child: message.getWidget() - ), Visibility( visible: showActorDisplayName, child: Positioned( @@ -399,6 +373,69 @@ class _ChatBubbleState extends State { child: actorText ), ), + Padding( + padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Visibility( + visible: parent != null && parent.message.isNotEmpty, + child: Wrap( + alignment: WrapAlignment.start, + clipBehavior: Clip.hardEdge, + children: [ + DecoratedBox( + decoration: BoxDecoration( + color: isSenderOfParent + ? getSelfStyle(false).color?.withGreen(255).withOpacity(0.2) + : Colors.orange.withOpacity(0.2), + borderRadius: const BorderRadius.all(Radius.circular(5)), + border: Border( + left: BorderSide( + color: isSenderOfParent + ? getSelfStyle(false).color!.withGreen(255) + : Colors.orange, + width: 5, + ), + ), + ), + child: Padding( + padding: const EdgeInsets.all(5).add(const EdgeInsets.only(left: 5)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + parent?.actorDisplayName ?? '', + maxLines: 1, + style: TextStyle( + overflow: TextOverflow.ellipsis, + color: isSenderOfParent + ? getSelfStyle(false).color?.withGreen(255) + : Colors.orange, + fontSize: 12, + ), + ), + Text( + parentMessage, + maxLines: 2, + style: TextStyle( + overflow: TextOverflow.ellipsis, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.9), + fontSize: 12, + ), + ), + ], + ), + ), + ), + ], + ), + ), + const SizedBox(height: 5), + message.getWidget(), + ], + ), + ), Visibility( visible: showBubbleTime, child: Positioned( diff --git a/lib/view/pages/talk/components/chatTextfield.dart b/lib/view/pages/talk/components/chatTextfield.dart index a4199cd..734f641 100644 --- a/lib/view/pages/talk/components/chatTextfield.dart +++ b/lib/view/pages/talk/components/chatTextfield.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart'; @@ -18,7 +19,8 @@ import '../../files/filesUploadDialog.dart'; class ChatTextfield extends StatefulWidget { final String sendToToken; - const ChatTextfield(this.sendToToken, {super.key}); + final String? selfId; + const ChatTextfield(this.sendToToken, {this.selfId, super.key}); @override State createState() => _ChatTextfieldState(); @@ -106,7 +108,50 @@ class _ChatTextfieldState extends State { icon: const Icon(Icons.close_outlined), padding: const EdgeInsets.only(left: 0), ), - Text(referenceMessage.message), + Flexible( + child: DecoratedBox( + decoration: BoxDecoration( + color: referenceMessage.actorId == widget.selfId + ? Colors.green.withOpacity(0.2) + : Colors.orange.withOpacity(0.2), + borderRadius: const BorderRadius.all(Radius.circular(5)), + border: Border(left: BorderSide( + color: referenceMessage.actorId == widget.selfId + ? Colors.green + : Colors.orange, + width: 5 + )), + ), + child: Padding( + padding: const EdgeInsets.all(5).add(const EdgeInsets.only(left: 5)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + referenceMessage.actorDisplayName, + maxLines: 1, + style: TextStyle( + overflow: TextOverflow.ellipsis, + color: referenceMessage.actorId == widget.selfId + ? Colors.green + : Colors.orange, + fontSize: 12, + ), + ), + Text( + referenceMessage.message, + maxLines: 2, + style: TextStyle( + overflow: TextOverflow.ellipsis, + color: Theme.of(context).colorScheme.onSurface.withOpacity(0.9), + fontSize: 12, + ), + ), + ], + ), + ), + ), + ), ], ); } else {