diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 60ad3bd10..3eea95c70 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -1,3 +1,10 @@ +## Upcoming + +🐞 Fixed + +- Fixed StreamGallery not respecting the safe area for fullscreen + media. [[#2454]](https://github.com/GetStream/stream-chat-flutter/issues/2454) + ## 9.20.0 ✅ Added diff --git a/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media.dart index 00aed71d5..eb95489c2 100644 --- a/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media.dart @@ -281,56 +281,53 @@ class _FullScreenMediaState extends State { return ValueListenableBuilder( valueListenable: _isDisplayingDetail, builder: (context, isDisplayingDetail, child) { + final padding = MediaQuery.paddingOf(context); + return AnimatedContainer( duration: kThemeChangeDuration, - color: isDisplayingDetail - ? StreamChannelHeaderTheme.of(context).color - : Colors.black, - child: Builder( - builder: (context) { - if (attachment.type == AttachmentType.image || - attachment.type == AttachmentType.giphy) { - return PhotoView.customChild( - maxScale: PhotoViewComputedScale.covered, - minScale: PhotoViewComputedScale.contained, - backgroundDecoration: const BoxDecoration( - color: Colors.transparent, - ), - child: StreamMediaAttachmentThumbnail( - media: attachment, - width: double.infinity, - height: double.infinity, - ), - ); - } else if (attachment.type == AttachmentType.video) { - final controller = videoPackages[attachment.id]!; - if (!controller.initialized) { - return const Center( - child: CircularProgressIndicator.adaptive(), - ); - } - - final mediaQuery = MediaQuery.of(context); - final bottomPadding = mediaQuery.padding.bottom; - - return AnimatedPadding( - duration: kThemeChangeDuration, - padding: EdgeInsets.symmetric( - vertical: isDisplayingDetail - ? kToolbarHeight + bottomPadding - : 0, - ), - child: Chewie( - controller: controller.chewieController!, - ), - ); - } - - return const Empty(); - }, + color: switch (isDisplayingDetail) { + true => StreamChannelHeaderTheme.of(context).color, + false => Colors.black, + }, + padding: EdgeInsetsDirectional.only( + top: padding.top + kToolbarHeight, + bottom: padding.bottom + kToolbarHeight, ), + child: child, ); }, + child: Builder( + builder: (context) { + if (attachment.type == AttachmentType.image || + attachment.type == AttachmentType.giphy) { + return PhotoView.customChild( + maxScale: PhotoViewComputedScale.covered, + minScale: PhotoViewComputedScale.contained, + backgroundDecoration: const BoxDecoration( + color: Colors.transparent, + ), + child: StreamMediaAttachmentThumbnail( + media: attachment, + width: double.infinity, + height: double.infinity, + ), + ); + } else if (attachment.type == AttachmentType.video) { + final controller = videoPackages[attachment.id]!; + if (!controller.initialized) { + return const Center( + child: CircularProgressIndicator.adaptive(), + ); + } + + return Chewie( + controller: controller.chewieController!, + ); + } + + return const Empty(); + }, + ), ); }, ), diff --git a/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media_desktop.dart b/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media_desktop.dart index 1296535ca..3e04fc5e7 100644 --- a/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media_desktop.dart +++ b/packages/stream_chat_flutter/lib/src/fullscreen_media/full_screen_media_desktop.dart @@ -317,73 +317,70 @@ class _FullScreenMediaDesktopState extends State { return ValueListenableBuilder( valueListenable: _isDisplayingDetail, builder: (context, isDisplayingDetail, child) { + final padding = MediaQuery.paddingOf(context); + return AnimatedContainer( duration: kThemeChangeDuration, - color: isDisplayingDetail - ? StreamChannelHeaderTheme.of(context).color - : Colors.black, - child: Builder( - builder: (context) { - if (attachment.type == AttachmentType.image || - attachment.type == AttachmentType.giphy) { - return PhotoView.customChild( - maxScale: PhotoViewComputedScale.covered, - minScale: PhotoViewComputedScale.contained, - backgroundDecoration: const BoxDecoration( - color: Colors.transparent, - ), - child: StreamMediaAttachmentThumbnail( - media: attachment, - width: double.infinity, - height: double.infinity, - ), - ); - } else if (attachment.type == AttachmentType.video) { - final package = videoPackages[attachment.id]!; - if (package.attachment.assetUrl != null) { - package.player.open( - Playlist( - [ - Media(package.attachment.assetUrl!), - ], - ), - play: widget.autoplayVideos, - ); - } - - final mediaQuery = MediaQuery.of(context); - final bottomPadding = mediaQuery.padding.bottom; - - return AnimatedPadding( - duration: kThemeChangeDuration, - padding: EdgeInsets.symmetric( - vertical: isDisplayingDetail - ? kToolbarHeight + bottomPadding - : 0, - ), - child: ContextMenuRegion( - contextMenuBuilder: (_, anchor) { - return ContextMenu( - anchor: anchor, - menuItems: [ - DownloadMenuItem( - attachment: attachment, - ), - ], - ); - }, - child: Video( - controller: package.controller, - ), - ), - ); - } - - return const Empty(); - }, + color: switch (isDisplayingDetail) { + true => StreamChannelHeaderTheme.of(context).color, + false => Colors.black, + }, + padding: EdgeInsetsDirectional.only( + top: padding.top + kToolbarHeight, + bottom: padding.bottom + kToolbarHeight, ), + child: child, ); }, + child: Builder( + builder: (context) { + if (attachment.type == AttachmentType.image || + attachment.type == AttachmentType.giphy) { + return PhotoView.customChild( + maxScale: PhotoViewComputedScale.covered, + minScale: PhotoViewComputedScale.contained, + backgroundDecoration: const BoxDecoration( + color: Colors.transparent, + ), + child: StreamMediaAttachmentThumbnail( + media: attachment, + width: double.infinity, + height: double.infinity, + ), + ); + } else if (attachment.type == AttachmentType.video) { + final package = videoPackages[attachment.id]!; + if (package.attachment.assetUrl != null) { + package.player.open( + Playlist( + [ + Media(package.attachment.assetUrl!), + ], + ), + play: widget.autoplayVideos, + ); + } + + return ContextMenuRegion( + contextMenuBuilder: (_, anchor) { + return ContextMenu( + anchor: anchor, + menuItems: [ + DownloadMenuItem( + attachment: attachment, + ), + ], + ); + }, + child: Video( + controller: package.controller, + ), + ); + } + + return const Empty(); + }, + ), ); }, ), diff --git a/sample_app/ios/Runner.xcodeproj/project.pbxproj b/sample_app/ios/Runner.xcodeproj/project.pbxproj index 2b3de5b64..17806dba6 100644 --- a/sample_app/ios/Runner.xcodeproj/project.pbxproj +++ b/sample_app/ios/Runner.xcodeproj/project.pbxproj @@ -304,7 +304,6 @@ "${BUILT_PRODUCTS_DIR}/sqlite3_flutter_libs/sqlite3_flutter_libs.framework", "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", "${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework", - "${BUILT_PRODUCTS_DIR}/volume_controller/volume_controller.framework", "${BUILT_PRODUCTS_DIR}/wakelock_plus/wakelock_plus.framework", ); name = "[CP] Embed Pods Frameworks"; @@ -348,7 +347,6 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqlite3_flutter_libs.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/volume_controller.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock_plus.framework", ); runOnlyForDeploymentPostprocessing = 0;