Connect a radio: one page with Bluetooth, USB and TCP tabs

Replace the scanner, USB and TCP screens with one page and a tab for
each, so the design and the connection options are consistent. Fixes
#699, where the USB screen's Bluetooth button went back to the main
screens instead of the scanner.

The "Need a new node?" banner shows on every tab, with a close button
that hides it until the page is opened again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
celsoazevedoandClaude Opus 5.5 committed 2026-11-26 08:57:32 +00:00
1 parent 86b3e252c6
commit 9104b4a60a
60 files changed
+989 -1474

No files matched your search

+68 -66
View File
@@ -1,51 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import '../l10n/l10n.dart';
import '../theme/mesh_theme.dart';
import 'mesh_ui.dart';
import 'signal_ui.dart';
/// A MeshCard-based row for displaying a scanned BLE device.
/// Shows an AvatarCircle (router icon, deterministic hue from device name),
/// device name, mono MAC address, mono RSSI dBm, and SignalBars on the right.
/// While connecting, shows a small progress ring instead of signal bars.
/// A MeshCard row for a radio to connect to: an AvatarCircle, the name, a
/// mono id and, for a scanned BLE device, its signal ([rssi]) on the right.
/// While connecting, shows a small progress ring instead of the signal.
class DeviceTile extends StatelessWidget {
final ScanResult scanResult;
final String name;
final String? id;
final IconData icon;
final Color? color;
final int? rssi;
final VoidCallback? onTap;
final bool isConnecting;
const DeviceTile({
super.key,
required this.scanResult,
required this.name,
this.id,
required this.icon,
this.color,
this.rssi,
required this.onTap,
this.isConnecting = false,
});
@override
Widget build(BuildContext context) {
final device = scanResult.device;
final rssi = scanResult.rssi;
final name = device.platformName.isNotEmpty
? device.platformName
: scanResult.advertisementData.advName;
final displayName = name.isNotEmpty
? name
: context.l10n.common_unknownDevice;
final mac = device.remoteId.toString();
final scheme = Theme.of(context).colorScheme;
final tier = rssi >= -60
? 0
: rssi >= -70
? 1
: rssi >= -80
? 2
: rssi >= -90
? 3
: 4;
final signalUi = signalUiForStrengthTier(tier);
final trailing = isConnecting
? SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: scheme.primary,
),
)
: rssi == null
? null
: _signal(rssi!);
return MeshCard(
onTap: onTap == null
@@ -57,7 +54,7 @@ class DeviceTile extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
child: Row(
children: [
AvatarCircle(name: displayName, size: 42, icon: Icons.router),
AvatarCircle(name: name, size: 42, icon: icon, color: color),
const SizedBox(width: 12),
Expanded(
child: Column(
@@ -65,7 +62,7 @@ class DeviceTile extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
displayName,
name,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w600,
color: scheme.onSurface,
@@ -73,48 +70,53 @@ class DeviceTile extends StatelessWidget {
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 3),
Text(
mac,
style: MeshTheme.mono(
fontSize: 13,
color: scheme.onSurfaceVariant,
if (id != null) ...[
const SizedBox(height: 3),
Text(
id!,
style: MeshTheme.mono(
fontSize: 13,
color: scheme.onSurfaceVariant,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
],
),
),
const SizedBox(width: 12),
if (isConnecting)
SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: scheme.primary,
),
)
else
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Icon(signalUi.icon, size: 20, color: signalUi.color),
const SizedBox(height: 3),
Text(
'$rssi dBm',
style: MeshTheme.mono(
fontSize: 13,
fontWeight: FontWeight.w600,
color: signalUi.color,
),
),
],
),
if (trailing != null) ...[const SizedBox(width: 12), trailing],
],
),
);
}
Widget _signal(int rssi) {
final tier = rssi >= -60
? 0
: rssi >= -70
? 1
: rssi >= -80
? 2
: rssi >= -90
? 3
: 4;
final signalUi = signalUiForStrengthTier(tier);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Icon(signalUi.icon, size: 20, color: signalUi.color),
const SizedBox(height: 3),
Text(
'$rssi dBm',
style: MeshTheme.mono(
fontSize: 13,
fontWeight: FontWeight.w600,
color: signalUi.color,
),
),
],
);
}
}