feat: Added copyWith to stream_attachment_picker.dart
This commit is contained in:
@@ -84,6 +84,13 @@ typedef MessageRelatedBuilder = Widget Function(
|
|||||||
MessageInputController messageInputController,
|
MessageInputController messageInputController,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Widget builder for a custom attachment picker.
|
||||||
|
typedef AttachmentsPickerBuilder = Widget Function(
|
||||||
|
BuildContext context,
|
||||||
|
MessageInputController messageInputController,
|
||||||
|
StreamAttachmentPicker defaultPicker,
|
||||||
|
);
|
||||||
|
|
||||||
/// Location for actions on the [MessageInput]
|
/// Location for actions on the [MessageInput]
|
||||||
enum ActionsLocation {
|
enum ActionsLocation {
|
||||||
/// Align to left
|
/// Align to left
|
||||||
@@ -330,7 +337,7 @@ 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 MessageRelatedBuilder? attachmentsPickerBuilder;
|
final AttachmentsPickerBuilder? attachmentsPickerBuilder;
|
||||||
|
|
||||||
/// Builder for creating send button
|
/// Builder for creating send button
|
||||||
final MessageRelatedBuilder? sendButtonBuilder;
|
final MessageRelatedBuilder? sendButtonBuilder;
|
||||||
@@ -951,14 +958,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildFilePickerSection() {
|
Widget _buildFilePickerSection() {
|
||||||
if (_openFilePickerSection && widget.attachmentsPickerBuilder != null) {
|
final picker = StreamAttachmentPicker(
|
||||||
return widget.attachmentsPickerBuilder!(
|
|
||||||
context,
|
|
||||||
messageInputController,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StreamAttachmentPicker(
|
|
||||||
messageInputController: messageInputController,
|
messageInputController: messageInputController,
|
||||||
onFilePicked: pickFile,
|
onFilePicked: pickFile,
|
||||||
isOpen: _openFilePickerSection,
|
isOpen: _openFilePickerSection,
|
||||||
@@ -975,6 +975,16 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
},
|
},
|
||||||
onError: _showErrorAlert,
|
onError: _showErrorAlert,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (_openFilePickerSection && widget.attachmentsPickerBuilder != null) {
|
||||||
|
return widget.attachmentsPickerBuilder!(
|
||||||
|
context,
|
||||||
|
messageInputController,
|
||||||
|
picker,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return picker;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMentionsOverlayEntry() {
|
Widget _buildMentionsOverlayEntry() {
|
||||||
|
|||||||
@@ -9,16 +9,19 @@ import 'package:stream_chat_flutter/src/video_service.dart';
|
|||||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
import 'package:video_compress/video_compress.dart';
|
import 'package:video_compress/video_compress.dart';
|
||||||
|
|
||||||
|
/// Callback for when a file has to be picked.
|
||||||
typedef FilePickerCallback = void Function(
|
typedef FilePickerCallback = void Function(
|
||||||
DefaultAttachmentTypes fileType, {
|
DefaultAttachmentTypes fileType, {
|
||||||
bool camera,
|
bool camera,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Callback for building an icon for a custom attachment type.
|
||||||
typedef CustomAttachmentIconBuilder = Widget Function(
|
typedef CustomAttachmentIconBuilder = Widget Function(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
bool active,
|
bool active,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
///
|
||||||
class StreamAttachmentPicker extends StatefulWidget {
|
class StreamAttachmentPicker extends StatefulWidget {
|
||||||
final bool isOpen;
|
final bool isOpen;
|
||||||
final double pickerSize;
|
final double pickerSize;
|
||||||
@@ -65,6 +68,45 @@ class StreamAttachmentPicker extends StatefulWidget {
|
|||||||
this.customAttachmentTypes = const [],
|
this.customAttachmentTypes = const [],
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
StreamAttachmentPicker copyWith({
|
||||||
|
Key? key,
|
||||||
|
MessageInputController? messageInputController,
|
||||||
|
FilePickerCallback? onFilePicked,
|
||||||
|
bool? isOpen,
|
||||||
|
double? pickerSize,
|
||||||
|
int? attachmentLimit,
|
||||||
|
AttachmentLimitExceedListener? onAttachmentLimitExceeded,
|
||||||
|
int? maxAttachmentSize,
|
||||||
|
VideoQuality? compressedVideoQuality,
|
||||||
|
int? compressedVideoFrameRate,
|
||||||
|
ValueChanged<bool>? onChangeInputState,
|
||||||
|
ValueChanged<String>? onError,
|
||||||
|
List<DefaultAttachmentTypes>? allowedAttachmentTypes,
|
||||||
|
List<CustomAttachmentType>? customAttachmentTypes = const [],
|
||||||
|
}) =>
|
||||||
|
StreamAttachmentPicker(
|
||||||
|
key: key ?? this.key,
|
||||||
|
messageInputController:
|
||||||
|
messageInputController ?? this.messageInputController,
|
||||||
|
onFilePicked: onFilePicked ?? this.onFilePicked,
|
||||||
|
isOpen: isOpen ?? this.isOpen,
|
||||||
|
pickerSize: pickerSize ?? this.pickerSize,
|
||||||
|
attachmentLimit: attachmentLimit ?? this.attachmentLimit,
|
||||||
|
onAttachmentLimitExceeded:
|
||||||
|
onAttachmentLimitExceeded ?? this.onAttachmentLimitExceeded,
|
||||||
|
maxAttachmentSize: maxAttachmentSize ?? this.maxAttachmentSize,
|
||||||
|
compressedVideoQuality:
|
||||||
|
compressedVideoQuality ?? this.compressedVideoQuality,
|
||||||
|
compressedVideoFrameRate:
|
||||||
|
compressedVideoFrameRate ?? this.compressedVideoFrameRate,
|
||||||
|
onChangeInputState: onChangeInputState ?? this.onChangeInputState,
|
||||||
|
onError: onError ?? this.onError,
|
||||||
|
allowedAttachmentTypes:
|
||||||
|
allowedAttachmentTypes ?? this.allowedAttachmentTypes,
|
||||||
|
customAttachmentTypes:
|
||||||
|
customAttachmentTypes ?? this.customAttachmentTypes,
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StreamAttachmentPicker> createState() => _StreamAttachmentPickerState();
|
State<StreamAttachmentPicker> createState() => _StreamAttachmentPickerState();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user