Merge pull request #629 from ericszimmermann/ez_filter_online_map

Add online map filtering
This commit is contained in:
zjs81 authored and GitHub committed 2026-11-03 09:10:24 -07:00
commit 5ef2c2cd7d
27 files changed
+423 -24

No files matched your search

+3
View File
@@ -604,6 +604,8 @@
"appSettings_showChatNodesSubtitle": "Display chat nodes on the map",
"appSettings_showOtherNodes": "Show Other Nodes",
"appSettings_showOtherNodesSubtitle": "Display other node types on the map",
"appSettings_showOnlineLinks": "Show Online Map Connections",
"appSettings_showOnlineLinksSubtitle": "Display connection lines between nodes from the online map",
"appSettings_timeFilter": "Time Filter",
"appSettings_timeFilterShowAll": "Show all nodes",
"appSettings_timeFilterShowLast": "Show nodes from last {hours} hours",
@@ -1398,6 +1400,7 @@
"map_chatNodes": "Chat Nodes",
"map_repeaters": "Repeaters",
"map_otherNodes": "Other Nodes",
"map_showOnlineLinks": "Show Online Map Connections",
"map_showOverlaps": "Repeater Key Overlaps",
"map_keyPrefix": "Key Prefix",
"map_filterByKeyPrefix": "Filter by key prefix",
+18
View File
@@ -2566,6 +2566,18 @@ abstract class AppLocalizations {
/// **'Display other node types on the map'**
String get appSettings_showOtherNodesSubtitle;
/// No description provided for @appSettings_showOnlineLinks.
///
/// In en, this message translates to:
/// **'Show Online Map Connections'**
String get appSettings_showOnlineLinks;
/// No description provided for @appSettings_showOnlineLinksSubtitle.
///
/// In en, this message translates to:
/// **'Display connection lines between nodes from the online map'**
String get appSettings_showOnlineLinksSubtitle;
/// No description provided for @appSettings_timeFilter.
///
/// In en, this message translates to:
@@ -4774,6 +4786,12 @@ abstract class AppLocalizations {
/// **'Other Nodes'**
String get map_otherNodes;
/// No description provided for @map_showOnlineLinks.
///
/// In en, this message translates to:
/// **'Show Online Map Connections'**
String get map_showOnlineLinks;
/// No description provided for @map_showOverlaps.
///
/// In en, this message translates to:
+10
View File
@@ -1420,6 +1420,13 @@ class AppLocalizationsBg extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Покажи други типове възли на картата';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Филтриране по време';
@@ -2698,6 +2705,9 @@ class AppLocalizationsBg extends AppLocalizations {
@override
String get map_otherNodes => 'Други възли';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Покриване на ключа на повтаряча';
+10
View File
@@ -1418,6 +1418,13 @@ class AppLocalizationsDe extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Andere Knotentypen auf der Karte anzeigen';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Zeitfilter';
@@ -2697,6 +2704,9 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get map_otherNodes => 'Andere Knoten';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Repeater-Schlüsselüberlappungen';
+10
View File
@@ -1395,6 +1395,13 @@ class AppLocalizationsEn extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Display other node types on the map';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Time Filter';
@@ -2656,6 +2663,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get map_otherNodes => 'Other Nodes';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Repeater Key Overlaps';
+10
View File
@@ -1409,6 +1409,13 @@ class AppLocalizationsEs extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Mostrar otros tipos de nodo en el mapa';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Filtro de tiempo';
@@ -2687,6 +2694,9 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get map_otherNodes => 'Otros nodos';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Superposiciones de tecla repetidora';
+10
View File
@@ -1417,6 +1417,13 @@ class AppLocalizationsFr extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Afficher d\'autres types de nœuds sur la carte';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Filtre du temps';
@@ -2695,6 +2702,9 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get map_otherNodes => 'Autres nœuds';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Chevauchements de clés de répéteur';
+10
View File
@@ -1407,6 +1407,13 @@ class AppLocalizationsHu extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Más csomóponttípusok megjelenítése a térképen';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Időszűrő';
@@ -2685,6 +2692,9 @@ class AppLocalizationsHu extends AppLocalizations {
@override
String get map_otherNodes => 'Egyéb csomópontok';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Repeater Key átfedések';
+10
View File
@@ -1418,6 +1418,13 @@ class AppLocalizationsIt extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Mostra altri tipi di nodo sulla mappa';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Filtro Temporale';
@@ -2696,6 +2703,9 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get map_otherNodes => 'Altri nodi';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Sovrapposizioni chiave ripetitore';
+10
View File
@@ -1338,6 +1338,13 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get appSettings_showOtherNodesSubtitle => '地図上に、他のノードの種類を表示する';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => '時間フィルター';
@@ -2576,6 +2583,9 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get map_otherNodes => 'その他のノード';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'リピータキーの重複';
+10
View File
@@ -1343,6 +1343,13 @@ class AppLocalizationsKo extends AppLocalizations {
@override
String get appSettings_showOtherNodesSubtitle => '지도에 다른 노드 유형을 표시';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => '시간 필터';
@@ -2580,6 +2587,9 @@ class AppLocalizationsKo extends AppLocalizations {
@override
String get map_otherNodes => '다른 노드';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => '반복 키 중복';
+10
View File
@@ -1408,6 +1408,13 @@ class AppLocalizationsNl extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Toon andere nodetypes op de kaart';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Filter op tijd';
@@ -2679,6 +2686,9 @@ class AppLocalizationsNl extends AppLocalizations {
@override
String get map_otherNodes => 'Andere Nodes';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Overlappende repeatersleutels';
+10
View File
@@ -1422,6 +1422,13 @@ class AppLocalizationsPl extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Wyświetl inne typy węzłów na mapie';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Filtrowanie Czasu';
@@ -2712,6 +2719,9 @@ class AppLocalizationsPl extends AppLocalizations {
@override
String get map_otherNodes => 'Inne węzły';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Nakładające się klucze przekaźników';
+10
View File
@@ -1412,6 +1412,13 @@ class AppLocalizationsPt extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Exibir outros tipos de nó no mapa';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Filtro de Tempo';
@@ -2690,6 +2697,9 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get map_otherNodes => 'Outros Nós';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Sobreposições da Chave Repeater';
+10
View File
@@ -1418,6 +1418,13 @@ class AppLocalizationsRu extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Отображать другие типы нод на карте';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Фильтр по времени';
@@ -2696,6 +2703,9 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get map_otherNodes => 'Другие ноды';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Перекрытия ключа повтора';
+10
View File
@@ -1408,6 +1408,13 @@ class AppLocalizationsSk extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Zobraziť ostatné typy uzlov na mape';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Časový filter';
@@ -2687,6 +2694,9 @@ class AppLocalizationsSk extends AppLocalizations {
@override
String get map_otherNodes => 'Ostatné uzly';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Prekrývanie opakovača kľúča';
+10
View File
@@ -1406,6 +1406,13 @@ class AppLocalizationsSl extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Pokaži druge vrste naprav na zemljevidu.';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Filter po času';
@@ -2678,6 +2685,9 @@ class AppLocalizationsSl extends AppLocalizations {
@override
String get map_otherNodes => 'Druge vozlišča';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Prekrivanje ključa ponovnega predvajanja';
+10
View File
@@ -1393,6 +1393,13 @@ class AppLocalizationsSv extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Visa andra nodtyper på kartan';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Tidsfilter';
@@ -2664,6 +2671,9 @@ class AppLocalizationsSv extends AppLocalizations {
@override
String get map_otherNodes => 'Andra noder';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Repeater-nyckelöverlappningar';
+10
View File
@@ -1410,6 +1410,13 @@ class AppLocalizationsUk extends AppLocalizations {
String get appSettings_showOtherNodesSubtitle =>
'Відображати інші типи вузлів на карті';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => 'Фільтр часу';
@@ -2688,6 +2695,9 @@ class AppLocalizationsUk extends AppLocalizations {
@override
String get map_otherNodes => 'Інші вузли';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => 'Перекриття ключів ретрансляторів';
+10
View File
@@ -1320,6 +1320,13 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get appSettings_showOtherNodesSubtitle => '在地图上显示其他节点类型';
@override
String get appSettings_showOnlineLinks => 'Show Online Map Connections';
@override
String get appSettings_showOnlineLinksSubtitle =>
'Display connection lines between nodes from the online map';
@override
String get appSettings_timeFilter => '时间过滤器';
@@ -2540,6 +2547,9 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get map_otherNodes => '其他节点';
@override
String get map_showOnlineLinks => 'Show Online Map Connections';
@override
String get map_showOverlaps => '重复键重叠';
+6
View File
@@ -102,6 +102,7 @@ class AppSettings {
final bool mapShowRepeaters;
final bool mapShowChatNodes;
final bool mapShowOtherNodes;
final bool mapShowOnlineLinks;
final bool mapShowOverlaps;
final double mapTimeFilterHours; // 0 = all time
final bool mapKeyPrefixEnabled;
@@ -254,6 +255,7 @@ class AppSettings {
this.mapShowRepeaters = true,
this.mapShowChatNodes = true,
this.mapShowOtherNodes = true,
this.mapShowOnlineLinks = true,
this.mapShowOverlaps = false,
this.mapTimeFilterHours = 168,
this.mapKeyPrefixEnabled = false,
@@ -349,6 +351,7 @@ class AppSettings {
'map_show_repeaters': mapShowRepeaters,
'map_show_chat_nodes': mapShowChatNodes,
'map_show_other_nodes': mapShowOtherNodes,
'map_show_online_links': mapShowOnlineLinks,
'map_show_overlaps': mapShowOverlaps,
'map_time_filter_hours': mapTimeFilterHours,
'map_key_prefix_enabled': mapKeyPrefixEnabled,
@@ -481,6 +484,7 @@ class AppSettings {
mapShowRepeaters: json['map_show_repeaters'] as bool? ?? true,
mapShowChatNodes: json['map_show_chat_nodes'] as bool? ?? true,
mapShowOtherNodes: json['map_show_other_nodes'] as bool? ?? true,
mapShowOnlineLinks: json['map_show_online_links'] as bool? ?? true,
mapShowOverlaps: json['map_show_overlaps'] as bool? ?? false,
mapTimeFilterHours:
(json['map_time_filter_hours'] as num?)?.toDouble() ?? 168,
@@ -648,6 +652,7 @@ class AppSettings {
bool? mapShowRepeaters,
bool? mapShowChatNodes,
bool? mapShowOtherNodes,
bool? mapShowOnlineLinks,
bool? mapShowOverlaps,
double? mapTimeFilterHours,
bool? mapKeyPrefixEnabled,
@@ -727,6 +732,7 @@ class AppSettings {
mapShowRepeaters: mapShowRepeaters ?? this.mapShowRepeaters,
mapShowChatNodes: mapShowChatNodes ?? this.mapShowChatNodes,
mapShowOtherNodes: mapShowOtherNodes ?? this.mapShowOtherNodes,
mapShowOnlineLinks: mapShowOnlineLinks ?? this.mapShowOnlineLinks,
mapShowOverlaps: mapShowOverlaps ?? this.mapShowOverlaps,
mapTimeFilterHours: mapTimeFilterHours ?? this.mapTimeFilterHours,
mapKeyPrefixEnabled: mapKeyPrefixEnabled ?? this.mapKeyPrefixEnabled,
+9
View File
@@ -1130,6 +1130,15 @@ class AppSettingsScreen extends StatelessWidget {
onChanged: (value) => settingsService.setMapShowOtherNodes(value),
),
const Divider(height: 1, indent: 16),
SwitchListTile(
contentPadding: tilePadding,
secondary: const Icon(Icons.polyline_outlined, size: 24),
title: Text(context.l10n.appSettings_showOnlineLinks),
subtitle: Text(context.l10n.appSettings_showOnlineLinksSubtitle),
value: settings.mapShowOnlineLinks,
onChanged: (value) => settingsService.setMapShowOnlineLinks(value),
),
const Divider(height: 1, indent: 16),
MeshNavTile(
icon: Icons.timer_outlined,
title: context.l10n.appSettings_timeFilter,
+62 -1
View File
@@ -237,7 +237,13 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
void _requestOnlineData() {
try {
_online.requestBounds(_mapController.camera.visibleBounds);
_online.requestBounds(
_mapController.camera.visibleBounds,
fetchLinks: context
.read<AppSettingsService>()
.settings
.mapShowOnlineLinks,
);
} catch (_) {
// Camera not ready yet; onMapReady requests once it is.
}
@@ -714,6 +720,11 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
contactsWithLocation,
settings,
);
final visibleOnlineRepeaters = _filterOnlineRepeatersBySettings(
_online.repeaters,
settings,
showGuessedLocations: settings.mapShowGuessedLocations,
);
Contact? selectedContact;
if (_selectedKey != null) {
for (final c in allContacts) {
@@ -937,6 +948,8 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
if (showOnline)
...buildNetworkMapOnlineLayers(
controller: _online,
repeaters: visibleOnlineRepeaters,
showLinks: settings.mapShowOnlineLinks,
localMarkerKeys: showLocal
? {for (final c in visibleContacts) c.publicKeyHex}
: const {},
@@ -1425,6 +1438,43 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
return filtered;
}
List<NetworkMapRepeater> _filterOnlineRepeatersBySettings(
List<NetworkMapRepeater> repeaters,
dynamic settings, {
required bool showGuessedLocations,
}) {
final keyPrefix = settings.mapKeyPrefix.trim().toLowerCase();
final now = DateTime.now();
return repeaters.where((repeater) {
if (repeater.isEstimated && !showGuessedLocations) return false;
final typeVisible = switch (repeater.type) {
advTypeRepeater => settings.mapShowRepeaters,
advTypeChat => settings.mapShowChatNodes,
_ => settings.mapShowOtherNodes,
};
if (!typeVisible) return false;
final freshnessVisible = switch (_freshness) {
_Freshness.all => true,
_Freshness.online => repeater.status == NetworkMapRepeaterStatus.active,
_Freshness.recent => repeater.status != NetworkMapRepeaterStatus.stale,
_Freshness.stale => repeater.status == NetworkMapRepeaterStatus.stale,
};
if (!freshnessVisible) return false;
if (settings.mapTimeFilterHours > 0 && repeater.lastSeen != null) {
final age = now.difference(repeater.lastSeen!).inHours;
if (age > settings.mapTimeFilterHours) return false;
}
return !settings.mapKeyPrefixEnabled ||
keyPrefix.isEmpty ||
repeater.key.toLowerCase().startsWith(keyPrefix);
}).toList();
}
List<Marker> _buildNodeMarkers(
List<Contact> contacts,
settings, {
@@ -2116,6 +2166,7 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
!settings.mapShowChatNodes,
!settings.mapShowRepeaters,
!settings.mapShowOtherNodes,
!settings.mapShowOnlineLinks,
settings.mapKeyPrefixEnabled,
].where((active) => active).length;
@@ -3564,6 +3615,8 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
BuildContext context,
AppSettingsService settingsService,
) {
final showOnlineFilters =
context.read<UiViewStateService>().mapSource != MapSourceOption.local;
showMeshSheet(
context,
builder: (sheetContext) => StatefulBuilder(
@@ -3694,6 +3747,14 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
onChanged: (value) =>
service.setMapShowOtherNodes(value),
),
if (showOnlineFilters)
SwitchListTile(
title: Text(sheetContext.l10n.map_showOnlineLinks),
value: settings.mapShowOnlineLinks,
dense: true,
onChanged: (value) =>
service.setMapShowOnlineLinks(value),
),
SectionHeader(sheetContext.l10n.map_markers),
SwitchListTile(
title: Text(sheetContext.l10n.map_showSharedMarkers),
+4
View File
@@ -95,6 +95,10 @@ class AppSettingsService extends ChangeNotifier {
await updateSettings(_settings.copyWith(mapShowOtherNodes: value));
}
Future<void> setMapShowOnlineLinks(bool value) async {
await updateSettings(_settings.copyWith(mapShowOnlineLinks: value));
}
Future<void> setMapShowOverlaps(bool value) async {
await updateSettings(_settings.copyWith(mapShowOverlaps: value));
}
+31 -22
View File
@@ -40,9 +40,9 @@ class NetworkMapOnlineController extends ChangeNotifier {
List<NetworkMapLink> get links => _links;
NetworkMapLoadState get state => _state;
void requestBounds(LatLngBounds bounds) {
void requestBounds(LatLngBounds bounds, {bool fetchLinks = true}) {
_timer?.cancel();
_timer = Timer(_debounce, () => _load(bounds));
_timer = Timer(_debounce, () => _load(bounds, fetchLinks: fetchLinks));
}
/// Drops any pending or in-flight request (the online layer was hidden).
@@ -51,7 +51,7 @@ class NetworkMapOnlineController extends ChangeNotifier {
_generation++;
}
Future<void> _load(LatLngBounds bounds) async {
Future<void> _load(LatLngBounds bounds, {required bool fetchLinks}) async {
final boxes = NetworkMapBbox.forVisibleArea(
west: bounds.west,
south: bounds.south,
@@ -65,19 +65,21 @@ class NetworkMapOnlineController extends ChangeNotifier {
}
_setState(NetworkMapLoadState.loading);
try {
final results = await Future.wait([
Future.wait(boxes.map(_client.fetchRepeaters)),
Future.wait(boxes.map((b) => _client.fetchLinks(b))),
]);
final repeaterFuture = Future.wait(boxes.map(_client.fetchRepeaters));
final Future<List<List<NetworkMapLink>>> linkFuture = fetchLinks
? Future.wait<List<NetworkMapLink>>(
boxes.map((b) => _client.fetchLinks(b)),
)
: Future.value(const <List<NetworkMapLink>>[]);
final repeaterResults = await repeaterFuture;
final linkResults = await linkFuture;
if (_disposed || generation != _generation) return;
// Two boxes (antimeridian) can both return items on the seam.
_repeaters = {
for (final r in results[0].expand((l) => l as List<NetworkMapRepeater>))
r.key: r,
for (final r in repeaterResults.expand((l) => l)) r.key: r,
}.values.toList();
_links = {
for (final l in results[1].expand((l) => l as List<NetworkMapLink>))
'${l.a}:${l.b}': l,
for (final l in linkResults.expand((l) => l)) '${l.a}:${l.b}': l,
}.values.toList();
_setState(NetworkMapLoadState.ready);
} catch (_) {
@@ -140,20 +142,27 @@ Polyline _onlineLinkPolyline(NetworkMapLink link, {required bool simple}) {
/// their hexagon outline is added.
List<Widget> buildNetworkMapOnlineLayers({
required NetworkMapOnlineController controller,
List<NetworkMapRepeater>? repeaters,
bool showLinks = true,
required Set<String> localMarkerKeys,
required ValueChanged<NetworkMapRepeater> onTap,
}) {
final repeaters = controller.repeaters;
final links = controller.links;
final dropHexagons = repeaters.length > networkMapDenseNodeCount;
final visibleRepeaters = repeaters ?? controller.repeaters;
final visibleKeys = {for (final repeater in visibleRepeaters) repeater.key};
final links = [
for (final link in controller.links)
if (visibleKeys.contains(link.a) && visibleKeys.contains(link.b)) link,
];
final dropHexagons = visibleRepeaters.length > networkMapDenseNodeCount;
final simpleLines = links.length > networkMapDenseLinkCount;
return [
PolylineLayer(
polylines: [
for (final link in links)
_onlineLinkPolyline(link, simple: simpleLines),
],
),
if (showLinks)
PolylineLayer(
polylines: [
for (final link in links)
_onlineLinkPolyline(link, simple: simpleLines),
],
),
if (!dropHexagons)
GestureDetector(
onTap: () {
@@ -163,7 +172,7 @@ List<Widget> buildNetworkMapOnlineLayers({
child: PolygonLayer<NetworkMapRepeater>(
hitNotifier: controller.hitNotifier,
polygons: [
for (final repeater in repeaters)
for (final repeater in visibleRepeaters)
if (repeater.cell.boundary.length >= 3)
Polygon<NetworkMapRepeater>(
points: repeater.cell.boundary,
@@ -184,7 +193,7 @@ List<Widget> buildNetworkMapOnlineLayers({
),
MarkerLayer(
markers: [
for (final repeater in repeaters)
for (final repeater in visibleRepeaters)
if (!localMarkerKeys.contains(repeater.key))
Marker(
point: repeater.cell.center,
+7
View File
@@ -450,6 +450,13 @@ void main() {
expect(AppSettings.fromJson(saved).loadLinkImages, isFalse);
});
test('online map links default on and round-trip through JSON', () {
expect(AppSettings().mapShowOnlineLinks, isTrue);
expect(AppSettings.fromJson({}).mapShowOnlineLinks, isTrue);
final saved = AppSettings(mapShowOnlineLinks: false).toJson();
expect(AppSettings.fromJson(saved).mapShowOnlineLinks, isFalse);
});
test('show link images by default is off and round-trips', () {
expect(AppSettings().showLinkImagesByDefault, isFalse);
expect(AppSettings.fromJson({}).showLinkImagesByDefault, isFalse);
+103 -1
View File
@@ -1 +1,103 @@
{}
{
"bg": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"de": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"es": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"fr": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"hu": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"it": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"ja": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"ko": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"nl": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"pl": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"pt": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"ru": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"sk": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"sl": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"sv": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"uk": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
],
"zh": [
"appSettings_showOnlineLinks",
"appSettings_showOnlineLinksSubtitle",
"map_showOnlineLinks"
]
}