From acef63b310bacddc3189915fdc2e839f7d0c7ff3 Mon Sep 17 00:00:00 2001 From: adrianoct42 Date: Mon, 8 Jan 2024 18:24:24 -0300 Subject: [PATCH 1/4] feat: File message bubble is now one single bubble instead of two separate messages --- .../chat/ds_file_message_bubble.widget.dart | 36 +++++++++++++------ lib/src/widgets/utils/ds_card.widget.dart | 1 + 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/src/widgets/chat/ds_file_message_bubble.widget.dart b/lib/src/widgets/chat/ds_file_message_bubble.widget.dart index 1e5e046d..74aead7a 100644 --- a/lib/src/widgets/chat/ds_file_message_bubble.widget.dart +++ b/lib/src/widgets/chat/ds_file_message_bubble.widget.dart @@ -14,10 +14,12 @@ import '../texts/ds_body_text.widget.dart'; import '../texts/ds_caption_small_text.widget.dart'; import '../utils/ds_file_extension_icon.util.dart'; import 'ds_message_bubble.widget.dart'; +import 'ds_show_more_text.widget.dart'; class DSFileMessageBubble extends StatelessWidget { final DSAlign align; final String url; + final String? text; final int size; final String filename; final DSFileMessageBubbleController controller; @@ -34,6 +36,7 @@ class DSFileMessageBubble extends StatelessWidget { required this.url, required this.size, required this.filename, + this.text, this.borderRadius = const [DSBorderRadius.all], this.shouldAuthenticate = false, DSMessageBubbleStyle? style, @@ -60,14 +63,27 @@ class DSFileMessageBubble extends StatelessWidget { padding: EdgeInsets.zero, align: align, style: style, - child: SizedBox( - height: 80.0, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - _buildIcon(), - _buildText(), - ], + child: Padding( + padding: const EdgeInsets.all(12.0), + child: LayoutBuilder( + builder: (_, constraints) => Column( + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + _buildIcon(), + _buildTitle(), + ], + ), + if (text?.isNotEmpty ?? false) + DSShowMoreText( + text: text!, + maxWidth: constraints.maxWidth, + align: align, + style: style, + ) + ], + ), ), ), ), @@ -101,7 +117,7 @@ class DSFileMessageBubble extends StatelessWidget { ); } - Widget _buildText() { + Widget _buildTitle() { final color = style.isLightBubbleBackground(align) ? DSColors.neutralDarkCity : DSColors.neutralLightSnow; @@ -131,7 +147,7 @@ class DSFileMessageBubble extends StatelessWidget { controller.getFileSize(size), color: color, ), - ) + ), ], ), ), diff --git a/lib/src/widgets/utils/ds_card.widget.dart b/lib/src/widgets/utils/ds_card.widget.dart index 56729ed2..f69a4608 100644 --- a/lib/src/widgets/utils/ds_card.widget.dart +++ b/lib/src/widgets/utils/ds_card.widget.dart @@ -323,6 +323,7 @@ class DSCard extends StatelessWidget { return DSFileMessageBubble( align: align, url: media.uri, + text: media.text, replyContent: replyContent, size: size, filename: media.title ?? From 3fcbfd30931914f4fdfccb2bcb0b22e8b9339bf4 Mon Sep 17 00:00:00 2001 From: adrianoct42 Date: Tue, 9 Jan 2024 11:45:43 -0300 Subject: [PATCH 2/4] fix: sample_message_bubble now has one of its examples showing a text within a file as a description --- sample/lib/widgets/showcase/sample_message_bubble.showcase.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sample/lib/widgets/showcase/sample_message_bubble.showcase.dart b/sample/lib/widgets/showcase/sample_message_bubble.showcase.dart index 07d10eb7..76ff0196 100644 --- a/sample/lib/widgets/showcase/sample_message_bubble.showcase.dart +++ b/sample/lib/widgets/showcase/sample_message_bubble.showcase.dart @@ -350,6 +350,8 @@ class SampleMessageBubbleShowcase extends StatelessWidget { align: DSAlign.right, ), DSFileMessageBubble( + text: + 'Texto de exemplo para exemplificar uma descrição enviado junto com um File.', align: DSAlign.left, filename: 'teste.pdf', size: 0, From b8c853d7f458fadbab52c72eaeea0547e853f0b7 Mon Sep 17 00:00:00 2001 From: adrianoct42 Date: Tue, 9 Jan 2024 16:53:47 -0300 Subject: [PATCH 3/4] fix: fixing the style of the FileMessageBuble --- .../chat/ds_file_message_bubble.widget.dart | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/src/widgets/chat/ds_file_message_bubble.widget.dart b/lib/src/widgets/chat/ds_file_message_bubble.widget.dart index 74aead7a..81cb876d 100644 --- a/lib/src/widgets/chat/ds_file_message_bubble.widget.dart +++ b/lib/src/widgets/chat/ds_file_message_bubble.widget.dart @@ -63,28 +63,32 @@ class DSFileMessageBubble extends StatelessWidget { padding: EdgeInsets.zero, align: align, style: style, - child: Padding( - padding: const EdgeInsets.all(12.0), - child: LayoutBuilder( - builder: (_, constraints) => Column( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisSize: MainAxisSize.min, children: [ - Row( - mainAxisSize: MainAxisSize.min, - children: [ - _buildIcon(), - _buildTitle(), - ], - ), - if (text?.isNotEmpty ?? false) - DSShowMoreText( + _buildIcon(), + _buildTitle(), + ], + ), + if (text?.isNotEmpty ?? false) + LayoutBuilder( + builder: (_, constraints) => Padding( + padding: const EdgeInsets.symmetric( + vertical: 8.0, + horizontal: 16.0, + ), + child: DSShowMoreText( text: text!, maxWidth: constraints.maxWidth, align: align, style: style, - ) - ], - ), - ), + ), + ), + ) + ], ), ), ), @@ -94,6 +98,7 @@ class DSFileMessageBubble extends StatelessWidget { Widget _buildIcon() { return Container( width: 80.0, + height: 80.0, color: DSColors.neutralLightSnow, child: Obx( () => controller.isDownloading.value From a878edc231f177f097c72dffb807ed709bedd267 Mon Sep 17 00:00:00 2001 From: adrianoct42 Date: Tue, 9 Jan 2024 17:26:29 -0300 Subject: [PATCH 4/4] fix: Padding widget is now outside of LayoutBuilder --- .../chat/ds_file_message_bubble.widget.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/widgets/chat/ds_file_message_bubble.widget.dart b/lib/src/widgets/chat/ds_file_message_bubble.widget.dart index 81cb876d..8b4f40ef 100644 --- a/lib/src/widgets/chat/ds_file_message_bubble.widget.dart +++ b/lib/src/widgets/chat/ds_file_message_bubble.widget.dart @@ -74,13 +74,13 @@ class DSFileMessageBubble extends StatelessWidget { ], ), if (text?.isNotEmpty ?? false) - LayoutBuilder( - builder: (_, constraints) => Padding( - padding: const EdgeInsets.symmetric( - vertical: 8.0, - horizontal: 16.0, - ), - child: DSShowMoreText( + Padding( + padding: const EdgeInsets.symmetric( + vertical: 8.0, + horizontal: 16.0, + ), + child: LayoutBuilder( + builder: (_, constraints) => DSShowMoreText( text: text!, maxWidth: constraints.maxWidth, align: align,