From 38c3e73638ca0ead67207f8f7ebc3c328b503666 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Fri, 9 Aug 2024 20:18:28 +0530 Subject: [PATCH] fix: move panorama icon to middle --- mobile/lib/ui/viewer/file/detail_page.dart | 63 +++++++ .../lib/ui/viewer/file/file_bottom_bar.dart | 158 ++++++------------ .../viewer/file/panorama_viewer_screen.dart | 6 + 3 files changed, 121 insertions(+), 106 deletions(-) diff --git a/mobile/lib/ui/viewer/file/detail_page.dart b/mobile/lib/ui/viewer/file/detail_page.dart index 521a12ea69..87c282d2ba 100644 --- a/mobile/lib/ui/viewer/file/detail_page.dart +++ b/mobile/lib/ui/viewer/file/detail_page.dart @@ -12,6 +12,7 @@ import 'package:photos/core/errors.dart'; import "package:photos/core/event_bus.dart"; import "package:photos/events/file_swipe_lock_event.dart"; import "package:photos/generated/l10n.dart"; +import "package:photos/models/file/extensions/file_props.dart"; import 'package:photos/models/file/file.dart'; import "package:photos/models/file/file_type.dart"; import "package:photos/services/local_authentication_service.dart"; @@ -21,10 +22,12 @@ import "package:photos/ui/tools/editor/video_editor_page.dart"; import "package:photos/ui/viewer/file/file_app_bar.dart"; import "package:photos/ui/viewer/file/file_bottom_bar.dart"; import 'package:photos/ui/viewer/file/file_widget.dart'; +import "package:photos/ui/viewer/file/panorama_viewer_screen.dart"; import 'package:photos/ui/viewer/gallery/gallery.dart'; import 'package:photos/utils/dialog_util.dart'; import 'package:photos/utils/file_util.dart'; import 'package:photos/utils/navigation_util.dart'; +import "package:photos/utils/thumbnail_util.dart"; import 'package:photos/utils/toast_util.dart'; enum DetailPageMode { @@ -184,6 +187,48 @@ class _DetailPageState extends State { }, valueListenable: _selectedIndexNotifier, ), + ValueListenableBuilder( + valueListenable: _selectedIndexNotifier, + builder: (BuildContext context, int selectedIndex, _) { + if (_files![selectedIndex].isPanorama() == true) { + return ValueListenableBuilder( + valueListenable: _enableFullScreenNotifier, + builder: (context, value, child) { + return IgnorePointer( + ignoring: value, + child: AnimatedOpacity( + duration: const Duration(milliseconds: 200), + opacity: !value ? 1.0 : 0.0, + child: Align( + alignment: Alignment.center, + child: Tooltip( + message: S.of(context).panorama, + child: IconButton( + style: IconButton.styleFrom( + backgroundColor: const Color(0xAA252525), + fixedSize: const Size(44, 44), + ), + icon: const Icon( + Icons.threesixty, + color: Colors.white, + size: 26, + ), + onPressed: () async { + await openPanoramaViewerPage( + _files![selectedIndex], + ); + }, + ), + ), + ), + ), + ); + }, + ); + } + return const SizedBox(); + }, + ), ], ), ), @@ -191,6 +236,24 @@ class _DetailPageState extends State { ); } + Future openPanoramaViewerPage(EnteFile file) async { + final fetchedFile = await getFile(file); + if (fetchedFile == null) { + return; + } + final fetchedThumbnail = await getThumbnail(file); + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) { + return PanoramaViewerScreen( + file: fetchedFile, + thumbnail: fetchedThumbnail, + ); + }, + ), + ).ignore(); + } + Widget _buildPageView(BuildContext context) { return PageView.builder( clipBehavior: Clip.none, diff --git a/mobile/lib/ui/viewer/file/file_bottom_bar.dart b/mobile/lib/ui/viewer/file/file_bottom_bar.dart index 9b60748386..0d08abcb96 100644 --- a/mobile/lib/ui/viewer/file/file_bottom_bar.dart +++ b/mobile/lib/ui/viewer/file/file_bottom_bar.dart @@ -17,12 +17,9 @@ import "package:photos/theme/colors.dart"; import "package:photos/theme/ente_theme.dart"; import "package:photos/ui/actions/file/file_actions.dart"; import 'package:photos/ui/collections/collection_action_sheet.dart'; -import "package:photos/ui/viewer/file/panorama_viewer_screen.dart"; import 'package:photos/utils/delete_file_util.dart'; -import "package:photos/utils/file_util.dart"; import "package:photos/utils/panorama_util.dart"; import 'package:photos/utils/share_util.dart'; -import "package:photos/utils/thumbnail_util.dart"; class FileBottomBar extends StatefulWidget { final EnteFile file; @@ -198,92 +195,59 @@ class FileBottomBarState extends State { curve: Curves.easeInOut, child: Align( alignment: Alignment.bottomCenter, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - if (widget.file.isPanorama() == true) - Align( - alignment: Alignment.centerRight, - child: Tooltip( - message: S.of(context).panorama, - child: Padding( - padding: const EdgeInsets.only( - top: 12, - bottom: 12, - right: 20, - ), - child: IconButton( - style: IconButton.styleFrom( - backgroundColor: const Color(0xFF252525), - fixedSize: const Size(44, 44), - ), - icon: const Icon( - Icons.vrpano_outlined, - color: Colors.white, - size: 26, - ), - onPressed: () async { - await openPanoramaViewerPage(widget.file); - }, - ), - ), - ), - ), - Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Colors.transparent, - Colors.black.withOpacity(0.6), - Colors.black.withOpacity(0.72), - ], - stops: const [0, 0.8, 1], - ), - ), - child: Padding( - padding: EdgeInsets.only(bottom: safeAreaBottomPadding), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - widget.file.caption?.isNotEmpty ?? false - ? Padding( - padding: const EdgeInsets.fromLTRB( - 16, - 12, - 16, - 0, - ), - child: GestureDetector( - onTap: () async { - await _displayDetails(widget.file); - await Future.delayed( - const Duration(milliseconds: 500), - ); //Waiting for some time till the caption gets updated in db if the user closes the bottom sheet without pressing 'done' - safeRefresh(); - }, - child: Text( - widget.file.caption!, - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: getEnteTextTheme(context) - .mini - .copyWith(color: textBaseDark), - textAlign: TextAlign.center, - ), - ), - ) - : const SizedBox.shrink(), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: children, - ), - ], - ), - ), + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.transparent, + Colors.black.withOpacity(0.6), + Colors.black.withOpacity(0.72), + ], + stops: const [0, 0.8, 1], ), - ], + ), + child: Padding( + padding: EdgeInsets.only(bottom: safeAreaBottomPadding), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + widget.file.caption?.isNotEmpty ?? false + ? Padding( + padding: const EdgeInsets.fromLTRB( + 16, + 12, + 16, + 0, + ), + child: GestureDetector( + onTap: () async { + await _displayDetails(widget.file); + await Future.delayed( + const Duration(milliseconds: 500), + ); //Waiting for some time till the caption gets updated in db if the user closes the bottom sheet without pressing 'done' + safeRefresh(); + }, + child: Text( + widget.file.caption!, + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: getEnteTextTheme(context) + .mini + .copyWith(color: textBaseDark), + textAlign: TextAlign.center, + ), + ), + ) + : const SizedBox.shrink(), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: children, + ), + ], + ), + ), ), ), ), @@ -292,24 +256,6 @@ class FileBottomBarState extends State { ); } - Future openPanoramaViewerPage(EnteFile file) async { - final fetchedFile = await getFile(file); - if (fetchedFile == null) { - return; - } - final fetchedThumbnail = await getThumbnail(file); - Navigator.of(context).push( - MaterialPageRoute( - builder: (_) { - return PanoramaViewerScreen( - file: fetchedFile, - thumbnail: fetchedThumbnail, - ); - }, - ), - ).ignore(); - } - Future _showSingleFileDeleteSheet(EnteFile file) async { await showSingleFileDeleteSheet( context, diff --git a/mobile/lib/ui/viewer/file/panorama_viewer_screen.dart b/mobile/lib/ui/viewer/file/panorama_viewer_screen.dart index c9437b5ab6..27dedfcc60 100644 --- a/mobile/lib/ui/viewer/file/panorama_viewer_screen.dart +++ b/mobile/lib/ui/viewer/file/panorama_viewer_screen.dart @@ -36,6 +36,12 @@ class _PanoramaViewerScreenState extends State { super.initState(); } + @override + void dispose() { + SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); + super.dispose(); + } + void initTimer() { timer = Timer(const Duration(seconds: 5), () { setState(() {