replies now get displayed

This commit is contained in:
Lars Neuhaus 2024-05-01 17:37:03 +02:00
parent ae6b6511d7
commit 91ef689d2a
3 changed files with 122 additions and 39 deletions

View File

@ -71,6 +71,7 @@ class _ChatViewState extends State<ChatView> {
chatData: widget.room, chatData: widget.room,
refetch: _query, refetch: _query,
isRead: element.id <= commonRead, isRead: element.id <= commonRead,
selfId: widget.selfId,
) )
); );
}); });
@ -129,8 +130,8 @@ class _ChatViewState extends State<ChatView> {
Container( Container(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
child: TalkNavigator.isSecondaryVisible(context) child: TalkNavigator.isSecondaryVisible(context)
? ChatTextfield(widget.room.token) ? ChatTextfield(widget.room.token, selfId: widget.selfId)
: SafeArea(child: ChatTextfield(widget.room.token) : SafeArea(child: ChatTextfield(widget.room.token, selfId: widget.selfId)
), ),
) )
], ],

View File

@ -30,6 +30,7 @@ class ChatBubble extends StatefulWidget {
final GetChatResponseObject bubbleData; final GetChatResponseObject bubbleData;
final GetRoomResponseObject chatData; final GetRoomResponseObject chatData;
final bool isRead; final bool isRead;
final String? selfId;
final double spacing = 3; final double spacing = 3;
final double timeIconSize = 11; final double timeIconSize = 11;
@ -44,6 +45,7 @@ class ChatBubble extends StatefulWidget {
required this.chatData, required this.chatData,
required this.refetch, required this.refetch,
this.isRead = false, this.isRead = false,
this.selfId,
super.key}); super.key});
@override @override
@ -267,7 +269,14 @@ 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 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( var actorText = Text(
widget.bubbleData.actorDisplayName, widget.bubbleData.actorDisplayName,
@ -347,37 +356,6 @@ class _ChatBubbleState extends State<ChatBubble> {
style: getStyle(), style: getStyle(),
child: Column( child: Column(
children: [ 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( Container(
constraints: BoxConstraints( constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.9, maxWidth: MediaQuery.of(context).size.width * 0.9,
@ -387,10 +365,6 @@ class _ChatBubbleState extends State<ChatBubble> {
), ),
child: Stack( child: Stack(
children: [ children: [
Padding(
padding: EdgeInsets.only(bottom: showBubbleTime ? 18 : 0, top: showActorDisplayName ? 18 : 0),
child: message.getWidget()
),
Visibility( Visibility(
visible: showActorDisplayName, visible: showActorDisplayName,
child: Positioned( child: Positioned(
@ -399,6 +373,69 @@ class _ChatBubbleState extends State<ChatBubble> {
child: actorText 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( Visibility(
visible: showBubbleTime, visible: showBubbleTime,
child: Positioned( child: Positioned(

View File

@ -1,5 +1,6 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.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 { class ChatTextfield extends StatefulWidget {
final String sendToToken; final String sendToToken;
const ChatTextfield(this.sendToToken, {super.key}); final String? selfId;
const ChatTextfield(this.sendToToken, {this.selfId, super.key});
@override @override
State<ChatTextfield> createState() => _ChatTextfieldState(); State<ChatTextfield> createState() => _ChatTextfieldState();
@ -106,7 +108,50 @@ class _ChatTextfieldState extends State<ChatTextfield> {
icon: const Icon(Icons.close_outlined), icon: const Icon(Icons.close_outlined),
padding: const EdgeInsets.only(left: 0), 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 { } else {