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

This commit is contained in:
ashilkn
2024-10-21 08:34:57 +05:30
parent f63e8b51d9
commit 8a130b52c2
2 changed files with 98 additions and 74 deletions

View File

@@ -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 {

View File

@@ -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 {