mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Add transmission timing details
This commit is contained in:
@@ -21,10 +21,19 @@ class _ConnectionDialogState extends State<ConnectionDialog>
|
||||
final List<DiscoveredServer> _discoveredServers = [];
|
||||
int _scannedCount = 0;
|
||||
int _totalToScan = 0;
|
||||
String? _connectingToServerKey; // Track which server is being connected to (ip:port)
|
||||
int _lastTabIndex = 0;
|
||||
String?
|
||||
_connectingToServerKey; // Track which server is being connected to (ip:port)
|
||||
|
||||
// Named listener method for proper cleanup
|
||||
void _onTabChanged() {
|
||||
if (_tabController.index == _lastTabIndex) return;
|
||||
_lastTabIndex = _tabController.index;
|
||||
|
||||
if (_tabController.index == 0) {
|
||||
_refreshBleDevices();
|
||||
}
|
||||
|
||||
if (_tabController.index == 1) {
|
||||
// Switched to network tab
|
||||
if (_networkScanner.hasCachedResults && _discoveredServers.isEmpty) {
|
||||
@@ -47,13 +56,16 @@ class _ConnectionDialogState extends State<ConnectionDialog>
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
_connectionProvider = Provider.of<ConnectionProvider>(context, listen: false);
|
||||
_connectionProvider = Provider.of<ConnectionProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
|
||||
// Defer scan startup until after the first frame so Provider listeners
|
||||
// are not notified while this dialog is still being built.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
_connectionProvider.startScan();
|
||||
_refreshBleDevices();
|
||||
});
|
||||
|
||||
// Set up network scanner callbacks
|
||||
@@ -101,6 +113,12 @@ class _ConnectionDialogState extends State<ConnectionDialog>
|
||||
_networkScanner.scan();
|
||||
}
|
||||
|
||||
Future<void> _refreshBleDevices() async {
|
||||
await _connectionProvider.stopScan();
|
||||
if (!mounted) return;
|
||||
await _connectionProvider.startScan();
|
||||
}
|
||||
|
||||
Color _getSignalColor(int rssi) {
|
||||
if (rssi >= -60) return Colors.green;
|
||||
if (rssi >= -75) return Colors.orange;
|
||||
@@ -218,10 +236,7 @@ class _ConnectionDialogState extends State<ConnectionDialog>
|
||||
Icons.refresh,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
onPressed: () {
|
||||
connectionProvider.stopScan();
|
||||
connectionProvider.startScan();
|
||||
},
|
||||
onPressed: _refreshBleDevices,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -255,10 +270,7 @@ class _ConnectionDialogState extends State<ConnectionDialog>
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextButton.icon(
|
||||
onPressed: () {
|
||||
connectionProvider.stopScan();
|
||||
connectionProvider.startScan();
|
||||
},
|
||||
onPressed: _refreshBleDevices,
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: Text(AppLocalizations.of(context)!.scanAgain),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user