π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Show thumbnail for 'only them' filter with different layouts depending on the number of faces in filter
ashilkn4717e4859860
diff --git a/mobile/lib/models/search/hierarchical/only_them_filter.dart b/mobile/lib/models/search/hierarchical/only_them_filter.dartindex 838584d34e..ee874edfcf 100644--- a/mobile/lib/models/search/hierarchical/only_them_filter.dart+++ b/mobile/lib/models/search/hierarchical/only_them_filter.dart@@ -7,23 +7,13 @@ class OnlyThemFilter extends HierarchicalSearchFilter {final List<FaceFilter> faceFilters;final List<FaceFilter> faceFiltersToAvoid;final int occurrence;- final _personIDs = <String>[];- final _clusterIDs = <String>[];OnlyThemFilter({required this.faceFilters,required this.faceFiltersToAvoid,required this.occurrence,super.filterTypeName = "onlyThemFilter",- }) {- for (var filter in faceFilters) {- if (filter.personId != null) {- _personIDs.add(filter.personId!);- } else {- _clusterIDs.add(filter.clusterId!);- }- }- }+ });@overrideString name() {@@ -57,7 +47,4 @@ class OnlyThemFilter extends HierarchicalSearchFilter {}return false;}-- List<String> get personIDs => _personIDs;- List<String> get clusterIDs => _clusterIDs;}diff --git a/mobile/lib/ui/viewer/hierarchicial_search/applied_filters.dart b/mobile/lib/ui/viewer/hierarchicial_search/applied_filters.dartindex e88693075b..b7b6dd28e9 100644--- a/mobile/lib/ui/viewer/hierarchicial_search/applied_filters.dart+++ b/mobile/lib/ui/viewer/hierarchicial_search/applied_filters.dart@@ -76,8 +76,7 @@ class _AppliedFiltersState extends State<AppliedFilters> {): filter is OnlyThemFilter? OnlyThemFilterChip(- personIds: filter.personIDs,- clusterIds: filter.clusterIDs,+ faceFilters: filter.faceFilters,apply: () {_searchFilterDataProvider.applyFilters([filter]);},diff --git a/mobile/lib/ui/viewer/hierarchicial_search/filter_chip.dart b/mobile/lib/ui/viewer/hierarchicial_search/filter_chip.dartindex f70fd41f83..a3a94bf175 100644--- a/mobile/lib/ui/viewer/hierarchicial_search/filter_chip.dart+++ b/mobile/lib/ui/viewer/hierarchicial_search/filter_chip.dart@@ -1,6 +1,7 @@import "package:flutter/material.dart";import "package:photos/core/constants.dart";import "package:photos/models/file/file.dart";+import "package:photos/models/search/hierarchical/face_filter.dart";import "package:photos/theme/ente_theme.dart";import "package:photos/ui/viewer/search/result/person_face_widget.dart";@@ -231,15 +232,13 @@ class _FaceFilterChipState extends State<FaceFilterChip> {}class OnlyThemFilterChip extends StatelessWidget {- final List<String> personIds;- final List<String> clusterIds;+ final List<FaceFilter> faceFilters;final VoidCallback apply;final VoidCallback remove;final bool isApplied;final bool isInAllFiltersView;const OnlyThemFilterChip({- required this.personIds,- required this.clusterIds,+ required this.faceFilters,required this.apply,required this.remove,required this.isApplied,@@ -257,47 +256,42 @@ class OnlyThemFilterChip extends StatelessWidget {apply();}},- child: SizedBox(- // +1 to account for the filter's outer stroke width- height: kFilterChipHeight + 1,- child: Container(- decoration: BoxDecoration(- color: getEnteColorScheme(context).fillFaint,- borderRadius: const BorderRadius.all(- Radius.circular(kFilterChipHeight / 2),- ),- border: Border.all(- color: getEnteColorScheme(context).strokeFaint,- width: 0.5,- ),+ child: Container(+ decoration: BoxDecoration(+ color: getEnteColorScheme(context).fillFaint,+ borderRadius: const BorderRadius.all(+ Radius.circular(kFilterChipHeight / 2),),- child: Padding(- padding: const EdgeInsets.all(8.0),- child: Row(- mainAxisSize: MainAxisSize.min,- mainAxisAlignment: MainAxisAlignment.center,- children: [- _OnlyThemFilterThumbnail(- personIds: personIds,- clusterIds: clusterIds,- ),- Padding(- padding: const EdgeInsets.symmetric(horizontal: 4),- child: Text(- "Only them",- style: getEnteTextTheme(context).miniBold,- ),+ border: Border.all(+ color: getEnteColorScheme(context).strokeFaint,+ width: 0.5,+ ),+ ),+ child: Padding(+ padding: const EdgeInsets.only(right: 8.0),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ _OnlyThemFilterThumbnail(+ faceFilters: faceFilters,+ ),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: 4),+ child: Text(+ "Only them",+ style: getEnteTextTheme(context).miniBold,),- isApplied ? const SizedBox(width: 2) : const SizedBox.shrink(),- isApplied- ? Icon(- Icons.close_rounded,- size: 16,- color: getEnteColorScheme(context).textMuted,- )- : const SizedBox.shrink(),- ],- ),+ ),+ isApplied ? const SizedBox(width: 2) : const SizedBox.shrink(),+ isApplied+ ? Icon(+ Icons.close_rounded,+ size: 16,+ color: getEnteColorScheme(context).textMuted,+ )+ : const SizedBox.shrink(),+ ],),),),@@ -306,15 +300,191 @@ class OnlyThemFilterChip extends StatelessWidget {}class _OnlyThemFilterThumbnail extends StatelessWidget {- final List<String> personIds;- final List<String> clusterIds;+ final List<FaceFilter> faceFilters;const _OnlyThemFilterThumbnail({- required this.personIds,- required this.clusterIds,- });+ required this.faceFilters,+ }) : assert(faceFilters.length > 0 && faceFilters.length <= 4);@overrideWidget build(BuildContext context) {- return const SizedBox.shrink();+ final numberOfFaces = faceFilters.length;+ if (numberOfFaces == 1) {+ return ClipOval(+ child: SizedBox(+ width: kFilterChipHeight,+ height: kFilterChipHeight,+ child: PersonFaceWidget(+ faceFilters.first.faceFile,+ personId: faceFilters.first.personId,+ clusterID: faceFilters.first.clusterId,+ thumbnailFallback: false,+ ),+ ),+ );+ } else if (numberOfFaces == 2) {+ return ClipOval(+ child: Row(+ children: [+ SizedBox(+ width: kFilterChipHeight / 2,+ height: kFilterChipHeight,+ child: PersonFaceWidget(+ faceFilters.first.faceFile,+ personId: faceFilters.first.personId,+ clusterID: faceFilters.first.clusterId,+ thumbnailFallback: false,+ ),+ ),+ const SizedBox(width: 1),+ SizedBox(+ width: kFilterChipHeight / 2,+ height: kFilterChipHeight,+ child: PersonFaceWidget(+ faceFilters.last.faceFile,+ personId: faceFilters.last.personId,+ clusterID: faceFilters.last.clusterId,+ thumbnailFallback: false,+ ),+ ),+ ],+ ),+ );+ } else if (faceFilters.length == 3) {+ return ClipOval(+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox(+ height: kFilterChipHeight,+ width: kFilterChipHeight / 2 - 0.5,+ child: PersonFaceWidget(+ faceFilters[0].faceFile,+ personId: faceFilters[0].personId,+ clusterID: faceFilters[0].clusterId,+ thumbnailFallback: false,+ ),+ ),+ const SizedBox(width: 1),+ Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox(+ width: kFilterChipHeight / 2 - 0.5,+ height: kFilterChipHeight / 2 - 0.5,+ child: ClipRRect(+ borderRadius: const BorderRadius.only(+ bottomLeft: Radius.circular(1),+ ),+ child: PersonFaceWidget(+ faceFilters[1].faceFile,+ personId: faceFilters[1].personId,+ clusterID: faceFilters[1].clusterId,+ thumbnailFallback: false,+ ),+ ),+ ),+ const SizedBox(height: 1),+ SizedBox(+ width: kFilterChipHeight / 2 - 0.5,+ height: kFilterChipHeight / 2 - 0.5,+ child: ClipRRect(+ borderRadius: const BorderRadius.only(+ topLeft: Radius.circular(1),+ ),+ child: PersonFaceWidget(+ faceFilters[2].faceFile,+ personId: faceFilters[2].personId,+ clusterID: faceFilters[2].clusterId,+ thumbnailFallback: false,+ ),+ ),+ ),+ ],+ ),+ ],+ ),+ );+ } else {+ return ClipOval(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox(+ width: kFilterChipHeight / 2 - 0.5,+ height: kFilterChipHeight / 2 - 0.5,+ child: ClipRRect(+ borderRadius: const BorderRadius.only(+ bottomRight: Radius.circular(1),+ ),+ child: PersonFaceWidget(+ faceFilters[0].faceFile,+ personId: faceFilters[0].personId,+ clusterID: faceFilters[0].clusterId,+ thumbnailFallback: false,+ ),+ ),+ ),+ const SizedBox(width: 1),+ SizedBox(+ width: kFilterChipHeight / 2 - 0.5,+ height: kFilterChipHeight / 2 - 0.5,+ child: ClipRRect(+ borderRadius: const BorderRadius.only(+ bottomLeft: Radius.circular(1),+ ),+ child: PersonFaceWidget(+ faceFilters[1].faceFile,+ personId: faceFilters[1].personId,+ clusterID: faceFilters[1].clusterId,+ thumbnailFallback: false,+ ),+ ),+ ),+ ],+ ),+ const SizedBox(height: 1),+ Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox(+ width: kFilterChipHeight / 2 - 0.5,+ height: kFilterChipHeight / 2 - 0.5,+ child: ClipRRect(+ borderRadius: const BorderRadius.only(+ topRight: Radius.circular(1),+ ),+ child: PersonFaceWidget(+ faceFilters[2].faceFile,+ personId: faceFilters[2].personId,+ clusterID: faceFilters[2].clusterId,+ thumbnailFallback: false,+ ),+ ),+ ),+ const SizedBox(width: 1),+ SizedBox(+ width: kFilterChipHeight / 2 - 0.5,+ height: kFilterChipHeight / 2 - 0.5,+ child: ClipRRect(+ borderRadius: const BorderRadius.only(+ topLeft: Radius.circular(1),+ ),+ child: PersonFaceWidget(+ faceFilters[3].faceFile,+ personId: faceFilters[3].personId,+ clusterID: faceFilters[3].clusterId,+ thumbnailFallback: false,+ ),+ ),+ ),+ ],+ ),+ ],+ ),+ );+ }}}diff --git a/mobile/lib/ui/viewer/hierarchicial_search/filter_options_bottom_sheet.dart b/mobile/lib/ui/viewer/hierarchicial_search/filter_options_bottom_sheet.dartindex dda5c35efc..b68e1ecca7 100644--- a/mobile/lib/ui/viewer/hierarchicial_search/filter_options_bottom_sheet.dart+++ b/mobile/lib/ui/viewer/hierarchicial_search/filter_options_bottom_sheet.dart@@ -69,8 +69,7 @@ class _FilterOptionsBottomSheetState extends State<FilterOptionsBottomSheet> {)else if (filter is OnlyThemFilter)OnlyThemFilterChip(- personIds: filter.personIDs,- clusterIds: filter.clusterIDs,+ faceFilters: filter.faceFilters,apply: () {widget.searchFilterDataProvider.applyFilters([filter]);diff --git a/mobile/lib/ui/viewer/hierarchicial_search/recommended_filters.dart b/mobile/lib/ui/viewer/hierarchicial_search/recommended_filters.dartindex b5e86110cf..3f929999f5 100644--- a/mobile/lib/ui/viewer/hierarchicial_search/recommended_filters.dart+++ b/mobile/lib/ui/viewer/hierarchicial_search/recommended_filters.dart@@ -130,8 +130,7 @@ class _RecommendedFiltersState extends State<RecommendedFilters> {): filter is OnlyThemFilter? OnlyThemFilterChip(- personIds: filter.personIDs,- clusterIds: filter.clusterIDs,+ faceFilters: filter.faceFilters,apply: () {_searchFilterDataProvider.applyFilters([filter]);},