From d9507214d772cd5be6e199a9c6662ec89d30529c Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Mon, 23 Nov 2020 16:44:44 +0530 Subject: [PATCH] fmt --- lib/src/full_screen_image.dart | 8 +- lib/src/giphy_attachment.dart | 28 ++--- lib/src/image_attachment.dart | 8 +- lib/src/image_footer.dart | 185 +++++++++++++++++---------------- lib/src/image_group.dart | 22 ++-- 5 files changed, 135 insertions(+), 116 deletions(-) diff --git a/lib/src/full_screen_image.dart b/lib/src/full_screen_image.dart index 52e75871..8ab0415f 100644 --- a/lib/src/full_screen_image.dart +++ b/lib/src/full_screen_image.dart @@ -132,9 +132,13 @@ class _FullScreenImageState extends State String getDay(DateTime dateTime) { var now = DateTime.now(); - if(DateTime(dateTime.year, dateTime.month, dateTime.day) == DateTime(now.year, now.month, now.day)) { + if (DateTime(dateTime.year, dateTime.month, dateTime.day) == + DateTime(now.year, now.month, now.day)) { return 'today'; - } else if(DateTime(now.year, now.month, now.day).difference(dateTime).inHours < 24) { + } else if (DateTime(now.year, now.month, now.day) + .difference(dateTime) + .inHours < + 24) { return 'yesterday'; } else { return 'on ${Jiffy(dateTime).format("MMM do")}'; diff --git a/lib/src/giphy_attachment.dart b/lib/src/giphy_attachment.dart index f6d1d473..bb859263 100644 --- a/lib/src/giphy_attachment.dart +++ b/lib/src/giphy_attachment.dart @@ -64,12 +64,14 @@ class GiphyAttachment extends StatelessWidget { onTap: () { Navigator.push(context, MaterialPageRoute(builder: (_) { return FullScreenImage( - urls: [attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl], - userName: message.user.name, - sentAt: message.createdAt, - message: message, + urls: [ + attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl + ], + userName: message.user.name, + sentAt: message.createdAt, + message: message, ); })); }, @@ -285,12 +287,14 @@ class GiphyAttachment extends StatelessWidget { onTap: () { Navigator.push(context, MaterialPageRoute(builder: (_) { return FullScreenImage( - urls: [attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl], - userName: message.user.name, - sentAt: message.createdAt, - message: message, + urls: [ + attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl + ], + userName: message.user.name, + sentAt: message.createdAt, + message: message, ); })); }, diff --git a/lib/src/image_attachment.dart b/lib/src/image_attachment.dart index b429e064..83f747db 100644 --- a/lib/src/image_attachment.dart +++ b/lib/src/image_attachment.dart @@ -48,9 +48,11 @@ class ImageAttachment extends StatelessWidget { return StreamChannel( channel: channel, child: FullScreenImage( - urls: [attachment.imageUrl ?? - attachment.assetUrl ?? - attachment.thumbUrl], + urls: [ + attachment.imageUrl ?? + attachment.assetUrl ?? + attachment.thumbUrl + ], userName: message.user.name, sentAt: message.createdAt, message: message, diff --git a/lib/src/image_footer.dart b/lib/src/image_footer.dart index 5f4710d1..d71ee3af 100644 --- a/lib/src/image_footer.dart +++ b/lib/src/image_footer.dart @@ -378,8 +378,9 @@ class _ImageFooterState extends State { child: Material( child: InkWell( onTap: () async { - await GallerySaver.saveImage( - widget.urls[widget.currentPage].split('?')[0]); + await GallerySaver.saveImage(widget + .urls[widget.currentPage] + .split('?')[0]); Navigator.pop(context); }, child: SizedBox.expand( @@ -434,7 +435,8 @@ class _ImageFooterState extends State { autofocus: true, decoration: InputDecoration( isDense: true, - prefixIconConstraints: BoxConstraints.tight(Size(38.0, 38.0)), + prefixIconConstraints: + BoxConstraints.tight(Size(38.0, 38.0)), prefixIcon: Transform.scale( scale: 1.2, alignment: Alignment.center, @@ -462,7 +464,10 @@ class _ImageFooterState extends State { width: 8.0, ), IconButton( - icon: Icon(StreamIcons.close_circle, color: Colors.black.withOpacity(0.5),), + icon: Icon( + StreamIcons.close_circle, + color: Colors.black.withOpacity(0.5), + ), onPressed: () { modalSetState(() { _userSearchMode = false; @@ -533,98 +538,100 @@ class _ImageFooterState extends State { child: Container( color: Colors.white, height: 56.0, - child: _loading ? Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: CircularProgressIndicator(), - ), - ) : Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 8.0), - child: TextField( - controller: _messageController, - onChanged: (val) { - modalSetState(() {}); - }, - onTap: () { - modalSetState(() {}); - setState(() {}); - }, - decoration: InputDecoration( - isDense: true, - prefixText: ' ', - hintText: 'Add a comment', - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(32.0), - borderSide: BorderSide( - color: Colors.black.withOpacity(0.16), - ), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(32.0), - borderSide: BorderSide( - color: Colors.black.withOpacity(0.16), - )), - contentPadding: EdgeInsets.symmetric(vertical: 12.0), - ), + child: _loading + ? Center( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: CircularProgressIndicator(), ), - ), - ), - AnimatedCrossFade( - crossFadeState: _messageController.text.isNotEmpty - ? CrossFadeState.showFirst - : CrossFadeState.showSecond, - firstChild: IconTheme( - data: StreamChatTheme.of(context) - .channelTheme - .messageInputButtonIconTheme, - child: Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: InkWell( - onTap: () async { - modalSetState(() { - _loading = true; - }); - await sendMessage(); - modalSetState(() { - _loading = false; - }); - }, - child: Transform.rotate( - angle: -pi / 2, - child: Icon( - StreamIcons.send_message, - color: StreamChatTheme.of(context).accentColor, + ) + : Row( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.only(left: 8.0), + child: TextField( + controller: _messageController, + onChanged: (val) { + modalSetState(() {}); + }, + onTap: () { + modalSetState(() {}); + setState(() {}); + }, + decoration: InputDecoration( + isDense: true, + prefixText: ' ', + hintText: 'Add a comment', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(32.0), + borderSide: BorderSide( + color: Colors.black.withOpacity(0.16), + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(32.0), + borderSide: BorderSide( + color: Colors.black.withOpacity(0.16), + )), + contentPadding: EdgeInsets.symmetric(vertical: 12.0), ), ), ), ), - ), - ), - secondChild: IconTheme( - data: StreamChatTheme.of(context) - .channelTheme - .messageInputButtonIconTheme, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: InkWell( - onTap: () {}, - child: Icon( - StreamIcons.send_message, - color: Colors.grey, + AnimatedCrossFade( + crossFadeState: _messageController.text.isNotEmpty + ? CrossFadeState.showFirst + : CrossFadeState.showSecond, + firstChild: IconTheme( + data: StreamChatTheme.of(context) + .channelTheme + .messageInputButtonIconTheme, + child: Center( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: InkWell( + onTap: () async { + modalSetState(() { + _loading = true; + }); + await sendMessage(); + modalSetState(() { + _loading = false; + }); + }, + child: Transform.rotate( + angle: -pi / 2, + child: Icon( + StreamIcons.send_message, + color: StreamChatTheme.of(context).accentColor, + ), + ), + ), + ), + ), ), - )), - ), + secondChild: IconTheme( + data: StreamChatTheme.of(context) + .channelTheme + .messageInputButtonIconTheme, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: InkWell( + onTap: () {}, + child: Icon( + StreamIcons.send_message, + color: Colors.grey, + ), + )), + ), + ), + duration: Duration(milliseconds: 300), + alignment: Alignment.center, + ), + ], ), - duration: Duration(milliseconds: 300), - alignment: Alignment.center, - ), - ], - ), ), ); } diff --git a/lib/src/image_group.dart b/lib/src/image_group.dart index afccaf7a..1b6e48f2 100644 --- a/lib/src/image_group.dart +++ b/lib/src/image_group.dart @@ -113,16 +113,18 @@ class ImageGroup extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => - StreamChannel( - channel: channel, - child: FullScreenImage(urls: images.map((e) => e.imageUrl ?? e.thumbUrl ?? e.assetUrl).toList(), - startIndex: index, - userName: message.user.name, - sentAt: message.createdAt, - message: message, - ), - ), + builder: (context) => StreamChannel( + channel: channel, + child: FullScreenImage( + urls: images + .map((e) => e.imageUrl ?? e.thumbUrl ?? e.assetUrl) + .toList(), + startIndex: index, + userName: message.user.name, + sentAt: message.createdAt, + message: message, + ), + ), ), ); }