From 4f49664a41dee66b440bc66bea16f6fffa900d10 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 3 Dec 2020 14:38:25 +0100 Subject: [PATCH 1/5] use boxfit.cover --- lib/src/image_footer.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/image_footer.dart b/lib/src/image_footer.dart index 7c39fb4c..3c37a66a 100644 --- a/lib/src/image_footer.dart +++ b/lib/src/image_footer.dart @@ -220,6 +220,7 @@ class _ImageFooterState extends State { widget.mediaSelectedCallBack(position); }, child: FittedBox( + fit: BoxFit.cover, child: Chewie( controller: controllerPackage.chewieController, ), From b05df980748010f8b0103059ff79b5e9afb099e5 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 4 Dec 2020 11:06:00 +0100 Subject: [PATCH 2/5] update default users and app --- example/lib/choose_user_page.dart | 12 ++++++------ example/pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/example/lib/choose_user_page.dart b/example/lib/choose_user_page.dart index c728a193..a64013b9 100644 --- a/example/lib/choose_user_page.dart +++ b/example/lib/choose_user_page.dart @@ -13,41 +13,41 @@ import 'routes/routes.dart'; const kStreamApiKey = 'STREAM_API_KEY'; const kStreamUserId = 'STREAM_USER_ID'; const kStreamToken = 'STREAM_TOKEN'; -const kDefaultStreamApiKey = 's2dxdhpxd94g'; +const kDefaultStreamApiKey = 'uj7qrdbfrzvg'; class ChooseUserPage extends StatelessWidget { @override Widget build(BuildContext context) { final users = { - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidmlzaGFsIn0._JHWzo92fpTWZMZriJHXqOng6ShYVmWrdaIaPwEPKBg': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidmlzaGFsIn0.lCz-idDgaZ-xszjnuB_hTfeIOhTFmJtTB2fEjhwrcCI': User( id: 'vishal', extraData: { 'name': 'Vishal', }, ), - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.1AvvK2TvEsfcxAlfOK2iUMFACucnk6N-Q8f5bbfnjCM': User( id: 'super-band-9', extraData: { 'name': 'John Doe', }, ), - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoic2FsdmF0b3JlIn0.GMEKyEhONmFnqtkf1TR1A3oUOSIWhjfQv5RpI906dAM': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoic2FsdmF0b3JlIn0.uQ-pz8e1_C-Df2rIFpkkvWf7g4M0aW2Zkr7pHVhmU1Y': User( id: 'salvatore', extraData: { 'name': 'Salvatore', }, ), - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidG9tbWFzbyJ9.GTalMeZHaBdpIM5w-KWrVIDSy-ODkHTRkf1GZbWAveM': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidG9tbWFzbyJ9.feLvMytd5_3-eETKrRdwtO3jcA0HxD8woFUbFU7gQCg': User( id: 'tommaso', extraData: { 'name': 'Tommaso', }, ), - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiamFhcCJ9.xpGE2lu4OoYS7-2yy6PbF0gJnxOaxeGO4EU6xo4EdMU': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiamFhcCJ9.VLkLs6KH-jRRkPvhYMa4_lqN0R6WiK7JhJVmYvxcKz0': User( id: 'jaap', extraData: { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6ae2ab54..c5bfa14f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.87+89 +version: 1.0.88+90 environment: sdk: ">=2.2.2 <3.0.0" From 44cd3754fb51fa93c859a15f1ef48e74e1e7d294 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 4 Dec 2020 15:23:25 +0100 Subject: [PATCH 3/5] fix giphy badge --- lib/src/giphy_attachment.dart | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 6ab38c83..90e5929e 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -103,33 +103,30 @@ class GiphyAttachment extends StatelessWidget { ), ), Positioned( - left: 0, - top: 0, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(16.0), - )), + bottom: 16, + left: 16, + child: Material( + color: Colors.black.withOpacity(.5), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), child: Padding( - padding: const EdgeInsets.only( - left: 8.0, - right: 8.0, - top: 8.0, - bottom: 4.0, + padding: const EdgeInsets.symmetric( + horizontal: 8.0, + vertical: 4.0, ), child: Row( children: [ StreamSvgIcon.lightning( - color: StreamChatTheme.of(context).accentColor, - size: 16.0, + color: Colors.white, + size: 16, ), Text( 'GIPHY', style: TextStyle( - color: StreamChatTheme.of(context).accentColor, + color: Colors.white, fontWeight: FontWeight.bold, - fontSize: 11.0, + fontSize: 11, ), ), ], From 5365082e4a10ebb69a90872a85fa93f8227a91c8 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 4 Dec 2020 15:42:26 +0100 Subject: [PATCH 4/5] fix giphy background --- lib/src/message_widget.dart | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index e5fe146f..f761f756 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -186,9 +186,7 @@ class MessageWidget extends StatefulWidget { 'giphy': (context, message, attachment) { return GiphyAttachment( attachment: attachment, - messageTheme: messageTheme.copyWith( - messageBackgroundColor: Colors.white, - ), + messageTheme: messageTheme, message: message, size: Size( MediaQuery.of(context).size.width * 0.8, @@ -219,13 +217,6 @@ class _MessageWidgetState extends State { ? widget.messageTheme.avatarTheme.constraints.maxWidth + 16.0 : 6.0; - final isGiphy = - widget.message.attachments?.any((element) => element.type == 'giphy') == - true; - - final isOnlyEmoji = - widget.message.text.characters.every((c) => Emoji.byChar(c) != null); - final hasFiles = widget.message.attachments?.any((element) => element.type == 'file') == true; @@ -484,6 +475,10 @@ class _MessageWidgetState extends State { ); } + bool get isGiphy => + widget.message.attachments?.any((element) => element.type == 'giphy') == + true; + Widget _buildReadIndicator() { var padding = 0.0; return Stack( @@ -675,9 +670,8 @@ class _MessageWidgetState extends State { onTap: () => retryMessage(context), onLongPress: () => onLongPress(context), child: Material( - color: - attachment?.type == 'giphy' ? Colors.white : _getBackgroundColor(), - clipBehavior: Clip.hardEdge, + color: _getBackgroundColor(), + clipBehavior: Clip.antiAlias, shape: attachmentShape, child: Padding( padding: widget.attachmentPadding, @@ -828,9 +822,6 @@ class _MessageWidgetState extends State { } Widget _buildTextBubble(BuildContext context) { - final isOnlyEmoji = - widget.message.text.characters.every((c) => Emoji.byChar(c) != null); - Widget child = Transform( transform: Matrix4.rotationY(widget.reverse ? pi : 0), alignment: Alignment.center, @@ -874,10 +865,11 @@ class _MessageWidgetState extends State { ); } - Color _getBackgroundColor() { - final isOnlyEmoji = - widget.message.text.characters.every((c) => Emoji.byChar(c) != null); + bool get isOnlyEmoji => + widget.message.text.characters.isNotEmpty && + widget.message.text.characters.every((c) => Emoji.byChar(c) != null); + Color _getBackgroundColor() { if ((widget.message.status == MessageSendingStatus.FAILED || widget.message.status == MessageSendingStatus.FAILED_UPDATE || widget.message.status == MessageSendingStatus.FAILED_DELETE)) { @@ -893,6 +885,11 @@ class _MessageWidgetState extends State { if (isOnlyEmoji) { return Colors.transparent; } + + if (isGiphy) { + return Colors.transparent; + } + return widget.messageTheme.messageBackgroundColor; } From e80a30dca45a5aeb7f704b87682d417811688dc1 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 4 Dec 2020 16:08:46 +0100 Subject: [PATCH 5/5] fix giphy borderradius --- lib/src/giphy_attachment.dart | 44 ++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 90e5929e..3e29b2f1 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -79,26 +79,32 @@ class GiphyAttachment extends StatelessWidget { ); })); }, - child: CachedNetworkImage( - height: size?.height, - width: size?.width, - placeholder: (_, __) { - return Container( - width: size?.width, - height: size?.height, - child: Center( - child: CircularProgressIndicator(), - ), - ); - }, - imageUrl: attachment.thumbUrl ?? - attachment.imageUrl ?? - attachment.assetUrl, - errorWidget: (context, url, error) => AttachmentError( - attachment: attachment, - size: size, + child: ClipRRect( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + child: CachedNetworkImage( + height: size?.height, + width: size?.width, + placeholder: (_, __) { + return Container( + width: size?.width, + height: size?.height, + child: Center( + child: CircularProgressIndicator(), + ), + ); + }, + imageUrl: attachment.thumbUrl ?? + attachment.imageUrl ?? + attachment.assetUrl, + errorWidget: (context, url, error) => AttachmentError( + attachment: attachment, + size: size, + ), + fit: BoxFit.cover, ), - fit: BoxFit.cover, ), ), ),