import { toFixed, round } from 'common/math'; import { useBackend } from '../backend'; import { Box, Button, LabeledList, NumberInput, Section } from '../components'; import { RADIO_CHANNELS } from '../constants'; import { Window } from '../layouts'; export const Radio = (props, context) => { const { act, data } = useBackend(context); const { rawfreq, minFrequency, maxFrequency, listening, broadcasting, subspace, subspaceSwitchable, chan_list, loudspeaker, mic_cut, spk_cut, useSyndMode, } = data; const tunedChannel = RADIO_CHANNELS.find((channel) => channel.freq === Number(rawfreq)); // Calculate window height let height = 156; if (chan_list && chan_list.length > 0) { height += chan_list.length * 28 + 6; } else { height += 24; } if (subspaceSwitchable) { height += 38; } return (
toFixed(value, 1)} onDrag={(e, value) => act('setFrequency', { freq: round(value * 10), }) } /> {tunedChannel && ( [{tunedChannel.name}] )}
{(!chan_list || chan_list.length === 0) && ( No channels detected. )} {!chan_list ? null : chan_list.map((channel) => { const channeldata = RADIO_CHANNELS.find((c) => c.freq === Number(channel.freq)); let color = 'default'; if (channeldata) { color = channeldata.color; } return ( {channel.secure_channel && subspace ? (
); };