Skip to content

Commit

Permalink
scan classic only on android, ble on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Feb 3, 2025
1 parent 90a9698 commit 19bef28
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions lib/ui/setup/pair_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:cobble/domain/connection/connection_state_provider.dart';
import 'package:cobble/domain/connection/scan_provider.dart';
import 'package:cobble/domain/entities/pebble_scan_device.dart';
Expand Down Expand Up @@ -97,7 +99,11 @@ class PairPage extends HookConsumerWidget implements CobbleScreen {
}, [scan, /*pair,*/ connectionState]);

useEffect(() {
scanControl.startBleScan();
if (Platform.isIOS) {
scanControl.startBleScan();
} else {
scanControl.startClassicScan();
}
return null;
}, []);

Expand All @@ -115,6 +121,14 @@ class PairPage extends HookConsumerWidget implements CobbleScreen {
}
}

_refreshDevices() {
if (Platform.isIOS) {
_refreshDevicesBle();
} else {
_refreshDevicesClassic();
}
}

_targetPebble(PebbleScanDevice dev) async {
StringWrapper addressWrapper = StringWrapper();
addressWrapper.value = dev.address;
Expand Down Expand Up @@ -195,20 +209,20 @@ class PairPage extends HookConsumerWidget implements CobbleScreen {
)
.toList(),
if (!scan.scanning) ...[
Padding(
/*Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0),
child: CobbleButton(
outlined: false,
label: tr.pairPage.searchAgain.ble,
onPressed: connectionState.isConnected == true || connectionState.isConnecting == true ? null : _refreshDevicesBle,
),
),
),*/
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0),
child: CobbleButton(
outlined: false,
label: tr.pairPage.searchAgain.classic,
onPressed: connectionState.isConnected == true || connectionState.isConnecting == true ? null : _refreshDevicesClassic,
label: Platform.isIOS ? tr.pairPage.searchAgain.ble : tr.pairPage.searchAgain.classic,
onPressed: connectionState.isConnected == true || connectionState.isConnecting == true ? null : _refreshDevices,
),
),
],
Expand Down

0 comments on commit 19bef28

Please sign in to comment.