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;
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( final response = await _client.post(
'/channels/$channelType/$channelId/image', '/channels/$channelType/$channelId/image',
data: FormData.fromMap({ data: FormData.fromMap({
'file': await MultipartFile.fromFile( 'file': multiPartFile,
file.path,
filename: filename,
contentType: mimeType,
),
}), }),
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;
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( final response = await _client.post(
'/channels/$channelType/$channelId/file', '/channels/$channelType/$channelId/file',
data: FormData.fromMap({ data: FormData.fromMap({
'file': await MultipartFile.fromFile( 'file': multiPartFile,
file.path,
filename: filename,
contentType: mimeType,
),
}), }),
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';
} }
+57 -55
View File
@@ -36,63 +36,65 @@ 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(
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
SizedBox(height: 26.0), children: [
if (icon != null) icon, SizedBox(height: 26.0),
SizedBox(height: 26.0), if (icon != null) icon,
Text( SizedBox(height: 26.0),
title, Text(
style: StreamChatTheme.of(context).textTheme.headlineBold, title,
), style: StreamChatTheme.of(context).textTheme.headlineBold,
SizedBox(height: 7.0), ),
Text( SizedBox(height: 7.0),
question, Text(
textAlign: TextAlign.center, question,
), textAlign: TextAlign.center,
SizedBox(height: 36.0), ),
Container( SizedBox(height: 36.0),
color: effect.color.withOpacity(effect.alpha ?? 1), Container(
height: 1, color: effect.color.withOpacity(effect.alpha ?? 1),
), height: 1,
Row( ),
mainAxisAlignment: MainAxisAlignment.spaceBetween, Row(
children: [ mainAxisAlignment: MainAxisAlignment.spaceBetween,
TextButton( children: [
child: Text( TextButton(
cancelText, child: Text(
style: StreamChatTheme.of(context) cancelText,
.textTheme style: StreamChatTheme.of(context)
.bodyBold .textTheme
.copyWith( .bodyBold
color: StreamChatTheme.of(context) .copyWith(
.colorTheme color: StreamChatTheme.of(context)
.black .colorTheme
.withOpacity(0.5)), .black
.withOpacity(0.5)),
),
onPressed: () {
Navigator.of(context).pop(false);
},
), ),
onPressed: () { TextButton(
Navigator.of(context).pop(false); child: Text(
}, okText,
), style: StreamChatTheme.of(context)
TextButton( .textTheme
child: Text( .bodyBold
okText, .copyWith(
style: StreamChatTheme.of(context) color: StreamChatTheme.of(context)
.textTheme .colorTheme
.bodyBold .accentRed),
.copyWith( ),
color: StreamChatTheme.of(context) onPressed: () {
.colorTheme Navigator.pop(context, true);
.accentRed), },
), ),
onPressed: () { ],
Navigator.pop(context, true); ),
}, ],
), ),
],
),
],
); );
}); });
} }
@@ -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