fixed query filter
This commit is contained in:
parent
54ba3c977f
commit
94b8ddc854
4 changed files with 59 additions and 42 deletions
|
@ -6,12 +6,12 @@ import 'package:outline_material_icons/outline_material_icons.dart';
|
|||
class QueryFilter extends CollectionFilter {
|
||||
static const type = 'query';
|
||||
|
||||
final String query;
|
||||
final String query, upQuery;
|
||||
|
||||
const QueryFilter(this.query);
|
||||
QueryFilter(this.query) : upQuery = query.toUpperCase();
|
||||
|
||||
@override
|
||||
bool filter(ImageEntry entry) => entry.search(query);
|
||||
bool filter(ImageEntry entry) => entry.search(upQuery);
|
||||
|
||||
@override
|
||||
bool get isUnique => false;
|
||||
|
@ -32,5 +32,5 @@ class QueryFilter extends CollectionFilter {
|
|||
}
|
||||
|
||||
@override
|
||||
int get hashCode => hashValues('MetadataFilter', query);
|
||||
int get hashCode => hashValues('QueryFilter', query);
|
||||
}
|
||||
|
|
|
@ -205,9 +205,9 @@ class ImageEntry {
|
|||
}
|
||||
|
||||
bool search(String query) {
|
||||
if (title.toLowerCase().contains(query)) return true;
|
||||
if (catalogMetadata?.xmpSubjects?.toLowerCase()?.contains(query) ?? false) return true;
|
||||
if (isLocated && addressDetails.addressLine.toLowerCase().contains(query)) return true;
|
||||
if (title?.toUpperCase()?.contains(query) ?? false) return true;
|
||||
if (catalogMetadata?.xmpSubjects?.toUpperCase()?.contains(query) ?? false) return true;
|
||||
if (addressDetails?.addressLine?.toUpperCase()?.contains(query) ?? false) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:aves/model/filters/filters.dart';
|
||||
import 'package:aves/utils/constants.dart';
|
||||
import 'package:aves/widgets/album/search/search_delegate.dart';
|
||||
import 'package:aves/widgets/common/aves_filter_chip.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:outline_material_icons/outline_material_icons.dart';
|
||||
|
@ -47,9 +46,12 @@ class ExpandableFilterRow extends StatelessWidget {
|
|||
}
|
||||
|
||||
final filtersList = filters.toList();
|
||||
final filterChips = isExpanded
|
||||
? Padding(
|
||||
final wrap = Container(
|
||||
key: ValueKey('wrap$title'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: AvesFilterChip.buttonBorderWidth / 2 + 6),
|
||||
// specify transparent as a workaround to prevent
|
||||
// chip border clipping when the floating app bar is fading
|
||||
color: Colors.transparent,
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
children: filtersList
|
||||
|
@ -59,8 +61,12 @@ class ExpandableFilterRow extends StatelessWidget {
|
|||
))
|
||||
.toList(),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
);
|
||||
final list = Container(
|
||||
key: ValueKey('list$title'),
|
||||
// specify transparent as a workaround to prevent
|
||||
// chip border clipping when the floating app bar is fading
|
||||
color: Colors.transparent,
|
||||
height: kMinInteractiveDimension,
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
|
@ -80,12 +86,22 @@ class ExpandableFilterRow extends StatelessWidget {
|
|||
itemCount: filtersList.length,
|
||||
),
|
||||
);
|
||||
final filterChips = isExpanded ? wrap : list;
|
||||
return titleRow != null
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
titleRow,
|
||||
filterChips,
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: filterChips,
|
||||
layoutBuilder: (currentChild, previousChildren) => Stack(
|
||||
children: [
|
||||
...previousChildren,
|
||||
if (currentChild != null) currentChild,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: filterChips;
|
||||
|
|
|
@ -53,7 +53,7 @@ class ImageSearchDelegate extends SearchDelegate<CollectionFilter> {
|
|||
@override
|
||||
Widget buildSuggestions(BuildContext context) {
|
||||
final source = collection.source;
|
||||
final upQuery = query.toUpperCase();
|
||||
final upQuery = query.trim().toUpperCase();
|
||||
final containQuery = (String s) => s.toUpperCase().contains(upQuery);
|
||||
return SafeArea(
|
||||
child: ValueListenableBuilder<String>(
|
||||
|
@ -98,7 +98,8 @@ class ImageSearchDelegate extends SearchDelegate<CollectionFilter> {
|
|||
|
||||
@override
|
||||
Widget buildResults(BuildContext context) {
|
||||
close(context, QueryFilter(query));
|
||||
final cleanQuery = query.trim();
|
||||
close(context, cleanQuery.isNotEmpty ? QueryFilter(cleanQuery) : null);
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue