in src/bluetooth/Bluetooth.tsx [80:122]
function BluetoothList({navigation}: BluetoothListProps) {
const {colors} = useTheme();
const [isVisible, setIsVisible] = React.useState(true);
const {devices} = useBluetoothDevicesList(isVisible);
React.useEffect(() => {
const unsubscribeFocus = navigation.addListener('focus', () => {
setIsVisible(true);
});
const unsubscribeBlur = navigation.addListener('blur', () => {
setIsVisible(false);
});
return () => {
unsubscribeFocus();
unsubscribeBlur();
};
}, [navigation, setIsVisible]);
return (
<View style={styles.container}>
<FlatList<Device>
data={devices}
renderItem={({item}) => (
<BluetoothDeviceListItem
item={item}
colors={colors}
navigation={navigation}
/>
)}
onRefresh={() => IotcBleManager.getInstance().resetDeviceList()}
refreshing={devices.length === 0}
refreshControl={
<RefreshControl
refreshing={devices.length === 0}
onRefresh={() => IotcBleManager.getInstance().resetDeviceList()}
colors={[colors.text]}
/>
}
/>
</View>
);
}