Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Improve UI of appbar when there are added filters

ashilkn8a130b52c20e
diff --git a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 8c2b280f24..d0c2b7853d 100644
--- a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -42,6 +42,7 @@ import 'package:photos/ui/sharing/share_collection_page.dart';
import 'package:photos/ui/tools/free_space_page.dart';
import "package:photos/ui/viewer/gallery/hooks/add_photos_sheet.dart";
import 'package:photos/ui/viewer/gallery/hooks/pick_cover_photo.dart';
+import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";
import "package:photos/ui/viewer/hierarchicial_search/applied_filters.dart";
import "package:photos/ui/viewer/hierarchicial_search/recommended_filters.dart";
import "package:photos/ui/viewer/location/edit_location_sheet.dart";
@@ -132,45 +133,57 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
@override
Widget build(BuildContext context) {
+ final inheritedSearchFilterData =
+ InheritedSearchFilterData.maybeOf(context);
+ final isHierarchicalSearchable =
+ inheritedSearchFilterData?.isHierarchicalSearchable ?? false;
return galleryType == GalleryType.homepage
? const SizedBox.shrink()
- : AppBar(
- elevation: 0,
- centerTitle: false,
- title: Expanded(
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Expanded(
- child: Text(
- _appBarTitle!,
- style: Theme.of(context)
- .textTheme
- .headlineSmall!
- .copyWith(fontSize: 16),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- const SizedBox(
- width: 200,
- height: kFilterChipHeight,
- child: AppliedFilters(),
- ),
- ],
- ),
- ),
- // actions: _getDefaultActions(context),
- bottom: galleryType == GalleryType.searchResults ||
- galleryType == GalleryType.ownedCollection ||
- galleryType == GalleryType.locationTag ||
- galleryType == GalleryType.magic
- ? const PreferredSize(
- preferredSize: Size.fromHeight(0),
- child: Flexible(child: RecommendedFilters()),
- )
- : null,
- );
+ : isHierarchicalSearchable
+ ? ValueListenableBuilder(
+ valueListenable: inheritedSearchFilterData!
+ .searchFilterDataProvider!.isSearchingNotifier,
+ child: const PreferredSize(
+ preferredSize: Size.fromHeight(0),
+ child: Flexible(child: RecommendedFilters()),
+ ),
+ builder: (context, isSearching, child) {
+ return AppBar(
+ elevation: 0,
+ centerTitle: false,
+ title: isSearching
+ ? const SizedBox(
+ height: kFilterChipHeight,
+ child: AppliedFilters(),
+ )
+ : Text(
+ _appBarTitle!,
+ style: Theme.of(context)
+ .textTheme
+ .headlineSmall!
+ .copyWith(fontSize: 16),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ ),
+ actions: isSearching ? null : _getDefaultActions(context),
+ bottom: child as PreferredSizeWidget,
+ );
+ },
+ )
+ : AppBar(
+ elevation: 0,
+ centerTitle: false,
+ title: Text(
+ _appBarTitle!,
+ style: Theme.of(context)
+ .textTheme
+ .headlineSmall!
+ .copyWith(fontSize: 16),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ ),
+ actions: _getDefaultActions(context),
+ );
}
Future<dynamic> _renameAlbum(BuildContext context) async {
diff --git a/mobile/lib/ui/viewer/people/people_app_bar.dart b/mobile/lib/ui/viewer/people/people_app_bar.dart
index 8166cd6946..70b46ad721 100644
--- a/mobile/lib/ui/viewer/people/people_app_bar.dart
+++ b/mobile/lib/ui/viewer/people/people_app_bar.dart
@@ -16,6 +16,7 @@ import 'package:photos/models/selected_files.dart';
import 'package:photos/services/collections_service.dart';
import "package:photos/services/machine_learning/face_ml/person/person_service.dart";
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
+import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";
import "package:photos/ui/viewer/hierarchicial_search/applied_filters.dart";
import "package:photos/ui/viewer/hierarchicial_search/recommended_filters.dart";
import "package:photos/ui/viewer/people/add_person_action_sheet.dart";
@@ -87,45 +88,55 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
@override
Widget build(BuildContext context) {
- return AppBar(
- elevation: 0,
- centerTitle: false,
- // title: Text(
- // _appBarTitle!,
- // style:
- // Theme.of(context).textTheme.headlineSmall!.copyWith(fontSize: 16),
- // maxLines: 2,
- // overflow: TextOverflow.ellipsis,
- // ),
- title: Expanded(
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Expanded(
- child: Text(
- _appBarTitle!,
- style: Theme.of(context)
- .textTheme
- .headlineSmall!
- .copyWith(fontSize: 16),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- ),
+ final inheritedSearchFilterData =
+ InheritedSearchFilterData.maybeOf(context);
+ final isHierarchicalSearchable =
+ inheritedSearchFilterData?.isHierarchicalSearchable ?? false;
+ return isHierarchicalSearchable
+ ? ValueListenableBuilder(
+ valueListenable: inheritedSearchFilterData!
+ .searchFilterDataProvider!.isSearchingNotifier,
+ child: const PreferredSize(
+ preferredSize: Size.fromHeight(0),
+ child: Flexible(child: RecommendedFilters()),
),
- const SizedBox(
- width: 200,
- height: kFilterChipHeight,
- child: AppliedFilters(),
+ builder: (context, isSearching, child) {
+ return AppBar(
+ elevation: 0,
+ centerTitle: false,
+ title: isSearching
+ ? const SizedBox(
+ height: kFilterChipHeight,
+ child: AppliedFilters(),
+ )
+ : Text(
+ _appBarTitle!,
+ style: Theme.of(context)
+ .textTheme
+ .headlineSmall!
+ .copyWith(fontSize: 16),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ ),
+ bottom: child as PreferredSizeWidget,
+ actions: isSearching ? null : _getDefaultActions(context),
+ );
+ },
+ )
+ : AppBar(
+ elevation: 0,
+ centerTitle: false,
+ title: Text(
+ _appBarTitle!,
+ style: Theme.of(context)
+ .textTheme
+ .headlineSmall!
+ .copyWith(fontSize: 16),
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
),
- ],
- ),
- ),
- bottom: const PreferredSize(
- preferredSize: Size.fromHeight(0),
- child: Flexible(child: RecommendedFilters()),
- ),
- actions: _getDefaultActions(context),
- );
+ actions: _getDefaultActions(context),
+ );
}
Future<dynamic> _renamePerson(BuildContext context) async {