π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Hide/show caption with enabling/disabling full screen
ashilkn13c36d9c4028
diff --git a/mobile/lib/states/detail_page_state.dart b/mobile/lib/states/detail_page_state.dartnew file mode 100644index 0000000000..83df0558cb--- /dev/null+++ b/mobile/lib/states/detail_page_state.dart@@ -0,0 +1,37 @@+import "package:flutter/material.dart";+import "package:flutter/services.dart";++class InheritedDetailPageState extends InheritedWidget {+ final enableFullScreenNotifier = ValueNotifier(false);+ InheritedDetailPageState({+ super.key,+ required super.child,+ });++ static InheritedDetailPageState of(BuildContext context) =>+ context.dependOnInheritedWidgetOfExactType<InheritedDetailPageState>()!;++ void toggleFullScreen({bool? shouldEnable}) {+ if (shouldEnable != null) {+ if (enableFullScreenNotifier.value == shouldEnable) return;+ }+ enableFullScreenNotifier.value = !enableFullScreenNotifier.value;+ if (enableFullScreenNotifier.value) {+ Future.delayed(const Duration(milliseconds: 200), () {+ SystemChrome.setEnabledSystemUIMode(+ SystemUiMode.manual,+ overlays: [],+ );+ });+ } else {+ SystemChrome.setEnabledSystemUIMode(+ SystemUiMode.edgeToEdge,+ overlays: SystemUiOverlay.values,+ );+ }+ }++ @override+ bool updateShouldNotify(InheritedDetailPageState oldWidget) =>+ oldWidget.enableFullScreenNotifier != enableFullScreenNotifier;+}diff --git a/mobile/lib/ui/viewer/file/detail_page.dart b/mobile/lib/ui/viewer/file/detail_page.dartindex 0dab65b96d..82c9eb14a0 100644--- a/mobile/lib/ui/viewer/file/detail_page.dart+++ b/mobile/lib/ui/viewer/file/detail_page.dart@@ -16,6 +16,7 @@ import 'package:photos/models/file/file.dart';import "package:photos/models/file/file_type.dart";import "package:photos/service_locator.dart";import "package:photos/services/local_authentication_service.dart";+import "package:photos/states/detail_page_state.dart";import "package:photos/ui/common/fast_scroll_physics.dart";import 'package:photos/ui/notification/toast.dart';import 'package:photos/ui/tools/editor/image_editor_page.dart';@@ -77,7 +78,6 @@ class _DetailPageState extends State<DetailPage> {List<EnteFile>? _files;late PageController _pageController;final _selectedIndexNotifier = ValueNotifier(0);- final _enableFullScreenNotifier = ValueNotifier(false);bool _isFirstOpened = true;bool isGuestView = false;bool swipeLocked = false;@@ -103,7 +103,6 @@ class _DetailPageState extends State<DetailPage> {void dispose() {_guestViewEventSubscription.cancel();_pageController.dispose();- _enableFullScreenNotifier.dispose();_selectedIndexNotifier.dispose();super.dispose();@@ -137,96 +136,102 @@ class _DetailPageState extends State<DetailPage> {_files!.length.toString() +" files .",);- return PopScope(- canPop: !isGuestView,- onPopInvoked: (didPop) async {- if (isGuestView) {- final authenticated = await _requestAuthentication();- if (authenticated) {- Bus.instance.fire(GuestViewEvent(false, false));- await localSettings.setOnGuestView(false);+ return InheritedDetailPageState(+ child: PopScope(+ canPop: !isGuestView,+ onPopInvoked: (didPop) async {+ if (isGuestView) {+ final authenticated = await _requestAuthentication();+ if (authenticated) {+ Bus.instance.fire(GuestViewEvent(false, false));+ await localSettings.setOnGuestView(false);+ }}- }- },- child: Scaffold(- appBar: PreferredSize(- preferredSize: const Size.fromHeight(80),- child: ValueListenableBuilder(- builder: (BuildContext context, int selectedIndex, _) {- return FileAppBar(- _files![selectedIndex],- _onFileRemoved,- widget.config.mode == DetailPageMode.full,- enableFullScreenNotifier: _enableFullScreenNotifier,- );- },- valueListenable: _selectedIndexNotifier,+ },+ child: Scaffold(+ appBar: PreferredSize(+ preferredSize: const Size.fromHeight(80),+ child: ValueListenableBuilder(+ builder: (BuildContext context, int selectedIndex, _) {+ return FileAppBar(+ _files![selectedIndex],+ _onFileRemoved,+ widget.config.mode == DetailPageMode.full,+ enableFullScreenNotifier: InheritedDetailPageState.of(context)+ .enableFullScreenNotifier,+ );+ },+ valueListenable: _selectedIndexNotifier,+ ),),- ),- extendBodyBehindAppBar: true,- resizeToAvoidBottomInset: false,- backgroundColor: Colors.black,- body: Center(- child: Stack(- children: [- _buildPageView(context),- ValueListenableBuilder(- builder: (BuildContext context, int selectedIndex, _) {- return FileBottomBar(- _files![selectedIndex],- _onEditFileRequested,- widget.config.mode == DetailPageMode.minimalistic &&- !isGuestView,- onFileRemoved: _onFileRemoved,- userID: Configuration.instance.getUserID(),- enableFullScreenNotifier: _enableFullScreenNotifier,- );- },- 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,+ extendBodyBehindAppBar: true,+ resizeToAvoidBottomInset: false,+ backgroundColor: Colors.black,+ body: Center(+ child: Stack(+ children: [+ _buildPageView(),+ ValueListenableBuilder(+ builder: (BuildContext context, int selectedIndex, _) {+ return FileBottomBar(+ _files![selectedIndex],+ _onEditFileRequested,+ widget.config.mode == DetailPageMode.minimalistic &&+ !isGuestView,+ onFileRemoved: _onFileRemoved,+ userID: Configuration.instance.getUserID(),+ enableFullScreenNotifier:+ InheritedDetailPageState.of(context)+ .enableFullScreenNotifier,+ );+ },+ valueListenable: _selectedIndexNotifier,+ ),+ ValueListenableBuilder(+ valueListenable: _selectedIndexNotifier,+ builder: (BuildContext context, int selectedIndex, _) {+ if (_files![selectedIndex].isPanorama() == true) {+ return ValueListenableBuilder(+ valueListenable: InheritedDetailPageState.of(context)+ .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],+ );+ },),- onPressed: () async {- await openPanoramaViewerPage(- _files![selectedIndex],- );- },),),),- ),- );- },- );- }- return const SizedBox();- },- ),- ],+ );+ },+ );+ }+ return const SizedBox();+ },+ ),+ ],+ ),),),),@@ -251,7 +256,7 @@ class _DetailPageState extends State<DetailPage> {).ignore();}- Widget _buildPageView(BuildContext context) {+ Widget _buildPageView() {return PageView.builder(clipBehavior: Clip.none,itemBuilder: (context, index) {@@ -271,14 +276,17 @@ class _DetailPageState extends State<DetailPage> {},playbackCallback: (isPlaying) {Future.delayed(Duration.zero, () {- _toggleFullScreen(shouldEnable: isPlaying);+ InheritedDetailPageState.of(context)+ .toggleFullScreen(shouldEnable: isPlaying);});},backgroundDecoration: const BoxDecoration(color: Colors.black),);return GestureDetector(onTap: () {- file.fileType != FileType.video ? _toggleFullScreen() : null;+ file.fileType != FileType.video+ ? InheritedDetailPageState.of(context).toggleFullScreen()+ : null;},child: fileContent,);@@ -313,26 +321,6 @@ class _DetailPageState extends State<DetailPage> {return false;}- void _toggleFullScreen({bool? shouldEnable}) {- if (shouldEnable != null) {- if (_enableFullScreenNotifier.value == shouldEnable) return;- }- _enableFullScreenNotifier.value = !_enableFullScreenNotifier.value;- if (_enableFullScreenNotifier.value) {- Future.delayed(const Duration(milliseconds: 200), () {- SystemChrome.setEnabledSystemUIMode(- SystemUiMode.manual,- overlays: [],- );- });- } else {- SystemChrome.setEnabledSystemUIMode(- SystemUiMode.edgeToEdge,- overlays: SystemUiOverlay.values,- );- }- }-void _preloadFiles(int index) {if (index > 0) {preloadFile(_files![index - 1]);diff --git a/mobile/lib/ui/viewer/file/zoomable_image.dart b/mobile/lib/ui/viewer/file/zoomable_image.dartindex 041732e8b6..399fdcf33c 100644--- a/mobile/lib/ui/viewer/file/zoomable_image.dart+++ b/mobile/lib/ui/viewer/file/zoomable_image.dart@@ -13,6 +13,7 @@ import "package:photos/events/files_updated_event.dart";import 'package:photos/events/local_photos_updated_event.dart';import "package:photos/models/file/extensions/file_props.dart";import 'package:photos/models/file/file.dart';+import "package:photos/states/detail_page_state.dart";import "package:photos/theme/ente_theme.dart";import "package:photos/ui/actions/file/file_actions.dart";import 'package:photos/ui/common/loading_widget.dart';@@ -177,26 +178,36 @@ class _ZoomableImageState extends State<ZoomableImage> {bottom: 72 + MediaQuery.of(context).padding.bottom,left: 0,right: 0,- child: Container(- color: Colors.black.withOpacity(0.1),- width: double.infinity,- child: Row(- mainAxisAlignment: MainAxisAlignment.center,- children: [- Padding(- padding: const EdgeInsets.symmetric(- vertical: 4.0,- horizontal: 8.0,- ),- child: Text(- widget.photo.caption!,- maxLines: 3,- overflow: TextOverflow.ellipsis,- style: getEnteTextTheme(context).mini,+ child: ValueListenableBuilder<bool>(+ valueListenable: InheritedDetailPageState.of(context)+ .enableFullScreenNotifier,+ builder: (context, doNotShowCaption, _) {+ return AnimatedOpacity(+ opacity: doNotShowCaption ? 0.0 : 1.0,+ duration: const Duration(milliseconds: 200),+ child: Container(+ color: Colors.black.withOpacity(0.1),+ width: double.infinity,+ child: Row(+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ Padding(+ padding: const EdgeInsets.symmetric(+ vertical: 4.0,+ horizontal: 8.0,+ ),+ child: Text(+ widget.photo.caption!,+ maxLines: 3,+ overflow: TextOverflow.ellipsis,+ style: getEnteTextTheme(context).mini,+ ),+ ),+ ],),),- ],- ),+ );+ },),),],