feat(ui): added a new bottomRowBuilderWithDefaultWidget param in MessageWidget.
- Deprecated `StreamMessageWidget.bottomRowBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`. - Deprecated `StreamMessageWidget.deletedBottomRowBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`. - Deprecated `StreamMessageWidget.usernameBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`. Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
## Upcomming
|
## Upcomming
|
||||||
|
|
||||||
✅ Added
|
✅ Added
|
||||||
- Added third parameter (default `BottomRow` widget with `copyWith` method available) to `bottomRowBuilder` of `StreamMessageWidget` to allow easier customization.
|
- Added a new `bottomRowBuilderWithDefaultWidget` parameter to `StreamMessageWidget` which contains a third parameter (default `BottomRow` widget with `copyWith` method available) to allow easier customization.
|
||||||
|
|
||||||
🔄 Changed
|
🔄 Changed
|
||||||
|
|
||||||
@@ -10,6 +10,9 @@
|
|||||||
- Updated `connectivity_plus` dependency to `^3.0.2`
|
- Updated `connectivity_plus` dependency to `^3.0.2`
|
||||||
- Updated `dart_vlc` dependency to `^0.4.0`
|
- Updated `dart_vlc` dependency to `^0.4.0`
|
||||||
- Updated `file_picker` dependency to `^5.2.4`
|
- Updated `file_picker` dependency to `^5.2.4`
|
||||||
|
- Deprecated `StreamMessageWidget.bottomRowBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
||||||
|
- Deprecated `StreamMessageWidget.deletedBottomRowBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
||||||
|
- Deprecated `StreamMessageWidget.usernameBuilder` in favor of `StreamMessageWidget.bottomRowBuilderWithDefaultWidget`.
|
||||||
|
|
||||||
🐞 Fixed
|
🐞 Fixed
|
||||||
- [[#1379]](https://github.com/GetStream/stream-chat-flutter/issues/1379) Fixed "Issues with photo attachments on web", where the cached image attachment would not render while uploading.
|
- [[#1379]](https://github.com/GetStream/stream-chat-flutter/issues/1379) Fixed "Issues with photo attachments on web", where the cached image attachment would not render while uploading.
|
||||||
|
|||||||
@@ -80,8 +80,15 @@ class StreamMessageWidget extends StatefulWidget {
|
|||||||
this.userAvatarBuilder,
|
this.userAvatarBuilder,
|
||||||
this.editMessageInputBuilder,
|
this.editMessageInputBuilder,
|
||||||
this.textBuilder,
|
this.textBuilder,
|
||||||
this.bottomRowBuilder,
|
@Deprecated('''
|
||||||
this.deletedBottomRowBuilder,
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
|
Will be removed in the next major version.
|
||||||
|
''') this.bottomRowBuilder,
|
||||||
|
this.bottomRowBuilderWithDefaultWidget,
|
||||||
|
@Deprecated('''
|
||||||
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
|
Will be removed in the next major version.
|
||||||
|
''') this.deletedBottomRowBuilder,
|
||||||
this.customAttachmentBuilders,
|
this.customAttachmentBuilders,
|
||||||
this.padding,
|
this.padding,
|
||||||
this.textPadding = const EdgeInsets.symmetric(
|
this.textPadding = const EdgeInsets.symmetric(
|
||||||
@@ -93,11 +100,18 @@ class StreamMessageWidget extends StatefulWidget {
|
|||||||
this.onQuotedMessageTap,
|
this.onQuotedMessageTap,
|
||||||
this.customActions = const [],
|
this.customActions = const [],
|
||||||
this.onAttachmentTap,
|
this.onAttachmentTap,
|
||||||
this.usernameBuilder,
|
@Deprecated('''
|
||||||
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
|
Will be removed in the next major version.
|
||||||
|
''') this.usernameBuilder,
|
||||||
this.imageAttachmentThumbnailSize = const Size(400, 400),
|
this.imageAttachmentThumbnailSize = const Size(400, 400),
|
||||||
this.imageAttachmentThumbnailResizeType = 'clip',
|
this.imageAttachmentThumbnailResizeType = 'clip',
|
||||||
this.imageAttachmentThumbnailCropType = 'center',
|
this.imageAttachmentThumbnailCropType = 'center',
|
||||||
}) : attachmentBuilders = {
|
}) : assert(
|
||||||
|
bottomRowBuilder == null || bottomRowBuilderWithDefaultWidget == null,
|
||||||
|
'You can only use one of the two bottom row builders',
|
||||||
|
),
|
||||||
|
attachmentBuilders = {
|
||||||
'image': (context, message, attachments) {
|
'image': (context, message, attachments) {
|
||||||
final border = RoundedRectangleBorder(
|
final border = RoundedRectangleBorder(
|
||||||
side: attachmentBorderSide ??
|
side: attachmentBorderSide ??
|
||||||
@@ -307,7 +321,13 @@ class StreamMessageWidget extends StatefulWidget {
|
|||||||
/// {@template bottomRowBuilder}
|
/// {@template bottomRowBuilder}
|
||||||
/// Widget builder for building a bottom row below the message
|
/// Widget builder for building a bottom row below the message
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
final Widget Function(BuildContext, Message, BottomRow)? bottomRowBuilder;
|
final BottomRowBuilder? bottomRowBuilder;
|
||||||
|
|
||||||
|
/// {@template bottomRowBuilderWithDefaultWidget}
|
||||||
|
/// Widget builder for building a bottom row below the message.
|
||||||
|
/// Also contains the default bottom row widget.
|
||||||
|
/// {@endtemplate}
|
||||||
|
final BottomRowBuilderWithDefaultWidget? bottomRowBuilderWithDefaultWidget;
|
||||||
|
|
||||||
/// {@template deletedBottomRowBuilder}
|
/// {@template deletedBottomRowBuilder}
|
||||||
/// Widget builder for building a bottom row below a deleted message
|
/// Widget builder for building a bottom row below a deleted message
|
||||||
@@ -538,9 +558,19 @@ class StreamMessageWidget extends StatefulWidget {
|
|||||||
void Function(Message)? onReplyTap,
|
void Function(Message)? onReplyTap,
|
||||||
Widget Function(BuildContext, Message)? editMessageInputBuilder,
|
Widget Function(BuildContext, Message)? editMessageInputBuilder,
|
||||||
Widget Function(BuildContext, Message)? textBuilder,
|
Widget Function(BuildContext, Message)? textBuilder,
|
||||||
Widget Function(BuildContext, Message)? usernameBuilder,
|
@Deprecated('''
|
||||||
Widget Function(BuildContext, Message, BottomRow)? bottomRowBuilder,
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
Widget Function(BuildContext, Message)? deletedBottomRowBuilder,
|
Will be removed in the next major version.
|
||||||
|
''') Widget Function(BuildContext, Message)? usernameBuilder,
|
||||||
|
@Deprecated('''
|
||||||
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
|
Will be removed in the next major version.
|
||||||
|
''') BottomRowBuilder? bottomRowBuilder,
|
||||||
|
BottomRowBuilderWithDefaultWidget? bottomRowBuilderWithDefaultWidget,
|
||||||
|
@Deprecated('''
|
||||||
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
|
Will be removed in the next major version.
|
||||||
|
''') Widget Function(BuildContext, Message)? deletedBottomRowBuilder,
|
||||||
void Function(BuildContext, Message)? onMessageActions,
|
void Function(BuildContext, Message)? onMessageActions,
|
||||||
Message? message,
|
Message? message,
|
||||||
StreamMessageThemeData? messageTheme,
|
StreamMessageThemeData? messageTheme,
|
||||||
@@ -588,6 +618,23 @@ class StreamMessageWidget extends StatefulWidget {
|
|||||||
String? imageAttachmentThumbnailResizeType,
|
String? imageAttachmentThumbnailResizeType,
|
||||||
String? imageAttachmentThumbnailCropType,
|
String? imageAttachmentThumbnailCropType,
|
||||||
}) {
|
}) {
|
||||||
|
var _bottomRowBuilderWithDefaultWidget =
|
||||||
|
bottomRowBuilderWithDefaultWidget ??
|
||||||
|
this.bottomRowBuilderWithDefaultWidget;
|
||||||
|
|
||||||
|
_bottomRowBuilderWithDefaultWidget ??= (context, message, defaultWidget) {
|
||||||
|
final _bottomRowBuilder = bottomRowBuilder ?? this.bottomRowBuilder;
|
||||||
|
if (_bottomRowBuilder != null) {
|
||||||
|
return _bottomRowBuilder(context, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultWidget.copyWith(
|
||||||
|
onThreadTap: onThreadTap,
|
||||||
|
usernameBuilder: usernameBuilder,
|
||||||
|
deletedBottomRowBuilder: deletedBottomRowBuilder,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return StreamMessageWidget(
|
return StreamMessageWidget(
|
||||||
key: key ?? this.key,
|
key: key ?? this.key,
|
||||||
onMentionTap: onMentionTap ?? this.onMentionTap,
|
onMentionTap: onMentionTap ?? this.onMentionTap,
|
||||||
@@ -596,10 +643,7 @@ class StreamMessageWidget extends StatefulWidget {
|
|||||||
editMessageInputBuilder:
|
editMessageInputBuilder:
|
||||||
editMessageInputBuilder ?? this.editMessageInputBuilder,
|
editMessageInputBuilder ?? this.editMessageInputBuilder,
|
||||||
textBuilder: textBuilder ?? this.textBuilder,
|
textBuilder: textBuilder ?? this.textBuilder,
|
||||||
usernameBuilder: usernameBuilder ?? this.usernameBuilder,
|
bottomRowBuilderWithDefaultWidget: _bottomRowBuilderWithDefaultWidget,
|
||||||
bottomRowBuilder: bottomRowBuilder ?? this.bottomRowBuilder,
|
|
||||||
deletedBottomRowBuilder:
|
|
||||||
deletedBottomRowBuilder ?? this.deletedBottomRowBuilder,
|
|
||||||
onMessageActions: onMessageActions ?? this.onMessageActions,
|
onMessageActions: onMessageActions ?? this.onMessageActions,
|
||||||
message: message ?? this.message,
|
message: message ?? this.message,
|
||||||
messageTheme: messageTheme ?? this.messageTheme,
|
messageTheme: messageTheme ?? this.messageTheme,
|
||||||
@@ -871,8 +915,6 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>
|
|||||||
showUserAvatar: widget.showUserAvatar,
|
showUserAvatar: widget.showUserAvatar,
|
||||||
streamChat: _streamChat,
|
streamChat: _streamChat,
|
||||||
translateUserAvatar: widget.translateUserAvatar,
|
translateUserAvatar: widget.translateUserAvatar,
|
||||||
deletedBottomRowBuilder: widget.deletedBottomRowBuilder,
|
|
||||||
onThreadTap: widget.onThreadTap,
|
|
||||||
shape: widget.shape,
|
shape: widget.shape,
|
||||||
borderSide: widget.borderSide,
|
borderSide: widget.borderSide,
|
||||||
borderRadiusGeometry: widget.borderRadiusGeometry,
|
borderRadiusGeometry: widget.borderRadiusGeometry,
|
||||||
@@ -880,10 +922,10 @@ class _StreamMessageWidgetState extends State<StreamMessageWidget>
|
|||||||
onLinkTap: widget.onLinkTap,
|
onLinkTap: widget.onLinkTap,
|
||||||
onMentionTap: widget.onMentionTap,
|
onMentionTap: widget.onMentionTap,
|
||||||
onQuotedMessageTap: widget.onQuotedMessageTap,
|
onQuotedMessageTap: widget.onQuotedMessageTap,
|
||||||
bottomRowBuilder: widget.bottomRowBuilder,
|
bottomRowBuilderWithDefaultWidget:
|
||||||
|
widget.bottomRowBuilderWithDefaultWidget,
|
||||||
onUserAvatarTap: widget.onUserAvatarTap,
|
onUserAvatarTap: widget.onUserAvatarTap,
|
||||||
userAvatarBuilder: widget.userAvatarBuilder,
|
userAvatarBuilder: widget.userAvatarBuilder,
|
||||||
usernameBuilder: widget.usernameBuilder,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,6 +4,18 @@ import 'package:stream_chat_flutter/src/message_widget/message_widget_content_co
|
|||||||
import 'package:stream_chat_flutter/src/message_widget/reactions/desktop_reactions_builder.dart';
|
import 'package:stream_chat_flutter/src/message_widget/reactions/desktop_reactions_builder.dart';
|
||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
|
/// Signature for the builder function that will be called when the message
|
||||||
|
/// bottom row is built. Includes the [Message].
|
||||||
|
typedef BottomRowBuilder = Widget Function(BuildContext, Message);
|
||||||
|
|
||||||
|
/// Signature for the builder function that will be called when the message
|
||||||
|
/// bottom row is built. Includes the [Message] and the default [BottomRow].
|
||||||
|
typedef BottomRowBuilderWithDefaultWidget = Widget Function(
|
||||||
|
BuildContext,
|
||||||
|
Message,
|
||||||
|
BottomRow,
|
||||||
|
);
|
||||||
|
|
||||||
/// {@template messageWidgetContent}
|
/// {@template messageWidgetContent}
|
||||||
/// The main content of a [StreamMessageWidget].
|
/// The main content of a [StreamMessageWidget].
|
||||||
///
|
///
|
||||||
@@ -51,12 +63,28 @@ class MessageWidgetContent extends StatelessWidget {
|
|||||||
this.onMentionTap,
|
this.onMentionTap,
|
||||||
this.onLinkTap,
|
this.onLinkTap,
|
||||||
this.textBuilder,
|
this.textBuilder,
|
||||||
this.bottomRowBuilder,
|
@Deprecated('''
|
||||||
this.onThreadTap,
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
this.deletedBottomRowBuilder,
|
Will be removed in the next major version.
|
||||||
|
''') this.bottomRowBuilder,
|
||||||
|
this.bottomRowBuilderWithDefaultWidget,
|
||||||
|
@Deprecated('''
|
||||||
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
|
Will be removed in the next major version.
|
||||||
|
''') this.onThreadTap,
|
||||||
|
@Deprecated('''
|
||||||
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
|
Will be removed in the next major version.
|
||||||
|
''') this.deletedBottomRowBuilder,
|
||||||
this.userAvatarBuilder,
|
this.userAvatarBuilder,
|
||||||
this.usernameBuilder,
|
@Deprecated('''
|
||||||
});
|
Use [bottomRowBuilderWithDefaultWidget] instead.
|
||||||
|
Will be removed in the next major version.
|
||||||
|
''') this.usernameBuilder,
|
||||||
|
}) : assert(
|
||||||
|
bottomRowBuilder == null || bottomRowBuilderWithDefaultWidget == null,
|
||||||
|
'You can only use one of the two bottom row builders',
|
||||||
|
);
|
||||||
|
|
||||||
/// {@macro reverse}
|
/// {@macro reverse}
|
||||||
final bool reverse;
|
final bool reverse;
|
||||||
@@ -152,7 +180,10 @@ class MessageWidgetContent extends StatelessWidget {
|
|||||||
final double bottomRowPadding;
|
final double bottomRowPadding;
|
||||||
|
|
||||||
/// {@macro bottomRowBuilder}
|
/// {@macro bottomRowBuilder}
|
||||||
final Widget Function(BuildContext, Message, BottomRow)? bottomRowBuilder;
|
final BottomRowBuilder? bottomRowBuilder;
|
||||||
|
|
||||||
|
/// {@macro bottomRowBuilderWithDefaultWidget}
|
||||||
|
final BottomRowBuilderWithDefaultWidget? bottomRowBuilderWithDefaultWidget;
|
||||||
|
|
||||||
/// {@macro showInChannelIndicator}
|
/// {@macro showInChannelIndicator}
|
||||||
final bool showInChannel;
|
final bool showInChannel;
|
||||||
@@ -457,7 +488,16 @@ class MessageWidgetContent extends StatelessWidget {
|
|||||||
usernameBuilder: usernameBuilder,
|
usernameBuilder: usernameBuilder,
|
||||||
);
|
);
|
||||||
|
|
||||||
return bottomRowBuilder?.call(context, message, defaultWidget) ??
|
if (bottomRowBuilder != null) {
|
||||||
defaultWidget;
|
return bottomRowBuilder!(context, message);
|
||||||
|
} else if (bottomRowBuilderWithDefaultWidget != null) {
|
||||||
|
return bottomRowBuilderWithDefaultWidget!(
|
||||||
|
context,
|
||||||
|
message,
|
||||||
|
defaultWidget,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultWidget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user