diff --git a/CHANGELOG_UNRELEASED.md b/CHANGELOG_UNRELEASED.md index 40466313..e3a4b889 100644 --- a/CHANGELOG_UNRELEASED.md +++ b/CHANGELOG_UNRELEASED.md @@ -1 +1,3 @@ # [Unreleased] + +- Added new method selectPoiBy that allows poi selection either by identifier or by customField \ No newline at end of file diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 532013a9..bb758170 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -99,7 +99,7 @@ PODS: - hermes-engine/Pre-built (0.72.3) - libevent (2.1.12) - OpenSSL-Universal (1.1.1100) - - Protobuf (3.24.3) + - Protobuf (3.24.4) - RCT-Folly (2021.07.22.00): - boost - DoubleConversion @@ -520,17 +520,17 @@ PODS: - React-jsi (= 0.72.3) - React-logger (= 0.72.3) - React-perflogger (= 0.72.3) - - ReactNativeSitumPlugin (3.0.8): + - ReactNativeSitumPlugin (3.1.8): - RCT-Folly (= 2021.07.22.00) - React - React-Core - - SitumSDK (= 3.0.2) + - SitumSDK (= 3.2.2) - RNPermissions (3.9.2): - React-Core - RNScreens (3.25.0): - React-Core - React-RCTImage - - SitumSDK (3.0.2): + - SitumSDK (3.2.2): - Protobuf (~> 3.7) - SSZipArchive (~> 2.4) - SocketRocket (0.6.1) @@ -757,7 +757,7 @@ SPEC CHECKSUMS: hermes-engine: 10fbd3f62405c41ea07e71973ea61e1878d07322 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c - Protobuf: 970f7ee93a3a08e3cf64859b8efd95ee32b4f87f + Protobuf: 351e9022fe13a6e2af00e9aefc22077cb88520f8 RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: a2faf4bad4e438ca37b2040cb8f7799baa065c18 RCTTypeSafety: cb09f3e4747b6d18331a15eb05271de7441ca0b3 @@ -794,10 +794,10 @@ SPEC CHECKSUMS: React-runtimescheduler: 837c1bebd2f84572db17698cd702ceaf585b0d9a React-utils: bcb57da67eec2711f8b353f6e3d33bd8e4b2efa3 ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9 - ReactNativeSitumPlugin: 20706df54319d2c40aa9bd5d37b09e0e2cb9b595 + ReactNativeSitumPlugin: a73690f1a7301a4b0ab70533cd676270b27d9952 RNPermissions: a9db2f3c0bd0c6d9f435010b7a0a02d27a3713b3 RNScreens: 85d3880b52d34db7b8eeebe2f1a0e807c05e69fa - SitumSDK: be23e4d95a1f8eee260ee4b909451122c12a1eb7 + SitumSDK: 862cd8ce7b9253e067e3df7ac127056a30e7596c SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce @@ -805,4 +805,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 3ff723ecb04e832ba5848d09f983499ca9059752 -COCOAPODS: 1.12.1 +COCOAPODS: 1.12.0 diff --git a/example/src/examples/wayfinding/SelectPoi.tsx b/example/src/examples/wayfinding/SelectPoi.tsx index a67f7b5e..f3bfe936 100644 --- a/example/src/examples/wayfinding/SelectPoi.tsx +++ b/example/src/examples/wayfinding/SelectPoi.tsx @@ -103,7 +103,10 @@ const Screen: React.FC = () => { diff --git a/src/wayfinding/components/MapView.tsx b/src/wayfinding/components/MapView.tsx index c2a5f98c..53ef8a86 100644 --- a/src/wayfinding/components/MapView.tsx +++ b/src/wayfinding/components/MapView.tsx @@ -32,7 +32,7 @@ import { } from "../types"; import { ErrorName } from "../types/constants"; import { sendMessageToViewer } from "../utils"; -import ViewerMapper from "../utils/mapper"; +import ViewerMapper, { type SelectPoiFilterProps } from "../utils/mapper"; const SITUM_BASE_DOMAIN = "https://map-viewer.situm.com"; const NETWORK_ERROR_CODE = { @@ -139,7 +139,7 @@ const MapView = React.forwardRef( }, []); // Cartography - const _selectPoi = useCallback((poiId: number) => { + const _selectPoiBy = useCallback((filters: SelectPoiFilterProps) => { if (!webViewRef.current) { return; } @@ -149,7 +149,7 @@ const MapView = React.forwardRef( ); return; } - sendMessageToViewer(webViewRef.current, ViewerMapper.selectPoi(poiId)); + sendMessageToViewer(webViewRef.current, ViewerMapper.selectPoi(filters)); }, []); /** @@ -185,7 +185,10 @@ const MapView = React.forwardRef( ); }, selectPoi(poiId: number) { - _selectPoi(poiId); + _selectPoiBy({ type: "identifier", data: poiId }); + }, + selectPoiBy(filters: SelectPoiFilterProps) { + _selectPoiBy(filters); }, deselectPoi() { webViewRef.current && @@ -210,7 +213,7 @@ const MapView = React.forwardRef( }, }; }, - [stopNavigation, _navigateToPoi, _navigateToPoint, _selectPoi] + [stopNavigation, _navigateToPoi, _navigateToPoint, _selectPoiBy] ); useEffect(() => { diff --git a/src/wayfinding/types/index.ts b/src/wayfinding/types/index.ts index 9f756269..245cb290 100644 --- a/src/wayfinding/types/index.ts +++ b/src/wayfinding/types/index.ts @@ -1,4 +1,5 @@ import { AccessibilityMode } from "src/sdk"; +import type { SelectPoiFilterProps } from "src/wayfinding/utils/mapper"; import type { Point } from "../../sdk/types"; import { ErrorName } from "./constants"; @@ -10,6 +11,7 @@ export interface MapViewError { export interface MapViewRef { selectPoi: (poiId: number) => void; + selectPoiBy: (filters: SelectPoiFilterProps) => void; navigateToPoi: ({ identifier, accessibilityMode = AccessibilityMode.CHOOSE_SHORTEST, diff --git a/src/wayfinding/utils/mapper.ts b/src/wayfinding/utils/mapper.ts index 96b27816..d4ac435a 100644 --- a/src/wayfinding/utils/mapper.ts +++ b/src/wayfinding/utils/mapper.ts @@ -16,6 +16,23 @@ import type { OnNavigationResult, } from "../types"; +type SelectPoiByIdentifier = { + type: "identifier" | null; + data: number; +}; + +type SelectPoiByCf = { + type: "customField"; + data: { + key: string; + value?: any; + }; +}; + +export type SelectPoiFilterProps = + | ({ type: "identifier" } & SelectPoiByIdentifier) + | ({ type: "customField" } & SelectPoiByCf); + export const createPoint = (payload: any): Point => { return { buildingIdentifier: payload.buildingIdentifier, @@ -78,7 +95,7 @@ const mapperWrapper = (type: string, payload: unknown) => { const ViewerMapper = { // Configuration followUser: (follow: boolean) => { - return mapperWrapper("camera.follow_user", {value: follow}); + return mapperWrapper("camera.follow_user", { value: follow }); }, setLanguage: (lang: string) => { return mapperWrapper("ui.set_language", lang); @@ -91,8 +108,8 @@ const ViewerMapper = { }); }, // Cartography - selectPoi: (poiId: number | null) => { - return mapperWrapper(`cartography.select_poi`, { identifier: poiId }); + selectPoi: (filters: SelectPoiFilterProps | null) => { + return mapperWrapper(`cartography.select_poi`, filters); }, // Location location: (location: Location) => {