mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
Enhance path management dialog to display direct repeaters with color coding based on signal strength
This commit is contained in:
parent
5751cddaa1
commit
246cf99415
1 changed files with 36 additions and 3 deletions
|
|
@ -133,6 +133,17 @@ class _PathManagementDialog extends StatelessWidget {
|
|||
builder: (context, connector, pathService, _) {
|
||||
final currentContact = _resolveContact(connector);
|
||||
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(
|
||||
title: Text(l10n.chat_pathManagement),
|
||||
|
|
@ -174,15 +185,37 @@ class _PathManagementDialog extends StatelessWidget {
|
|||
],
|
||||
const SizedBox(height: 8),
|
||||
...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(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: ListTile(
|
||||
dense: true,
|
||||
leading: CircleAvatar(
|
||||
radius: 16,
|
||||
backgroundColor: path.wasFloodDiscovery
|
||||
? Colors.blue
|
||||
: Colors.green,
|
||||
backgroundColor: color,
|
||||
child: Text(
|
||||
'${path.hopCount}',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue