Skip to content

Commit

Permalink
refs #18: unfocus keyboard before picking attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
imtoori committed Apr 10, 2020
1 parent 3e0c749 commit 354fd43
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
23 changes: 15 additions & 8 deletions lib/src/message_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ import 'stream_channel.dart';
/// The widget renders the ui based on the first ancestor of type [StreamChatTheme].
/// Modify it to change the widget appearance.
class MessageInput extends StatefulWidget {
MessageInput(
{Key key,
this.onMessageSent,
this.parentMessage,
this.editMessage,
this.maxHeight = 150})
: super(key: key);
MessageInput({
Key key,
this.onMessageSent,
this.parentMessage,
this.editMessage,
this.maxHeight = 150,
}) : super(key: key);

/// Message to edit
final Message editMessage;
Expand Down Expand Up @@ -506,6 +506,10 @@ class _MessageInputState extends State<MessageInput> {
}

void _showAttachmentModal() {
if (_focusNode.hasFocus) {
_focusNode.unfocus();
}

showModalBottomSheet(
clipBehavior: Clip.hardEdge,
shape: RoundedRectangleBorder(
Expand Down Expand Up @@ -548,7 +552,6 @@ class _MessageInputState extends State<MessageInput> {
leading: Icon(Icons.camera_alt),
title: Text('Photo from camera'),
onTap: () {
ImagePicker.pickImage(source: ImageSource.camera);
_pickFile(FileType.image, true);
Navigator.pop(context);
},
Expand Down Expand Up @@ -587,6 +590,10 @@ class _MessageInputState extends State<MessageInput> {
file = await FilePicker.getFile(type: type);
}

if (file == null) {
return;
}

final channel = StreamChannel.of(context).channel;

final bytes = await file.readAsBytes();
Expand Down
2 changes: 0 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ dependencies:
flutter:
sdk: flutter
rxdart: ^0.23.1


jiffy: ^3.0.1
cached_network_image: ^2.0.0
flutter_markdown: ^0.3.4
Expand Down

0 comments on commit 354fd43

Please sign in to comment.