Skip to content

Commit 542fbb8

Browse files
committed
feat: new filters for select poi function
1 parent 9dab7ae commit 542fbb8

6 files changed

Lines changed: 44 additions & 17 deletions

File tree

CHANGELOG_UNRELEASED.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# [Unreleased]
2+
3+
- Added new method selectPoiBy that allows poi selection either by identifier or by customField

example/ios/Podfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ PODS:
9999
- hermes-engine/Pre-built (0.72.3)
100100
- libevent (2.1.12)
101101
- OpenSSL-Universal (1.1.1100)
102-
- Protobuf (3.24.3)
102+
- Protobuf (3.24.4)
103103
- RCT-Folly (2021.07.22.00):
104104
- boost
105105
- DoubleConversion
@@ -520,17 +520,17 @@ PODS:
520520
- React-jsi (= 0.72.3)
521521
- React-logger (= 0.72.3)
522522
- React-perflogger (= 0.72.3)
523-
- ReactNativeSitumPlugin (3.0.8):
523+
- ReactNativeSitumPlugin (3.1.8):
524524
- RCT-Folly (= 2021.07.22.00)
525525
- React
526526
- React-Core
527-
- SitumSDK (= 3.0.2)
527+
- SitumSDK (= 3.2.2)
528528
- RNPermissions (3.9.2):
529529
- React-Core
530530
- RNScreens (3.25.0):
531531
- React-Core
532532
- React-RCTImage
533-
- SitumSDK (3.0.2):
533+
- SitumSDK (3.2.2):
534534
- Protobuf (~> 3.7)
535535
- SSZipArchive (~> 2.4)
536536
- SocketRocket (0.6.1)
@@ -757,7 +757,7 @@ SPEC CHECKSUMS:
757757
hermes-engine: 10fbd3f62405c41ea07e71973ea61e1878d07322
758758
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
759759
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
760-
Protobuf: 970f7ee93a3a08e3cf64859b8efd95ee32b4f87f
760+
Protobuf: 351e9022fe13a6e2af00e9aefc22077cb88520f8
761761
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
762762
RCTRequired: a2faf4bad4e438ca37b2040cb8f7799baa065c18
763763
RCTTypeSafety: cb09f3e4747b6d18331a15eb05271de7441ca0b3
@@ -794,15 +794,15 @@ SPEC CHECKSUMS:
794794
React-runtimescheduler: 837c1bebd2f84572db17698cd702ceaf585b0d9a
795795
React-utils: bcb57da67eec2711f8b353f6e3d33bd8e4b2efa3
796796
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
797-
ReactNativeSitumPlugin: 20706df54319d2c40aa9bd5d37b09e0e2cb9b595
797+
ReactNativeSitumPlugin: a73690f1a7301a4b0ab70533cd676270b27d9952
798798
RNPermissions: a9db2f3c0bd0c6d9f435010b7a0a02d27a3713b3
799799
RNScreens: 85d3880b52d34db7b8eeebe2f1a0e807c05e69fa
800-
SitumSDK: be23e4d95a1f8eee260ee4b909451122c12a1eb7
800+
SitumSDK: 862cd8ce7b9253e067e3df7ac127056a30e7596c
801801
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
802802
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
803803
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
804804
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
805805

806806
PODFILE CHECKSUM: 3ff723ecb04e832ba5848d09f983499ca9059752
807807

808-
COCOAPODS: 1.12.1
808+
COCOAPODS: 1.12.0

example/src/examples/wayfinding/SelectPoi.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ const Screen: React.FC = () => {
103103
<Button
104104
mode="outlined"
105105
onPress={() => {
106-
_controller?.selectPoi(Number(selectedPoiIdentifier));
106+
_controller?.selectPoiBy({
107+
type: 'identifier',
108+
data: Number(selectedPoiIdentifier),
109+
});
107110
}}>
108111
Select POI
109112
</Button>

src/wayfinding/components/MapView.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
} from "../types";
3333
import { ErrorName } from "../types/constants";
3434
import { sendMessageToViewer } from "../utils";
35-
import ViewerMapper from "../utils/mapper";
35+
import ViewerMapper, { type SelectPoiFilterProps } from "../utils/mapper";
3636
const SITUM_BASE_DOMAIN = "https://map-viewer.situm.com";
3737

3838
const NETWORK_ERROR_CODE = {
@@ -139,7 +139,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
139139
}, []);
140140

141141
// Cartography
142-
const _selectPoi = useCallback((poiId: number) => {
142+
const _selectPoiBy = useCallback((filters: SelectPoiFilterProps) => {
143143
if (!webViewRef.current) {
144144
return;
145145
}
@@ -149,7 +149,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
149149
);
150150
return;
151151
}
152-
sendMessageToViewer(webViewRef.current, ViewerMapper.selectPoi(poiId));
152+
sendMessageToViewer(webViewRef.current, ViewerMapper.selectPoi(filters));
153153
}, []);
154154

155155
/**
@@ -185,7 +185,10 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
185185
);
186186
},
187187
selectPoi(poiId: number) {
188-
_selectPoi(poiId);
188+
_selectPoiBy({ type: "identifier", data: poiId });
189+
},
190+
selectPoiBy(filters: SelectPoiFilterProps) {
191+
_selectPoiBy(filters);
189192
},
190193
deselectPoi() {
191194
webViewRef.current &&
@@ -210,7 +213,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
210213
},
211214
};
212215
},
213-
[stopNavigation, _navigateToPoi, _navigateToPoint, _selectPoi]
216+
[stopNavigation, _navigateToPoi, _navigateToPoint, _selectPoiBy]
214217
);
215218

216219
useEffect(() => {

src/wayfinding/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AccessibilityMode } from "src/sdk";
2+
import type { SelectPoiFilterProps } from "src/wayfinding/utils/mapper";
23

34
import type { Point } from "../../sdk/types";
45
import { ErrorName } from "./constants";
@@ -10,6 +11,7 @@ export interface MapViewError {
1011

1112
export interface MapViewRef {
1213
selectPoi: (poiId: number) => void;
14+
selectPoiBy: (filters: SelectPoiFilterProps) => void;
1315
navigateToPoi: ({
1416
identifier,
1517
accessibilityMode = AccessibilityMode.CHOOSE_SHORTEST,

src/wayfinding/utils/mapper.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ import type {
1616
OnNavigationResult,
1717
} from "../types";
1818

19+
type SelectPoiByIdentifier = {
20+
type: "identifier" | null;
21+
data: number;
22+
};
23+
24+
type SelectPoiByCf = {
25+
type: "customField";
26+
data: {
27+
key: string;
28+
value?: any;
29+
};
30+
};
31+
32+
export type SelectPoiFilterProps =
33+
| ({ type: "identifier" } & SelectPoiByIdentifier)
34+
| ({ type: "customField" } & SelectPoiByCf);
35+
1936
export const createPoint = (payload: any): Point => {
2037
return {
2138
buildingIdentifier: payload.buildingIdentifier,
@@ -78,7 +95,7 @@ const mapperWrapper = (type: string, payload: unknown) => {
7895
const ViewerMapper = {
7996
// Configuration
8097
followUser: (follow: boolean) => {
81-
return mapperWrapper("camera.follow_user", {value: follow});
98+
return mapperWrapper("camera.follow_user", { value: follow });
8299
},
83100
setLanguage: (lang: string) => {
84101
return mapperWrapper("ui.set_language", lang);
@@ -91,8 +108,8 @@ const ViewerMapper = {
91108
});
92109
},
93110
// Cartography
94-
selectPoi: (poiId: number | null) => {
95-
return mapperWrapper(`cartography.select_poi`, { identifier: poiId });
111+
selectPoi: (filters: SelectPoiFilterProps | null) => {
112+
return mapperWrapper(`cartography.select_poi`, filters);
96113
},
97114
// Location
98115
location: (location: Location) => {

0 commit comments

Comments
 (0)