Refactor code structure for improved readability and maintainability

This commit is contained in:
Winston Lowe
2026-02-24 19:01:22 -08:00
parent c81c3efe7c
commit 77be2b8e6f
32 changed files with 187 additions and 50 deletions
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_multiAck": "Мулти-потвърди: {value}", "settings_multiAck": "Мулти-потвърди: {value}",
"settings_telemetryModeUpdated": "Режим на телеметрията е обновен", "settings_telemetryModeUpdated": "Режим на телеметрията е обновен",
"map_showOverlaps": "Покриване на ключа на повтаряча" "map_showOverlaps": "Покриване на ключа на повтаряча",
"map_runTraceWithReturnPath": "Върни се по същия път."
} }
+2 -1
View File
@@ -1970,5 +1970,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Telemetriemodus aktualisiert", "settings_telemetryModeUpdated": "Telemetriemodus aktualisiert",
"settings_multiAck": "Mehrfach-Bestätigungen: {value}", "settings_multiAck": "Mehrfach-Bestätigungen: {value}",
"map_showOverlaps": "Überlappungen der Repeater-Taste" "map_showOverlaps": "Überlappungen der Repeater-Taste",
"map_runTraceWithReturnPath": "Auf dem gleichen Pfad zurückkehren."
} }
+2 -1
View File
@@ -892,7 +892,8 @@
"map_joinRoom": "Join Room", "map_joinRoom": "Join Room",
"map_manageRepeater": "Manage Repeater", "map_manageRepeater": "Manage Repeater",
"map_tapToAdd": "Tap on nodes to add them to the path.", "map_tapToAdd": "Tap on nodes to add them to the path.",
"map_runTrace": "Run Path Trace", "map_runTrace": "Run path trace",
"map_runTraceWithReturnPath": "Return back on the same path.",
"map_removeLast": "Remove Last", "map_removeLast": "Remove Last",
"map_pathTraceCancelled": "Path trace cancelled.", "map_pathTraceCancelled": "Path trace cancelled.",
"mapCache_title": "Offline Map Cache", "mapCache_title": "Offline Map Cache",
+3 -1
View File
@@ -1969,5 +1969,7 @@
"appSettings_maxMessageRetriesSubtitle": "Número de intentos de reintento antes de marcar un mensaje como fallido.", "appSettings_maxMessageRetriesSubtitle": "Número de intentos de reintento antes de marcar un mensaje como fallido.",
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Modo de telemetría actualizado", "settings_telemetryModeUpdated": "Modo de telemetría actualizado",
"settings_multiAck": "Multi-ACKs: {value}" "settings_multiAck": "Multi-ACKs: {value}",
"map_showOverlaps": "Superposiciones de tecla repetidora",
"map_runTraceWithReturnPath": "Volver atrás por el mismo camino."
} }
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_multiAck": "Multi-ACKs : {value}", "settings_multiAck": "Multi-ACKs : {value}",
"settings_telemetryModeUpdated": "Le mode télémétrie a été mis à jour", "settings_telemetryModeUpdated": "Le mode télémétrie a été mis à jour",
"map_showOverlaps": "Chevauchement de la touche répétitive" "map_showOverlaps": "Chevauchement de la touche répétitive",
"map_runTraceWithReturnPath": "Revenir sur le même chemin."
} }
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Modalità telemetria aggiornata", "settings_telemetryModeUpdated": "Modalità telemetria aggiornata",
"settings_multiAck": "Multi-ACKs: {value}", "settings_multiAck": "Multi-ACKs: {value}",
"map_showOverlaps": "Sovrapposizioni della chiave ripetitore" "map_showOverlaps": "Sovrapposizioni della chiave ripetitore",
"map_runTraceWithReturnPath": "Tornare indietro sullo stesso percorso"
} }
+7 -1
View File
@@ -3139,9 +3139,15 @@ abstract class AppLocalizations {
/// No description provided for @map_runTrace. /// No description provided for @map_runTrace.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'Run Path Trace'** /// **'Run path trace'**
String get map_runTrace; String get map_runTrace;
/// No description provided for @map_runTraceWithReturnPath.
///
/// In en, this message translates to:
/// **'Return back on the same path.'**
String get map_runTraceWithReturnPath;
/// No description provided for @map_removeLast. /// No description provided for @map_removeLast.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
+3
View File
@@ -1736,6 +1736,9 @@ class AppLocalizationsBg extends AppLocalizations {
@override @override
String get map_runTrace => 'Изпълни Път на Следване'; String get map_runTrace => 'Изпълни Път на Следване';
@override
String get map_runTraceWithReturnPath => 'Върни се по същия път.';
@override @override
String get map_removeLast => 'Премахни Последно'; String get map_removeLast => 'Премахни Последно';
+4
View File
@@ -1733,6 +1733,10 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get map_runTrace => 'Pfadverlauf ausführen'; String get map_runTrace => 'Pfadverlauf ausführen';
@override
String get map_runTraceWithReturnPath =>
'Auf dem gleichen Pfad zurückkehren.';
@override @override
String get map_removeLast => 'Letztes Entfernen'; String get map_removeLast => 'Letztes Entfernen';
+4 -1
View File
@@ -1699,7 +1699,10 @@ class AppLocalizationsEn extends AppLocalizations {
String get map_tapToAdd => 'Tap on nodes to add them to the path.'; String get map_tapToAdd => 'Tap on nodes to add them to the path.';
@override @override
String get map_runTrace => 'Run Path Trace'; String get map_runTrace => 'Run path trace';
@override
String get map_runTraceWithReturnPath => 'Return back on the same path.';
@override @override
String get map_removeLast => 'Remove Last'; String get map_removeLast => 'Remove Last';
+3
View File
@@ -1731,6 +1731,9 @@ class AppLocalizationsEs extends AppLocalizations {
@override @override
String get map_runTrace => 'Ejecutar Rastreo de Ruta'; String get map_runTrace => 'Ejecutar Rastreo de Ruta';
@override
String get map_runTraceWithReturnPath => 'Volver atrás por el mismo camino.';
@override @override
String get map_removeLast => 'Eliminar último'; String get map_removeLast => 'Eliminar último';
+3
View File
@@ -1742,6 +1742,9 @@ class AppLocalizationsFr extends AppLocalizations {
@override @override
String get map_runTrace => 'Exécuter la traçage de chemin'; String get map_runTrace => 'Exécuter la traçage de chemin';
@override
String get map_runTraceWithReturnPath => 'Revenir sur le même chemin.';
@override @override
String get map_removeLast => 'Supprimer le dernier'; String get map_removeLast => 'Supprimer le dernier';
+4
View File
@@ -1732,6 +1732,10 @@ class AppLocalizationsIt extends AppLocalizations {
@override @override
String get map_runTrace => 'Esegui Path Trace'; String get map_runTrace => 'Esegui Path Trace';
@override
String get map_runTraceWithReturnPath =>
'Tornare indietro sullo stesso percorso';
@override @override
String get map_removeLast => 'Rimuovi ultimo'; String get map_removeLast => 'Rimuovi ultimo';
+3
View File
@@ -1721,6 +1721,9 @@ class AppLocalizationsNl extends AppLocalizations {
@override @override
String get map_runTrace => 'Padeshulp traceren'; String get map_runTrace => 'Padeshulp traceren';
@override
String get map_runTraceWithReturnPath => 'Terugkeren op hetzelfde pad.';
@override @override
String get map_removeLast => 'Verwijder Laatste'; String get map_removeLast => 'Verwijder Laatste';
+3
View File
@@ -1734,6 +1734,9 @@ class AppLocalizationsPl extends AppLocalizations {
@override @override
String get map_runTrace => 'Uruchom ślad ścieżki'; String get map_runTrace => 'Uruchom ślad ścieżki';
@override
String get map_runTraceWithReturnPath => 'Wróć z powrotem tą samą ścieżką';
@override @override
String get map_removeLast => 'Usuń ostatni'; String get map_removeLast => 'Usuń ostatni';
+3
View File
@@ -1732,6 +1732,9 @@ class AppLocalizationsPt extends AppLocalizations {
@override @override
String get map_runTrace => 'Executar Traçado de Caminho'; String get map_runTrace => 'Executar Traçado de Caminho';
@override
String get map_runTraceWithReturnPath => 'Retornar ao mesmo caminho.';
@override @override
String get map_removeLast => 'Remover Último'; String get map_removeLast => 'Remover Último';
+3
View File
@@ -1735,6 +1735,9 @@ class AppLocalizationsRu extends AppLocalizations {
@override @override
String get map_runTrace => 'Запустить трассировку пути'; String get map_runTrace => 'Запустить трассировку пути';
@override
String get map_runTraceWithReturnPath => 'Вернуться обратно по тому же пути';
@override @override
String get map_removeLast => 'Удалить последний'; String get map_removeLast => 'Удалить последний';
+3
View File
@@ -1721,6 +1721,9 @@ class AppLocalizationsSk extends AppLocalizations {
@override @override
String get map_runTrace => 'Spustiť trasovaním cesty'; String get map_runTrace => 'Spustiť trasovaním cesty';
@override
String get map_runTraceWithReturnPath => 'Vráťte sa späť po tej istej ceste.';
@override @override
String get map_removeLast => 'Odstrániť posledný'; String get map_removeLast => 'Odstrániť posledný';
+3
View File
@@ -1716,6 +1716,9 @@ class AppLocalizationsSl extends AppLocalizations {
@override @override
String get map_runTrace => 'Zaženi sledenje poti'; String get map_runTrace => 'Zaženi sledenje poti';
@override
String get map_runTraceWithReturnPath => 'Vrni se nazaj po isti poti.';
@override @override
String get map_removeLast => 'Odstrani Zadnji'; String get map_removeLast => 'Odstrani Zadnji';
+3
View File
@@ -1710,6 +1710,9 @@ class AppLocalizationsSv extends AppLocalizations {
@override @override
String get map_runTrace => 'Kör spårsökning'; String get map_runTrace => 'Kör spårsökning';
@override
String get map_runTraceWithReturnPath => 'Gå tillbaka på samma väg';
@override @override
String get map_removeLast => 'Ta bort sista'; String get map_removeLast => 'Ta bort sista';
+3
View File
@@ -1730,6 +1730,9 @@ class AppLocalizationsUk extends AppLocalizations {
@override @override
String get map_runTrace => 'Виконати трасування шляху'; String get map_runTrace => 'Виконати трасування шляху';
@override
String get map_runTraceWithReturnPath => 'Повернутися назад тим же шляхом';
@override @override
String get map_removeLast => 'Видалити останній'; String get map_removeLast => 'Видалити останній';
+3
View File
@@ -1627,6 +1627,9 @@ class AppLocalizationsZh extends AppLocalizations {
@override @override
String get map_runTrace => '运行路径追踪'; String get map_runTrace => '运行路径追踪';
@override
String get map_runTraceWithReturnPath => '沿着相同的路径返回';
@override @override
String get map_removeLast => '移除最后一个'; String get map_removeLast => '移除最后一个';
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Telemetrie-modus bijgewerkt", "settings_telemetryModeUpdated": "Telemetrie-modus bijgewerkt",
"settings_multiAck": "Multi-ACKs: {value}", "settings_multiAck": "Multi-ACKs: {value}",
"map_showOverlaps": "Herhalingssleutel overlapt" "map_showOverlaps": "Herhalingssleutel overlapt",
"map_runTraceWithReturnPath": "Terugkeren op hetzelfde pad."
} }
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Tryb telemetryczny zaktualizowany", "settings_telemetryModeUpdated": "Tryb telemetryczny zaktualizowany",
"settings_multiAck": "Wiele potwierdzeń: {value}", "settings_multiAck": "Wiele potwierdzeń: {value}",
"map_showOverlaps": "Nakładające się klucze powtarzalne" "map_showOverlaps": "Nakładające się klucze powtarzalne",
"map_runTraceWithReturnPath": "Wróć z powrotem tą samą ścieżką"
} }
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Modo de telemetria atualizado", "settings_telemetryModeUpdated": "Modo de telemetria atualizado",
"settings_multiAck": "Multi-ACKs: {value}", "settings_multiAck": "Multi-ACKs: {value}",
"map_showOverlaps": "Sobreposições da Chave Repeater" "map_showOverlaps": "Sobreposições da Chave Repeater",
"map_runTraceWithReturnPath": "Retornar ao mesmo caminho."
} }
+2 -1
View File
@@ -1182,5 +1182,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Режим телеметрии обновлен", "settings_telemetryModeUpdated": "Режим телеметрии обновлен",
"settings_multiAck": "Мульти-ACK: {value}", "settings_multiAck": "Мульти-ACK: {value}",
"map_showOverlaps": "Перекрытия ключа повтора" "map_showOverlaps": "Перекрытия ключа повтора",
"map_runTraceWithReturnPath": "Вернуться обратно по тому же пути"
} }
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Režim telemetrie bol aktualizovaný", "settings_telemetryModeUpdated": "Režim telemetrie bol aktualizovaný",
"settings_multiAck": "Viaceré ACK: {value}", "settings_multiAck": "Viaceré ACK: {value}",
"map_showOverlaps": "Prekrývanie opakovača kľúča" "map_showOverlaps": "Prekrývanie opakovača kľúča",
"map_runTraceWithReturnPath": "Vráťte sa späť po tej istej ceste."
} }
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_multiAck": "Večkratni potrditvi: {value}", "settings_multiAck": "Večkratni potrditvi: {value}",
"settings_telemetryModeUpdated": "Način telemetrije posodobljen", "settings_telemetryModeUpdated": "Način telemetrije posodobljen",
"map_showOverlaps": "Prekrivanje ključa ponovnega predvajanja" "map_showOverlaps": "Prekrivanje ključa ponovnega predvajanja",
"map_runTraceWithReturnPath": "Vrni se nazaj po isti poti."
} }
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Telemetri-läge uppdaterat", "settings_telemetryModeUpdated": "Telemetri-läge uppdaterat",
"settings_multiAck": "Multi-ACKs: {value}", "settings_multiAck": "Multi-ACKs: {value}",
"map_showOverlaps": "Repeater-nyckelöverlappningar" "map_showOverlaps": "Repeater-nyckelöverlappningar",
"map_runTraceWithReturnPath": "Gå tillbaka på samma väg"
} }
+2 -1
View File
@@ -1942,5 +1942,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_telemetryModeUpdated": "Режим телеметрії оновлено", "settings_telemetryModeUpdated": "Режим телеметрії оновлено",
"settings_multiAck": "Багатократне підтвердження: {value}", "settings_multiAck": "Багатократне підтвердження: {value}",
"map_showOverlaps": "Перекриття ключа повторювача" "map_showOverlaps": "Перекриття ключа повторювача",
"map_runTraceWithReturnPath": "Повернутися назад тим же шляхом"
} }
+2 -1
View File
@@ -1947,5 +1947,6 @@
"path_routeWeight": "{weight}/{max}", "path_routeWeight": "{weight}/{max}",
"settings_multiAck": "多重ACK{value}", "settings_multiAck": "多重ACK{value}",
"settings_telemetryModeUpdated": "遥测模式已更新", "settings_telemetryModeUpdated": "遥测模式已更新",
"map_showOverlaps": "重复键重叠" "map_showOverlaps": "重复键重叠",
"map_runTraceWithReturnPath": "沿着相同的路径返回"
} }
+101 -33
View File
@@ -480,10 +480,12 @@ class _MapScreenState extends State<MapScreen> {
point: highlightPosition, point: highlightPosition,
width: 40, width: 40,
height: 40, height: 40,
child: Icon( child: IgnorePointer(
Icons.location_on_outlined, child: Icon(
color: Colors.red[600], Icons.location_on_outlined,
size: 34, color: Colors.red[600],
size: 34,
),
), ),
), ),
if (!_isBuildingPathTrace) if (!_isBuildingPathTrace)
@@ -506,28 +508,33 @@ class _MapScreenState extends State<MapScreen> {
), ),
width: 40, width: 40,
height: 40, height: 40,
child: Container( child: IgnorePointer(
padding: const EdgeInsets.all(4), ignoring: true,
decoration: BoxDecoration( child: Container(
color: Colors.teal, padding: const EdgeInsets.all(4),
shape: BoxShape.circle, decoration: BoxDecoration(
border: Border.all( color: Colors.teal,
color: Colors.white, shape: BoxShape.circle,
width: 2, border: Border.all(
), color: Colors.white,
boxShadow: [ width: 2,
BoxShadow(
color: Colors.black.withValues(alpha: 0.3),
blurRadius: 4,
offset: const Offset(0, 2),
), ),
], boxShadow: [
), BoxShadow(
alignment: Alignment.center, color: Colors.black.withValues(
child: const Icon( alpha: 0.3,
Icons.person_pin_circle, ),
color: Colors.white, blurRadius: 4,
size: 20, offset: const Offset(0, 2),
),
],
),
alignment: Alignment.center,
child: const Icon(
Icons.person_pin_circle,
color: Colors.white,
size: 20,
),
), ),
), ),
), ),
@@ -547,6 +554,7 @@ class _MapScreenState extends State<MapScreen> {
), ),
if (!_isBuildingPathTrace) if (!_isBuildingPathTrace)
_buildLegend( _buildLegend(
contacts,
contactsWithLocation, contactsWithLocation,
settings, settings,
sharedMarkers.length, sharedMarkers.length,
@@ -832,13 +840,16 @@ class _MapScreenState extends State<MapScreen> {
List<Contact> _filterContactsBySettings( List<Contact> _filterContactsBySettings(
List<Contact> contacts, List<Contact> contacts,
dynamic settings, dynamic settings, {
) { bool noLocations = false,
}) {
List<Contact> filtered = []; List<Contact> filtered = [];
bool addContact = false; bool addContact = false;
for (final contact in contacts) { for (final contact in contacts) {
addContact = false; addContact = false;
if (!contact.hasLocation) continue; if (!contact.hasLocation && !noLocations) {
continue;
}
// Apply node type filters // Apply node type filters
if (contact.type == advTypeRepeater && if (contact.type == advTypeRepeater &&
@@ -1012,17 +1023,25 @@ class _MapScreenState extends State<MapScreen> {
} }
Widget _buildLegend( Widget _buildLegend(
List<Contact> contacts,
List<Contact> contactsWithLocation, List<Contact> contactsWithLocation,
settings, settings,
int markerCount, int markerCount,
int guessedCount, int guessedCount,
) { ) {
final filteredContacts = _filterContactsBySettings( final filteredContacts = _filterContactsBySettings(
contactsWithLocation, contacts,
settings, settings,
noLocations: false,
);
final filteredContactsAll = _filterContactsBySettings(
contacts,
settings,
noLocations: true,
); );
final nodeCount = filteredContacts.length; final nodeCount = filteredContacts.length;
final nodeCountAll = filteredContactsAll.length;
return Positioned( return Positioned(
top: 16, top: 16,
@@ -1058,6 +1077,54 @@ class _MapScreenState extends State<MapScreen> {
fontSize: 14, fontSize: 14,
), ),
), ),
Row(
children: [
Icon(
Icons.location_on,
size: 16,
color: Colors.grey,
),
Text(
": $nodeCount",
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
],
),
Row(
children: [
const Icon(
Icons.wrong_location,
size: 16,
color: Colors.grey,
),
Text(
": ${nodeCountAll - nodeCount}",
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
],
),
Row(
children: [
const Icon(
Icons.add_outlined,
size: 16,
color: Colors.grey,
),
Text(
": $nodeCountAll",
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
],
),
Text( Text(
context.l10n.map_pinsCount(markerCount), context.l10n.map_pinsCount(markerCount),
style: const TextStyle( style: const TextStyle(
@@ -2137,7 +2204,7 @@ class _MapScreenState extends State<MapScreen> {
_isBuildingPathTrace = false; _isBuildingPathTrace = false;
}); });
}, },
tooltip: "Path Trace", tooltip: l10n.map_runTrace,
icon: const Icon(Icons.arrow_forward_outlined), icon: const Icon(Icons.arrow_forward_outlined),
), ),
if (_pathTrace.isNotEmpty) if (_pathTrace.isNotEmpty)
@@ -2157,14 +2224,14 @@ class _MapScreenState extends State<MapScreen> {
_isBuildingPathTrace = false; _isBuildingPathTrace = false;
}); });
}, },
tooltip: "Build Return Path", tooltip: l10n.map_runTraceWithReturnPath,
icon: const Icon(Icons.replay), icon: const Icon(Icons.replay),
), ),
if (_pathTrace.isNotEmpty) if (_pathTrace.isNotEmpty)
IconButton( IconButton(
onPressed: _removePath, onPressed: _removePath,
tooltip: "Remove Last Point", tooltip: l10n.map_removeLast,
icon: const Icon(Icons.delete), icon: const Icon(Icons.undo),
), ),
if (_pathTrace.isEmpty) if (_pathTrace.isEmpty)
IconButton( IconButton(
@@ -2179,6 +2246,7 @@ class _MapScreenState extends State<MapScreen> {
SnackBar(content: Text(l10n.map_pathTraceCancelled)), SnackBar(content: Text(l10n.map_pathTraceCancelled)),
); );
}, },
tooltip: l10n.common_cancel,
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
), ),
], ],