-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make location sources switchable
This adds the option to disable certain location sources. See #930
- Loading branch information
1 parent
72bdf4b
commit bd6c177
Showing
12 changed files
with
192 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.location-source-selector.controls button.control.disabled { | ||
background-color: #959595; | ||
color: #3d3a3a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { useDeviceLocation } from '#context/DeviceLocation.js' | ||
import { useMapState } from '#context/MapState.js' | ||
import { | ||
LocationSource, | ||
LocationSourceLabels, | ||
} from '#map/LocationSourceLabels.js' | ||
import cx from 'classnames' | ||
import { | ||
BlendIcon, | ||
EyeOffIcon, | ||
HexagonIcon, | ||
SatelliteIcon, | ||
WifiIcon, | ||
} from 'lucide-preact' | ||
|
||
import './LocationSourceSelector.css' | ||
|
||
export const LocationSourceSelector = () => { | ||
const { enableLocation, disableLocation, state } = useMapState() | ||
const { locations } = useDeviceLocation() | ||
return ( | ||
<div class="location-source-selector controls horizontal me-3 mt-2 d-flex flex-row "> | ||
{[ | ||
LocationSource.GNSS, | ||
LocationSource.WIFI, | ||
LocationSource.MCELL, | ||
LocationSource.SCELL, | ||
].map((src) => { | ||
const disabled = | ||
locations[src] === undefined || | ||
(state?.disabledLocations?.includes(src) ?? false) | ||
const enabled = !disabled | ||
return ( | ||
<button | ||
type="button" | ||
title={`${enabled ? 'Disable' : 'Enable'} ${LocationSourceLabels.get(src)}`} | ||
onClick={() => { | ||
if (enabled) { | ||
disableLocation(src) | ||
} else { | ||
enableLocation(src) | ||
} | ||
}} | ||
class={cx(`d-flex flex-row align-items-center control`, { | ||
disabled: !enabled, | ||
})} | ||
> | ||
{enabled && ( | ||
<span> | ||
{src === LocationSource.SCELL && <HexagonIcon />} | ||
{src === LocationSource.MCELL && <BlendIcon />} | ||
{src === LocationSource.WIFI && <WifiIcon />} | ||
{src === LocationSource.GNSS && <SatelliteIcon />} | ||
</span> | ||
)} | ||
{!enabled && <EyeOffIcon />} | ||
{LocationSourceLabels.has(src) && ( | ||
<span class="ms-2 label">{LocationSourceLabels.get(src)}</span> | ||
)} | ||
</button> | ||
) | ||
})} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.