From c5cef8eeee11e36910e89814cb26d319b195520e Mon Sep 17 00:00:00 2001 From: Augustin Gjini Date: Thu, 17 Oct 2024 15:05:24 +0200 Subject: [PATCH] feat(app): improve point selection --- .../map/layers/RallyingPointsDisplayLayer.tsx | 73 +++++++++++-------- app/src/screens/publish/SelectOnMapView.tsx | 19 +---- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/app/src/components/map/layers/RallyingPointsDisplayLayer.tsx b/app/src/components/map/layers/RallyingPointsDisplayLayer.tsx index 1319dc31..2b307be8 100644 --- a/app/src/components/map/layers/RallyingPointsDisplayLayer.tsx +++ b/app/src/components/map/layers/RallyingPointsDisplayLayer.tsx @@ -1,13 +1,16 @@ import { RallyingPoint, Ref } from "@liane/common"; import React from "react"; -import { AppColors, AppColorPalettes } from "@/theme/colors"; +import { AppColors } from "@/theme/colors"; import MapLibreGL from "@maplibre/maplibre-react-native"; import { Feature, Point } from "geojson"; import { useAppMapViewController } from "@/components/map/AppMapView"; import { RNAppEnv } from "@/api/env"; -export const RallyingPointsDisplayLayer = ({ onSelect }: { onSelect?: (rp: RallyingPoint) => void; selected?: Ref | undefined }) => { +export type RallyingPointsDisplayLayerProps = { onSelect?: (rp: RallyingPoint) => void; selected?: Ref | undefined }; + +export const RallyingPointsDisplayLayer = ({ selected, onSelect }: RallyingPointsDisplayLayerProps) => { const controller = useAppMapViewController(); + return ( 0) { - const zoom = await controller.getZoom()!; - - let newZoom; - if (zoom < 10.5) { - newZoom = 12.1; //rp ? 12.1 : zoom + 1.5; - } else if (zoom < 12) { - newZoom = 12.1; - } else { - newZoom = zoom + 1; + if (!p.properties?.point_count) { + //@ts-ignore + onSelect({ ...p.properties, location: { lat: p.geometry.coordinates[1], lng: p.geometry.coordinates[0] } }); + await controller.setCenter(center); + return; } - await controller.setCenter(center, newZoom); } + + const zoom = await controller.getZoom()!; + + let newZoom; + if (zoom < 10.5) { + newZoom = 12.1; //rp ? 12.1 : zoom + 1.5; + } else if (zoom < 12) { + newZoom = 12.1; + } else { + newZoom = zoom + 1; + } + await controller.setCenter(center, newZoom); } : undefined }> - diff --git a/app/src/screens/publish/SelectOnMapView.tsx b/app/src/screens/publish/SelectOnMapView.tsx index f38597f2..03f0dc33 100644 --- a/app/src/screens/publish/SelectOnMapView.tsx +++ b/app/src/screens/publish/SelectOnMapView.tsx @@ -2,7 +2,7 @@ import React, { useState } from "react"; import { StyleSheet, View } from "react-native"; import { RallyingPoint } from "@liane/common"; import { useAppBackController } from "@/components/AppBackContextProvider"; -import { AppColorPalettes, AppColors, defaultTextColor } from "@/theme/colors"; +import { AppColors, defaultTextColor } from "@/theme/colors"; import { AppStyles } from "@/theme/styles"; import { Column, Row } from "@/components/base/AppLayout"; import AppMapView from "@/components/map/AppMapView"; @@ -10,8 +10,6 @@ import LocationPin from "@/assets/location_pin.svg"; import { RallyingPointItem } from "@/screens/ItinerarySearchForm"; import { AppRoundedButton } from "@/components/base/AppRoundedButton"; import { RallyingPointsDisplayLayer } from "@/components/map/layers/RallyingPointsDisplayLayer"; -import { WayPointDisplay } from "@/components/map/markers/WayPointDisplay"; -import Animated, { ZoomIn, ZoomOut } from "react-native-reanimated"; import { PageHeader } from "@/components/context/Navigation"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { AppPressableIcon } from "@/components/base/AppPressable"; @@ -29,21 +27,13 @@ export const SelectOnMapView = ({ onSelect, title }: SelectOnMapViewProps) => { return ( - {} - {selectedRP && ( - - - - )} + {selectedRP && ( - - - setSelectedRP(undefined)} /> - + { paddingVertical: 8, paddingHorizontal: 4, borderRadius: 16, - borderColor: AppColorPalettes.gray[200], - borderWidth: 1, position: "relative", top: -4 }} @@ -63,6 +51,7 @@ export const SelectOnMapView = ({ onSelect, title }: SelectOnMapViewProps) => { + setSelectedRP(undefined)} /> onSelect(selectedRP)} />