Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] #567769 - United File Message Bubble #248

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions lib/src/widgets/chat/ds_file_message_bubble.widget.dart
mpamaro marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -60,15 +63,32 @@ 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: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
_buildIcon(),
_buildTitle(),
],
),
if (text?.isNotEmpty ?? false)
LayoutBuilder(
builder: (_, constraints) => Padding(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This padding could be outside of LayoutBuilder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

padding: const EdgeInsets.symmetric(
vertical: 8.0,
horizontal: 16.0,
),
child: DSShowMoreText(
text: text!,
maxWidth: constraints.maxWidth,
align: align,
style: style,
),
),
)
],
),
),
),
Expand All @@ -78,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
Expand All @@ -101,7 +122,7 @@ class DSFileMessageBubble extends StatelessWidget {
);
}

Widget _buildText() {
Widget _buildTitle() {
final color = style.isLightBubbleBackground(align)
? DSColors.neutralDarkCity
: DSColors.neutralLightSnow;
Expand Down Expand Up @@ -131,7 +152,7 @@ class DSFileMessageBubble extends StatelessWidget {
controller.getFileSize(size),
color: color,
),
)
),
],
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/src/widgets/utils/ds_card.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down