Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# [Unreleased]

- Added new method selectPoiBy that allows poi selection either by identifier or by customField
16 changes: 8 additions & 8 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -794,15 +794,15 @@ 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
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 3ff723ecb04e832ba5848d09f983499ca9059752

COCOAPODS: 1.12.1
COCOAPODS: 1.12.0
5 changes: 4 additions & 1 deletion example/src/examples/wayfinding/SelectPoi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ const Screen: React.FC = () => {
<Button
mode="outlined"
onPress={() => {
_controller?.selectPoi(Number(selectedPoiIdentifier));
_controller?.selectPoiBy({
type: 'identifier',
data: Number(selectedPoiIdentifier),
});
}}>
Select POI
</Button>
Expand Down
13 changes: 8 additions & 5 deletions src/wayfinding/components/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -139,7 +139,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
}, []);

// Cartography
const _selectPoi = useCallback((poiId: number) => {
const _selectPoiBy = useCallback((filters: SelectPoiFilterProps) => {
if (!webViewRef.current) {
return;
}
Expand All @@ -149,7 +149,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
);
return;
}
sendMessageToViewer(webViewRef.current, ViewerMapper.selectPoi(poiId));
sendMessageToViewer(webViewRef.current, ViewerMapper.selectPoi(filters));
}, []);

/**
Expand Down Expand Up @@ -185,7 +185,10 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
);
},
selectPoi(poiId: number) {
_selectPoi(poiId);
_selectPoiBy({ type: "identifier", data: poiId });
},
selectPoiBy(filters: SelectPoiFilterProps) {
_selectPoiBy(filters);
},
deselectPoi() {
webViewRef.current &&
Expand All @@ -210,7 +213,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
},
};
},
[stopNavigation, _navigateToPoi, _navigateToPoint, _selectPoi]
[stopNavigation, _navigateToPoi, _navigateToPoint, _selectPoiBy]
);

useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/wayfinding/types/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -10,6 +11,7 @@ export interface MapViewError {

export interface MapViewRef {
selectPoi: (poiId: number) => void;
selectPoiBy: (filters: SelectPoiFilterProps) => void;
navigateToPoi: ({
identifier,
accessibilityMode = AccessibilityMode.CHOOSE_SHORTEST,
Expand Down
23 changes: 20 additions & 3 deletions src/wayfinding/utils/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Copy link
Contributor

@cristian-situm cristian-situm Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Estos 3 types non deberian de ir en types/index.ts ?

| ({ type: "identifier" } & SelectPoiByIdentifier)
| ({ type: "customField" } & SelectPoiByCf);

export const createPoint = (payload: any): Point => {
return {
buildingIdentifier: payload.buildingIdentifier,
Expand Down Expand Up @@ -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);
Expand All @@ -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) => {
Expand Down