Merge branch 'feature/new-ui' into feature/reactions

This commit is contained in:
Salvatore Giordano
2020-10-30 09:01:31 +01:00
committed by GitHub
10 changed files with 297 additions and 234 deletions
+63
View File
@@ -0,0 +1,63 @@
name: Build
on:
push:
branches:
- master
- feature/new-ui
release:
types:
- created
jobs:
build_and_deploy_ios:
runs-on: [macos-latest]
steps:
- uses: actions/checkout@v2
- name: Install RubyGems
run: |
cd example/ios
bundle install
- uses: subosito/[email protected]
with:
channel: 'stable'
- name: Install firebase-tools
run: npm install -g firebase-tools
- name: Flutter setup
run: |
cd example
flutter pub get
- name: Build and release
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: |
cd example
flutter build ios --release --no-codesign
cd ios
bundle exec fastlane deploy_to_firebase
build_and_deploy_android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/[email protected]
with:
channel: 'stable'
- run: |
cd example
flutter pub get
- name: Build
run: |
cd example
flutter build apk
- name: Deploy
uses: wzieba/[email protected]
with:
appId: ${{secrets.FIREBASE_ANDROID_APPID}}
token: ${{secrets.FIREBASE_TOKEN}}
groups: stream-testers
file: example/build/app/outputs/apk/release/app-release.apk
-86
View File
@@ -1,86 +0,0 @@
name: CI
on:
push:
branches:
- master
- feature/new-ui
jobs:
build_and_deploy_ios:
runs-on: [macos-latest]
steps:
- uses: actions/checkout@v2
- name: Install RubyGems
run: |
cd example/ios
bundle install
- uses: subosito/[email protected]
with:
channel: 'stable'
- name: Install firebase-tools
run: npm install -g firebase-tools
- name: Flutter setup
run: |
cd example
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
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
run: |
cd example
flutter build ios --release --no-codesign
cd ios
bundle exec fastlane deploy_to_firebase
build_and_deploy_android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/[email protected]
with:
channel: 'stable'
- run: |
cd example
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
run: |
cd example
flutter build apk
- name: Deploy
uses: wzieba/[email protected]
with:
appId: ${{secrets.FIREBASE_ANDROID_APPID}}
token: ${{secrets.FIREBASE_TOKEN}}
groups: stream-testers
file: example/build/app/outputs/apk/release/app-release.apk
+28
View File
@@ -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
+3 -2
View File
@@ -26,7 +26,8 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android { android {
compileSdkVersion 28 compileSdkVersion 29
ndkVersion '21.3.6528147'
sourceSets { sourceSets {
main.java.srcDirs += 'src/main/kotlin' main.java.srcDirs += 'src/main/kotlin'
@@ -40,7 +41,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example" applicationId "com.example.example"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 29
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+1 -1
View File
@@ -1 +1 @@
89eb023669fee58472de747080d78b5a bdf1751976c4ee1e2ef7638eabcfd1ea
+41 -49
View File
@@ -33,49 +33,45 @@ PODS:
- file_picker (0.0.1): - file_picker (0.0.1):
- DKImagePickerController/PhotoGallery - DKImagePickerController/PhotoGallery
- Flutter - Flutter
- Firebase/CoreOnly (6.26.0): - Firebase/CoreOnly (6.33.0):
- FirebaseCore (= 6.7.2) - FirebaseCore (= 6.10.3)
- Firebase/Messaging (6.26.0): - Firebase/Messaging (6.33.0):
- Firebase/CoreOnly - Firebase/CoreOnly
- FirebaseMessaging (~> 4.4.1) - FirebaseMessaging (~> 4.7.0)
- firebase_core (0.5.0-1): - firebase_core (0.5.1):
- Firebase/CoreOnly (~> 6.26.0) - Firebase/CoreOnly (~> 6.33.0)
- Flutter - Flutter
- firebase_messaging (7.0.3): - firebase_messaging (7.0.3):
- Firebase/CoreOnly (~> 6.26.0) - Firebase/CoreOnly (~> 6.33.0)
- Firebase/Messaging (~> 6.26.0) - Firebase/Messaging (~> 6.33.0)
- firebase_core - firebase_core
- Flutter - Flutter
- FirebaseAnalyticsInterop (1.5.0) - FirebaseCore (6.10.3):
- FirebaseCore (6.7.2): - FirebaseCoreDiagnostics (~> 1.6)
- FirebaseCoreDiagnostics (~> 1.3) - GoogleUtilities/Environment (~> 6.7)
- FirebaseCoreDiagnosticsInterop (~> 1.2) - GoogleUtilities/Logger (~> 6.7)
- GoogleUtilities/Environment (~> 6.5)
- GoogleUtilities/Logger (~> 6.5)
- FirebaseCoreDiagnostics (1.7.0): - FirebaseCoreDiagnostics (1.7.0):
- GoogleDataTransport (~> 7.4) - GoogleDataTransport (~> 7.4)
- GoogleUtilities/Environment (~> 6.7) - GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/Logger (~> 6.7) - GoogleUtilities/Logger (~> 6.7)
- nanopb (~> 1.30906.0) - nanopb (~> 1.30906.0)
- FirebaseCoreDiagnosticsInterop (1.2.0) - FirebaseInstallations (1.7.0):
- FirebaseInstallations (1.3.0): - FirebaseCore (~> 6.10)
- FirebaseCore (~> 6.6) - GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/Environment (~> 6.6) - GoogleUtilities/UserDefaults (~> 6.7)
- GoogleUtilities/UserDefaults (~> 6.6)
- PromisesObjC (~> 1.2) - PromisesObjC (~> 1.2)
- FirebaseInstanceID (4.3.4): - FirebaseInstanceID (4.8.0):
- FirebaseCore (~> 6.6) - FirebaseCore (~> 6.10)
- FirebaseInstallations (~> 1.0) - FirebaseInstallations (~> 1.6)
- GoogleUtilities/Environment (~> 6.5) - GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/UserDefaults (~> 6.5) - GoogleUtilities/UserDefaults (~> 6.7)
- FirebaseMessaging (4.4.1): - FirebaseMessaging (4.7.1):
- FirebaseAnalyticsInterop (~> 1.5) - FirebaseCore (~> 6.10)
- FirebaseCore (~> 6.6) - FirebaseInstanceID (~> 4.7)
- FirebaseInstanceID (~> 4.3) - GoogleUtilities/AppDelegateSwizzler (~> 6.7)
- GoogleUtilities/AppDelegateSwizzler (~> 6.5) - GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/Environment (~> 6.5) - GoogleUtilities/Reachability (~> 6.7)
- GoogleUtilities/Reachability (~> 6.5) - GoogleUtilities/UserDefaults (~> 6.7)
- GoogleUtilities/UserDefaults (~> 6.5)
- Protobuf (>= 3.9.2, ~> 3.9) - Protobuf (>= 3.9.2, ~> 3.9)
- Flutter (1.0.0) - Flutter (1.0.0)
- flutter_apns (0.0.1): - flutter_apns (0.0.1):
@@ -119,9 +115,9 @@ PODS:
- Flutter - Flutter
- PromisesObjC (1.2.11) - PromisesObjC (1.2.11)
- Protobuf (3.13.0) - Protobuf (3.13.0)
- SDWebImage (5.9.3): - SDWebImage (5.9.4):
- SDWebImage/Core (= 5.9.3) - SDWebImage/Core (= 5.9.4)
- SDWebImage/Core (5.9.3) - SDWebImage/Core (5.9.4)
- shared_preferences (0.0.1): - shared_preferences (0.0.1):
- Flutter - Flutter
- sqflite (0.0.2): - sqflite (0.0.2):
@@ -146,7 +142,7 @@ PODS:
- sqlite3/perf-threadsafe - sqlite3/perf-threadsafe
- sqlite3/rtree - sqlite3/rtree
- Starscream (4.0.4) - Starscream (4.0.4)
- StreamChatClient (2.4.0): - StreamChatClient (2.4.1):
- Starscream (~> 4.0) - Starscream (~> 4.0)
- SwiftyGif (5.3.0) - SwiftyGif (5.3.0)
- url_launcher (0.0.1): - url_launcher (0.0.1):
@@ -180,10 +176,8 @@ SPEC REPOS:
- DKImagePickerController - DKImagePickerController
- DKPhotoGallery - DKPhotoGallery
- Firebase - Firebase
- FirebaseAnalyticsInterop
- FirebaseCore - FirebaseCore
- FirebaseCoreDiagnostics - FirebaseCoreDiagnostics
- FirebaseCoreDiagnosticsInterop
- FirebaseInstallations - FirebaseInstallations
- FirebaseInstanceID - FirebaseInstanceID
- FirebaseMessaging - FirebaseMessaging
@@ -237,16 +231,14 @@ SPEC CHECKSUMS:
DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1 file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1
Firebase: 7cf5f9c67f03cb3b606d1d6535286e1080e57eb6 Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5
firebase_core: 00e54a4744164a6b5a250b96dd1ad5afaba7a342 firebase_core: aa25a5dc6b492ecab37587c53d8420135f0cac90
firebase_messaging: 666d9994651b1ecf8c582b52dd913f3fa58c17ef firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75
FirebaseAnalyticsInterop: 3f86269c38ae41f47afeb43ebf32a001f58fcdae FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd
FirebaseCore: f42e5e5f382cdcf6b617ed737bf6c871a6947b17
FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1 FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1
FirebaseCoreDiagnosticsInterop: 296e2c5f5314500a850ad0b83e9e7c10b011a850 FirebaseInstallations: 466c7b4d1f58fe16707693091da253726a731ed2
FirebaseInstallations: 6f5f680e65dc374397a483c32d1799ba822a395b FirebaseInstanceID: bd3ffc24367f901a43c063b36c640b345a4a5dd1
FirebaseInstanceID: cef67c4967c7cecb56ea65d8acbb4834825c587b FirebaseMessaging: 5eca4ef173de76253352511aafef774caa1cba2a
FirebaseMessaging: 29543feb343b09546ab3aa04d008ee8595b43c44
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_apns: ddc629f26016140bf52165040b0a8e8869f9ce32 flutter_apns: ddc629f26016140bf52165040b0a8e8869f9ce32
flutter_app_badger: 65de4d6f0c34a891df49e6cfb8a1c0496426fa68 flutter_app_badger: 65de4d6f0c34a891df49e6cfb8a1c0496426fa68
@@ -260,13 +252,13 @@ SPEC CHECKSUMS:
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
PromisesObjC: 8c196f5a328c2cba3e74624585467a557dcb482f PromisesObjC: 8c196f5a328c2cba3e74624585467a557dcb482f
Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748 Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748
SDWebImage: a31ee8e90a97303529e03fb0c333eae0eacb88e9 SDWebImage: b69257f4ab14e9b6a2ef53e910fdf914d8f757c1
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
sqlite3: 8f7d2078ae27778699a622a94b853285793422a2 sqlite3: 8f7d2078ae27778699a622a94b853285793422a2
sqlite3_flutter_libs: 5651f8ff48e3b44d910863c4ea5916085b1b245f sqlite3_flutter_libs: 5651f8ff48e3b44d910863c4ea5916085b1b245f
Starscream: 5178aed56b316f13fa3bc55694e583d35dd414d9 Starscream: 5178aed56b316f13fa3bc55694e583d35dd414d9
StreamChatClient: 8c83a141e753e45fa096ff56d4b782d59e46f251 StreamChatClient: d061cf52babcd9df930aee9cf864ab0379427eff
SwiftyGif: e466e86c660d343357ab944a819a101c4127cb40 SwiftyGif: e466e86c660d343357ab944a819a101c4127cb40
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e
+1 -1
View File
@@ -1,6 +1,6 @@
name: example name: example
description: A new Flutter project. description: A new Flutter project.
version: 1.0.37+39 version: 1.0.39+41
environment: environment:
sdk: ">=2.2.2 <3.0.0" sdk: ">=2.2.2 <3.0.0"
Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

+158 -95
View File
@@ -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,
@@ -223,10 +223,14 @@ class MessageInputState extends State<MessageInput> {
return Row( return Row(
children: [ children: [
Checkbox( Checkbox(
value: _sendAsDm, value: _sendAsDm,
onChanged: (val) => setState(() { onChanged: (val) => setState(
_sendAsDm = val; () {
})), _sendAsDm = val;
},
),
activeColor: StreamChatTheme.of(context).accentColor,
),
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text('Send also as direct message'), child: Text('Send also as direct message'),
@@ -278,21 +282,21 @@ class MessageInputState extends State<MessageInput> {
Expanded _buildTextInput(BuildContext context) { Expanded _buildTextInput(BuildContext context) {
return Expanded( return Expanded(
child: Center( child: Center(
child: LimitedBox( child: Container(
maxHeight: widget.maxHeight, clipBehavior: Clip.antiAlias,
child: Container( decoration: BoxDecoration(
clipBehavior: Clip.antiAlias, borderRadius: BorderRadius.circular(32.0),
decoration: BoxDecoration( border: Border.all(
borderRadius: BorderRadius.circular(32.0), color: Colors.grey,
border: Border.all(
color: Colors.grey,
),
), ),
child: Column( ),
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
_buildAttachments(), children: [
TextField( _buildAttachments(),
LimitedBox(
maxHeight: widget.maxHeight,
child: TextField(
key: Key('messageInputText'), key: Key('messageInputText'),
enabled: _inputEnabled, enabled: _inputEnabled,
minLines: null, minLines: null,
@@ -360,7 +364,10 @@ class MessageInputState extends State<MessageInput> {
autofocus: false, autofocus: false,
textAlignVertical: TextAlignVertical.center, textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Write a message', hintText:
(_commandEnabled && _chosenCommand.name == 'giphy')
? 'Search GIFs'
: 'Write a message',
prefixText: _commandEnabled ? null : ' ', prefixText: _commandEnabled ? null : ' ',
border: OutlineInputBorder( border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.transparent)), borderSide: BorderSide(color: Colors.transparent)),
@@ -404,8 +411,8 @@ class MessageInputState extends State<MessageInput> {
), ),
textCapitalization: TextCapitalization.sentences, textCapitalization: TextCapitalization.sentences,
), ),
], )
), ],
), ),
), ),
), ),
@@ -467,6 +474,9 @@ class MessageInputState extends State<MessageInput> {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Card( child: Card(
elevation: 2.0, elevation: 2.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
color: StreamChatTheme.of(context).primaryColor, color: StreamChatTheme.of(context).primaryColor,
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: Container( child: Container(
@@ -503,6 +513,18 @@ class MessageInputState extends State<MessageInput> {
...commands ...commands
.map( .map(
(c) => ListTile( (c) => ListTile(
leading: c.name == 'giphy'
? CircleAvatar(
backgroundColor: Colors.black,
child: Image.asset(
'images/giphy_icon.png',
package: 'stream_chat_flutter',
width: 16.0,
height: 16.0,
),
maxRadius: 12.0,
)
: null,
title: Text.rich( title: Text.rich(
TextSpan( TextSpan(
text: '${c.name.capitalize()}', text: '${c.name.capitalize()}',
@@ -525,7 +547,7 @@ class MessageInputState extends State<MessageInput> {
color: Colors.white, color: Colors.white,
size: 12.5, size: 12.5,
), ),
maxRadius: 15, maxRadius: 12,
), ),
//subtitle: Text(c.description), //subtitle: Text(c.description),
onTap: () { onTap: () {
@@ -576,6 +598,9 @@ class MessageInputState extends State<MessageInput> {
margin: EdgeInsets.all(8.0), margin: EdgeInsets.all(8.0),
elevation: 2.0, elevation: 2.0,
color: StreamChatTheme.of(context).primaryColor, color: StreamChatTheme.of(context).primaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: Container( child: Container(
constraints: BoxConstraints.loose(Size.fromHeight(400)), constraints: BoxConstraints.loose(Size.fromHeight(400)),
@@ -605,9 +630,9 @@ class MessageInputState extends State<MessageInput> {
'${m.user.name}', '${m.user.name}',
style: TextStyle(fontWeight: FontWeight.bold), style: TextStyle(fontWeight: FontWeight.bold),
), ),
subtitle: Text('${m.userId}'), subtitle: Text('@${m.userId}'),
trailing: Icon( trailing: Icon(
Icons.alternate_email, StreamIcons.at_mention,
color: StreamChatTheme.of(context).accentColor, color: StreamChatTheme.of(context).accentColor,
), ),
onTap: () { onTap: () {
@@ -752,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(
@@ -782,7 +807,10 @@ class MessageInputState extends State<MessageInput> {
child: Padding( child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
left: 4.0, right: 8.0, top: 8.0, bottom: 8.0), left: 4.0, right: 8.0, top: 8.0, bottom: 8.0),
child: Icon(StreamIcons.lightning), child: Icon(
StreamIcons.lightning,
color: Color(0xFF000000).withAlpha(128),
),
), ),
onTap: () { onTap: () {
if (_commandsOverlay == null) { if (_commandsOverlay == null) {
@@ -804,7 +832,10 @@ class MessageInputState extends State<MessageInput> {
child: Padding( child: Padding(
padding: padding:
EdgeInsets.only(left: 8.0, right: padding, top: 8.0, bottom: 8.0), EdgeInsets.only(left: 8.0, right: padding, top: 8.0, bottom: 8.0),
child: Icon(StreamIcons.attach), child: Icon(
StreamIcons.attach,
color: Color(0xFF000000).withAlpha(128),
),
), ),
onTap: () { onTap: () {
showAttachmentModal(); showAttachmentModal();
@@ -857,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'),
@@ -904,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) {
@@ -922,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) {
@@ -932,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}');
} }
} }
@@ -947,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,
), ),
); );
@@ -978,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 {
@@ -999,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,
@@ -1012,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,
@@ -1037,7 +1077,7 @@ class MessageInputState extends State<MessageInput> {
sendMessage(); sendMessage();
}, },
child: Icon( child: Icon(
StreamIcons.send_message, _getIdleSendIcon(),
color: Colors.grey, color: Colors.grey,
), ),
)), )),
@@ -1056,21 +1096,42 @@ class MessageInputState extends State<MessageInput> {
onTap: () { onTap: () {
sendMessage(); sendMessage();
}, },
child: Transform.rotate( child: _getSendIcon(),
angle: widget.editMessage == null ? -pi / 2 : 0,
child: Icon(
widget.editMessage == null
? StreamIcons.send_message
: StreamIcons.check_send,
color: StreamChatTheme.of(context).accentColor,
),
),
), ),
), ),
), ),
); );
} }
IconData _getIdleSendIcon() {
if (_commandEnabled) {
return StreamIcons.search;
} else {
return StreamIcons.send_message;
}
}
Widget _getSendIcon() {
if (widget.editMessage != null) {
return Icon(
StreamIcons.check_send,
color: StreamChatTheme.of(context).accentColor,
);
} else if (_commandEnabled) {
return Icon(
StreamIcons.search,
color: StreamChatTheme.of(context).accentColor,
);
} else {
return Transform.rotate(
angle: -pi / 2,
child: Icon(
StreamIcons.send_message,
color: StreamChatTheme.of(context).accentColor,
));
}
}
/// Sends the current message /// Sends the current message
void sendMessage() async { void sendMessage() async {
var text = textEditingController.text.trim(); var text = textEditingController.text.trim();
@@ -1157,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();
@@ -1211,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();
} }
@@ -1227,7 +1290,7 @@ class MessageInputState extends State<MessageInput> {
} }
class _SendingAttachment { class _SendingAttachment {
File file; PlatformFile file;
Attachment attachment; Attachment attachment;
bool uploaded; bool uploaded;
+2
View File
@@ -34,6 +34,8 @@ dependencies:
widgets_visibility_provider: ^2.0.2 widgets_visibility_provider: ^2.0.2
flutter: flutter:
assets:
- images/giphy_icon.png
fonts: fonts:
- family: stream-icons - family: stream-icons
fonts: fonts: