Enhance path management dialog to display direct repeaters with color coding based on signal strength

This commit is contained in:
Winston Lowe
2026-02-15 12:45:43 -08:00
parent 5751cddaa1
commit 246cf99415
+36 -3
View File
@@ -133,6 +133,17 @@ class _PathManagementDialog extends StatelessWidget {
builder: (context, connector, pathService, _) { builder: (context, connector, pathService, _) {
final currentContact = _resolveContact(connector); final currentContact = _resolveContact(connector);
final paths = pathService.getRecentPaths(currentContact.publicKeyHex); final paths = pathService.getRecentPaths(currentContact.publicKeyHex);
final directRepeaters = List.of(connector.directRepeaters)
..sort((a, b) => (b.snr).compareTo(a.snr));
final directRepeater = directRepeaters.isEmpty
? null
: directRepeaters.first;
final secondDirectRepeater = directRepeaters.length < 2
? null
: directRepeaters.elementAt(1);
final thirdDirectRepeater = directRepeaters.length < 3
? null
: directRepeaters.elementAt(2);
return AlertDialog( return AlertDialog(
title: Text(l10n.chat_pathManagement), title: Text(l10n.chat_pathManagement),
@@ -174,15 +185,37 @@ class _PathManagementDialog extends StatelessWidget {
], ],
const SizedBox(height: 8), const SizedBox(height: 8),
...paths.map((path) { ...paths.map((path) {
final isDirectRepeater =
directRepeater != null &&
path.pathBytes.isNotEmpty &&
directRepeater.pubkeyFirstByte == path.pathBytes.first;
final isSecoundDirectRepeater =
secondDirectRepeater != null &&
path.pathBytes.isNotEmpty &&
secondDirectRepeater.pubkeyFirstByte ==
path.pathBytes.first;
final isThirdDirectRepeater =
thirdDirectRepeater != null &&
path.pathBytes.isNotEmpty &&
thirdDirectRepeater.pubkeyFirstByte ==
path.pathBytes.first;
Color color = Colors.grey;
if (isDirectRepeater) {
color = Colors.green;
} else if (isSecoundDirectRepeater) {
color = Colors.yellow;
} else if (isThirdDirectRepeater) {
color = Colors.red;
} else if (path.wasFloodDiscovery) {
color = Colors.blue;
}
return Card( return Card(
margin: const EdgeInsets.symmetric(vertical: 4), margin: const EdgeInsets.symmetric(vertical: 4),
child: ListTile( child: ListTile(
dense: true, dense: true,
leading: CircleAvatar( leading: CircleAvatar(
radius: 16, radius: 16,
backgroundColor: path.wasFloodDiscovery backgroundColor: color,
? Colors.blue
: Colors.green,
child: Text( child: Text(
'${path.hopCount}', '${path.hopCount}',
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),