fix: minor

This commit is contained in:
Salvatore Giordano
2021-03-03 12:47:19 +01:00
parent 529995164d
commit b28ae12597
8 changed files with 114 additions and 77 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ build/
.project .project
.classpath .classpath
.settings .settings
/.fvm **/.fvm
.melos_tool/ .melos_tool/
/packages/flutter_widgets/example/ios/Flutter/.last_build_id /packages/flutter_widgets/example/ios/Flutter/.last_build_id
@@ -277,6 +277,7 @@ class Channel {
); );
} }
}).catchError((e, stk) { }).catchError((e, stk) {
client.logger.severe('error uploading the attachment', e, stk);
updateAttachment( updateAttachment(
it.copyWith(uploadState: UploadState.failed(error: e.toString())), it.copyWith(uploadState: UploadState.failed(error: e.toString())),
); );
@@ -70,16 +70,28 @@ class StreamAttachmentFileUploader implements AttachmentFileUploader {
ProgressCallback onSendProgress, ProgressCallback onSendProgress,
CancelToken cancelToken, CancelToken cancelToken,
}) async { }) async {
final filename = file.path?.split('/')?.last; final filename = file.path?.split('/')?.last ?? file.name;
final mimeType = filename.mimeType; final mimeType = filename.mimeType;
final response = await _client.post(
'/channels/$channelType/$channelId/image', MultipartFile multiPartFile;
data: FormData.fromMap({ if (file.path != null) {
'file': await MultipartFile.fromFile( multiPartFile = await MultipartFile.fromFile(
file.path, file.path,
filename: filename, filename: filename,
contentType: mimeType, contentType: mimeType,
), );
} else if (file.bytes != null) {
multiPartFile = MultipartFile.fromBytes(
file.bytes,
filename: filename,
contentType: mimeType,
);
}
final response = await _client.post(
'/channels/$channelType/$channelId/image',
data: FormData.fromMap({
'file': multiPartFile,
}), }),
onSendProgress: onSendProgress, onSendProgress: onSendProgress,
cancelToken: cancelToken, cancelToken: cancelToken,
@@ -95,16 +107,28 @@ class StreamAttachmentFileUploader implements AttachmentFileUploader {
ProgressCallback onSendProgress, ProgressCallback onSendProgress,
CancelToken cancelToken, CancelToken cancelToken,
}) async { }) async {
final filename = file.path?.split('/')?.last; final filename = file.path?.split('/')?.last ?? file.name;
final mimeType = filename.mimeType; final mimeType = filename.mimeType;
final response = await _client.post(
'/channels/$channelType/$channelId/file', MultipartFile multiPartFile;
data: FormData.fromMap({ if (file.path != null) {
'file': await MultipartFile.fromFile( multiPartFile = await MultipartFile.fromFile(
file.path, file.path,
filename: filename, filename: filename,
contentType: mimeType, contentType: mimeType,
), );
} else if (file.bytes != null) {
multiPartFile = MultipartFile.fromBytes(
file.bytes,
filename: filename,
contentType: mimeType,
);
}
final response = await _client.post(
'/channels/$channelType/$channelId/file',
data: FormData.fromMap({
'file': multiPartFile,
}), }),
onSendProgress: onSendProgress, onSendProgress: onSendProgress,
cancelToken: cancelToken, cancelToken: cancelToken,
@@ -25,7 +25,11 @@ dependencies:
sdk: flutter sdk: flutter
stream_chat_flutter: stream_chat_flutter:
path: ../ path: ../
stream_chat_persistence: ^1.3.0-beta stream_chat_persistence:
git:
url: https://github.com/GetStream/stream-chat-flutter.git
ref: develop
path: packages/stream_chat_persistence
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
@@ -304,7 +304,7 @@ class MessageInputState extends State<MessageInput> {
Flex _buildTextField(BuildContext context) { Flex _buildTextField(BuildContext context) {
return Flex( return Flex(
direction: Axis.horizontal, direction: Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
if (!_commandEnabled) _buildExpandActionsButton(), if (!_commandEnabled) _buildExpandActionsButton(),
if (widget.actionsLocation == ActionsLocation.left) if (widget.actionsLocation == ActionsLocation.left)
@@ -1903,14 +1903,12 @@ class MessageInputState extends State<MessageInput> {
if (file == null) return; if (file == null) return;
final mimeType = file.path.split('/').last.mimeType; final mimeType = file.name?.mimeType;
final extraDataMap = <String, dynamic>{}; final extraDataMap = <String, dynamic>{};
if (camera) {
if (mimeType.type == 'video' || mimeType.type == 'image') { if (mimeType.type == 'video' || mimeType.type == 'image') {
attachmentType = mimeType.type; attachmentType = mimeType.type;
}
} else { } else {
attachmentType = 'file'; attachmentType = 'file';
} }
@@ -36,7 +36,8 @@ Future<bool> showConfirmationDialog(
)), )),
builder: (context) { builder: (context) {
final effect = StreamChatTheme.of(context).colorTheme.borderTop; final effect = StreamChatTheme.of(context).colorTheme.borderTop;
return Column( return SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
SizedBox(height: 26.0), SizedBox(height: 26.0),
@@ -93,6 +94,7 @@ Future<bool> showConfirmationDialog(
], ],
), ),
], ],
),
); );
}); });
} }
@@ -10,7 +10,11 @@ environment:
flutter: ">=1.17.0" flutter: ">=1.17.0"
dependencies: dependencies:
stream_chat: ^1.3.2+1-beta stream_chat:
git:
url: https://github.com/GetStream/stream-chat-flutter.git
ref: develop
path: packages/stream_chat
flutter: flutter:
sdk: flutter sdk: flutter
rxdart: ^0.25.0 rxdart: ^0.25.0
@@ -15,7 +15,11 @@ dependencies:
path: ^1.7.0 path: ^1.7.0
path_provider: ^1.6.27 path_provider: ^1.6.27
sqlite3_flutter_libs: ^0.4.0+1 sqlite3_flutter_libs: ^0.4.0+1
stream_chat: ^1.3.0-beta stream_chat:
git:
url: https://github.com/GetStream/stream-chat-flutter.git
ref: develop
path: packages/stream_chat
dev_dependencies: dev_dependencies:
test: ^1.15.7 test: ^1.15.7