|
1 | 1 | import React, { useRef, useState, useEffect } from 'react'; |
2 | | -import { Alert, ActivityIndicator, Modal, StyleSheet } from 'react-native'; |
| 2 | +import { Alert, ActivityIndicator, Modal, Platform, StyleSheet } from 'react-native'; |
3 | 3 | import AsyncStorage from '@react-native-async-storage/async-storage'; |
4 | 4 | import { |
5 | 5 | FxArrowLeftIcon, |
@@ -67,6 +67,7 @@ export const BluetoothCommandsScreen = () => { |
67 | 67 | const [securityCode, setSecurityCode] = useState(''); |
68 | 68 | const [pendingCommand, setPendingCommand] = useState<string | null>(null); |
69 | 69 | const [showConnectHint, setShowConnectHint] = useState(false); |
| 70 | + const [connectionAttempted, setConnectionAttempted] = useState(false); |
70 | 71 | const [discoveredDevices, setDiscoveredDevices] = useState<DiscoveredDevice[]>([]); |
71 | 72 | const deviceSelectionResolverRef = useRef<((id: string | null) => void) | null>(null); |
72 | 73 | const bottomSheetRef = useRef<FxBottomSheetModalMethods>(null); |
@@ -179,6 +180,7 @@ export const BluetoothCommandsScreen = () => { |
179 | 180 | console.log('BluetoothCommands: Starting BLE connection...'); |
180 | 181 | setRunningCommand(true); |
181 | 182 | setIsConnecting(true); |
| 183 | + setConnectionAttempted(true); |
182 | 184 |
|
183 | 185 | // Add a small delay to ensure UI updates |
184 | 186 | await new Promise(resolve => setTimeout(resolve, 100)); |
@@ -373,10 +375,26 @@ export const BluetoothCommandsScreen = () => { |
373 | 375 | <FxLoadingSpinner marginLeft="4" /> |
374 | 376 | </FxBox> |
375 | 377 | ) : ( |
376 | | - <FxText variant="bodyMediumRegular"> |
377 | | - Click the plug icon in the top right corner to connect to your |
378 | | - FxBlox device using Bluetooth |
379 | | - </FxText> |
| 378 | + <> |
| 379 | + <FxText variant="bodyMediumRegular"> |
| 380 | + Click the plug icon in the top right corner to connect to your |
| 381 | + FxBlox device using Bluetooth |
| 382 | + </FxText> |
| 383 | + {Platform.OS === 'ios' && connectionAttempted && ( |
| 384 | + <FxBox |
| 385 | + marginTop="16" |
| 386 | + padding="12" |
| 387 | + borderRadius="s" |
| 388 | + backgroundColor="warningBase" |
| 389 | + > |
| 390 | + <FxText variant="bodySmallRegular" color="backgroundApp"> |
| 391 | + If your device is not found, go to iOS Settings → Bluetooth, |
| 392 | + find your Blox device (fulatower/fxblox), tap the (i) icon, |
| 393 | + and select "Forget This Device". Then try connecting again. |
| 394 | + </FxText> |
| 395 | + </FxBox> |
| 396 | + )} |
| 397 | + </> |
380 | 398 | )} |
381 | 399 | </FxBox> |
382 | 400 | ) : ( |
|
0 commit comments