From 45f15490795fb3d26211651cae6bfb1ba0c57ca0 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 11 Feb 2025 15:49:58 +0530 Subject: [PATCH] [mob][photos] Fix: FileAppbar buttons not working on some screens --- mobile/lib/ui/viewer/file/custom_app_bar.dart | 25 --------- mobile/lib/ui/viewer/file/detail_page.dart | 1 - mobile/lib/ui/viewer/file/file_app_bar.dart | 56 +++++++++---------- 3 files changed, 26 insertions(+), 56 deletions(-) delete mode 100644 mobile/lib/ui/viewer/file/custom_app_bar.dart diff --git a/mobile/lib/ui/viewer/file/custom_app_bar.dart b/mobile/lib/ui/viewer/file/custom_app_bar.dart deleted file mode 100644 index 1003e56af9..0000000000 --- a/mobile/lib/ui/viewer/file/custom_app_bar.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter/material.dart'; - -class CustomAppBar extends PreferredSize { - @override - final Widget child; - @override - final Size preferredSize; - final double height; - - const CustomAppBar( - this.child, - this.preferredSize, { - Key? key, - this.height = kToolbarHeight, - }) : super(key: key, child: child, preferredSize: preferredSize); - - @override - Widget build(BuildContext context) { - return Container( - height: preferredSize.height, - alignment: Alignment.center, - child: child, - ); - } -} diff --git a/mobile/lib/ui/viewer/file/detail_page.dart b/mobile/lib/ui/viewer/file/detail_page.dart index 7e8795c978..3751e327f6 100644 --- a/mobile/lib/ui/viewer/file/detail_page.dart +++ b/mobile/lib/ui/viewer/file/detail_page.dart @@ -156,7 +156,6 @@ class _DetailPageState extends State { return FileAppBar( _files![selectedIndex], _onFileRemoved, - 100, widget.config.mode == DetailPageMode.full, enableFullScreenNotifier: _enableFullScreenNotifier, ); diff --git a/mobile/lib/ui/viewer/file/file_app_bar.dart b/mobile/lib/ui/viewer/file/file_app_bar.dart index e763a174cc..46adbad5d4 100644 --- a/mobile/lib/ui/viewer/file/file_app_bar.dart +++ b/mobile/lib/ui/viewer/file/file_app_bar.dart @@ -23,7 +23,6 @@ import "package:photos/services/local_authentication_service.dart"; import "package:photos/services/preview_video_store.dart"; import "package:photos/theme/ente_theme.dart"; import 'package:photos/ui/collections/collection_action_sheet.dart'; -import 'package:photos/ui/viewer/file/custom_app_bar.dart'; import "package:photos/ui/viewer/file_details/favorite_widget.dart"; import "package:photos/ui/viewer/file_details/upload_icon_widget.dart"; import 'package:photos/utils/dialog_util.dart'; @@ -35,14 +34,12 @@ import 'package:photos/utils/toast_util.dart'; class FileAppBar extends StatefulWidget { final EnteFile file; final Function(EnteFile) onFileRemoved; - final double height; final bool shouldShowActions; final ValueNotifier enableFullScreenNotifier; const FileAppBar( this.file, this.onFileRemoved, - this.height, this.shouldShowActions, { required this.enableFullScreenNotifier, super.key, @@ -98,8 +95,9 @@ class FileAppBarState extends State { final isTrashedFile = widget.file is TrashFile; final shouldShowActions = widget.shouldShowActions && !isTrashedFile; - return CustomAppBar( - ValueListenableBuilder( + return PreferredSize( + preferredSize: const Size.fromHeight(kToolbarHeight), + child: ValueListenableBuilder( valueListenable: widget.enableFullScreenNotifier, builder: (context, bool isFullScreen, child) { return IgnorePointer( @@ -124,32 +122,33 @@ class FileAppBarState extends State { stops: const [0, 0.2, 1], ), ), - child: AnimatedSwitcher( - duration: const Duration(milliseconds: 250), - switchInCurve: Curves.easeInOut, - switchOutCurve: Curves.easeInOut, - child: AppBar( - clipBehavior: Clip.none, - key: ValueKey(isGuestView), - iconTheme: const IconThemeData( - color: Colors.white, - ), //same for both themes - leading: IconButton( - icon: const Icon(Icons.arrow_back), - onPressed: () { - isGuestView - ? _requestAuthentication() - : Navigator.of(context).pop(); - }, + child: SafeArea( + child: AnimatedSwitcher( + duration: const Duration(milliseconds: 250), + switchInCurve: Curves.easeInOut, + switchOutCurve: Curves.easeInOut, + child: AppBar( + clipBehavior: Clip.none, + key: ValueKey(isGuestView), + iconTheme: const IconThemeData( + color: Colors.white, + ), //same for both themes + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () { + isGuestView + ? _requestAuthentication() + : Navigator.of(context).pop(); + }, + ), + actions: shouldShowActions && !isGuestView ? _actions : [], + elevation: 0, + backgroundColor: const Color(0x00000000), ), - actions: shouldShowActions && !isGuestView ? _actions : [], - elevation: 0, - backgroundColor: const Color(0x00000000), ), ), ), ), - Size.fromHeight(Platform.isAndroid ? 84 : 96), ); } @@ -179,10 +178,7 @@ class FileAppBarState extends State { } if (!isFileHidden && isFileUploaded) { _actions.add( - Padding( - padding: const EdgeInsets.all(8), - child: FavoriteWidget(widget.file), - ), + Center(child: FavoriteWidget(widget.file)), ); } if (!isFileUploaded) {