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
.classpath
.settings
/.fvm
**/.fvm
.melos_tool/
/packages/flutter_widgets/example/ios/Flutter/.last_build_id
@@ -277,6 +277,7 @@ class Channel {
);
}
}).catchError((e, stk) {
client.logger.severe('error uploading the attachment', e, stk);
updateAttachment(
it.copyWith(uploadState: UploadState.failed(error: e.toString())),
);
@@ -70,16 +70,28 @@ class StreamAttachmentFileUploader implements AttachmentFileUploader {
ProgressCallback onSendProgress,
CancelToken cancelToken,
}) async {
final filename = file.path?.split('/')?.last;
final filename = file.path?.split('/')?.last ?? file.name;
final mimeType = filename.mimeType;
MultipartFile multiPartFile;
if (file.path != null) {
multiPartFile = await MultipartFile.fromFile(
file.path,
filename: filename,
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': await MultipartFile.fromFile(
file.path,
filename: filename,
contentType: mimeType,
),
'file': multiPartFile,
}),
onSendProgress: onSendProgress,
cancelToken: cancelToken,
@@ -95,16 +107,28 @@ class StreamAttachmentFileUploader implements AttachmentFileUploader {
ProgressCallback onSendProgress,
CancelToken cancelToken,
}) async {
final filename = file.path?.split('/')?.last;
final filename = file.path?.split('/')?.last ?? file.name;
final mimeType = filename.mimeType;
MultipartFile multiPartFile;
if (file.path != null) {
multiPartFile = await MultipartFile.fromFile(
file.path,
filename: filename,
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': await MultipartFile.fromFile(
file.path,
filename: filename,
contentType: mimeType,
),
'file': multiPartFile,
}),
onSendProgress: onSendProgress,
cancelToken: cancelToken,
@@ -25,7 +25,11 @@ dependencies:
sdk: flutter
stream_chat_flutter:
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.
# Use with the CupertinoIcons class for iOS style icons.
@@ -304,7 +304,7 @@ class MessageInputState extends State<MessageInput> {
Flex _buildTextField(BuildContext context) {
return Flex(
direction: Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
if (!_commandEnabled) _buildExpandActionsButton(),
if (widget.actionsLocation == ActionsLocation.left)
@@ -1903,14 +1903,12 @@ class MessageInputState extends State<MessageInput> {
if (file == null) return;
final mimeType = file.path.split('/').last.mimeType;
final mimeType = file.name?.mimeType;
final extraDataMap = <String, dynamic>{};
if (camera) {
if (mimeType.type == 'video' || mimeType.type == 'image') {
attachmentType = mimeType.type;
}
if (mimeType.type == 'video' || mimeType.type == 'image') {
attachmentType = mimeType.type;
} else {
attachmentType = 'file';
}
+57 -55
View File
@@ -36,63 +36,65 @@ Future<bool> showConfirmationDialog(
)),
builder: (context) {
final effect = StreamChatTheme.of(context).colorTheme.borderTop;
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 26.0),
if (icon != null) icon,
SizedBox(height: 26.0),
Text(
title,
style: StreamChatTheme.of(context).textTheme.headlineBold,
),
SizedBox(height: 7.0),
Text(
question,
textAlign: TextAlign.center,
),
SizedBox(height: 36.0),
Container(
color: effect.color.withOpacity(effect.alpha ?? 1),
height: 1,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
child: Text(
cancelText,
style: StreamChatTheme.of(context)
.textTheme
.bodyBold
.copyWith(
color: StreamChatTheme.of(context)
.colorTheme
.black
.withOpacity(0.5)),
return SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 26.0),
if (icon != null) icon,
SizedBox(height: 26.0),
Text(
title,
style: StreamChatTheme.of(context).textTheme.headlineBold,
),
SizedBox(height: 7.0),
Text(
question,
textAlign: TextAlign.center,
),
SizedBox(height: 36.0),
Container(
color: effect.color.withOpacity(effect.alpha ?? 1),
height: 1,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
child: Text(
cancelText,
style: StreamChatTheme.of(context)
.textTheme
.bodyBold
.copyWith(
color: StreamChatTheme.of(context)
.colorTheme
.black
.withOpacity(0.5)),
),
onPressed: () {
Navigator.of(context).pop(false);
},
),
onPressed: () {
Navigator.of(context).pop(false);
},
),
TextButton(
child: Text(
okText,
style: StreamChatTheme.of(context)
.textTheme
.bodyBold
.copyWith(
color: StreamChatTheme.of(context)
.colorTheme
.accentRed),
TextButton(
child: Text(
okText,
style: StreamChatTheme.of(context)
.textTheme
.bodyBold
.copyWith(
color: StreamChatTheme.of(context)
.colorTheme
.accentRed),
),
onPressed: () {
Navigator.pop(context, true);
},
),
onPressed: () {
Navigator.pop(context, true);
},
),
],
),
],
],
),
],
),
);
});
}
@@ -10,7 +10,11 @@ environment:
flutter: ">=1.17.0"
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:
sdk: flutter
rxdart: ^0.25.0
@@ -15,7 +15,11 @@ dependencies:
path: ^1.7.0
path_provider: ^1.6.27
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:
test: ^1.15.7