From 95d466bb9ba85d917a9e596ae7444d3be85eff41 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 13:51:02 +0530 Subject: [PATCH 01/20] init: Start working on attachment --- lib/src/giphy_attachment.dart | 104 +++++++++++++++++----------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 62de980b..28092b02 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -31,63 +31,65 @@ class GiphyAttachment extends StatelessWidget { ); } - return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Stack( - children: [ - GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (_) { - return FullScreenImage( - url: attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl, - ); - })); - }, - child: CachedNetworkImage( - height: size?.height, - width: size?.width, - placeholder: (_, __) { - return Container( - width: size?.width, - height: size?.height, - child: Center( - child: CircularProgressIndicator(), - ), - ); + return Card( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Stack( + children: [ + GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); }, - imageUrl: attachment.thumbUrl ?? - attachment.imageUrl ?? - attachment.assetUrl, - errorWidget: (context, url, error) => AttachmentError( + 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, + ), + ), + ], + ), + if (attachment.title != null) + Container( + alignment: Alignment.bottomCenter, + child: Material( + color: messageTheme.messageBackgroundColor, + child: AttachmentTitle( + messageTheme: messageTheme, attachment: attachment, - size: size, ), - fit: BoxFit.cover, ), ), - ], - ), - if (attachment.title != null) - Container( - alignment: Alignment.bottomCenter, - child: Material( - color: messageTheme.messageBackgroundColor, - child: AttachmentTitle( - messageTheme: messageTheme, - attachment: attachment, - ), + if (attachment.actions != null) + AttachmentActions( + attachment: attachment, + message: message, ), - ), - if (attachment.actions != null) - AttachmentActions( - attachment: attachment, - message: message, - ), - ], + ], + ), ); } } From d94d0ba8af67ee0b2b91c56649f285bdabf4e334 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 13:56:24 +0530 Subject: [PATCH 02/20] init: Start working on attachment --- lib/src/giphy_attachment.dart | 104 +++++++++++++++++----------------- lib/src/message_widget.dart | 2 +- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 28092b02..62de980b 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -31,65 +31,63 @@ class GiphyAttachment extends StatelessWidget { ); } - return Card( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Stack( - children: [ - GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (_) { - return FullScreenImage( - url: attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl, - ); - })); + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Stack( + children: [ + GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); + }, + child: CachedNetworkImage( + height: size?.height, + width: size?.width, + placeholder: (_, __) { + return Container( + width: size?.width, + height: size?.height, + child: Center( + child: CircularProgressIndicator(), + ), + ); }, - 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, - ), - ), - ], - ), - if (attachment.title != null) - Container( - alignment: Alignment.bottomCenter, - child: Material( - color: messageTheme.messageBackgroundColor, - child: AttachmentTitle( - messageTheme: messageTheme, + imageUrl: attachment.thumbUrl ?? + attachment.imageUrl ?? + attachment.assetUrl, + errorWidget: (context, url, error) => AttachmentError( attachment: attachment, + size: size, ), + fit: BoxFit.cover, ), ), - if (attachment.actions != null) - AttachmentActions( - attachment: attachment, - message: message, + ], + ), + if (attachment.title != null) + Container( + alignment: Alignment.bottomCenter, + child: Material( + color: messageTheme.messageBackgroundColor, + child: AttachmentTitle( + messageTheme: messageTheme, + attachment: attachment, + ), ), - ], - ), + ), + if (attachment.actions != null) + AttachmentActions( + attachment: attachment, + message: message, + ), + ], ); } } diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 0e703fa0..e155e509 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -175,7 +175,7 @@ class MessageWidget extends StatefulWidget { 'giphy': (context, message, attachment) { return GiphyAttachment( attachment: attachment, - messageTheme: messageTheme, + messageTheme: messageTheme.copyWith(messageBackgroundColor: Colors.white), message: message, size: Size( MediaQuery.of(context).size.width * 0.8, From dcc9edd97864670822c7f9ee803d76186790fd44 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 14:02:38 +0530 Subject: [PATCH 03/20] feat: giphy color --- lib/src/giphy_attachment.dart | 104 +++++++++++++++++----------------- lib/src/message_widget.dart | 2 +- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 62de980b..ed0bfcbf 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -31,63 +31,65 @@ class GiphyAttachment extends StatelessWidget { ); } - return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Stack( - children: [ - GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (_) { - return FullScreenImage( - url: attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl, - ); - })); - }, - child: CachedNetworkImage( - height: size?.height, - width: size?.width, - placeholder: (_, __) { - return Container( - width: size?.width, - height: size?.height, - child: Center( - child: CircularProgressIndicator(), - ), - ); + return Container( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Stack( + children: [ + GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); }, - imageUrl: attachment.thumbUrl ?? - attachment.imageUrl ?? - attachment.assetUrl, - errorWidget: (context, url, error) => AttachmentError( + 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, + ), + ), + ], + ), + if (attachment.title != null) + Container( + alignment: Alignment.bottomCenter, + child: Material( + color: Colors.white, + child: AttachmentTitle( + messageTheme: messageTheme, attachment: attachment, - size: size, ), - fit: BoxFit.cover, ), ), - ], - ), - if (attachment.title != null) - Container( - alignment: Alignment.bottomCenter, - child: Material( - color: messageTheme.messageBackgroundColor, - child: AttachmentTitle( - messageTheme: messageTheme, - attachment: attachment, - ), + if (attachment.actions != null) + AttachmentActions( + attachment: attachment, + message: message, ), - ), - if (attachment.actions != null) - AttachmentActions( - attachment: attachment, - message: message, - ), - ], + ], + ), ); } } diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index e155e509..021fd588 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -175,7 +175,7 @@ class MessageWidget extends StatefulWidget { 'giphy': (context, message, attachment) { return GiphyAttachment( attachment: attachment, - messageTheme: messageTheme.copyWith(messageBackgroundColor: Colors.white), + messageTheme: messageTheme.copyWith(messageBackgroundColor: Colors.white,), message: message, size: Size( MediaQuery.of(context).size.width * 0.8, From 950d852b0ce9688de2afd4197e7048d7a3f55bdf Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 14:04:46 +0530 Subject: [PATCH 04/20] feat: giphy color --- lib/src/giphy_attachment.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index ed0bfcbf..febc757e 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -32,6 +32,7 @@ class GiphyAttachment extends StatelessWidget { } return Container( + color: Colors.white, child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, From 5488fde66e3f17b7c4fac8ecb840fc94a7756666 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 2 Nov 2020 15:50:19 +0530 Subject: [PATCH 05/20] change bg to white --- lib/src/giphy_attachment.dart | 105 +++++++++++++++++----------------- lib/src/message_widget.dart | 6 +- 2 files changed, 54 insertions(+), 57 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index febc757e..6a5d44b8 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -31,66 +31,63 @@ class GiphyAttachment extends StatelessWidget { ); } - return Container( - color: Colors.white, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Stack( - children: [ - GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (_) { - return FullScreenImage( - url: attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl, - ); - })); + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Stack( + children: [ + GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); + }, + child: CachedNetworkImage( + height: size?.height, + width: size?.width, + placeholder: (_, __) { + return Container( + width: size?.width, + height: size?.height, + child: Center( + child: CircularProgressIndicator(), + ), + ); }, - 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, - ), - ), - ], - ), - if (attachment.title != null) - Container( - alignment: Alignment.bottomCenter, - child: Material( - color: Colors.white, - child: AttachmentTitle( - messageTheme: messageTheme, + imageUrl: attachment.thumbUrl ?? + attachment.imageUrl ?? + attachment.assetUrl, + errorWidget: (context, url, error) => AttachmentError( attachment: attachment, + size: size, ), + fit: BoxFit.cover, ), ), - if (attachment.actions != null) - AttachmentActions( - attachment: attachment, - message: message, + ], + ), + if (attachment.title != null) + Container( + alignment: Alignment.bottomCenter, + child: Material( + color: Colors.white, + child: AttachmentTitle( + messageTheme: messageTheme, + attachment: attachment, + ), ), - ], - ), + ), + if (attachment.actions != null) + AttachmentActions( + attachment: attachment, + message: message, + ), + ], ); } } diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 021fd588..73ace68b 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -512,12 +512,12 @@ class _MessageWidgetState extends State { widget.message, attachment, ); - return wrapAttachmentWidget(context, attachmentWidget); + return wrapAttachmentWidget(context, attachmentWidget, attachment: attachment); })?.toList() ?? []; } - Padding wrapAttachmentWidget(BuildContext context, Widget attachmentWidget) { + Padding wrapAttachmentWidget(BuildContext context, Widget attachmentWidget, {Attachment attachment}) { return Padding( padding: EdgeInsets.only( bottom: 4, @@ -526,7 +526,7 @@ class _MessageWidgetState extends State { onTap: () => retryMessage(context), onLongPress: () => onLongPress(context), child: Material( - color: _getBackgroundColor(), + color: attachment?.type == 'giphy' ? Colors.white : _getBackgroundColor(), clipBehavior: Clip.hardEdge, shape: widget.attachmentShape ?? widget.shape ?? From 8949598e2f0d0af80ceaad42241fde2adb342214 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 2 Nov 2020 18:57:55 +0530 Subject: [PATCH 06/20] created giphy sending and sent attachments --- lib/src/giphy_attachment.dart | 294 ++++++++++++++++++++++++++++------ 1 file changed, 245 insertions(+), 49 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 6a5d44b8..73278fb7 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -1,5 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:jiffy/jiffy.dart'; import 'package:stream_chat_flutter/src/attachment_actions.dart'; import '../stream_chat_flutter.dart'; @@ -31,63 +33,257 @@ class GiphyAttachment extends StatelessWidget { ); } - return Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Stack( - children: [ - GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (_) { - return FullScreenImage( - url: attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl, - ); - })); - }, - child: CachedNetworkImage( - height: size?.height, - width: size?.width, - placeholder: (_, __) { - return Container( - width: size?.width, - height: size?.height, - child: Center( - child: CircularProgressIndicator(), - ), - ); + return attachment.actions != null + ? _buildSendingAttachment(context) + : _buildSentAttachment(context); + } + + Widget _buildSendingAttachment(context) { + final streamChannel = StreamChannel.of(context); + + return Card( + clipBehavior: Clip.antiAlias, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Stack( + children: [ + GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); }, - imageUrl: attachment.thumbUrl ?? - attachment.imageUrl ?? - attachment.assetUrl, - errorWidget: (context, url, error) => AttachmentError( - attachment: attachment, - size: size, + child: Padding( + padding: const EdgeInsets.all(8.0), + 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, + ), + ), + ), + Positioned( + left: 0, + top: 0, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(16.0), + )), + child: Padding( + padding: const EdgeInsets.only( + left: 4.0, right: 4.0, top: 6.0, bottom: 2.0), + child: Row( + children: [ + Icon( + StreamIcons.lightning, + color: StreamChatTheme.of(context).accentColor, + size: 15.0, + ), + Text( + 'GIPHY', + style: TextStyle( + color: StreamChatTheme.of(context).accentColor, + fontWeight: FontWeight.bold, + fontSize: 11.0, + ), + ), + ], + ), + ), + ), + ), + ], + ), + if (attachment.title != null) + Container( + alignment: Alignment.bottomCenter, + child: Material( + color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Card( + child: IconButton( + icon: Icon( + StreamIcons.left, + size: 18.0, + ), + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'shuffle', + }); + }, + ), + shape: CircleBorder(), + ), + Expanded( + child: Text( + '"${attachment.title}"', + style: TextStyle( + fontStyle: FontStyle.italic, + ), + ), + ), + Card( + child: IconButton( + icon: Icon( + StreamIcons.right, + size: 18.0, + ), + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'shuffle', + }); + }, + ), + shape: CircleBorder(), + ), + ], ), - fit: BoxFit.cover, ), ), - ], - ), - if (attachment.title != null) + SizedBox( + height: 4.0, + ), Container( - alignment: Alignment.bottomCenter, - child: Material( - color: Colors.white, - child: AttachmentTitle( - messageTheme: messageTheme, - attachment: attachment, + color: Colors.black.withOpacity(0.2), + width: double.infinity, + height: 0.5, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FlatButton( + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'cancel', + }); + }, + child: Row( + children: [ + Text( + 'Cancel', + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), + ], + ), ), + Container( + width: 0.5, + color: Colors.black.withOpacity(0.2), + height: 50.0, + ), + FlatButton( + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'send', + }); + }, + child: Row( + children: [ + Text( + 'Send', + style: TextStyle( + color: StreamChatTheme.of(context).accentColor, + fontWeight: FontWeight.bold), + ), + ], + ), + ), + ], + ), + ], + ), + ); + } + + Widget _buildSentAttachment(context) { + return Container( + child: Column( + children: [ + 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, ), - if (attachment.actions != null) - AttachmentActions( - attachment: attachment, - message: message, - ), - ], + Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Row( + children: [ + Row( + children: [ + Icon( + StreamIcons.lightning, + color: StreamChatTheme.of(context).accentColor, + size: 15.0, + ), + Text( + 'GIPHY', + style: TextStyle( + color: StreamChatTheme.of(context).accentColor, + fontWeight: FontWeight.bold, + fontSize: 11.0, + ), + ), + ], + ), + Text( + Jiffy(message.createdAt.toLocal()).format(' HH:mm'), + style: TextStyle( + fontSize: 12.0, + color: Colors.black.withOpacity(0.5), + ), + ) + ], + mainAxisAlignment: MainAxisAlignment.spaceBetween, + ), + ) + ], + ), ); } } From c605821940a8005af0b0ad6ba684c836d4795888 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 15:28:42 +0530 Subject: [PATCH 07/20] fix: Fix sizes and colors --- lib/src/giphy_attachment.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 73278fb7..fded52cc 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -102,7 +102,7 @@ class GiphyAttachment extends StatelessWidget { Icon( StreamIcons.lightning, color: StreamChatTheme.of(context).accentColor, - size: 15.0, + size: 16.0, ), Text( 'GIPHY', @@ -142,10 +142,12 @@ class GiphyAttachment extends StatelessWidget { shape: CircleBorder(), ), Expanded( - child: Text( - '"${attachment.title}"', - style: TextStyle( - fontStyle: FontStyle.italic, + child: Center( + child: Text( + '"${attachment.title}"', + style: TextStyle( + fontStyle: FontStyle.italic, + ), ), ), ), @@ -191,6 +193,7 @@ class GiphyAttachment extends StatelessWidget { 'Cancel', style: TextStyle( fontWeight: FontWeight.bold, + color: Colors.black.withOpacity(0.5) ), ), ], From 3575089bf3c0cd02e5cf15533b39e309538e30d7 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 16:41:59 +0530 Subject: [PATCH 08/20] fix: Fix sizes and colors --- lib/src/giphy_attachment.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index fded52cc..357d5024 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -131,7 +131,7 @@ class GiphyAttachment extends StatelessWidget { child: IconButton( icon: Icon( StreamIcons.left, - size: 18.0, + size: 24.0, ), onPressed: () { streamChannel.channel.sendAction(message, { @@ -155,7 +155,7 @@ class GiphyAttachment extends StatelessWidget { child: IconButton( icon: Icon( StreamIcons.right, - size: 18.0, + size: 24.0, ), onPressed: () { streamChannel.channel.sendAction(message, { From 9c3fc656e2bfa3898ff96948ebb8a93cd18b1bfa Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 16:54:58 +0530 Subject: [PATCH 09/20] fix: Added visibility message --- lib/src/giphy_attachment.dart | 365 ++++++++++++++++++---------------- 1 file changed, 198 insertions(+), 167 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 357d5024..c96f34fd 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -41,190 +41,221 @@ class GiphyAttachment extends StatelessWidget { Widget _buildSendingAttachment(context) { final streamChannel = StreamChannel.of(context); - return Card( - clipBehavior: Clip.antiAlias, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Stack( + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + Card( + clipBehavior: Clip.antiAlias, + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (_) { - return FullScreenImage( - url: attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl, - ); - })); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: CachedNetworkImage( - height: size?.height, - width: size?.width, - placeholder: (_, __) { - return Container( - width: size?.width, - height: size?.height, - child: Center( - child: CircularProgressIndicator(), - ), - ); + Stack( + children: [ + GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); }, - imageUrl: attachment.thumbUrl ?? - attachment.imageUrl ?? - attachment.assetUrl, - errorWidget: (context, url, error) => AttachmentError( - attachment: attachment, - size: size, - ), - fit: BoxFit.cover, - ), - ), - ), - Positioned( - left: 0, - top: 0, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(16.0), - )), - child: Padding( - padding: const EdgeInsets.only( - left: 4.0, right: 4.0, top: 6.0, bottom: 2.0), - child: Row( - children: [ - Icon( - StreamIcons.lightning, - color: StreamChatTheme.of(context).accentColor, - size: 16.0, + child: Padding( + padding: const EdgeInsets.all(8.0), + 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, ), - Text( - 'GIPHY', - style: TextStyle( - color: StreamChatTheme.of(context).accentColor, - fontWeight: FontWeight.bold, - fontSize: 11.0, + fit: BoxFit.cover, + ), + ), + ), + Positioned( + left: 0, + top: 0, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(16.0), + )), + child: Padding( + padding: const EdgeInsets.only( + left: 4.0, right: 4.0, top: 6.0, bottom: 2.0), + child: Row( + children: [ + Icon( + StreamIcons.lightning, + color: StreamChatTheme.of(context).accentColor, + size: 16.0, + ), + Text( + 'GIPHY', + style: TextStyle( + color: StreamChatTheme.of(context).accentColor, + fontWeight: FontWeight.bold, + fontSize: 11.0, + ), + ), + ], + ), + ), + ), + ), + ], + ), + if (attachment.title != null) + Container( + alignment: Alignment.bottomCenter, + child: Material( + color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Card( + child: IconButton( + icon: Icon( + StreamIcons.left, + size: 24.0, + ), + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'shuffle', + }); + }, ), + shape: CircleBorder(), + ), + Expanded( + child: Center( + child: Text( + '"${attachment.title}"', + style: TextStyle( + fontStyle: FontStyle.italic, + ), + ), + ), + ), + Card( + child: IconButton( + icon: Icon( + StreamIcons.right, + size: 24.0, + ), + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'shuffle', + }); + }, + ), + shape: CircleBorder(), ), ], ), ), ), - ), - ], - ), - if (attachment.title != null) - Container( - alignment: Alignment.bottomCenter, - child: Material( - color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Card( - child: IconButton( - icon: Icon( - StreamIcons.left, - size: 24.0, - ), - onPressed: () { - streamChannel.channel.sendAction(message, { - 'image_action': 'shuffle', - }); - }, - ), - shape: CircleBorder(), - ), - Expanded( - child: Center( - child: Text( - '"${attachment.title}"', - style: TextStyle( - fontStyle: FontStyle.italic, - ), - ), - ), - ), - Card( - child: IconButton( - icon: Icon( - StreamIcons.right, - size: 24.0, - ), - onPressed: () { - streamChannel.channel.sendAction(message, { - 'image_action': 'shuffle', - }); - }, - ), - shape: CircleBorder(), - ), - ], - ), - ), - ), - SizedBox( - height: 4.0, - ), - Container( - color: Colors.black.withOpacity(0.2), - width: double.infinity, - height: 0.5, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - FlatButton( - onPressed: () { - streamChannel.channel.sendAction(message, { - 'image_action': 'cancel', - }); - }, - child: Row( - children: [ - Text( - 'Cancel', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black.withOpacity(0.5) - ), - ), - ], - ), + SizedBox( + height: 4.0, ), Container( - width: 0.5, color: Colors.black.withOpacity(0.2), - height: 50.0, + width: double.infinity, + height: 0.5, ), - FlatButton( - onPressed: () { - streamChannel.channel.sendAction(message, { - 'image_action': 'send', - }); - }, - child: Row( - children: [ - Text( - 'Send', - style: TextStyle( - color: StreamChatTheme.of(context).accentColor, - fontWeight: FontWeight.bold), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + FlatButton( + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'cancel', + }); + }, + child: Row( + children: [ + Text( + 'Cancel', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black.withOpacity(0.5)), + ), + ], ), - ], - ), + ), + Container( + width: 0.5, + color: Colors.black.withOpacity(0.2), + height: 50.0, + ), + FlatButton( + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'send', + }); + }, + child: Row( + children: [ + Text( + 'Send', + style: TextStyle( + color: StreamChatTheme.of(context).accentColor, + fontWeight: FontWeight.bold), + ), + ], + ), + ), + ], ), ], ), - ], - ), + ), + SizedBox( + height: 4.0, + ), + Align( + alignment: Alignment.centerRight, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + StreamIcons.eye, + color: Colors.black.withOpacity(0.5), + size: 16.0, + ), + SizedBox( + width: 4.0, + ), + Text( + 'Only visible to you', + style: TextStyle(color: Colors.black.withOpacity(0.5)), + ), + ], + ), + ), + ), + ], ); } From c8a8b81102853a8fd9681cbf8accfdd058204b1e Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 17:02:31 +0530 Subject: [PATCH 10/20] fix: Added visibility message --- lib/src/giphy_attachment.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index c96f34fd..7bb76a84 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -235,7 +235,7 @@ class GiphyAttachment extends StatelessWidget { Align( alignment: Alignment.centerRight, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), + padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), child: Row( mainAxisSize: MainAxisSize.min, children: [ @@ -245,11 +245,14 @@ class GiphyAttachment extends StatelessWidget { size: 16.0, ), SizedBox( - width: 4.0, + width: 8.0, ), Text( 'Only visible to you', - style: TextStyle(color: Colors.black.withOpacity(0.5)), + style: TextStyle( + color: Colors.black.withOpacity(0.5), + fontSize: 12.0, + ), ), ], ), From 756e8d6555966a7caa788ea3e63e6051ba6015d5 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 17:26:21 +0530 Subject: [PATCH 11/20] fix: Removed bubble for giphy --- lib/src/message_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 73ace68b..84115d18 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -276,7 +276,7 @@ class _MessageWidgetState extends State { ..._parseAttachments(context), if (widget.message.text .trim() - .isNotEmpty) + .isNotEmpty && widget.message.type != 'giphy') _buildTextBubble(context), ], ), From 312e1722784a337539331ea42ad80f875082193f Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 17:48:31 +0530 Subject: [PATCH 12/20] fix: Removed bubble for giphy --- lib/src/giphy_attachment.dart | 9 +-------- lib/src/message_widget.dart | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 7bb76a84..1227572d 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -308,15 +308,8 @@ class GiphyAttachment extends StatelessWidget { ), ], ), - Text( - Jiffy(message.createdAt.toLocal()).format(' HH:mm'), - style: TextStyle( - fontSize: 12.0, - color: Colors.black.withOpacity(0.5), - ), - ) ], - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.start, ), ) ], diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 84115d18..53be9ae6 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -175,7 +175,9 @@ class MessageWidget extends StatefulWidget { 'giphy': (context, message, attachment) { return GiphyAttachment( attachment: attachment, - messageTheme: messageTheme.copyWith(messageBackgroundColor: Colors.white,), + messageTheme: messageTheme.copyWith( + messageBackgroundColor: Colors.white, + ), message: message, size: Size( MediaQuery.of(context).size.width * 0.8, @@ -205,6 +207,10 @@ class _MessageWidgetState extends State { var leftPadding = widget.showUserAvatar != DisplayWidget.gone ? widget.messageTheme.avatarTheme.constraints.maxWidth + 16.0 : 6.0; + + bool isGiphy = + widget.message.attachments.any((element) => element.type == 'giphy'); + return Portal( child: Padding( padding: widget.padding ?? EdgeInsets.all(8), @@ -275,8 +281,9 @@ class _MessageWidgetState extends State { children: [ ..._parseAttachments(context), if (widget.message.text - .trim() - .isNotEmpty && widget.message.type != 'giphy') + .trim() + .isNotEmpty && + !isGiphy) _buildTextBubble(context), ], ), @@ -512,12 +519,14 @@ class _MessageWidgetState extends State { widget.message, attachment, ); - return wrapAttachmentWidget(context, attachmentWidget, attachment: attachment); + return wrapAttachmentWidget(context, attachmentWidget, + attachment: attachment); })?.toList() ?? []; } - Padding wrapAttachmentWidget(BuildContext context, Widget attachmentWidget, {Attachment attachment}) { + Padding wrapAttachmentWidget(BuildContext context, Widget attachmentWidget, + {Attachment attachment}) { return Padding( padding: EdgeInsets.only( bottom: 4, @@ -526,7 +535,9 @@ class _MessageWidgetState extends State { onTap: () => retryMessage(context), onLongPress: () => onLongPress(context), child: Material( - color: attachment?.type == 'giphy' ? Colors.white : _getBackgroundColor(), + color: attachment?.type == 'giphy' + ? Colors.white + : _getBackgroundColor(), clipBehavior: Clip.hardEdge, shape: widget.attachmentShape ?? widget.shape ?? From 1f8e49c45a40c885c93462176863a6bea6e71da1 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 18:10:25 +0530 Subject: [PATCH 13/20] fix: Removed bubble for giphy, changed border radii --- lib/src/giphy_attachment.dart | 48 +++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 1227572d..c1549aa9 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -266,26 +266,36 @@ class GiphyAttachment extends StatelessWidget { return Container( child: Column( children: [ - 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, + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topRight: Radius.circular(8.0), + bottomRight: Radius.circular(0.0), + topLeft: Radius.circular(8.0), + bottomLeft: Radius.circular(8.0), + ), + ), + 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, ), Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), From aa419da05424bbec56beb0468e432dba298b9bee Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 18:13:40 +0530 Subject: [PATCH 14/20] fix: Removed bubble for giphy, changed border radii --- lib/src/giphy_attachment.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index c1549aa9..66641f59 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -275,6 +275,7 @@ class GiphyAttachment extends StatelessWidget { bottomLeft: Radius.circular(8.0), ), ), + clipBehavior: Clip.antiAlias, child: CachedNetworkImage( height: size?.height, width: size?.width, From 88501ed4f81cdd11d1a98479dc2bf8f03e080397 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 18:37:04 +0530 Subject: [PATCH 15/20] fix: Removed bubble for giphy, changed border radii --- lib/src/giphy_attachment.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 66641f59..fbb2e585 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -269,10 +269,10 @@ class GiphyAttachment extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.only( - topRight: Radius.circular(8.0), + topRight: Radius.circular(16.0), bottomRight: Radius.circular(0.0), - topLeft: Radius.circular(8.0), - bottomLeft: Radius.circular(8.0), + topLeft: Radius.circular(16.0), + bottomLeft: Radius.circular(16.0), ), ), clipBehavior: Clip.antiAlias, From 70e7a8dc83d352889840070bb7da29a16fee8de4 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Wed, 4 Nov 2020 19:21:33 +0530 Subject: [PATCH 16/20] fix: Removed bubble for giphy, changed border radii --- lib/src/giphy_attachment.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index fbb2e585..d6d378d2 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -46,8 +46,14 @@ class GiphyAttachment extends StatelessWidget { children: [ Card( clipBehavior: Clip.antiAlias, - shape: - RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topRight: Radius.circular(16.0), + bottomRight: Radius.circular(0.0), + topLeft: Radius.circular(16.0), + bottomLeft: Radius.circular(16.0), + ), + ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, From af836d97112cc6577ee9b1f020ff20537625b69c Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 5 Nov 2020 10:42:13 +0100 Subject: [PATCH 17/20] fix button inkwells --- lib/src/attachment_actions.dart | 53 ------- lib/src/giphy_attachment.dart | 246 +++++++++++++++++--------------- lib/src/message_input.dart | 3 +- 3 files changed, 129 insertions(+), 173 deletions(-) delete mode 100644 lib/src/attachment_actions.dart diff --git a/lib/src/attachment_actions.dart b/lib/src/attachment_actions.dart deleted file mode 100644 index f101ef53..00000000 --- a/lib/src/attachment_actions.dart +++ /dev/null @@ -1,53 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/stream_chat_flutter.dart'; - -class AttachmentActions extends StatelessWidget { - final Attachment attachment; - final Message message; - - const AttachmentActions({ - Key key, - this.attachment, - this.message, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - final streamChannel = StreamChannel.of(context); - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.min, - children: attachment.actions?.map((action) { - if (action.style == 'primary') { - return FlatButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - child: Text('${action.text}'), - color: action.style == 'primary' - ? StreamChatTheme.of(context).accentColor - : null, - textColor: Colors.white, - onPressed: () { - streamChannel.channel.sendAction(message, { - action.name: action.value, - }); - }, - ); - } - return OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16), - ), - child: Text('${action.text}'), - color: StreamChatTheme.of(context).accentColor, - onPressed: () { - streamChannel.channel.sendAction(message, { - action.name: action.value, - }); - }, - ); - })?.toList(), - ); - } -} diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index d6d378d2..02c1ca5e 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -1,12 +1,9 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:jiffy/jiffy.dart'; -import 'package:stream_chat_flutter/src/attachment_actions.dart'; import '../stream_chat_flutter.dart'; import 'attachment_error.dart'; -import 'attachment_title.dart'; import 'full_screen_image.dart'; class GiphyAttachment extends StatelessWidget { @@ -58,76 +55,76 @@ class GiphyAttachment extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Stack( - children: [ - GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (_) { - return FullScreenImage( - url: attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl, - ); - })); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: CachedNetworkImage( - height: size?.height, + Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); + }, + child: CachedNetworkImage( + height: size?.height, + width: size?.width, + placeholder: (_, __) { + return Container( 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, + height: size?.height, + child: Center( + child: CircularProgressIndicator(), ), - fit: BoxFit.cover, - ), + ); + }, + imageUrl: attachment.thumbUrl ?? + attachment.imageUrl ?? + attachment.assetUrl, + errorWidget: (context, url, error) => AttachmentError( + attachment: attachment, + size: size, + ), + fit: BoxFit.cover, + ), + ), + ), + Positioned( + left: 0, + top: 0, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(16.0), + )), + child: Padding( + padding: const EdgeInsets.only( + left: 8.0, + right: 8.0, + top: 8.0, + bottom: 4.0, + ), + child: Row( + children: [ + Icon( + StreamIcons.lightning, + color: StreamChatTheme.of(context).accentColor, + size: 16.0, + ), + Text( + 'GIPHY', + style: TextStyle( + color: StreamChatTheme.of(context).accentColor, + fontWeight: FontWeight.bold, + fontSize: 11.0, + ), + ), + ], ), ), - Positioned( - left: 0, - top: 0, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(16.0), - )), - child: Padding( - padding: const EdgeInsets.only( - left: 4.0, right: 4.0, top: 6.0, bottom: 2.0), - child: Row( - children: [ - Icon( - StreamIcons.lightning, - color: StreamChatTheme.of(context).accentColor, - size: 16.0, - ), - Text( - 'GIPHY', - style: TextStyle( - color: StreamChatTheme.of(context).accentColor, - fontWeight: FontWeight.bold, - fontSize: 11.0, - ), - ), - ], - ), - ), - ), - ), - ], + ), ), if (attachment.title != null) Container( @@ -143,6 +140,7 @@ class GiphyAttachment extends StatelessWidget { StreamIcons.left, size: 24.0, ), + splashRadius: 24, onPressed: () { streamChannel.channel.sendAction(message, { 'image_action': 'shuffle', @@ -167,6 +165,7 @@ class GiphyAttachment extends StatelessWidget { StreamIcons.right, size: 24.0, ), + splashRadius: 24, onPressed: () { streamChannel.channel.sendAction(message, { 'image_action': 'shuffle', @@ -188,24 +187,23 @@ class GiphyAttachment extends StatelessWidget { height: 0.5, ), Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - FlatButton( - onPressed: () { - streamChannel.channel.sendAction(message, { - 'image_action': 'cancel', - }); - }, - child: Row( - children: [ - Text( - 'Cancel', - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black.withOpacity(0.5)), - ), - ], + Expanded( + child: FlatButton( + height: 50, + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'cancel', + }); + }, + child: Text( + 'Cancel', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black.withOpacity(0.5)), + ), ), ), Container( @@ -213,21 +211,20 @@ class GiphyAttachment extends StatelessWidget { color: Colors.black.withOpacity(0.2), height: 50.0, ), - FlatButton( - onPressed: () { - streamChannel.channel.sendAction(message, { - 'image_action': 'send', - }); - }, - child: Row( - children: [ - Text( - 'Send', - style: TextStyle( - color: StreamChatTheme.of(context).accentColor, - fontWeight: FontWeight.bold), - ), - ], + Expanded( + child: FlatButton( + height: 50, + onPressed: () { + streamChannel.channel.sendAction(message, { + 'image_action': 'send', + }); + }, + child: Text( + 'Send', + style: TextStyle( + color: StreamChatTheme.of(context).accentColor, + fontWeight: FontWeight.bold), + ), ), ), ], @@ -282,26 +279,37 @@ class GiphyAttachment extends StatelessWidget { ), ), clipBehavior: Clip.antiAlias, - child: CachedNetworkImage( - height: size?.height, - width: size?.width, - placeholder: (_, __) { - return Container( - width: size?.width, - height: size?.height, - child: Center( - child: CircularProgressIndicator(), - ), - ); + child: GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); }, - imageUrl: attachment.thumbUrl ?? - attachment.imageUrl ?? - attachment.assetUrl, - errorWidget: (context, url, error) => AttachmentError( - attachment: attachment, - size: size, + 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, ), ), Padding( diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index 7bdbfd5d..9c9cf67f 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -335,7 +335,7 @@ class MessageInputState extends State { setState(() { _commandEnabled = true; }); - _commandsOverlay.remove(); + _commandsOverlay?.remove(); _commandsOverlay = null; } else { _commandsOverlay = _buildCommandsOverlayEntry(); @@ -344,6 +344,7 @@ class MessageInputState extends State { } if (textEditingController.selection.isCollapsed && + s.isNotEmpty && (s[textEditingController.selection.start - 1] == '@' || textEditingController.text .substring( From 16b199c91c4caec4244e75106595ea857dba0827 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 5 Nov 2020 10:50:48 +0100 Subject: [PATCH 18/20] fix padding --- lib/src/giphy_attachment.dart | 2 +- lib/src/message_widget.dart | 18 +++--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index 02c1ca5e..f913b557 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -313,7 +313,7 @@ class GiphyAttachment extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), + padding: const EdgeInsets.only(top: 8.0), child: Row( children: [ Row( diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index d57ef0f9..e768c39d 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -293,8 +293,9 @@ class _MessageWidgetState extends State { children: [ ..._parseAttachments(context), if (widget.message.text - .trim() - .isNotEmpty) + .trim() + .isNotEmpty && + !isGiphy) _buildTextBubble(context), ], ), @@ -314,19 +315,6 @@ class _MessageWidgetState extends State { .reactionsBorderColor, ), ), - ) - : Column( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - ..._parseAttachments(context), - if (widget.message.text - .trim() - .isNotEmpty && - !isGiphy) - _buildTextBubble(context), - ], ), ), ], From 5099b55fdeb649336b4a3dc0e692a1e70eddfb63 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 5 Nov 2020 10:53:25 +0100 Subject: [PATCH 19/20] fix tests --- lib/src/message_widget.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index e768c39d..ad574fc8 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -216,8 +216,9 @@ class _MessageWidgetState extends State { ? widget.messageTheme.avatarTheme.constraints.maxWidth + 16.0 : 6.0; - bool isGiphy = - widget.message.attachments.any((element) => element.type == 'giphy'); + final isGiphy = + widget.message.attachments?.any((element) => element.type == 'giphy') == + true; return Portal( child: Padding( From da2ca558743e5e9ce603ae317210503e19e72184 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 5 Nov 2020 11:37:12 +0100 Subject: [PATCH 20/20] fix giphy corner tag --- lib/src/giphy_attachment.dart | 136 +++++++++++++++++----------------- 1 file changed, 70 insertions(+), 66 deletions(-) diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index f913b557..89beb4b1 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -55,76 +55,80 @@ class GiphyAttachment extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: GestureDetector( - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (_) { - return FullScreenImage( - url: attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl, - ); - })); - }, - child: CachedNetworkImage( - height: size?.height, - width: size?.width, - placeholder: (_, __) { - return Container( - width: size?.width, + Stack( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (_) { + return FullScreenImage( + url: attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl, + ); + })); + }, + child: CachedNetworkImage( height: size?.height, - child: Center( - child: CircularProgressIndicator(), + 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, ), - ); - }, - imageUrl: attachment.thumbUrl ?? - attachment.imageUrl ?? - attachment.assetUrl, - errorWidget: (context, url, error) => AttachmentError( - attachment: attachment, - size: size, - ), - fit: BoxFit.cover, - ), - ), - ), - Positioned( - left: 0, - top: 0, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(16.0), - )), - child: Padding( - padding: const EdgeInsets.only( - left: 8.0, - right: 8.0, - top: 8.0, - bottom: 4.0, - ), - child: Row( - children: [ - Icon( - StreamIcons.lightning, - color: StreamChatTheme.of(context).accentColor, - size: 16.0, - ), - Text( - 'GIPHY', - style: TextStyle( - color: StreamChatTheme.of(context).accentColor, - fontWeight: FontWeight.bold, - fontSize: 11.0, - ), - ), - ], + fit: BoxFit.cover, + ), ), ), - ), + Positioned( + left: 0, + top: 0, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(16.0), + )), + child: Padding( + padding: const EdgeInsets.only( + left: 8.0, + right: 8.0, + top: 8.0, + bottom: 4.0, + ), + child: Row( + children: [ + Icon( + StreamIcons.lightning, + color: StreamChatTheme.of(context).accentColor, + size: 16.0, + ), + Text( + 'GIPHY', + style: TextStyle( + color: StreamChatTheme.of(context).accentColor, + fontWeight: FontWeight.bold, + fontSize: 11.0, + ), + ), + ], + ), + ), + ), + ), + ], ), if (attachment.title != null) Container(