Skip to content

Commit

Permalink
fix(ui): custom attachment builders (#1938)
Browse files Browse the repository at this point in the history
* added custom attachments to default builders

* slight docs change

* Update packages/stream_chat_flutter/CHANGELOG.md
  • Loading branch information
deven98 authored Jun 11, 2024
1 parent 5ea210e commit dc3aa45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

✅ Added

- Added `customAttachmentBuilders` parameter for `StreamAttachmentWidgetBuilder.defaultBuilders`.
- `attachmentBuilders` parameter for `StreamMessageWidget` now only expects custom builders.
- Added `StreamMediaAttachmentBuilder` widget to show media attachments in a message.

## 7.2.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ abstract class StreamAttachmentWidgetBuilder {
/// Example:
///
/// ```dart
/// final myBuilders = [
/// ...StreamAttachmentWidgetBuilder.defaultBuilders,
/// MyCustomAttachmentBuilder(),
/// MyOtherCustomAttachmentBuilder(),
/// ...
/// ];
/// final myBuilders = StreamAttachmentWidgetBuilder.defaultBuilders(
/// customAttachmentBuilders: [
/// MyCustomAttachmentBuilder(),
/// MyOtherCustomAttachmentBuilder(),
/// ]
/// );
/// ```
///
/// **Note**: The order of the builders in the list is important. The first
Expand All @@ -67,8 +67,11 @@ abstract class StreamAttachmentWidgetBuilder {
ShapeBorder? shape,
EdgeInsetsGeometry padding = const EdgeInsets.all(4),
StreamAttachmentWidgetTapCallback? onAttachmentTap,
List<StreamAttachmentWidgetBuilder>? customAttachmentBuilders,
}) {
return [
...?customAttachmentBuilders,

// Handles a mix of image, gif, video, url and file attachments.
MixedAttachmentBuilder(
padding: padding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ class ParseAttachments extends StatelessWidget {
};

// Create a default attachmentBuilders list if not provided.
var builders = attachmentBuilders;
builders ??= StreamAttachmentWidgetBuilder.defaultBuilders(
final builders = StreamAttachmentWidgetBuilder.defaultBuilders(
message: message,
shape: attachmentShape,
padding: attachmentPadding,
onAttachmentTap: onAttachmentTap,
customAttachmentBuilders: attachmentBuilders,
);

final catalog = AttachmentWidgetCatalog(builders: builders);
Expand Down

0 comments on commit dc3aa45

Please sign in to comment.