#861 strip unlocated filter from context collection when editing location via map

This commit is contained in:
Thibault Deckers 2023-12-30 14:33:35 +01:00
parent e2cce43620
commit b57253c251
4 changed files with 19 additions and 6 deletions

View file

@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.
- Collection: allow hiding thumbnail overlay HDR icon
### Changed
- Info: strip `unlocated` filter from context collection when editing location via map
## <a id="v1.10.2"></a>[v1.10.2] - 2023-12-24
### Changed

View file

@ -15,6 +15,11 @@ class LocationFilter extends CoveredCollectionFilter {
late final String? _code;
late final EntryFilter _test;
static final unlocated = LocationFilter(LocationLevel.place, '');
static final located = unlocated.reverse();
bool get _isUnlocated => _location.isEmpty;
@override
List<Object?> get props => [level, _location, _code, reversed];
@ -23,7 +28,7 @@ class LocationFilter extends CoveredCollectionFilter {
_location = split.isNotEmpty ? split[0] : location;
_code = split.length > 1 ? split[1] : null;
if (_location.isEmpty) {
if (_isUnlocated) {
_test = (entry) => !entry.hasGps;
} else {
switch (level) {
@ -81,11 +86,11 @@ class LocationFilter extends CoveredCollectionFilter {
String get universalLabel => _location;
@override
String getLabel(BuildContext context) => _location.isEmpty ? context.l10n.filterNoLocationLabel : _location;
String getLabel(BuildContext context) => _isUnlocated ? context.l10n.filterNoLocationLabel : _location;
@override
Widget iconBuilder(BuildContext context, double size, {bool showGenericIcon = true}) {
if (_location.isEmpty) {
if (_isUnlocated) {
return Icon(AIcons.locationUnlocated, size: size);
}
switch (level) {

View file

@ -1,6 +1,7 @@
import 'package:aves/model/entry/entry.dart';
import 'package:aves/model/entry/extensions/location.dart';
import 'package:aves/model/entry/extensions/metadata_edition.dart';
import 'package:aves/model/filters/location.dart';
import 'package:aves/model/settings/enums/coordinate_format.dart';
import 'package:aves/model/settings/settings.dart';
import 'package:aves/model/source/collection_lens.dart';
@ -18,6 +19,7 @@ import 'package:aves/widgets/dialogs/item_picker.dart';
import 'package:aves/widgets/dialogs/pick_dialogs/item_pick_page.dart';
import 'package:aves/widgets/dialogs/pick_dialogs/location_pick_page.dart';
import 'package:aves_model/aves_model.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:latlong2/latlong.dart';
@ -172,8 +174,10 @@ class _EditEntryLocationDialogState extends State<EditEntryLocationDialog> {
final mapCollection = baseCollection != null
? CollectionLens(
source: baseCollection.source,
filters: baseCollection.filters,
fixedSelection: baseCollection.sortedEntries.where((entry) => entry.hasGps).toList(),
filters: {
...baseCollection.filters.whereNot((filter) => filter == LocationFilter.unlocated),
LocationFilter.located,
},
)
: null;
final latLng = await Navigator.maybeOf(context)?.push(

View file

@ -279,7 +279,7 @@ class CollectionSearchDelegate extends AvesSearchDelegate with FeedbackMixin, Va
title: context.l10n.searchMetadataSectionTitle,
filters: [
MissingFilter.date,
LocationFilter(LocationLevel.place, ''),
LocationFilter.unlocated,
MissingFilter.fineAddress,
TagFilter(''),
RatingFilter(0),