Merge pull request #1608 from GetStream/feat/allowed-attachment-picker-types
This commit is contained in:
@@ -7,6 +7,21 @@
|
||||
- [[#1605]](https://github.com/GetStream/stream-chat-flutter/issues/1605) Fixed Null exception is thrown on message list
|
||||
for unread messages when `ScrollToBottomButton` is pressed.
|
||||
|
||||
✅ Added
|
||||
|
||||
- Added support for `StreamMessageInput.allowedAttachmentPickerTypes` to specify the allowed attachment picker types.
|
||||
[#1601](https://github.com/GetStream/stream-chat-flutter/issues/1376)
|
||||
|
||||
```dart
|
||||
StreamMessageInput(
|
||||
...,
|
||||
allowedAttachmentPickerTypes: const [
|
||||
AttachmentPickerType.files,
|
||||
AttachmentPickerType.images,
|
||||
],
|
||||
)
|
||||
```
|
||||
|
||||
## 6.3.0
|
||||
|
||||
🐞 Fixed
|
||||
|
||||
+6
@@ -693,6 +693,7 @@ Widget mobileAttachmentPickerBuilder({
|
||||
required BuildContext context,
|
||||
required StreamAttachmentPickerController controller,
|
||||
Iterable<AttachmentPickerOption>? customOptions,
|
||||
List<AttachmentPickerType> allowedTypes = AttachmentPickerType.values,
|
||||
ThumbnailSize attachmentThumbnailSize = const ThumbnailSize(400, 400),
|
||||
ThumbnailFormat attachmentThumbnailFormat = ThumbnailFormat.jpeg,
|
||||
int attachmentThumbnailQuality = 100,
|
||||
@@ -702,6 +703,7 @@ Widget mobileAttachmentPickerBuilder({
|
||||
controller: controller,
|
||||
onSendAttachments: Navigator.of(context).pop,
|
||||
options: {
|
||||
...{
|
||||
if (customOptions != null) ...customOptions,
|
||||
AttachmentPickerOption(
|
||||
key: 'gallery-picker',
|
||||
@@ -770,6 +772,7 @@ Widget mobileAttachmentPickerBuilder({
|
||||
);
|
||||
},
|
||||
),
|
||||
}..where((option) => option.supportedTypes.every(allowedTypes.contains)),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -779,6 +782,7 @@ Widget webOrDesktopAttachmentPickerBuilder({
|
||||
required BuildContext context,
|
||||
required StreamAttachmentPickerController controller,
|
||||
Iterable<WebOrDesktopAttachmentPickerOption>? customOptions,
|
||||
List<AttachmentPickerType> allowedTypes = AttachmentPickerType.values,
|
||||
ThumbnailSize attachmentThumbnailSize = const ThumbnailSize(400, 400),
|
||||
ThumbnailFormat attachmentThumbnailFormat = ThumbnailFormat.jpeg,
|
||||
int attachmentThumbnailQuality = 100,
|
||||
@@ -787,6 +791,7 @@ Widget webOrDesktopAttachmentPickerBuilder({
|
||||
return StreamWebOrDesktopAttachmentPickerBottomSheet(
|
||||
controller: controller,
|
||||
options: {
|
||||
...{
|
||||
if (customOptions != null) ...customOptions,
|
||||
WebOrDesktopAttachmentPickerOption(
|
||||
key: 'image-picker',
|
||||
@@ -806,6 +811,7 @@ Widget webOrDesktopAttachmentPickerBuilder({
|
||||
icon: StreamSvgIcon.files(size: 36).toIconThemeSvgIcon(),
|
||||
title: context.translations.uploadAFileLabel,
|
||||
),
|
||||
}.where((option) => option.supportedTypes.every(allowedTypes.contains)),
|
||||
},
|
||||
onOptionTap: (context, controller, option) async {
|
||||
final attachment = await StreamAttachmentHandler.instance.pickFile(
|
||||
|
||||
+3
@@ -66,6 +66,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
Future<T?> showStreamAttachmentPickerModalBottomSheet<T>({
|
||||
required BuildContext context,
|
||||
Iterable<AttachmentPickerOption>? customOptions,
|
||||
List<AttachmentPickerType> allowedTypes = AttachmentPickerType.values,
|
||||
List<Attachment>? initialAttachments,
|
||||
StreamAttachmentPickerController? controller,
|
||||
Color? backgroundColor,
|
||||
@@ -117,6 +118,7 @@ Future<T?> showStreamAttachmentPickerModalBottomSheet<T>({
|
||||
return webOrDesktopAttachmentPickerBuilder.call(
|
||||
context: context,
|
||||
controller: controller,
|
||||
allowedTypes: allowedTypes,
|
||||
customOptions: customOptions?.map(
|
||||
WebOrDesktopAttachmentPickerOption.fromAttachmentPickerOption,
|
||||
),
|
||||
@@ -130,6 +132,7 @@ Future<T?> showStreamAttachmentPickerModalBottomSheet<T>({
|
||||
return mobileAttachmentPickerBuilder.call(
|
||||
context: context,
|
||||
controller: controller,
|
||||
allowedTypes: allowedTypes,
|
||||
customOptions: customOptions,
|
||||
attachmentThumbnailSize: attachmentThumbnailSize,
|
||||
attachmentThumbnailFormat: attachmentThumbnailFormat,
|
||||
|
||||
@@ -122,6 +122,7 @@ class StreamMessageInput extends StatefulWidget {
|
||||
this.maxAttachmentSize = kDefaultMaxAttachmentSize,
|
||||
this.onError,
|
||||
this.attachmentLimit = 10,
|
||||
this.allowedAttachmentPickerTypes = AttachmentPickerType.values,
|
||||
this.onAttachmentLimitExceed,
|
||||
this.attachmentButtonBuilder,
|
||||
this.commandButtonBuilder,
|
||||
@@ -233,6 +234,12 @@ class StreamMessageInput extends StatefulWidget {
|
||||
/// A limit for the no. of attachments that can be sent with a single message.
|
||||
final int attachmentLimit;
|
||||
|
||||
/// The list of allowed attachment types which can be picked using the
|
||||
/// attachment button.
|
||||
///
|
||||
/// By default, all the attachment types are allowed.
|
||||
final List<AttachmentPickerType> allowedAttachmentPickerTypes;
|
||||
|
||||
/// A callback for when the [attachmentLimit] is exceeded.
|
||||
///
|
||||
/// This will override the default error alert behaviour.
|
||||
@@ -771,8 +778,9 @@ class StreamMessageInputState extends State<StreamMessageInput>
|
||||
Future<void> _onAttachmentButtonPressed() async {
|
||||
final attachments = await showStreamAttachmentPickerModalBottomSheet(
|
||||
context: context,
|
||||
initialAttachments: _effectiveController.attachments,
|
||||
useRootNavigator: true,
|
||||
allowedTypes: widget.allowedAttachmentPickerTypes,
|
||||
initialAttachments: _effectiveController.attachments,
|
||||
);
|
||||
|
||||
if (attachments != null) {
|
||||
|
||||
Reference in New Issue
Block a user