Skip to content

Commit

Permalink
#861 strip unlocated filter from context collection when editing lo…
Browse files Browse the repository at this point in the history
…cation via map
  • Loading branch information
deckerst committed Dec 30, 2023
1 parent e2cce43 commit b57253c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions lib/model/filters/location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions lib/widgets/dialogs/entry_editors/edit_location_dialog.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/search/search_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit b57253c

Please sign in to comment.