From da772f17cc306d3e2187a251b5931bf562b13d56 Mon Sep 17 00:00:00 2001 From: lars Date: Tue, 10 Jun 2025 21:35:12 +0200 Subject: [PATCH 1/4] changed file messages to show their text or their file name --- .../pages/talk/components/chatMessage.dart | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/lib/view/pages/talk/components/chatMessage.dart b/lib/view/pages/talk/components/chatMessage.dart index 626d011..b60039a 100644 --- a/lib/view/pages/talk/components/chatMessage.dart +++ b/lib/view/pages/talk/components/chatMessage.dart @@ -21,39 +21,46 @@ class ChatMessage { ChatMessage({required this.originalMessage, this.originalData}) { if(originalData?.containsKey('file') ?? false) { file = originalData?['file']; - content = file?.name ?? 'Datei'; - } else { - content = RichObjectStringProcessor.parseToString(originalMessage, originalData); } + content = RichObjectStringProcessor.parseToString(originalMessage, originalData); } Widget getWidget() { - if(file == null) { - return Linkify( - text: content, - onOpen: onOpen, - ); - } + var contentWidget = Linkify( + text: content, + onOpen: onOpen, + ); - return Padding(padding: const EdgeInsets.only(top: 5), child: CachedNetworkImage( - errorWidget: (context, url, error) => Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, + if(file == null) return contentWidget; + + return Padding( + padding: const EdgeInsets.only(top: 5), + child: Column( children: [ - const Icon(Icons.file_open_outlined, size: 35), - const SizedBox(width: 10), - Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), - const SizedBox(width: 10), + CachedNetworkImage( + errorWidget: (context, url, error) => Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Icon(Icons.file_open_outlined, size: 35), + const SizedBox(width: 10), + Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), + const SizedBox(width: 10), + ], + ), + alignment: Alignment.center, + placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())), + fadeInDuration: Duration.zero, + fadeOutDuration: Duration.zero, + errorListener: (value) {}, + imageUrl: 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=100&y=-1&a=1', + ), + SizedBox(height: 5), + contentWidget ], - ), - alignment: Alignment.center, - placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())), - fadeInDuration: Duration.zero, - fadeOutDuration: Duration.zero, - errorListener: (value) {}, - imageUrl: 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=100&y=-1&a=1', - )); + ) + ); } Future onOpen(LinkableElement link) async { From 8000475c1fa1060ebc83d407726f1247dc82b0bb Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 16 Jun 2025 16:07:04 +0200 Subject: [PATCH 2/4] aligned text to the left --- lib/view/pages/talk/components/chatMessage.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/view/pages/talk/components/chatMessage.dart b/lib/view/pages/talk/components/chatMessage.dart index b60039a..5f9b397 100644 --- a/lib/view/pages/talk/components/chatMessage.dart +++ b/lib/view/pages/talk/components/chatMessage.dart @@ -37,6 +37,7 @@ class ChatMessage { return Padding( padding: const EdgeInsets.only(top: 5), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ CachedNetworkImage( errorWidget: (context, url, error) => Row( From f3de0bc165912eb9381b83477a74b996c92fd5d9 Mon Sep 17 00:00:00 2001 From: lars Date: Tue, 24 Jun 2025 15:09:37 +0200 Subject: [PATCH 3/4] centered file preview, made text copyable --- .../pages/talk/components/chatBubble.dart | 2 +- .../pages/talk/components/chatMessage.dart | 40 +++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/lib/view/pages/talk/components/chatBubble.dart b/lib/view/pages/talk/components/chatBubble.dart index 6e72b52..c4f5b56 100644 --- a/lib/view/pages/talk/components/chatBubble.dart +++ b/lib/view/pages/talk/components/chatBubble.dart @@ -206,7 +206,7 @@ class _ChatBubbleState extends State with SingleTickerProviderStateM ), ), Visibility( - visible: !message.containsFile, + visible: widget.bubbleData.message != '{file}', child: ListTile( leading: const Icon(Icons.copy), title: const Text('Nachricht kopieren'), diff --git a/lib/view/pages/talk/components/chatMessage.dart b/lib/view/pages/talk/components/chatMessage.dart index 5f9b397..c5bc379 100644 --- a/lib/view/pages/talk/components/chatMessage.dart +++ b/lib/view/pages/talk/components/chatMessage.dart @@ -39,23 +39,29 @@ class ChatMessage { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - CachedNetworkImage( - errorWidget: (context, url, error) => Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Icon(Icons.file_open_outlined, size: 35), - const SizedBox(width: 10), - Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), - const SizedBox(width: 10), - ], - ), - alignment: Alignment.center, - placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())), - fadeInDuration: Duration.zero, - fadeOutDuration: Duration.zero, - errorListener: (value) {}, - imageUrl: 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=100&y=-1&a=1', + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CachedNetworkImage( + errorWidget: (context, url, error) => Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Icon(Icons.file_open_outlined, size: 35), + const SizedBox(width: 10), + Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), + const SizedBox(width: 10), + ], + ), + alignment: Alignment.center, + placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())), + fadeInDuration: Duration.zero, + fadeOutDuration: Duration.zero, + errorListener: (value) {}, + imageUrl: 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=100&y=-1&a=1', + ) + ], ), SizedBox(height: 5), contentWidget From 9177c30d6ed674f3f82d37395b7f4aba5957c769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Sat, 6 Sep 2025 15:33:14 +0200 Subject: [PATCH 4/4] fixed display dimensions of messages with files --- .../pages/talk/components/chatMessage.dart | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/lib/view/pages/talk/components/chatMessage.dart b/lib/view/pages/talk/components/chatMessage.dart index c5bc379..90abb14 100644 --- a/lib/view/pages/talk/components/chatMessage.dart +++ b/lib/view/pages/talk/components/chatMessage.dart @@ -39,32 +39,28 @@ class ChatMessage { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - CachedNetworkImage( - errorWidget: (context, url, error) => Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const Icon(Icons.file_open_outlined, size: 35), - const SizedBox(width: 10), - Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), - const SizedBox(width: 10), - ], - ), - alignment: Alignment.center, - placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())), - fadeInDuration: Duration.zero, - fadeOutDuration: Duration.zero, - errorListener: (value) {}, - imageUrl: 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=100&y=-1&a=1', - ) - ], + CachedNetworkImage( + errorWidget: (context, url, error) => Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Icon(Icons.file_open_outlined, size: 35), + const SizedBox(width: 10), + Flexible(child: Text(file!.name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold))), + const SizedBox(width: 10), + ], + ), + alignment: Alignment.center, + placeholder: (context, url) => const Padding(padding: EdgeInsets.all(15), child: SizedBox(width: 50, child: LinearProgressIndicator())), + fadeInDuration: Duration.zero, + fadeOutDuration: Duration.zero, + errorListener: (value) {}, + imageUrl: 'https://${AccountData().buildHttpAuthString()}@${EndpointData().nextcloud().full()}/index.php/core/preview?fileId=${file!.id}&x=130&y=-1&a=1', ), - SizedBox(height: 5), - contentWidget + if(originalMessage != '{file}') ...[ + SizedBox(height: 5), + contentWidget + ] ], ) );