added new builder
This commit is contained in:
@@ -79,9 +79,11 @@ typedef ActionButtonBuilder = Widget Function(
|
|||||||
IconButton defaultActionButton,
|
IconButton defaultActionButton,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef AttachmentsPickerBuilder = Widget Function(
|
/// Widget builder for widgets that require may required data from the
|
||||||
|
/// [MessageInputController]
|
||||||
|
typedef MessageRelatedBuilder = Widget Function(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
List<Attachment> attachments,
|
MessageInputController messageInputController,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Location for actions on the [MessageInput]
|
/// Location for actions on the [MessageInput]
|
||||||
@@ -210,6 +212,7 @@ class MessageInput extends StatefulWidget {
|
|||||||
this.customOverlays = const [],
|
this.customOverlays = const [],
|
||||||
this.mentionAllAppUsers = false,
|
this.mentionAllAppUsers = false,
|
||||||
this.attachmentsPickerBuilder,
|
this.attachmentsPickerBuilder,
|
||||||
|
this.sendButtonBuilder,
|
||||||
}) : assert(
|
}) : assert(
|
||||||
initialMessage == null || editMessage == null,
|
initialMessage == null || editMessage == null,
|
||||||
"Can't provide both `initialMessage` and `editMessage`",
|
"Can't provide both `initialMessage` and `editMessage`",
|
||||||
@@ -329,7 +332,10 @@ class MessageInput extends StatefulWidget {
|
|||||||
final bool mentionAllAppUsers;
|
final bool mentionAllAppUsers;
|
||||||
|
|
||||||
/// Builds bottom sheet when attachment picker is opened.
|
/// Builds bottom sheet when attachment picker is opened.
|
||||||
final AttachmentsPickerBuilder? attachmentsPickerBuilder;
|
final MessageRelatedBuilder? attachmentsPickerBuilder;
|
||||||
|
|
||||||
|
/// Builder for creating send button
|
||||||
|
final MessageRelatedBuilder? sendButtonBuilder;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MessageInputState createState() => MessageInputState();
|
MessageInputState createState() => MessageInputState();
|
||||||
@@ -597,15 +603,20 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildSendButton(BuildContext context) => StreamMessageSendButton(
|
Widget _buildSendButton(BuildContext context) {
|
||||||
onSendMessage: sendMessage,
|
if (widget.sendButtonBuilder != null) {
|
||||||
timeOut: _timeOut,
|
return widget.sendButtonBuilder!(context, messageInputController);
|
||||||
isIdle:
|
}
|
||||||
!_messageIsPresent && messageInputController.attachments.isEmpty,
|
|
||||||
isEditEnabled: widget.editMessage != null,
|
return StreamMessageSendButton(
|
||||||
idleSendButton: widget.idleSendButton,
|
onSendMessage: sendMessage,
|
||||||
activeSendButton: widget.activeSendButton,
|
timeOut: _timeOut,
|
||||||
);
|
isIdle: !_messageIsPresent && messageInputController.attachments.isEmpty,
|
||||||
|
isEditEnabled: widget.editMessage != null,
|
||||||
|
idleSendButton: widget.idleSendButton,
|
||||||
|
activeSendButton: widget.activeSendButton,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildExpandActionsButton(BuildContext context) {
|
Widget _buildExpandActionsButton(BuildContext context) {
|
||||||
final channel = StreamChannel.of(context).channel;
|
final channel = StreamChannel.of(context).channel;
|
||||||
@@ -993,7 +1004,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
if (_openFilePickerSection && widget.attachmentsPickerBuilder != null) {
|
if (_openFilePickerSection && widget.attachmentsPickerBuilder != null) {
|
||||||
return widget.attachmentsPickerBuilder!(
|
return widget.attachmentsPickerBuilder!(
|
||||||
context,
|
context,
|
||||||
messageInputController.attachments,
|
messageInputController,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user