feat(todo): a pin in the map's middle, and what is around it (ADR 0033, D32)

The location picker fills the screen with its map, the search floating
over it. A pin stays in the middle, lifting while the map moves, as
Molly's; where it lands the instance names the address and lists the
places around, as Threema's. That is `nearby` on the search endpoint,
for those signed in, the point neither kept nor logged, counted among
the searches: two lookups, as a plain one finds house numbers alone.

Fixes the map's credit, which overflowed a phone and was pale on white.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-05 23:42:06 +01:00
commit ce07fab193
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -40,6 +40,33 @@ class _FakePhoton implements PlaceFinder {
}
return photonAnswer(answer);
}
/// What was asked around a point: with tags for places to go, else for the
/// address.
final around_ = <({Set<String> tags, String? language})>[];
/// What Photon finds around a point.
List<Map<String, Object?>> address = const [
{'lat': 47.5, 'lon': 9.7, 'street': 'Danziger Weg', 'housenumber': '4'},
];
List<Map<String, Object?>> neighbours = const [
{'lat': 47.5, 'lon': 9.7, 'name': 'EDEKA', 'osm_value': 'supermarket'},
];
@override
Future<Map<String, Object?>> around(
PlacePoint at, {
required double radiusKm,
Set<String> tags = const {},
String? language,
required int limit,
}) async {
around_.add((tags: tags, language: language));
if (failing) {
throw const PhotonFailed('down');
}
return photonAnswer(tags.isEmpty ? address : neighbours);
}
}
Matcher _refused(String reason) =>
@ -179,6 +206,93 @@ void main() {
expect(places.first.name, 'EDEKA 0');
});
test('around a point: the address, and the places to go to', () async {
final nearby = await endpoints.search.nearby(
alice,
PlacePoint(lat: 47.5, lon: 9.7),
language: 'de',
);
expect(nearby.spot?.name, 'Danziger Weg 4');
expect(nearby.places.single.name, 'EDEKA');
expect(photon.around_.map((asked) => asked.language), ['de', 'de']);
expect(photon.around_.map((asked) => asked.tags.isEmpty), [true, false]);
});
test('around a point nothing is found, without failing', () async {
photon
..address = const []
..neighbours = const [];
final nearby = await endpoints.search.nearby(
alice,
PlacePoint(lat: 47.5, lon: 9.7),
);
expect(nearby.spot, isNull);
expect(nearby.places, isEmpty);
});
test('the places around a point are no more than a search lists', () async {
photon.neighbours = [
for (var i = 0; i < PlaceSearch.limit + 2; i++)
{'lat': 1, 'lon': 2, 'name': 'Shop $i', 'osm_value': 'bakery'},
];
final nearby = await endpoints.search.nearby(
alice,
PlacePoint(lat: 47.5, lon: 9.7),
);
expect(nearby.places, hasLength(PlaceSearch.limit));
});
test('tells nobody signed in what is around a point', () async {
await expectLater(
endpoints.search.nearby(
sessionBuilder.copyWith(
authentication: AuthenticationOverride.unauthenticated(),
),
PlacePoint(lat: 47.5, lon: 9.7),
),
throwsA(isA<ServerpodUnauthenticatedException>()),
);
expect(photon.around_, isEmpty);
});
test(
'refuses around a point off the earth, without asking Photon',
() async {
await expectLater(
endpoints.search.nearby(alice, PlacePoint(lat: 91, lon: 9.7)),
_refused('invalid'),
);
expect(photon.around_, isEmpty);
},
);
test('tells nothing around a point without a Photon', () async {
useSearch(PlaceSearch());
await expectLater(
endpoints.search.nearby(alice, PlacePoint(lat: 47.5, lon: 9.7)),
_refused('off'),
);
});
test("says Photon didn't answer around a point", () async {
photon.failing = true;
await expectLater(
endpoints.search.nearby(alice, PlacePoint(lat: 47.5, lon: 9.7)),
_refused('unreachable'),
);
});
test('a look around a point counts among the searches', () async {
for (var i = 0; i < PlaceSearch.perMinute; i++) {
await endpoints.search.nearby(alice, PlacePoint(lat: 47.5, lon: 9.7));
}
await expectLater(
endpoints.search.places(alice, 'Berlin'),
_refused('tooOften'),
);
});
test("says Photon didn't answer where it fails", () async {
photon.failing = true;
await expectLater(