mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
linted and added greying out
This commit is contained in:
parent
9ce00556ec
commit
9332d8126f
1 changed files with 21 additions and 9 deletions
|
|
@ -44,12 +44,16 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
|||
|
||||
connector.addListener(_connectionListener);
|
||||
|
||||
_bluetoothStateSubscription =
|
||||
FlutterBluePlus.adapterState.listen((state) {
|
||||
_bluetoothStateSubscription = FlutterBluePlus.adapterState.listen((state) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_bluetoothState = state;
|
||||
});
|
||||
// Cancel scan if Bluetooth turns off while scanning
|
||||
if (state != BluetoothAdapterState.on &&
|
||||
connector.state == MeshCoreConnectionState.scanning) {
|
||||
connector.stopScan();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -94,15 +98,23 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
|||
builder: (context, connector, child) {
|
||||
final isScanning =
|
||||
connector.state == MeshCoreConnectionState.scanning;
|
||||
final isBluetoothOn = _bluetoothState == BluetoothAdapterState.on;
|
||||
|
||||
return FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
if (isScanning) {
|
||||
connector.stopScan();
|
||||
} else {
|
||||
connector.startScan();
|
||||
}
|
||||
},
|
||||
onPressed: isBluetoothOn
|
||||
? () {
|
||||
if (isScanning) {
|
||||
connector.stopScan();
|
||||
} else {
|
||||
connector.startScan();
|
||||
}
|
||||
}
|
||||
: null,
|
||||
backgroundColor: isBluetoothOn ? null : Colors.grey,
|
||||
foregroundColor: isBluetoothOn ? null : Colors.white,
|
||||
mouseCursor: isBluetoothOn
|
||||
? SystemMouseCursors.click
|
||||
: SystemMouseCursors.forbidden,
|
||||
icon: isScanning
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue