react-native-steerpath-smart-map 1.29.5 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/.eslintrc.js +66 -0
  2. package/.prettierrc +7 -0
  3. package/CHANGELOG.md +35 -0
  4. package/README.md +7 -0
  5. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNEventKeys.class +0 -0
  6. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartGeofenceManager.class +0 -0
  7. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartLocationManager.class +0 -0
  8. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapManager.class +0 -0
  9. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapModule.class +0 -0
  10. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.class +0 -0
  11. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.kt +28 -0
  12. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapView.class +0 -0
  13. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapViewManager.class +0 -0
  14. package/android/bin/src/main/java/com/steerpath/rnsmartmap/Utils.class +0 -0
  15. package/android/build.gradle +22 -33
  16. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  17. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartLocationManager.java +22 -14
  18. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapManager.java +9 -31
  19. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.java +11 -9
  20. package/android/src/main/java/com/steerpath/rnsmartmap/Utils.java +36 -36
  21. package/ios/RNSmartLocationManager.m +28 -3
  22. package/ios/RNSmartMapManager.m +10 -22
  23. package/lib/commonjs/SmartLocationManager.js +50 -0
  24. package/lib/commonjs/SmartLocationManager.js.map +1 -0
  25. package/lib/commonjs/SmartLocationManager.web.js +11 -0
  26. package/lib/commonjs/SmartLocationManager.web.js.map +1 -0
  27. package/lib/commonjs/SmartMapManager.js +59 -0
  28. package/lib/commonjs/SmartMapManager.js.map +1 -0
  29. package/lib/commonjs/SmartMapManager.web.js +24 -0
  30. package/lib/commonjs/SmartMapManager.web.js.map +1 -0
  31. package/lib/commonjs/index.js +28 -0
  32. package/lib/commonjs/index.js.map +1 -0
  33. package/lib/commonjs/package.json +1 -0
  34. package/lib/module/SmartLocationManager.js +46 -0
  35. package/lib/module/SmartLocationManager.js.map +1 -0
  36. package/lib/module/SmartLocationManager.web.js +7 -0
  37. package/lib/module/SmartLocationManager.web.js.map +1 -0
  38. package/lib/module/SmartMapManager.js +54 -0
  39. package/lib/module/SmartMapManager.js.map +1 -0
  40. package/lib/module/SmartMapManager.web.js +20 -0
  41. package/lib/module/SmartMapManager.web.js.map +1 -0
  42. package/lib/module/index.js +5 -0
  43. package/lib/module/index.js.map +1 -0
  44. package/lib/typescript/SmartLocationManager.d.ts +19 -0
  45. package/lib/typescript/SmartLocationManager.d.ts.map +1 -0
  46. package/{dist → lib/typescript}/SmartLocationManager.web.d.ts +1 -0
  47. package/lib/typescript/SmartLocationManager.web.d.ts.map +1 -0
  48. package/{dist → lib/typescript}/SmartMapManager.d.ts +13 -15
  49. package/lib/typescript/SmartMapManager.d.ts.map +1 -0
  50. package/lib/typescript/SmartMapManager.web.d.ts +8 -0
  51. package/lib/typescript/SmartMapManager.web.d.ts.map +1 -0
  52. package/lib/typescript/index.d.ts +5 -0
  53. package/lib/typescript/index.d.ts.map +1 -0
  54. package/package.json +38 -13
  55. package/react-native-steerpath-smart-map.podspec +15 -12
  56. package/src/SmartLocationManager.ts +25 -9
  57. package/src/SmartMapManager.ts +12 -19
  58. package/src/SmartMapManager.web.ts +3 -24
  59. package/src/index.ts +3 -4
  60. package/tsconfig.json +14 -9
  61. package/.eslintrc.json +0 -81
  62. package/android/bin/.project +0 -34
  63. package/android/bin/.settings/org.eclipse.buildship.core.prefs +0 -13
  64. package/android/bin/README.md +0 -14
  65. package/android/bin/build.gradle +0 -59
  66. package/android/bin/gradle/wrapper/gradle-wrapper.jar +0 -0
  67. package/android/bin/gradle/wrapper/gradle-wrapper.properties +0 -6
  68. package/android/bin/gradlew +0 -172
  69. package/android/bin/gradlew.bat +0 -84
  70. package/android/bin/src/main/AndroidManifest.xml +0 -4
  71. package/android/src/main/java/com/steerpath/rnsmartmap/RNEventKeys.java +0 -29
  72. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartGeofenceManager.java +0 -103
  73. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapModule.java +0 -284
  74. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapView.java +0 -470
  75. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapViewManager.java +0 -307
  76. package/dist/SmartGeofenceManager.d.ts +0 -17
  77. package/dist/SmartGeofenceManager.js +0 -61
  78. package/dist/SmartGeofenceManager.web.d.ts +0 -9
  79. package/dist/SmartGeofenceManager.web.js +0 -10
  80. package/dist/SmartLocationManager.d.ts +0 -11
  81. package/dist/SmartLocationManager.js +0 -22
  82. package/dist/SmartLocationManager.web.js +0 -4
  83. package/dist/SmartMapEventManager.web.d.ts +0 -5
  84. package/dist/SmartMapEventManager.web.js +0 -10
  85. package/dist/SmartMapManager.js +0 -53
  86. package/dist/SmartMapManager.web.d.ts +0 -12
  87. package/dist/SmartMapManager.web.js +0 -33
  88. package/dist/SmartMapView.d.ts +0 -3
  89. package/dist/SmartMapView.js +0 -294
  90. package/dist/SmartMapView.web.d.ts +0 -3
  91. package/dist/SmartMapView.web.js +0 -270
  92. package/dist/SmartMapViewProps.d.ts +0 -267
  93. package/dist/SmartMapViewProps.js +0 -76
  94. package/dist/index.d.ts +0 -5
  95. package/dist/index.js +0 -5
  96. package/dist/internalUtils.d.ts +0 -1
  97. package/dist/internalUtils.js +0 -5
  98. package/ios/RCTConvert+SmartMapView.h +0 -35
  99. package/ios/RCTConvert+SmartMapView.m +0 -295
  100. package/ios/RNSmartGeofenceManager.h +0 -24
  101. package/ios/RNSmartGeofenceManager.m +0 -110
  102. package/ios/RNSmartMapUserTaskEventManager.h +0 -19
  103. package/ios/RNSmartMapUserTaskEventManager.m +0 -46
  104. package/ios/RNSmartMapView.h +0 -37
  105. package/ios/RNSmartMapView.m +0 -21
  106. package/ios/RNSmartMapViewManager.h +0 -27
  107. package/ios/RNSmartMapViewManager.m +0 -608
  108. package/package-lock.json +0 -6570
  109. package/src/SmartGeofenceManager.ts +0 -94
  110. package/src/SmartGeofenceManager.web.ts +0 -11
  111. package/src/SmartMapEventManager.web.ts +0 -13
  112. package/src/SmartMapView.tsx +0 -377
  113. package/src/SmartMapView.web.tsx +0 -342
  114. package/src/SmartMapViewProps.ts +0 -338
  115. package/src/internalUtils.ts +0 -5
  116. package/src/typings/steerpath-smart-sdk.d.ts +0 -5
@@ -1,267 +0,0 @@
1
- import { ViewProperties } from "react-native";
2
- export interface ConfigSDK {
3
- apiKey: string;
4
- configFilePath?: string | null;
5
- configString?: string | null;
6
- }
7
- export interface SmartMapViewMethods {
8
- addMarker(smartMapObj: SmartMapObject, layout: Layout | null, iconName: string | null, textColor: string | null, textHaloColor: string | null): void;
9
- addMarkers(mapObjectsArray: SmartMapObject[], layout: Layout | null, iconName: string | null, textColor: string | null, textHaloColor: string | null): void;
10
- animateCamera(arg: {
11
- latitude: number;
12
- longitude: number;
13
- zoomLevel: number;
14
- bearing?: number;
15
- pitch?: number;
16
- floorIndex?: number;
17
- buildingRef?: string;
18
- }): void;
19
- animateCameraToBuildingRef(buildingRef: string, callback: (response: MapResponse) => void): void;
20
- animateCameraToObject(localRef: string, buildingRef: string, zoomLevel: number | null, callback: (response: MapResponse) => void): void;
21
- cancelCurrentUserTask(): void;
22
- getCurrentUserTask(callback: (userTaskResponse: SmartMapUserTaskResponse) => void): void;
23
- getMapObject(localRef: string, buildingRef: string, source: SmartObjectSource, callback: (mapObject: SmartMapObject | null) => void): void;
24
- getMapObjectByProperties(properties: Record<string, unknown>, callback: (mapObject: SmartMapObject | null) => void): void;
25
- getWidgetPadding(callback: (padding: {
26
- left: number;
27
- top: number;
28
- right: number;
29
- bottom: number;
30
- }) => void): void;
31
- onBackPressed(callback: (response: boolean) => void): void;
32
- removeMarker(smartMapObj: SmartMapObject): void;
33
- removeMarkers(mapObjectsArray: SmartMapObject[]): void;
34
- removeAllMarkers(): void;
35
- selectMapObject(mapObj: SmartMapObject): void;
36
- setCamera(arg: {
37
- latitude: number;
38
- longitude: number;
39
- zoomLevel: number;
40
- bearing?: number;
41
- pitch?: number;
42
- floorIndex?: number;
43
- buildingRef?: string;
44
- }): void;
45
- setCameraToBuildingRef(buildingRef: string, callback: (response: MapResponse) => void): void;
46
- setCameraToObject(localRef: string, buildingRef: string, zoomLevel: number, callback: (response: MapResponse) => void): void;
47
- setGeoJson(sourceId: string, geoJson: Record<string, unknown> | null, callback: (response: MapResponse) => void): void;
48
- setMapMode(mapMode: SmartMapMode): void;
49
- setWidgetPadding(left: number, top: number, right: number, bottom: number): void;
50
- start(): void;
51
- startUserTask(userTask: SmartMapUserTask): void;
52
- stop(): void;
53
- getSmartMapCameraOptions(callback: (options: SmartMapCameraOptions) => void): void;
54
- }
55
- export declare enum SmartMapMode {
56
- MAP_ONLY = "mapOnly",
57
- STATIC = "static",
58
- SEARCH = "search"
59
- }
60
- export declare enum SmartObjectSource {
61
- STATIC = "STATIC",
62
- MARKER = "MARKER",
63
- LIVE = "LIVE"
64
- }
65
- export declare enum Layout {
66
- TOP = "top",
67
- BOTTOM = "bottom",
68
- LEFT = "left",
69
- RIGHT = "right"
70
- }
71
- export declare enum MapResponse {
72
- SUCCESS = "success",
73
- OBJECT_NOT_FOUND = "objectNotFound",
74
- NETWORK_ERROR = "networkError",
75
- NOT_SUPPORTED = "notSupported"
76
- }
77
- export declare enum SmartGeofenceResponse {
78
- SUCCESS = "success",
79
- MALFORMED_DATA = "malformedData",
80
- NOT_FOUND = "notFound"
81
- }
82
- export declare enum SmartMapEvent {
83
- MAP_LOADED = "SPSmartMapLoaded",
84
- MAP_CLICKED = "SPSmartMapClicked",
85
- SEARCH_RESULT_SELECTED = "SPSearchResultSelected"
86
- }
87
- export declare enum SmartMapViewStatus {
88
- ONLY_MAP = "onlyMap",
89
- CARD_VIEW = "cardView",
90
- ERROR_VIEW = "errorView",
91
- SETTING_VIEW = "settingView",
92
- NAVIGATING_VIEW = "navigatingView",
93
- SEARCH_VIEW = "searchView"
94
- }
95
- export declare enum SmartBottomSheetState {
96
- HIDDEN = "hidden",
97
- COLLAPSED = "collapsed",
98
- HALF_EXPANDED = "halfExpanded",
99
- EXPANDED = "expanded"
100
- }
101
- export declare enum NavigationError {
102
- OBJECT_NOT_FOUND = "objectNotFound",
103
- ROUTE_NOT_FOUND = "routeNotFound",
104
- USER_LOCATION_NOT_FOUND = "userLocationNotFound"
105
- }
106
- export declare enum SmartMapUserTaskResponse {
107
- STARTED = "started",
108
- CANCELLED = "cancelled",
109
- ERROR = "error",
110
- BUSY = "busy",
111
- UNSUPPORTED = "unsupported",
112
- COMPLETED = "completed"
113
- }
114
- export interface LinkProperty {
115
- title: string;
116
- url: string;
117
- }
118
- export interface ImageProperty {
119
- title: string;
120
- url: string;
121
- }
122
- export declare type BookingIntegration = {
123
- integrationType: string;
124
- integrationRef: string;
125
- };
126
- export declare type OccupancyIntegrations = BookingIntegration;
127
- export interface SmartMapObjectProperties {
128
- amenities?: string[];
129
- bookingIntegrations?: BookingIntegration[];
130
- occupancyIntegrations?: OccupancyIntegrations[];
131
- buildingRef: string;
132
- calendarRef?: string;
133
- capacity?: number;
134
- cateringEmail?: string;
135
- css_class: string;
136
- description?: string;
137
- 'description:fi'?: string;
138
- 'description:nb'?: string;
139
- 'description:sv'?: string;
140
- 'description:en'?: string;
141
- images?: ImageProperty[];
142
- 'images:fi'?: ImageProperty[];
143
- 'images:sv'?: ImageProperty[];
144
- 'images:nb'?: ImageProperty[];
145
- 'images:en'?: ImageProperty[];
146
- integrationRef?: string;
147
- keywords?: string[];
148
- 'keywords:fi'?: string[];
149
- 'keywords:sv'?: string[];
150
- 'keywords:nb'?: string[];
151
- 'keywords:en'?: string[];
152
- layerIndex: number;
153
- links?: LinkProperty[];
154
- 'links:fi'?: LinkProperty[];
155
- 'links:sv'?: LinkProperty[];
156
- 'links:nb'?: LinkProperty[];
157
- 'links:en'?: LinkProperty[];
158
- localRef?: string;
159
- occupancy?: string;
160
- parentRef?: string;
161
- resourceType?: string;
162
- sp_maximum_advance_booking_hours_normal_user?: number;
163
- sp_maximum_booking_hours_normal_user?: number;
164
- sp_maximum_advance_booking_hours_power_user?: number;
165
- sp_maximum_booking_hours_power_user?: number;
166
- subType?: string;
167
- tags?: string[];
168
- title: string;
169
- 'title:fi'?: string;
170
- 'title:sv'?: string;
171
- 'title:nb'?: string;
172
- 'title:en'?: string;
173
- weekPlannerCapacity?: number;
174
- externalFeedbackUrl?: string;
175
- [key: string]: any;
176
- }
177
- export interface SmartMapObject {
178
- latitude: number;
179
- longitude: number;
180
- floorIndex: number;
181
- localRef: string;
182
- buildingRef: string;
183
- title: string;
184
- properties: SmartMapObjectProperties;
185
- source: SmartObjectSource;
186
- }
187
- export interface SmartViewWebProps {
188
- apiKey?: string;
189
- }
190
- export interface SearchAction {
191
- title: string;
192
- shortTitle: string;
193
- description: string;
194
- iconName: string;
195
- action: {
196
- allTags?: string[];
197
- anyTags?: string[];
198
- type: string;
199
- };
200
- }
201
- export interface SmartViewNativeProps {
202
- onBottomSheetStateChanged?: (payload: {
203
- state: SmartBottomSheetState;
204
- }) => void;
205
- onMapClicked?: (payload: {
206
- mapObjects: SmartMapObject[];
207
- }) => void;
208
- onNavigationDestinationReached?: () => void;
209
- onNavigationEnded?: () => void;
210
- onNavigationFailed?: (payload: {
211
- error: NavigationError;
212
- }) => void;
213
- onNavigationPreviewAppeared?: () => void;
214
- onNavigationStarted?: () => void;
215
- onSearchCategorySelected?: (payload: {
216
- searchAction: SearchAction;
217
- searchResults: SmartMapObject[];
218
- }) => void;
219
- onSearchResultSelected?: (payload: {
220
- mapObject: SmartMapObject;
221
- }) => void;
222
- onUserFloorChanged?: (payload: {
223
- floorIndex: number;
224
- buildingRef?: string;
225
- }) => void;
226
- onUserTaskResponse?: (payload: {
227
- response: SmartMapUserTaskResponse;
228
- userTask: SmartMapUserTask;
229
- }) => void;
230
- onViewStatusChanged?: (payload: {
231
- status: SmartMapViewStatus;
232
- poiDetail: SmartMapObject;
233
- }) => void;
234
- onVisibleFloorChanged?: (payload: {
235
- floorIndex: number;
236
- buildingRef?: string;
237
- }) => void;
238
- }
239
- export interface SmartMapViewProps extends ViewProperties, SmartViewWebProps, SmartViewNativeProps {
240
- /**
241
- * This is a quick hack for enabling typed ref
242
- */
243
- ref?: any;
244
- onMapLoaded?: () => void;
245
- }
246
- export declare type SmartMapNavigationUserTask = SmartMapObject;
247
- export interface SmartMapPOISelectionUserTask {
248
- shouldAddMarker: boolean;
249
- actionButtonText: string;
250
- actionButtonIcon: string;
251
- smartMapObject: SmartMapObject;
252
- }
253
- export declare enum SmartMapUserTaskType {
254
- NAVIGATION = "navigation",
255
- POI_SELECTION = "poiSelection"
256
- }
257
- export interface SmartMapUserTask {
258
- type: SmartMapUserTaskType;
259
- payload: SmartMapNavigationUserTask | SmartMapPOISelectionUserTask;
260
- }
261
- export interface SmartMapCameraOptions {
262
- pitch: number;
263
- bearing: number;
264
- zoomLevel: number;
265
- latitude: number;
266
- longitude: number;
267
- }
@@ -1,76 +0,0 @@
1
- export var SmartMapMode;
2
- (function (SmartMapMode) {
3
- SmartMapMode["MAP_ONLY"] = "mapOnly";
4
- SmartMapMode["STATIC"] = "static";
5
- SmartMapMode["SEARCH"] = "search";
6
- })(SmartMapMode || (SmartMapMode = {}));
7
- export var SmartObjectSource;
8
- (function (SmartObjectSource) {
9
- SmartObjectSource["STATIC"] = "STATIC";
10
- SmartObjectSource["MARKER"] = "MARKER";
11
- SmartObjectSource["LIVE"] = "LIVE";
12
- })(SmartObjectSource || (SmartObjectSource = {}));
13
- export var Layout;
14
- (function (Layout) {
15
- Layout["TOP"] = "top";
16
- Layout["BOTTOM"] = "bottom";
17
- Layout["LEFT"] = "left";
18
- Layout["RIGHT"] = "right";
19
- })(Layout || (Layout = {}));
20
- export var MapResponse;
21
- (function (MapResponse) {
22
- MapResponse["SUCCESS"] = "success";
23
- MapResponse["OBJECT_NOT_FOUND"] = "objectNotFound";
24
- MapResponse["NETWORK_ERROR"] = "networkError";
25
- MapResponse["NOT_SUPPORTED"] = "notSupported";
26
- })(MapResponse || (MapResponse = {}));
27
- export var SmartGeofenceResponse;
28
- (function (SmartGeofenceResponse) {
29
- SmartGeofenceResponse["SUCCESS"] = "success";
30
- SmartGeofenceResponse["MALFORMED_DATA"] = "malformedData";
31
- SmartGeofenceResponse["NOT_FOUND"] = "notFound";
32
- })(SmartGeofenceResponse || (SmartGeofenceResponse = {}));
33
- export var SmartMapEvent;
34
- (function (SmartMapEvent) {
35
- SmartMapEvent["MAP_LOADED"] = "SPSmartMapLoaded";
36
- SmartMapEvent["MAP_CLICKED"] = "SPSmartMapClicked";
37
- SmartMapEvent["SEARCH_RESULT_SELECTED"] = "SPSearchResultSelected";
38
- })(SmartMapEvent || (SmartMapEvent = {}));
39
- export var SmartMapViewStatus;
40
- (function (SmartMapViewStatus) {
41
- SmartMapViewStatus["ONLY_MAP"] = "onlyMap";
42
- SmartMapViewStatus["CARD_VIEW"] = "cardView";
43
- SmartMapViewStatus["ERROR_VIEW"] = "errorView";
44
- SmartMapViewStatus["SETTING_VIEW"] = "settingView";
45
- SmartMapViewStatus["NAVIGATING_VIEW"] = "navigatingView";
46
- SmartMapViewStatus["SEARCH_VIEW"] = "searchView";
47
- })(SmartMapViewStatus || (SmartMapViewStatus = {}));
48
- export var SmartBottomSheetState;
49
- (function (SmartBottomSheetState) {
50
- SmartBottomSheetState["HIDDEN"] = "hidden";
51
- SmartBottomSheetState["COLLAPSED"] = "collapsed";
52
- SmartBottomSheetState["HALF_EXPANDED"] = "halfExpanded";
53
- SmartBottomSheetState["EXPANDED"] = "expanded";
54
- })(SmartBottomSheetState || (SmartBottomSheetState = {}));
55
- export var NavigationError;
56
- (function (NavigationError) {
57
- NavigationError["OBJECT_NOT_FOUND"] = "objectNotFound";
58
- NavigationError["ROUTE_NOT_FOUND"] = "routeNotFound";
59
- NavigationError["USER_LOCATION_NOT_FOUND"] = "userLocationNotFound";
60
- })(NavigationError || (NavigationError = {}));
61
- export var SmartMapUserTaskResponse;
62
- (function (SmartMapUserTaskResponse) {
63
- SmartMapUserTaskResponse["STARTED"] = "started";
64
- SmartMapUserTaskResponse["CANCELLED"] = "cancelled";
65
- SmartMapUserTaskResponse["ERROR"] = "error";
66
- SmartMapUserTaskResponse["BUSY"] = "busy";
67
- SmartMapUserTaskResponse["UNSUPPORTED"] = "unsupported";
68
- SmartMapUserTaskResponse["COMPLETED"] = "completed";
69
- })(SmartMapUserTaskResponse || (SmartMapUserTaskResponse = {}));
70
- ;
71
- ;
72
- export var SmartMapUserTaskType;
73
- (function (SmartMapUserTaskType) {
74
- SmartMapUserTaskType["NAVIGATION"] = "navigation";
75
- SmartMapUserTaskType["POI_SELECTION"] = "poiSelection";
76
- })(SmartMapUserTaskType || (SmartMapUserTaskType = {}));
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './SmartGeofenceManager';
2
- export * from './SmartMapManager';
3
- export * from './SmartMapView';
4
- export * from './SmartMapViewProps';
5
- export * from './SmartLocationManager';
package/dist/index.js DELETED
@@ -1,5 +0,0 @@
1
- export * from './SmartGeofenceManager';
2
- export * from './SmartMapManager';
3
- export * from './SmartMapView';
4
- export * from './SmartMapViewProps';
5
- export * from './SmartLocationManager';
@@ -1 +0,0 @@
1
- export declare function convertNativePixelToDp(input: number): number;
@@ -1,5 +0,0 @@
1
- import { PixelRatio } from "react-native";
2
- export function convertNativePixelToDp(input) {
3
- var ratio = PixelRatio.get();
4
- return input / ratio;
5
- }
@@ -1,35 +0,0 @@
1
- //
2
- // RCTConvert+SmartMapView.h
3
- // SteerpathOfficeApp
4
- //
5
- // Created by Jarvis Luong on 25/07/2019.
6
- // Copyright © 2019 Facebook. All rights reserved.
7
- //
8
-
9
- #ifndef RCTConvert_SmartMapView_h
10
- #define RCTConvert_SmartMapView_h
11
-
12
- #import <SteerpathSmartSDK/SteerpathSmartSDK.h>
13
- #import <React/RCTConvert.h>
14
-
15
- @interface RCTConvert (SPSmartSDK)
16
-
17
- + (SPSmartMapObject*)SPSmartMapObject:(id)json;
18
- + (SPLayout)SPLayout:(NSString*)layout;
19
- + (SPObjectSource)SPObjectSource:(NSString*)source;
20
- + (NSString*)SPMapResponse:(SPMapResponse)response;
21
- + (NSString*)SPSmartGeofenceResponseType:(SPSmartGeofenceResponseType)response;
22
- + (SPSmartMapUserTask*)SPSmartUserTask:(id)json;
23
- + (SPSmartMapPOISelectionUserTask*)SPSmartMapPOISelectionUserTask:(id)json;
24
- + (NSDictionary*)convertUserTaskToJSONWith:(SPSmartMapUserTask*)task;
25
- + (NSDictionary*)convertMapObjectToJSONWith:(SPSmartMapObject*)mapObj;
26
- + (NSArray<NSDictionary*>*)convertMapObjects:(id)mapObjects;
27
- + (NSString*)SPMapViewStatus:(SPMapViewStatus)status;
28
- + (NSString*)SPSmartMapBottomSheetViewState:(SPSmartMapBottomSheetViewState)state;
29
- + (NSString*)SPNavigationError:(SPNavigationError)error;
30
- + (NSString*)SPSmartMapUserTaskResponse:(SPSmartMapUserTaskResponse)response;
31
- + (NSDictionary*)convertSmartMapCameraOptionsToJSONWith:(SPSmartMapCameraOptions*)opts;
32
-
33
- @end
34
-
35
- #endif /* RCTConvert_SmartMapView_h */
@@ -1,295 +0,0 @@
1
- //
2
- // RCTConvert+SmartMapView.m
3
- // SteerpathOfficeApp
4
- //
5
- // Created by Jarvis Luong on 25/07/2019.
6
- // Copyright © 2019 Facebook. All rights reserved.
7
- //
8
-
9
- #import "RCTConvert+SmartMapView.h"
10
-
11
- @implementation RCTConvert(SPSmartSDK)
12
-
13
- + (SPSmartMapObject*)SPSmartMapObject:(id)json
14
- {
15
- json = [self NSDictionary:json];
16
- SPSmartMapObject* obj = [[SPSmartMapObject alloc] initWithLatitude:[self double:json[@"latitude"]]
17
- longitude:[self double:json[@"longitude"]]
18
- floorIndex:[self NSInteger:json[@"floorIndex"]]
19
- localRef:[self NSString:json[@"localRef"]]
20
- buildingRef:[self NSString:json[@"buildingRef"]]];
21
- obj.title = [self NSString:json[@"title"]];
22
- obj.properties = [RCTConvert NSDictionary:json[@"properties"]];
23
-
24
- NSString* rawSource = [self NSString:json[@"source"]];
25
- NSArray *items = @[@"static", @"marker", @"live"];
26
-
27
- NSInteger item = [items indexOfObject:rawSource];
28
- switch (item) {
29
- case 0:
30
- obj.source = SPObjectSourceStatic;
31
- break;
32
- case 1:
33
- obj.source = SPObjectSourceMarker;
34
- break;
35
- case 2:
36
- obj.source = SPObjectSourceLive;
37
- break;
38
- default:
39
- break;
40
- }
41
- return obj;
42
- }
43
-
44
- + (SPLayout)SPLayout:(NSString*)layout
45
- {
46
- NSArray *items = @[@"top", @"bottom", @"left", @"right"];
47
- NSInteger item = [items indexOfObject:layout];
48
- switch (item) {
49
- case 0:
50
- return SPLayoutTop;
51
- case 1:
52
- return SPLayoutBottom;
53
- case 2:
54
- return SPLayoutLeft;
55
- case 3:
56
- return SPLayoutRight;
57
- default:
58
- return SPLayoutTop;
59
- }
60
- }
61
-
62
- + (SPObjectSource)SPObjectSource:(NSString *)source
63
- {
64
- NSArray *items = @[@"MARKER", @"LIVE", @"STATIC"];
65
- NSInteger item = [items indexOfObject:source];
66
- switch (item) {
67
- case 0:
68
- return SPObjectSourceMarker;
69
- case 1:
70
- return SPObjectSourceLive;
71
- case 2:
72
- return SPObjectSourceStatic;
73
- default:
74
- return SPObjectSourceStatic;
75
- }
76
- }
77
-
78
- + (NSString*)SPMapResponse:(SPMapResponse)response
79
- {
80
- switch (response) {
81
- case SPMapResponseSuccess:
82
- return @"success";
83
-
84
- case SPMapResponseNetworkError:
85
- return @"networkError";
86
-
87
- case SPMapResponseObjectNotFound:
88
- return @"objectNotFound";
89
-
90
- default:
91
- return @"invalid";
92
- }
93
- }
94
-
95
- + (NSString*)SPSmartGeofenceResponseType:(SPSmartGeofenceResponseType)response
96
- {
97
- switch (response) {
98
- case SPSmartGeofenceResponseTypeSuccess:
99
- return @"success";
100
-
101
- case SPSmartGeofenceResponseTypeMalformedData:
102
- return @"malformedData";
103
-
104
- case SPSmartGeofenceResponseTypeGeofenceNotFound:
105
- return @"notFound";
106
-
107
- default:
108
- return @"invalid";
109
- }
110
- }
111
-
112
- + (SPSmartMapUserTask*)SPSmartUserTask:(id)json
113
- {
114
- json = [self NSDictionary:json];
115
- NSString* type = [self NSString:json[@"type"]];
116
- NSArray *items = @[@"navigation", @"poiSelection"];
117
- NSInteger item = [items indexOfObject:type];
118
- switch (item) {
119
- case 0:
120
- return [[SPSmartMapNavigationUserTask alloc] initWithMapObject:[RCTConvert SPSmartMapObject:json[@"payload"]]];
121
-
122
- case 1:
123
- return [RCTConvert SPSmartMapPOISelectionUserTask:json[@"payload"]];
124
-
125
- default:
126
- break;
127
- }
128
- return [[SPSmartMapUserTask alloc] init];
129
- }
130
-
131
- + (SPSmartMapPOISelectionUserTask*)SPSmartMapPOISelectionUserTask:(id)json
132
- {
133
- json = [self NSDictionary:json];
134
- SPSmartMapObject* mapObj = [RCTConvert SPSmartMapObject:json[@"smartMapObject"]];
135
- BOOL shouldAddMarker = [self BOOL:json[@"shouldAddMarker"]];
136
- NSString* actionButtonText = [self NSString:json[@"actionButtonText"]];
137
- NSString* actionButtonIcon = [self NSString:json[@"actionButtonIcon"]];
138
- return [[SPSmartMapPOISelectionUserTask alloc] initWith:mapObj shouldAddMarker:shouldAddMarker actionButtonText:actionButtonText actionButtonIcon:actionButtonIcon];
139
- }
140
-
141
- + (NSDictionary*)convertUserTaskToJSONWith:(nullable SPSmartMapUserTask*)task
142
- {
143
- if (task == nil) {
144
- return @{};
145
- }
146
- if ([task isKindOfClass:[SPSmartMapNavigationUserTask class]]) {
147
- SPSmartMapNavigationUserTask* navigationTask = (SPSmartMapNavigationUserTask*) task;
148
- NSArray<SPSmartMapObject*>* objects = [navigationTask getNavigationObjects];
149
- return @{
150
- @"type": @"navigation",
151
- @"payload": objects.count > 0 ? [RCTConvert convertMapObjectToJSONWith:[objects objectAtIndex:0]] : [NSNull null]
152
- };
153
- }
154
- if ([task isKindOfClass:[SPSmartMapPOISelectionUserTask class]]) {
155
- SPSmartMapPOISelectionUserTask* poiTask = (SPSmartMapPOISelectionUserTask*) task;
156
- return @{
157
- @"type": @"poiSelection",
158
- @"payload": @{
159
- @"smartMapObject": [RCTConvert convertMapObjectToJSONWith:poiTask.getMapObject],
160
- @"shouldAddMarker": @(poiTask.shouldAddMarker),
161
- @"actionButtonText": [RCTConvert valueOrEmptyIfNil:poiTask.getActionButtonText] ,
162
- @"actionButtonIcon": [RCTConvert valueOrEmptyIfNil:poiTask.iconName]
163
- }
164
- };
165
- }
166
- return @{};
167
- }
168
-
169
- + (NSDictionary *)convertMapObjectToJSONWith:(SPSmartMapObject *)mapObj
170
- {
171
- if (mapObj == nil) {
172
- return @{};
173
- }
174
- return @{
175
- @"title": mapObj.title ?: @"",
176
- @"latitude": [NSNumber numberWithDouble:mapObj.latitude],
177
- @"longitude": [NSNumber numberWithDouble:mapObj.longitude],
178
- @"floorIndex": [NSNumber numberWithInteger:mapObj.floorIndex],
179
- @"localRef": mapObj.localRef ?: @"",
180
- @"buildingRef": mapObj.buildingRef ?: @"",
181
- @"properties": mapObj.properties ?: @{}
182
- };
183
- }
184
-
185
- + (NSArray<NSDictionary*>*)convertMapObjects:(id)mapObjects
186
- {
187
- if (mapObjects) {
188
- NSArray<SPSmartMapObject*>* convertedObjects = mapObjects;
189
- NSMutableArray<NSDictionary*>* convertedMapObjects = [NSMutableArray new];
190
- for (int i = 0; i < [convertedObjects count]; i++) {
191
- [convertedMapObjects addObject:[RCTConvert convertMapObjectToJSONWith:[convertedObjects objectAtIndex:i]]];
192
- }
193
- return [NSArray arrayWithArray:convertedMapObjects];
194
- }
195
- return nil;
196
- }
197
-
198
- + (NSString *)SPMapViewStatus:(SPMapViewStatus)status
199
- {
200
- switch (status) {
201
- case SPMapViewStatusOnlyMap:
202
- return @"onlyMap";
203
- case SPMapViewStatusCardView:
204
- return @"cardView";
205
- case SPMapViewStatusErrorView:
206
- return @"errorView";
207
- case SPMapViewStatusSettingView:
208
- return @"settingView";
209
- case SPMapViewStatusNavigatingView:
210
- return @"navigatingView";
211
- case SPMapViewStatusSearchView:
212
- return @"searchView";
213
- default:
214
- return @"unknownViewStatus";
215
- }
216
- }
217
-
218
- + (NSString *)SPSmartMapBottomSheetViewState:(SPSmartMapBottomSheetViewState)state
219
- {
220
- switch (state) {
221
- case SPSmartMapBottomSheetViewStateHidden:
222
- return @"hidden";
223
- case SPSmartMapBottomSheetViewStateCollapsed:
224
- return @"collapsed";
225
- case SPSmartMapBottomSheetViewStateHalfExpanded:
226
- return @"halfExpanded";
227
- case SPSmartMapBottomSheetViewStateExpanded:
228
- return @"expanded";
229
- default:
230
- return @"unknownState";
231
- }
232
- }
233
-
234
- + (NSString *)SPNavigationError:(SPNavigationError)error
235
- {
236
- switch (error) {
237
- case SPNavigationErrorRouteNotFound:
238
- return @"routeNotFound";
239
- case SPNavigationErrorObjectNotFound:
240
- return @"objectNotFound";
241
- case SPNavigationErrorUserLocationNotFound:
242
- return @"userLocationNotFound";
243
-
244
- default:
245
- return @"unknownNavigationError";
246
- }
247
- }
248
-
249
- + (NSString *)SPSmartMapUserTaskResponse:(SPSmartMapUserTaskResponse)response
250
- {
251
- switch (response) {
252
- case SPSmartMapUserTaskResponseBusy:
253
- return @"busy";
254
- case SPSmartMapUserTaskResponseError:
255
- return @"error";
256
- case SPSmartMapUserTaskResponseStarted:
257
- return @"started";
258
- case SPSmartMapUserTaskResponseCancelled:
259
- return @"cancelled";
260
- case SPSmartMapUserTaskResponseCompleted:
261
- return @"completed";
262
- case SPSmartMapUserTaskResponseUnSupported:
263
- return @"unsupported";
264
-
265
- default:
266
- return @"unknownUserTaskResponse";
267
- }
268
- }
269
-
270
- + (NSString*)valueOrEmptyIfNil:(nullable NSString*)str
271
- {
272
- NSString* guarded = @"";
273
- if (str != nil) {
274
- guarded = str;
275
- }
276
- return guarded;
277
- }
278
-
279
- + (NSDictionary*)convertSmartMapCameraOptionsToJSONWith:(SPSmartMapCameraOptions*)opts
280
- {
281
- if (opts == nil) {
282
- return @{};
283
- }
284
-
285
- return @{
286
- @"pitch": [NSNumber numberWithDouble:opts.getPitch],
287
- @"bearing": [NSNumber numberWithDouble:opts.getBearing],
288
- @"zoomLevel": [NSNumber numberWithDouble:opts.getZoomLevel],
289
- @"latitude:": [NSNumber numberWithDouble:opts.getLatitude],
290
- @"longitude": [NSNumber numberWithDouble:opts.getLongitude]
291
- };
292
- }
293
-
294
- @end
295
-