mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-22 02:14:28 +10:00
Enhance path management dialog to display direct repeaters with color coding based on signal strength
This commit is contained in:
@@ -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),
|
||||||
|
|||||||
Reference in New Issue
Block a user