Skip to content

Commit c19345c

Browse files
committed
color wifiicon in selector
1 parent 6376ed2 commit c19345c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

interface/src/framework/network/WiFiNetworkSelector.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import LockIcon from '@mui/icons-material/Lock';
22
import LockOpenIcon from '@mui/icons-material/LockOpen';
33
import WifiIcon from '@mui/icons-material/Wifi';
4-
import { Avatar, Badge, List, ListItem, ListItemAvatar, ListItemIcon, ListItemText } from '@mui/material';
4+
import { Avatar, Badge, List, ListItem, ListItemAvatar, ListItemIcon, ListItemText, useTheme } from '@mui/material';
55
import { useContext } from 'react';
66

77
import { WiFiConnectionContext } from './WiFiConnectionContext';
8+
import type { Theme } from '@mui/material';
89
import type { FC } from 'react';
910
import type { WiFiNetwork, WiFiNetworkList } from 'types';
1011
import { MessageBox } from 'components';
@@ -42,8 +43,18 @@ export const networkSecurityMode = ({ encryption_type }: WiFiNetwork) => {
4243
}
4344
};
4445

46+
const networkQualityHighlight = ({ rssi }: WiFiNetwork, theme: Theme) => {
47+
if (rssi <= -85) {
48+
return theme.palette.error.main;
49+
} else if (rssi <= -75) {
50+
return theme.palette.warning.main;
51+
}
52+
return theme.palette.success.main;
53+
};
54+
4555
const WiFiNetworkSelector: FC<WiFiNetworkSelectorProps> = ({ networkList }) => {
4656
const { LL } = useI18nContext();
57+
const theme = useTheme();
4758

4859
const wifiConnectionContext = useContext(WiFiConnectionContext);
4960

@@ -57,8 +68,8 @@ const WiFiNetworkSelector: FC<WiFiNetworkSelectorProps> = ({ networkList }) => {
5768
secondary={'Security: ' + networkSecurityMode(network) + ', Ch: ' + network.channel}
5869
/>
5970
<ListItemIcon>
60-
<Badge badgeContent={network.rssi + 'db'}>
61-
<WifiIcon />
71+
<Badge badgeContent={network.rssi + 'dBm'}>
72+
<WifiIcon sx={{ color: networkQualityHighlight(network, theme) }} />
6273
</Badge>
6374
</ListItemIcon>
6475
</ListItem>

0 commit comments

Comments
 (0)