Merge branch 'master' into feature/new-ui
This commit is contained in:
@@ -5,6 +5,9 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- feature/new-ui
|
- feature/new-ui
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- created
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_deploy_ios:
|
build_and_deploy_ios:
|
||||||
@@ -24,19 +27,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd example
|
cd example
|
||||||
flutter pub get
|
flutter pub get
|
||||||
- name: Coverage fix
|
|
||||||
run: |
|
|
||||||
file=test/coverage_helper_test.dart
|
|
||||||
echo "// Helper file to make coverage work for all dart files\n" > $file
|
|
||||||
echo "// ignore_for_file: unused_import" >> $file
|
|
||||||
find lib -name '*.dart' | grep -e '[^g]\.dart' | grep -v '_html.dart' | cut -c4- | awk -v package=stream_chat_flutter '{printf "import '\''package:%s%s'\'';\n", package, $1}' >> $file
|
|
||||||
echo "" >> $file
|
|
||||||
echo "void main(){}" >> $file
|
|
||||||
cat $file
|
|
||||||
- name: Run tests
|
|
||||||
run: flutter test --coverage
|
|
||||||
- name: Codecov
|
|
||||||
run: bash <(curl -s https://codecov.io/bash) -c -t ${{ secrets.CODECOV_TOKEN }} -f coverage/lcov.info -F flutter_tool
|
|
||||||
- name: Build and release
|
- name: Build and release
|
||||||
env:
|
env:
|
||||||
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
|
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
|
||||||
@@ -60,19 +50,6 @@ jobs:
|
|||||||
- run: |
|
- run: |
|
||||||
cd example
|
cd example
|
||||||
flutter pub get
|
flutter pub get
|
||||||
- name: Coverage fix
|
|
||||||
run: |
|
|
||||||
file=test/coverage_helper_test.dart
|
|
||||||
echo "// Helper file to make coverage work for all dart files\n" > $file
|
|
||||||
echo "// ignore_for_file: unused_import" >> $file
|
|
||||||
find lib -name '*.dart' | grep -e '[^g]\.dart' | grep -v '_html.dart' | cut -c4- | awk -v package=stream_chat_flutter '{printf "import '\''package:%s%s'\'';\n", package, $1}' >> $file
|
|
||||||
echo "" >> $file
|
|
||||||
echo "void main(){}" >> $file
|
|
||||||
cat $file
|
|
||||||
- name: Run tests
|
|
||||||
run: flutter test --coverage
|
|
||||||
- name: Codecov
|
|
||||||
run: bash <(curl -s https://codecov.io/bash) -c -t ${{ secrets.CODECOV_TOKEN }} -f coverage/lcov.info -F flutter_tool
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
cd example
|
cd example
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
name: Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: [ubuntu-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Flutter action
|
||||||
|
uses: subosito/[email protected]
|
||||||
|
with:
|
||||||
|
channel: 'stable'
|
||||||
|
- name: Get dependencies
|
||||||
|
run: flutter pub get
|
||||||
|
- name: Coverage fix
|
||||||
|
run: |
|
||||||
|
file=test/coverage_helper_test.dart
|
||||||
|
echo "// Helper file to make coverage work for all dart files\n" > $file
|
||||||
|
echo "// ignore_for_file: unused_import" >> $file
|
||||||
|
find lib -name '*.dart' | grep -e '[^g]\.dart' | grep -v '_html.dart' | cut -c4- | awk -v package=stream_chat_flutter '{printf "import '\''package:%s%s'\'';\n", package, $1}' >> $file
|
||||||
|
echo "" >> $file
|
||||||
|
echo "void main(){}" >> $file
|
||||||
|
cat $file
|
||||||
|
- name: Run tests
|
||||||
|
run: flutter test --coverage
|
||||||
|
- name: Codecov
|
||||||
|
run: bash <(curl -s https://codecov.io/bash) -c -t ${{ secrets.CODECOV_TOKEN }} -f coverage/lcov.info -F flutter_tool
|
||||||
+70
-59
@@ -1,9 +1,9 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
||||||
import 'package:http_parser/http_parser.dart';
|
import 'package:http_parser/http_parser.dart';
|
||||||
@@ -17,7 +17,7 @@ import 'package:stream_chat_flutter/src/user_avatar.dart';
|
|||||||
import '../stream_chat_flutter.dart';
|
import '../stream_chat_flutter.dart';
|
||||||
import 'stream_channel.dart';
|
import 'stream_channel.dart';
|
||||||
|
|
||||||
typedef FileUploader = Future<String> Function(File, Channel);
|
typedef FileUploader = Future<String> Function(PlatformFile, Channel);
|
||||||
typedef AttachmentThumbnailBuilder = Widget Function(
|
typedef AttachmentThumbnailBuilder = Widget Function(
|
||||||
BuildContext,
|
BuildContext,
|
||||||
_SendingAttachment,
|
_SendingAttachment,
|
||||||
@@ -777,8 +777,8 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
case 'image':
|
case 'image':
|
||||||
case 'giphy':
|
case 'giphy':
|
||||||
return attachment.file != null
|
return attachment.file != null
|
||||||
? Image.file(
|
? Image.memory(
|
||||||
attachment.file,
|
attachment.file.bytes,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
)
|
)
|
||||||
: Image.network(
|
: Image.network(
|
||||||
@@ -888,22 +888,24 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
if (!kIsWeb)
|
||||||
leading: Icon(Icons.camera_alt),
|
ListTile(
|
||||||
title: Text('Photo from camera'),
|
leading: Icon(Icons.camera_alt),
|
||||||
onTap: () {
|
title: Text('Photo from camera'),
|
||||||
pickFile(DefaultAttachmentTypes.image, true);
|
onTap: () {
|
||||||
Navigator.pop(context);
|
pickFile(DefaultAttachmentTypes.image, true);
|
||||||
},
|
Navigator.pop(context);
|
||||||
),
|
},
|
||||||
ListTile(
|
),
|
||||||
leading: Icon(Icons.videocam),
|
if (!kIsWeb)
|
||||||
title: Text('Video from camera'),
|
ListTile(
|
||||||
onTap: () {
|
leading: Icon(Icons.videocam),
|
||||||
pickFile(DefaultAttachmentTypes.video, true);
|
title: Text('Video from camera'),
|
||||||
Navigator.pop(context);
|
onTap: () {
|
||||||
},
|
pickFile(DefaultAttachmentTypes.video, true);
|
||||||
),
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.insert_drive_file),
|
leading: Icon(Icons.insert_drive_file),
|
||||||
title: Text('Upload a file'),
|
title: Text('Upload a file'),
|
||||||
@@ -935,7 +937,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
_inputEnabled = false;
|
_inputEnabled = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
File file;
|
PlatformFile file;
|
||||||
String attachmentType;
|
String attachmentType;
|
||||||
|
|
||||||
if (fileType == DefaultAttachmentTypes.image) {
|
if (fileType == DefaultAttachmentTypes.image) {
|
||||||
@@ -953,7 +955,11 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
} else if (fileType == DefaultAttachmentTypes.video) {
|
} else if (fileType == DefaultAttachmentTypes.video) {
|
||||||
pickedFile = await _imagePicker.getVideo(source: ImageSource.camera);
|
pickedFile = await _imagePicker.getVideo(source: ImageSource.camera);
|
||||||
}
|
}
|
||||||
file = File(pickedFile.path);
|
final bytes = await pickedFile.readAsBytes();
|
||||||
|
file = PlatformFile(
|
||||||
|
path: pickedFile.path,
|
||||||
|
bytes: bytes,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
FileType type;
|
FileType type;
|
||||||
if (fileType == DefaultAttachmentTypes.image) {
|
if (fileType == DefaultAttachmentTypes.image) {
|
||||||
@@ -963,9 +969,13 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
} else if (fileType == DefaultAttachmentTypes.file) {
|
} else if (fileType == DefaultAttachmentTypes.file) {
|
||||||
type = FileType.any;
|
type = FileType.any;
|
||||||
}
|
}
|
||||||
final res = await FilePicker.platform.pickFiles(type: type);
|
final res = await FilePicker.platform.pickFiles(
|
||||||
|
type: type,
|
||||||
|
withData: true,
|
||||||
|
);
|
||||||
if (res?.files?.isNotEmpty == true) {
|
if (res?.files?.isNotEmpty == true) {
|
||||||
file = File(res.files.first.path);
|
file = res.files.single;
|
||||||
|
print('file.bytes?.length: ${file.bytes?.length}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -978,11 +988,10 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final channel = StreamChannel.of(context).channel;
|
final channel = StreamChannel.of(context).channel;
|
||||||
|
|
||||||
final attachment = _SendingAttachment(
|
final attachment = _SendingAttachment(
|
||||||
file: file,
|
file: file,
|
||||||
attachment: Attachment(
|
attachment: Attachment(
|
||||||
localUri: file.uri,
|
localUri: file.path != null ? Uri.parse(file.path) : null,
|
||||||
type: attachmentType,
|
type: attachmentType,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -1009,7 +1018,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _uploadAttachment(
|
Future<String> _uploadAttachment(
|
||||||
File file,
|
PlatformFile file,
|
||||||
DefaultAttachmentTypes type,
|
DefaultAttachmentTypes type,
|
||||||
Channel channel,
|
Channel channel,
|
||||||
) async {
|
) async {
|
||||||
@@ -1030,9 +1039,9 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _uploadImage(File file, Channel channel) async {
|
Future<String> _uploadImage(PlatformFile file, Channel channel) async {
|
||||||
final filename = file.path.split('/').last;
|
final filename = file.name ?? file.path?.split('/')?.last;
|
||||||
final bytes = await file.readAsBytes();
|
final bytes = file.bytes;
|
||||||
final res = await channel.sendImage(
|
final res = await channel.sendImage(
|
||||||
MultipartFile.fromBytes(
|
MultipartFile.fromBytes(
|
||||||
bytes,
|
bytes,
|
||||||
@@ -1043,9 +1052,9 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
return res.file;
|
return res.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _uploadFile(File file, Channel channel) async {
|
Future<String> _uploadFile(PlatformFile file, Channel channel) async {
|
||||||
final filename = file.path.split('/').last;
|
final filename = file.name ?? file.path?.split('/')?.last;
|
||||||
final bytes = await file.readAsBytes();
|
final bytes = file.bytes;
|
||||||
final res = await channel.sendFile(
|
final res = await channel.sendFile(
|
||||||
MultipartFile.fromBytes(
|
MultipartFile.fromBytes(
|
||||||
bytes,
|
bytes,
|
||||||
@@ -1209,34 +1218,36 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_keyboardListener = KeyboardVisibility.onChange.listen((visible) {
|
if (!kIsWeb) {
|
||||||
if (visible) {
|
_keyboardListener = KeyboardVisibility.onChange.listen((visible) {
|
||||||
if (_commandsOverlay != null) {
|
if (visible) {
|
||||||
if (textEditingController.text.startsWith('/')) {
|
if (_commandsOverlay != null) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
if (textEditingController.text.startsWith('/')) {
|
||||||
_commandsOverlay = _buildCommandsOverlayEntry();
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
Overlay.of(context).insert(_commandsOverlay);
|
_commandsOverlay = _buildCommandsOverlayEntry();
|
||||||
});
|
Overlay.of(context).insert(_commandsOverlay);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_mentionsOverlay != null) {
|
if (_mentionsOverlay != null) {
|
||||||
if (textEditingController.text.contains('@')) {
|
if (textEditingController.text.contains('@')) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
_mentionsOverlay = _buildCommandsOverlayEntry();
|
_mentionsOverlay = _buildCommandsOverlayEntry();
|
||||||
Overlay.of(context).insert(_mentionsOverlay);
|
Overlay.of(context).insert(_mentionsOverlay);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (_commandsOverlay != null) {
|
||||||
|
_commandsOverlay.remove();
|
||||||
|
}
|
||||||
|
if (_mentionsOverlay != null) {
|
||||||
|
_mentionsOverlay.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
if (_commandsOverlay != null) {
|
}
|
||||||
_commandsOverlay.remove();
|
|
||||||
}
|
|
||||||
if (_mentionsOverlay != null) {
|
|
||||||
_mentionsOverlay.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
textEditingController =
|
textEditingController =
|
||||||
widget.textEditingController ?? TextEditingController();
|
widget.textEditingController ?? TextEditingController();
|
||||||
@@ -1263,7 +1274,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_commandsOverlay?.remove();
|
_commandsOverlay?.remove();
|
||||||
_mentionsOverlay?.remove();
|
_mentionsOverlay?.remove();
|
||||||
_keyboardListener.cancel();
|
_keyboardListener?.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1279,7 +1290,7 @@ class MessageInputState extends State<MessageInput> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SendingAttachment {
|
class _SendingAttachment {
|
||||||
File file;
|
PlatformFile file;
|
||||||
Attachment attachment;
|
Attachment attachment;
|
||||||
bool uploaded;
|
bool uploaded;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user