From a905a1fa4461b034d55872bb24dfc2266b57068e Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 3 Dec 2024 21:33:18 +0530 Subject: [PATCH] [mob][photos] Fix UX issue with video controls when viewing a video memory --- .../ui/home/memories/full_screen_memory.dart | 1 - mobile/lib/ui/viewer/file/detail_page.dart | 1 - mobile/lib/ui/viewer/file/file_widget.dart | 2 -- .../ui/viewer/file/video_widget_native.dart | 28 ++++++++++++------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/mobile/lib/ui/home/memories/full_screen_memory.dart b/mobile/lib/ui/home/memories/full_screen_memory.dart index a46d542606..c8e69b58d8 100644 --- a/mobile/lib/ui/home/memories/full_screen_memory.dart +++ b/mobile/lib/ui/home/memories/full_screen_memory.dart @@ -268,7 +268,6 @@ class _FullScreenMemoryState extends State { backgroundDecoration: const BoxDecoration( color: Colors.transparent, ), - isFromMemories: true, ), ); }, diff --git a/mobile/lib/ui/viewer/file/detail_page.dart b/mobile/lib/ui/viewer/file/detail_page.dart index a4f9a26cc4..7e8795c978 100644 --- a/mobile/lib/ui/viewer/file/detail_page.dart +++ b/mobile/lib/ui/viewer/file/detail_page.dart @@ -276,7 +276,6 @@ class _DetailPageState extends State { }); }, backgroundDecoration: const BoxDecoration(color: Colors.black), - isFromMemories: false, ); return GestureDetector( onTap: () { diff --git a/mobile/lib/ui/viewer/file/file_widget.dart b/mobile/lib/ui/viewer/file/file_widget.dart index b798aedf12..387bbad91b 100644 --- a/mobile/lib/ui/viewer/file/file_widget.dart +++ b/mobile/lib/ui/viewer/file/file_widget.dart @@ -12,7 +12,6 @@ class FileWidget extends StatelessWidget { final Function(bool)? playbackCallback; final BoxDecoration? backgroundDecoration; final bool? autoPlay; - final bool isFromMemories; const FileWidget( this.file, { @@ -21,7 +20,6 @@ class FileWidget extends StatelessWidget { this.playbackCallback, this.tagPrefix, this.backgroundDecoration, - required this.isFromMemories, super.key, }); diff --git a/mobile/lib/ui/viewer/file/video_widget_native.dart b/mobile/lib/ui/viewer/file/video_widget_native.dart index b5bea96495..c76d9d5e5e 100644 --- a/mobile/lib/ui/viewer/file/video_widget_native.dart +++ b/mobile/lib/ui/viewer/file/video_widget_native.dart @@ -200,12 +200,12 @@ class _VideoWidgetNativeState extends State ), GestureDetector( behavior: HitTestBehavior.opaque, - onTap: widget.playbackCallback != null - ? () { - _showControls.value = !_showControls.value; - widget.playbackCallback!(!_showControls.value); - } - : null, + onTap: () { + _showControls.value = !_showControls.value; + if (widget.playbackCallback != null) { + widget.playbackCallback!(!_showControls.value); + } + }, child: Container( constraints: const BoxConstraints.expand(), ), @@ -310,7 +310,9 @@ class _VideoWidgetNativeState extends State return; } _showControls.value = false; - widget.playbackCallback!(true); + if (widget.playbackCallback != null) { + widget.playbackCallback!(true); + } } }); } @@ -321,7 +323,7 @@ class _VideoWidgetNativeState extends State return; } if (_controller!.playbackInfo?.status == PlaybackStatus.playing) { - if (widget.playbackCallback != null && mounted) { + if (mounted) { _debouncer.run(() async { if (mounted) { if (_isSeeking.value || @@ -329,7 +331,9 @@ class _VideoWidgetNativeState extends State return; } _showControls.value = false; - widget.playbackCallback!(true); + if (widget.playbackCallback != null) { + widget.playbackCallback!(true); + } } }); } @@ -379,7 +383,11 @@ class _VideoWidgetNativeState extends State _setFilePathForNativePlayer(file.path); } }).onError((error, stackTrace) { - showErrorDialog(context, S.of(context).error, S.of(context).failedToDownloadVideo); + showErrorDialog( + context, + S.of(context).error, + S.of(context).failedToDownloadVideo, + ); }); }