From 425fd5c4d8d86f2a5dceb0ef1f70de61ffa34e3d Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 1 Apr 2021 12:01:50 +0200 Subject: [PATCH] fixes #370: remove all controls on full screen media if message is of type ephemeral (#373) --- .../lib/src/full_screen_media.dart | 31 +++++----- .../lib/src/image_footer.dart | 7 ++- .../lib/src/image_header.dart | 61 ++++++++++--------- 3 files changed, 54 insertions(+), 45 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/full_screen_media.dart index 91c66ca4..aa35ed15 100644 --- a/packages/stream_chat_flutter/lib/src/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/full_screen_media.dart @@ -185,21 +185,22 @@ class _FullScreenMediaState extends State widget.message, StreamChannel.of(context).channel); }, ), - ImageFooter( - currentPage: _currentPage, - totalPages: widget.mediaAttachments.length, - mediaAttachments: widget.mediaAttachments, - message: widget.message, - mediaSelectedCallBack: (val) { - setState(() { - _currentPage = val; - _pageController.animateToPage(val, - duration: Duration(milliseconds: 300), - curve: Curves.easeInOut); - Navigator.pop(context); - }); - }, - ), + if (widget.message.type != 'ephemeral') + ImageFooter( + currentPage: _currentPage, + totalPages: widget.mediaAttachments.length, + mediaAttachments: widget.mediaAttachments, + message: widget.message, + mediaSelectedCallBack: (val) { + setState(() { + _currentPage = val; + _pageController.animateToPage(val, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut); + Navigator.pop(context); + }); + }, + ), ], ), ), diff --git a/packages/stream_chat_flutter/lib/src/image_footer.dart b/packages/stream_chat_flutter/lib/src/image_footer.dart index 1d0d7e78..6833a52f 100644 --- a/packages/stream_chat_flutter/lib/src/image_footer.dart +++ b/packages/stream_chat_flutter/lib/src/image_footer.dart @@ -78,6 +78,7 @@ class _ImageFooterState extends State { @override Widget build(BuildContext context) { + final showShareButton = !kIsWeb; return SizedBox.fromSize( size: Size( MediaQuery.of(context).size.width, @@ -91,8 +92,10 @@ class _ImageFooterState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - kIsWeb - ? SizedBox() + !showShareButton + ? Container( + width: 48, + ) : IconButton( icon: StreamSvgIcon.iconShare( size: 24.0, diff --git a/packages/stream_chat_flutter/lib/src/image_header.dart b/packages/stream_chat_flutter/lib/src/image_header.dart index bf4ec474..023c8eaa 100644 --- a/packages/stream_chat_flutter/lib/src/image_header.dart +++ b/packages/stream_chat_flutter/lib/src/image_header.dart @@ -63,38 +63,43 @@ class ImageHeader extends StatelessWidget implements PreferredSizeWidget { backgroundColor: StreamChatTheme.of(context).channelTheme.channelHeaderTheme.color, actions: [ - IconButton( - icon: StreamSvgIcon.iconMenuPoint( - color: StreamChatTheme.of(context).colorTheme.black, + if (message.type != 'ephemeral') + IconButton( + icon: StreamSvgIcon.iconMenuPoint( + color: StreamChatTheme.of(context).colorTheme.black, + ), + onPressed: () { + _showMessageActionModalBottomSheet(context); + }, ), - onPressed: () { - _showMessageActionModalBottomSheet(context); - }, - ), ], centerTitle: true, - title: InkWell( - onTap: onTitleTap, - child: Container( - height: preferredSize.height, - width: preferredSize.width, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - userName, - style: StreamChatTheme.of(context).textTheme.headlineBold, + title: message.type != 'ephemeral' + ? InkWell( + onTap: onTitleTap, + child: Container( + height: preferredSize.height, + width: preferredSize.width, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + userName, + style: StreamChatTheme.of(context).textTheme.headlineBold, + ), + Text( + sentAt, + style: StreamChatTheme.of(context) + .channelPreviewTheme + .subtitle, + ), + ], + ), ), - Text( - sentAt, - style: StreamChatTheme.of(context).channelPreviewTheme.subtitle, - ), - ], - ), - ), - ), + ) + : SizedBox(), ); }