From d94d0ba8af67ee0b2b91c56649f285bdabf4e334 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 13:56:24 +0530 Subject: [PATCH] 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,