diff --git a/lib/api/marianumcloud/talk/chat/getChatResponse.dart b/lib/api/marianumcloud/talk/chat/getChatResponse.dart index b62b897..7055417 100644 --- a/lib/api/marianumcloud/talk/chat/getChatResponse.dart +++ b/lib/api/marianumcloud/talk/chat/getChatResponse.dart @@ -38,6 +38,7 @@ class GetChatResponseObject { Map? reactions; List? reactionsSelf; @JsonKey(fromJson: _fromJson) Map? messageParameters; + GetChatResponseObject? parent; GetChatResponseObject( this.id, @@ -53,7 +54,8 @@ class GetChatResponseObject { this.message, this.messageParameters, this.reactions, - this.reactionsSelf + this.reactionsSelf, + this.parent, ); factory GetChatResponseObject.fromJson(Map json) => _$GetChatResponseObjectFromJson(json); @@ -78,7 +80,8 @@ class GetChatResponseObject { text, null, null, - null + null, + null, ); } diff --git a/lib/api/marianumcloud/talk/chat/getChatResponse.g.dart b/lib/api/marianumcloud/talk/chat/getChatResponse.g.dart index 3da4655..0b241cb 100644 --- a/lib/api/marianumcloud/talk/chat/getChatResponse.g.dart +++ b/lib/api/marianumcloud/talk/chat/getChatResponse.g.dart @@ -52,6 +52,10 @@ GetChatResponseObject _$GetChatResponseObjectFromJson( (json['reactionsSelf'] as List?) ?.map((e) => e as String) .toList(), + json['parent'] == null + ? null + : GetChatResponseObject.fromJson( + json['parent'] as Map), ); Map _$GetChatResponseObjectToJson( @@ -74,6 +78,7 @@ Map _$GetChatResponseObjectToJson( 'reactionsSelf': instance.reactionsSelf, 'messageParameters': instance.messageParameters?.map((k, e) => MapEntry(k, e.toJson())), + 'parent': instance.parent?.toJson(), }; const _$GetRoomResponseObjectMessageActorTypeEnumMap = { diff --git a/lib/view/pages/talk/components/chatBubble.dart b/lib/view/pages/talk/components/chatBubble.dart index f8fb90c..c2a63c2 100644 --- a/lib/view/pages/talk/components/chatBubble.dart +++ b/lib/view/pages/talk/components/chatBubble.dart @@ -2,6 +2,7 @@ import 'package:better_open_file/better_open_file.dart'; import 'package:bubble/bubble.dart'; import 'package:emoji_picker_flutter/emoji_picker_flutter.dart' as emojis; import 'package:flowder/flowder.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -266,6 +267,7 @@ 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 actorText = Text( widget.bubbleData.actorDisplayName, @@ -343,57 +345,92 @@ class _ChatBubbleState extends State { }, child: Bubble( style: getStyle(), - child: Container( - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width * 0.9, - minWidth: showActorDisplayName - ? actorText.size.width - : timeText.size.width + (widget.isSender ? widget.spacing + widget.timeIconSize : 0) + 3, - ), - child: Stack( - children: [ - Padding( - padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0), - child: message.getWidget() + 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, + ), + ), + ), + ], ), - Visibility( - visible: showActorDisplayName, - child: Positioned( - top: 0, - left: 0, - child: actorText - ), + // 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, + minWidth: showActorDisplayName + ? actorText.size.width + : timeText.size.width + (widget.isSender ? widget.spacing + widget.timeIconSize : 0) + 3, ), - Visibility( - visible: showBubbleTime, - child: Positioned( - bottom: 0, - right: 0, - child: Row( - children: [ - timeText, - if(widget.isSender) ...[ - SizedBox(width: widget.spacing), - if(widget.isRead) - Icon(Icons.done_all_outlined, size: widget.timeIconSize, color: widget.timeIconColor) - else - Icon(Icons.done_outlined, size: widget.timeIconSize, color: widget.timeIconColor) - ] - ], - ) - ), + child: Stack( + children: [ + Padding( + padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0), + child: message.getWidget() + ), + Visibility( + visible: showActorDisplayName, + child: Positioned( + top: 0, + left: 0, + child: actorText + ), + ), + Visibility( + visible: showBubbleTime, + child: Positioned( + bottom: 0, + right: 0, + child: Row( + children: [ + timeText, + if(widget.isSender) ...[ + SizedBox(width: widget.spacing), + if(widget.isRead) + Icon(Icons.done_all_outlined, size: widget.timeIconSize, color: widget.timeIconColor) + else + Icon(Icons.done_outlined, size: widget.timeIconSize, color: widget.timeIconColor) + ] + ], + ) + ), + ), + Visibility( + visible: downloadProgress > 0, + child: Positioned( + bottom: 0, + right: 0, + left: 0, + child: LinearProgressIndicator(value: downloadProgress/100), + ), + ), + ], ), - Visibility( - visible: downloadProgress > 0, - child: Positioned( - bottom: 0, - right: 0, - left: 0, - child: LinearProgressIndicator(value: downloadProgress/100), - ), - ), - ], - ), + ), + ], ), ), ),