changing gpx color

This commit is contained in:
Fedor Katurov 2020-01-24 17:37:49 +07:00
parent 871f9bb8a2
commit c4aede5833
3 changed files with 16 additions and 4 deletions

View file

@ -66,6 +66,16 @@ const GpxDialogUnconnected: FC<Props> = ({
[gpx, editorSetGpx]
);
const onRouteColor = useCallback(
index => {
if (!gpx.enabled) return;
editorSetGpx({
list: gpx.list.map((el, i) => (i !== index ? el : { ...el, color: getRandomColor() })),
});
},
[gpx, editorSetGpx]
);
const toggleGpx = useCallback(() => {
editorSetGpx({ enabled: !gpx.enabled });
}, [gpx, editorSetGpx]);
@ -83,7 +93,7 @@ const GpxDialogUnconnected: FC<Props> = ({
const addCurrent = useCallback(() => {
if (!route.length) return;
const { path } = getUrlData()
const { path } = getUrlData();
editorSetGpx({
list: [
@ -115,6 +125,7 @@ const GpxDialogUnconnected: FC<Props> = ({
onRouteDrop={onRouteDrop}
onFocusRoute={onFocusRoute}
onRouteToggle={onRouteToggle}
onRouteColor={onRouteColor}
/>
))}