Skip to content

Commit 19bef28

Browse files
committed
scan classic only on android, ble on iOS
1 parent 90a9698 commit 19bef28

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

lib/ui/setup/pair_page.dart

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:io';
2+
13
import 'package:cobble/domain/connection/connection_state_provider.dart';
24
import 'package:cobble/domain/connection/scan_provider.dart';
35
import 'package:cobble/domain/entities/pebble_scan_device.dart';
@@ -97,7 +99,11 @@ class PairPage extends HookConsumerWidget implements CobbleScreen {
9799
}, [scan, /*pair,*/ connectionState]);
98100

99101
useEffect(() {
100-
scanControl.startBleScan();
102+
if (Platform.isIOS) {
103+
scanControl.startBleScan();
104+
} else {
105+
scanControl.startClassicScan();
106+
}
101107
return null;
102108
}, []);
103109

@@ -115,6 +121,14 @@ class PairPage extends HookConsumerWidget implements CobbleScreen {
115121
}
116122
}
117123

124+
_refreshDevices() {
125+
if (Platform.isIOS) {
126+
_refreshDevicesBle();
127+
} else {
128+
_refreshDevicesClassic();
129+
}
130+
}
131+
118132
_targetPebble(PebbleScanDevice dev) async {
119133
StringWrapper addressWrapper = StringWrapper();
120134
addressWrapper.value = dev.address;
@@ -195,20 +209,20 @@ class PairPage extends HookConsumerWidget implements CobbleScreen {
195209
)
196210
.toList(),
197211
if (!scan.scanning) ...[
198-
Padding(
212+
/*Padding(
199213
padding: const EdgeInsets.symmetric(horizontal: 32.0),
200214
child: CobbleButton(
201215
outlined: false,
202216
label: tr.pairPage.searchAgain.ble,
203217
onPressed: connectionState.isConnected == true || connectionState.isConnecting == true ? null : _refreshDevicesBle,
204218
),
205-
),
219+
),*/
206220
Padding(
207221
padding: const EdgeInsets.symmetric(horizontal: 32.0),
208222
child: CobbleButton(
209223
outlined: false,
210-
label: tr.pairPage.searchAgain.classic,
211-
onPressed: connectionState.isConnected == true || connectionState.isConnecting == true ? null : _refreshDevicesClassic,
224+
label: Platform.isIOS ? tr.pairPage.searchAgain.ble : tr.pairPage.searchAgain.classic,
225+
onPressed: connectionState.isConnected == true || connectionState.isConnecting == true ? null : _refreshDevices,
212226
),
213227
),
214228
],

0 commit comments

Comments
 (0)