From b828101babac416c32703455b28089721a4776aa Mon Sep 17 00:00:00 2001 From: bwees Date: Mon, 2 Jun 2025 14:44:39 -0500 Subject: [PATCH] only show casting snackbar if we are casting --- .../lib/pages/common/gallery_viewer.page.dart | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/mobile/lib/pages/common/gallery_viewer.page.dart b/mobile/lib/pages/common/gallery_viewer.page.dart index cca11b7a67..fd41a59030 100644 --- a/mobile/lib/pages/common/gallery_viewer.page.dart +++ b/mobile/lib/pages/common/gallery_viewer.page.dart @@ -64,6 +64,7 @@ class GalleryViewerPage extends HookConsumerWidget { final currentIndex = useValueNotifier(initialIndex); final loadAsset = renderList.loadAsset; final isPlayingMotionVideo = ref.watch(isPlayingMotionVideoProvider); + final isCasting = ref.watch(castProvider.select((c) => c.isCasting)); final videoPlayerKeys = useRef>({}); @@ -126,21 +127,23 @@ class GalleryViewerPage extends HookConsumerWidget { if (asset.isRemote) { ref.read(castProvider.notifier).loadMedia(asset, false); } else { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (context.mounted) { - context.scaffoldMessenger.showSnackBar( - SnackBar( - duration: const Duration(seconds: 1), - content: Text( - "local_asset_cast_failed".tr(), - style: context.textTheme.bodyLarge?.copyWith( - color: context.primaryColor, + if (isCasting) { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (context.mounted) { + context.scaffoldMessenger.showSnackBar( + SnackBar( + duration: const Duration(seconds: 1), + content: Text( + "local_asset_cast_failed".tr(), + style: context.textTheme.bodyLarge?.copyWith( + color: context.primaryColor, + ), ), ), - ), - ); - } - }); + ); + } + }); + } } return null; }, [ @@ -393,17 +396,20 @@ class GalleryViewerPage extends HookConsumerWidget { ref.read(castProvider.notifier).loadMedia(newAsset, false); } else { context.scaffoldMessenger.clearSnackBars(); - context.scaffoldMessenger.showSnackBar( - SnackBar( - duration: const Duration(seconds: 2), - content: Text( - "local_asset_cast_failed".tr(), - style: context.textTheme.bodyLarge?.copyWith( - color: context.primaryColor, + + if (isCasting) { + context.scaffoldMessenger.showSnackBar( + SnackBar( + duration: const Duration(seconds: 2), + content: Text( + "local_asset_cast_failed".tr(), + style: context.textTheme.bodyLarge?.copyWith( + color: context.primaryColor, + ), ), ), - ), - ); + ); + } } }, builder: buildAsset,