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

View File

@ -38,6 +38,7 @@ class GetChatResponseObject {
Map<String, int>? reactions; Map<String, int>? reactions;
List<String>? reactionsSelf; List<String>? reactionsSelf;
@JsonKey(fromJson: _fromJson) Map<String, RichObjectString>? messageParameters; @JsonKey(fromJson: _fromJson) Map<String, RichObjectString>? messageParameters;
GetChatResponseObject? parent;
GetChatResponseObject( GetChatResponseObject(
this.id, this.id,
@ -53,7 +54,8 @@ class GetChatResponseObject {
this.message, this.message,
this.messageParameters, this.messageParameters,
this.reactions, this.reactions,
this.reactionsSelf this.reactionsSelf,
this.parent,
); );
factory GetChatResponseObject.fromJson(Map<String, dynamic> json) => _$GetChatResponseObjectFromJson(json); factory GetChatResponseObject.fromJson(Map<String, dynamic> json) => _$GetChatResponseObjectFromJson(json);
@ -78,7 +80,8 @@ class GetChatResponseObject {
text, text,
null, null,
null, null,
null null,
null,
); );
} }

View File

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

View File

@ -2,6 +2,7 @@ import 'package:better_open_file/better_open_file.dart';
import 'package:bubble/bubble.dart'; import 'package:bubble/bubble.dart';
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart' as emojis; import 'package:emoji_picker_flutter/emoji_picker_flutter.dart' as emojis;
import 'package:flowder/flowder.dart'; import 'package:flowder/flowder.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.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); message = ChatMessage(originalMessage: widget.bubbleData.message, originalData: widget.bubbleData.messageParameters);
var showActorDisplayName = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment && widget.chatData.type != GetRoomResponseObjectConversationType.oneToOne; var showActorDisplayName = widget.bubbleData.messageType == GetRoomResponseObjectMessageType.comment && widget.chatData.type != GetRoomResponseObjectConversationType.oneToOne;
var showBubbleTime = widget.bubbleData.messageType != GetRoomResponseObjectMessageType.system; var showBubbleTime = widget.bubbleData.messageType != GetRoomResponseObjectMessageType.system;
var parent = widget.bubbleData.parent;
var actorText = Text( var actorText = Text(
widget.bubbleData.actorDisplayName, widget.bubbleData.actorDisplayName,
@ -343,7 +345,40 @@ class _ChatBubbleState extends State<ChatBubble> {
}, },
child: Bubble( child: Bubble(
style: getStyle(), 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( constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.9, maxWidth: MediaQuery.of(context).size.width * 0.9,
minWidth: showActorDisplayName minWidth: showActorDisplayName
@ -395,6 +430,8 @@ class _ChatBubbleState extends State<ChatBubble> {
], ],
), ),
), ),
],
),
), ),
), ),
Visibility( Visibility(