estim_control/src/page-components/state-bar/BleState.tsx
2025-02-26 05:39:36 +08:00

31 lines
901 B
TypeScript

import { useAtomValue } from 'jotai';
import { FC, useMemo } from 'react';
import { BleState } from '../../context/EstimContext';
import IconBluetooth from '../../icons/IconBluetooth';
const BleStates: FC = () => {
const ble = useAtomValue(BleState);
const bleIcon = useMemo(() => {
if (ble.ready && !ble.searching && !ble.connected) {
return 'material-symbols-light:bluetooth';
} else if (ble.ready && ble.searching) {
return 'material-symbols-light:bluetooth-searching';
} else if (ble.ready && !ble.searching && ble.connected) {
return 'material-symbols-light:bluetooth-connected';
} else {
return 'material-symbols-light:bluetooth-disabled';
}
}, [ble]);
return (
<IconBluetooth
height={16}
ready={ble.ready}
searching={ble.searching}
connected={ble.connected?.length > 0}
/>
);
};
export default BleStates;