parent message gets shown in chat bubble

This commit is contained in:
Lars Neuhaus 2024-04-19 18:55:07 +02:00
parent 232a767312
commit ae6b6511d7
3 changed files with 95 additions and 50 deletions
lib
api/marianumcloud/talk/chat
view/pages/talk/components

@ -38,6 +38,7 @@ class GetChatResponseObject {
Map<String, int>? reactions;
List<String>? reactionsSelf;
@JsonKey(fromJson: _fromJson) Map<String, RichObjectString>? 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<String, dynamic> json) => _$GetChatResponseObjectFromJson(json);
@ -78,7 +80,8 @@ class GetChatResponseObject {
text,
null,
null,
null
null,
null,
);
}

@ -52,6 +52,10 @@ GetChatResponseObject _$GetChatResponseObjectFromJson(
(json['reactionsSelf'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
json['parent'] == null
? null
: GetChatResponseObject.fromJson(
json['parent'] as Map<String, dynamic>),
);
Map<String, dynamic> _$GetChatResponseObjectToJson(
@ -74,6 +78,7 @@ Map<String, dynamic> _$GetChatResponseObjectToJson(
'reactionsSelf': instance.reactionsSelf,
'messageParameters':
instance.messageParameters?.map((k, e) => MapEntry(k, e.toJson())),
'parent': instance.parent?.toJson(),
};
const _$GetRoomResponseObjectMessageActorTypeEnumMap = {

@ -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<ChatBubble> {
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,7 +345,40 @@ class _ChatBubbleState extends State<ChatBubble> {
},
child: Bubble(
style: getStyle(),
child: Container(
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,
minWidth: showActorDisplayName
@ -395,6 +430,8 @@ class _ChatBubbleState extends State<ChatBubble> {
],
),
),
],
),
),
),
Visibility(