react-native-pointr 8.14.0 → 8.15.0
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.
- package/CHANGELOG.md +39 -0
- package/README.md +306 -3
- package/android/.settings/org.eclipse.buildship.core.prefs +2 -0
- package/android/build.gradle +2 -2
- package/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/java/com/pointr/PTRMapWidgetCommandType.kt +20 -0
- package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +777 -0
- package/android/src/main/java/com/pointr/PointrMapWidgetActivity.kt +102 -20
- package/android/src/main/java/com/pointr/PointrModule.kt +101 -21
- package/android/src/main/java/com/pointr/PointrPackage.kt +1 -1
- package/ios/PTRMapWidgetContainerView.h +19 -0
- package/ios/PTRMapWidgetContainerView.m +281 -0
- package/ios/PTRMapWidgetManager.m +256 -0
- package/ios/PTRNativeLibrary.h +0 -8
- package/ios/PTRNativeLibrary.m +17 -8
- package/ios/PointrApp.swift +124 -69
- package/package.json +1 -1
- package/react-native-pointr.podspec +1 -1
- package/src/PTRCommand.ts +119 -0
- package/src/PTRMapWidgetUtils.ts +93 -0
package/ios/PointrApp.swift
CHANGED
|
@@ -21,15 +21,16 @@ import PointrKit
|
|
|
21
21
|
|
|
22
22
|
@objc public static let sharedApp = PointrApp()
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
@objc public static var shouldRequestPermissionsAtStartup: Bool = true
|
|
25
|
+
|
|
26
|
+
@objc public static let params = PTRParams()
|
|
25
27
|
|
|
26
28
|
let dispatchGroup = DispatchGroup()
|
|
27
29
|
|
|
28
|
-
var
|
|
30
|
+
var ptrMapWidget: PTRMapWidgetViewController? = nil
|
|
29
31
|
|
|
30
32
|
var configuration: Dictionary<String,Any>? = nil
|
|
31
33
|
|
|
32
|
-
private var mapDispatchGroupDataManager = [Int32: [DispatchGroup]]()
|
|
33
34
|
private var dispatchGroupSiteManager = [DispatchGroup]()
|
|
34
35
|
|
|
35
36
|
var rootViewController: UIViewController? = nil
|
|
@@ -78,16 +79,16 @@ import PointrKit
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
func initialize(licenseKey: String, baseUrl: String, clientIdentifier: String, environment: String = "prod", logLevel: Int = 4, rootViewController: UIViewController) {
|
|
82
|
+
Pointr.shared.permissionManager?.delegate = self
|
|
81
83
|
self.rootViewController = rootViewController
|
|
82
|
-
|
|
84
|
+
PointrApp.params.mode = PointrDebugMode()
|
|
83
85
|
// No need to set environment
|
|
84
|
-
|
|
85
|
-
self.params.loggerLevel = PTRLoggerLevel.init(rawValue: Int32(logLevel)) ?? .error
|
|
86
|
+
PointrApp.params.loggerLevel = PTRLoggerLevel.init(rawValue: Int32(logLevel)) ?? .error
|
|
86
87
|
|
|
87
88
|
// Enter you license key
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
PointrApp.params.licenseKey = licenseKey
|
|
90
|
+
PointrApp.params.baseUrl = baseUrl
|
|
91
|
+
PointrApp.params.clientIdentifier = clientIdentifier
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
func getEnvironmentFromString(env: String) -> PTREnvironment {
|
|
@@ -155,16 +156,19 @@ import PointrKit
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
func start(completion: @escaping (String) -> Void) {
|
|
159
|
+
let dispatchGroup = DispatchGroup()
|
|
158
160
|
dispatchGroup.enter()
|
|
159
|
-
Pointr.shared.
|
|
160
|
-
|
|
161
|
+
Pointr.shared.start(with: PointrApp.params) { state in
|
|
162
|
+
if (state == .running || state.rawValue <= 0) {
|
|
163
|
+
dispatchGroup.leave()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
161
166
|
dispatchGroup.wait()
|
|
162
|
-
|
|
163
167
|
if Pointr.shared.state == .running {
|
|
164
168
|
Pointr.shared.positionManager?.addListener(self)
|
|
165
169
|
}
|
|
166
170
|
|
|
167
|
-
completion(getPointrStateStringFromPointrState(state: Pointr.shared.state))
|
|
171
|
+
completion(PointrApp.getPointrStateStringFromPointrState(state: Pointr.shared.state))
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
func stop() {
|
|
@@ -172,10 +176,22 @@ import PointrKit
|
|
|
172
176
|
Pointr.shared.stop()
|
|
173
177
|
}
|
|
174
178
|
|
|
179
|
+
func requestPermissions() {
|
|
180
|
+
guard let permissionManager = Pointr.shared.permissionManager else { return }
|
|
181
|
+
if (!permissionManager.hasLocationAuthorizationWhenInUseOrAlways) {
|
|
182
|
+
permissionManager.requestLocationAuthorizationPermissionForWhenInUse()
|
|
183
|
+
}
|
|
184
|
+
if #available(iOS 17.4, *) {
|
|
185
|
+
if (!permissionManager.hasCoreMotionAuthorization) {
|
|
186
|
+
permissionManager.requestCoreMotionAuthorizationPermission()
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
175
191
|
func showSite(siteExternalIdentifier id: String, animationType:Int, completion: @escaping (String?) -> Void) {
|
|
176
192
|
func showSiteWithCompletion(completion: @escaping (String?) -> Void) {
|
|
177
193
|
self.initializeMapWidget()
|
|
178
|
-
self.
|
|
194
|
+
self.ptrMapWidget!.showSite(siteExternalIdentifier: id, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
|
|
179
195
|
completion(self.getErrorStringFromMapWidgetError(error: error))
|
|
180
196
|
}
|
|
181
197
|
self.presentMapWidgetIfNotPresented()
|
|
@@ -197,7 +213,7 @@ import PointrKit
|
|
|
197
213
|
func showBuilding(siteExternalIdentifier: String, buildingExternalIdentifier: String, animationType:Int, completion: @escaping (String?) -> Void) {
|
|
198
214
|
func showBuildingWithCompletion(completion: @escaping (String?) -> Void) {
|
|
199
215
|
self.initializeMapWidget()
|
|
200
|
-
self.
|
|
216
|
+
self.ptrMapWidget!.showBuilding(siteExternalIdentifier: siteExternalIdentifier, buildingExternalIdentifier: buildingExternalIdentifier, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
|
|
201
217
|
completion(self.getErrorStringFromMapWidgetError(error: error))
|
|
202
218
|
}
|
|
203
219
|
self.presentMapWidgetIfNotPresented()
|
|
@@ -219,7 +235,7 @@ import PointrKit
|
|
|
219
235
|
func showLevel(siteExternalIdentifier: String, buildingExternalIdentifier: String, levelIndex: Int, animationType:Int, completion: @escaping (String?) -> Void) {
|
|
220
236
|
func showLevelWithCompletion(completion: @escaping (String?) -> Void) {
|
|
221
237
|
self.initializeMapWidget()
|
|
222
|
-
self.
|
|
238
|
+
self.ptrMapWidget!.showLevel(siteExternalIdentifier: siteExternalIdentifier, buildingExternalIdentifier: buildingExternalIdentifier, levelIndex: levelIndex, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
|
|
223
239
|
completion(self.getErrorStringFromMapWidgetError(error: error))
|
|
224
240
|
}
|
|
225
241
|
self.presentMapWidgetIfNotPresented()
|
|
@@ -241,7 +257,7 @@ import PointrKit
|
|
|
241
257
|
func showPoiDetails(siteExternalIdentifier id: String, poiExternalIdentifier: String, animationType:Int, completion: @escaping (String?) -> Void) {
|
|
242
258
|
func showPoiDetailsWithCompletion(completion: @escaping (String?) -> Void) {
|
|
243
259
|
self.initializeMapWidget()
|
|
244
|
-
self.
|
|
260
|
+
self.ptrMapWidget!.showPoiDetails(siteExternalIdentifier: id, poiExternalIdentifier: poiExternalIdentifier, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
|
|
245
261
|
completion(self.getErrorStringFromMapWidgetError(error: error))
|
|
246
262
|
}
|
|
247
263
|
self.presentMapWidgetIfNotPresented()
|
|
@@ -263,7 +279,7 @@ import PointrKit
|
|
|
263
279
|
func showPathFindingToPoi(siteExternalIdentifier id: String, poiExternalIdentifier: String, animationType:Int, completion: @escaping (String?) -> Void) {
|
|
264
280
|
func showPathFindingToPoiWithCompletion(completion: @escaping (String?) -> Void) {
|
|
265
281
|
self.initializeMapWidget()
|
|
266
|
-
self.
|
|
282
|
+
self.ptrMapWidget!.showPathFinding(siteExternalIdentifier: id, poiExternalIdentifier: poiExternalIdentifier, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
|
|
267
283
|
completion(self.getErrorStringFromMapWidgetError(error: error))
|
|
268
284
|
}
|
|
269
285
|
self.presentMapWidgetIfNotPresented()
|
|
@@ -307,7 +323,7 @@ import PointrKit
|
|
|
307
323
|
return
|
|
308
324
|
}
|
|
309
325
|
|
|
310
|
-
if !self.loadData(for: site
|
|
326
|
+
if !self.loadData(for: site) {
|
|
311
327
|
completion("Data are not ready for site: \(siteExternalIdentifier)")
|
|
312
328
|
return
|
|
313
329
|
}
|
|
@@ -334,16 +350,16 @@ import PointrKit
|
|
|
334
350
|
DispatchQueue.main.async {
|
|
335
351
|
self.initializeMapWidget()
|
|
336
352
|
self.presentMapWidgetIfNotPresented()
|
|
337
|
-
self.
|
|
353
|
+
self.ptrMapWidget!.showLevel(fromLevel, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
|
|
338
354
|
if let e = error {
|
|
339
355
|
completion(self.getErrorStringFromMapWidgetError(error: e))
|
|
340
356
|
return
|
|
341
357
|
}
|
|
342
358
|
let layer = PTRMapSymbolLayer(identifier: UUID().uuidString)
|
|
343
|
-
self.
|
|
344
|
-
self.
|
|
345
|
-
self.
|
|
346
|
-
self.
|
|
359
|
+
self.ptrMapWidget?.mapViewController.addLayer(layer)
|
|
360
|
+
self.ptrMapWidget?.mapViewController.addFeatures([to, from], toLayer: layer.identifier)
|
|
361
|
+
self.ptrMapWidget?.mapViewController.zoomToCoordinate(to.coordinate)
|
|
362
|
+
self.ptrMapWidget?.mapViewController.currentPath = path
|
|
347
363
|
completion(nil)
|
|
348
364
|
}
|
|
349
365
|
}
|
|
@@ -351,9 +367,7 @@ import PointrKit
|
|
|
351
367
|
}
|
|
352
368
|
|
|
353
369
|
func getSite(with siteExternalIdentifier: String, siteManager: PTRSiteManagerInterface, timeoutInSeconds: Int = 15) -> PTRSite? {
|
|
354
|
-
if
|
|
355
|
-
return site
|
|
356
|
-
} else {
|
|
370
|
+
if siteManager.sites().isEmpty {
|
|
357
371
|
let dispatchGroup = DispatchGroup()
|
|
358
372
|
self.dispatchGroupSiteManager.append(dispatchGroup)
|
|
359
373
|
dispatchGroup.enter()
|
|
@@ -364,19 +378,26 @@ import PointrKit
|
|
|
364
378
|
return siteManager.site(withExternalIdentifier: siteExternalIdentifier)
|
|
365
379
|
}
|
|
366
380
|
|
|
367
|
-
func loadData(for site: PTRSite,
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
let
|
|
372
|
-
|
|
373
|
-
self.mapDispatchGroupDataManager[site.internalIdentifier]?.append(dispatchGroup)
|
|
374
|
-
dataManager.addListener(self)
|
|
375
|
-
dispatchGroup.enter()
|
|
381
|
+
func loadData(for site: PTRSite, timeoutInSeconds: Int = 15) -> Bool {
|
|
382
|
+
guard let poiManager = Pointr.shared.poiManager else { return false }
|
|
383
|
+
guard !poiManager.hasContent(for: site) else { return true }
|
|
384
|
+
guard let dataManager = Pointr.shared.dataManager else { return false }
|
|
385
|
+
let listener = DataManagerListener(site: site)
|
|
386
|
+
dataManager.addListener(listener)
|
|
376
387
|
dataManager.loadData(forSite: site.internalIdentifier, shouldRespectCachePolicy: false)
|
|
377
|
-
|
|
378
|
-
dataManager.removeListener(
|
|
379
|
-
return
|
|
388
|
+
listener.wait(timeoutInSeconds)
|
|
389
|
+
dataManager.removeListener(listener)
|
|
390
|
+
return poiManager.hasContent(for: site)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
func waitForThemeManager(timeoutInSeconds: Int = 5) {
|
|
394
|
+
let themeManager = PTRMapWidgetThemeManager()
|
|
395
|
+
let listener = ThemeManagerListener()
|
|
396
|
+
themeManager.addListener(listener)
|
|
397
|
+
if (!themeManager.isConfigurationReady) {
|
|
398
|
+
listener.wait(timeoutInSeconds)
|
|
399
|
+
}
|
|
400
|
+
themeManager.removeListener(listener)
|
|
380
401
|
}
|
|
381
402
|
|
|
382
403
|
func getAnimationTypeFromInt(value: Int) -> PTRMapAnimationType {
|
|
@@ -392,14 +413,15 @@ import PointrKit
|
|
|
392
413
|
}
|
|
393
414
|
|
|
394
415
|
func initializeMapWidget() {
|
|
395
|
-
if self.
|
|
396
|
-
|
|
397
|
-
self.
|
|
398
|
-
self.
|
|
416
|
+
if self.ptrMapWidget != nil { return }
|
|
417
|
+
waitForThemeManager()
|
|
418
|
+
self.ptrMapWidget = PTRMapWidgetViewController(configuration: getMapWidgetConfiguration())
|
|
419
|
+
self.ptrMapWidget?.exitButton?.addListener(self)
|
|
420
|
+
self.ptrMapWidget?.mapViewController.addListener(self)
|
|
399
421
|
}
|
|
400
422
|
|
|
401
423
|
func presentMapWidgetIfNotPresented() {
|
|
402
|
-
guard let viewController =
|
|
424
|
+
guard let viewController = ptrMapWidget else {
|
|
403
425
|
return
|
|
404
426
|
}
|
|
405
427
|
if viewController.view.window != nil {
|
|
@@ -475,7 +497,7 @@ import PointrKit
|
|
|
475
497
|
}
|
|
476
498
|
}
|
|
477
499
|
|
|
478
|
-
func getPointrStateStringFromPointrState(state: PointrState) -> String {
|
|
500
|
+
@objc static func getPointrStateStringFromPointrState(state: PointrState) -> String {
|
|
479
501
|
switch state {
|
|
480
502
|
case .running:
|
|
481
503
|
return "running"
|
|
@@ -518,19 +540,10 @@ extension PointrApp: PTRPositionManagerDelegate {
|
|
|
518
540
|
}
|
|
519
541
|
}
|
|
520
542
|
|
|
521
|
-
extension PointrApp: PointrStateChangeListener {
|
|
522
|
-
public func pointrStateDidChange(to state: PointrState) {
|
|
523
|
-
if state.rawValue <= 0 || state == .running {
|
|
524
|
-
Pointr.shared.removeListener(self)
|
|
525
|
-
dispatchGroup.leave()
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
543
|
extension PointrApp: PTRExitButtonEventsListener {
|
|
531
544
|
public func exitButtonDidTap(_ exitbutton: PointrKit.PTRMapWidgetExitButton) {
|
|
532
|
-
self.
|
|
533
|
-
self.
|
|
545
|
+
self.ptrMapWidget?.view.removeFromSuperview()
|
|
546
|
+
self.ptrMapWidget = nil
|
|
534
547
|
}
|
|
535
548
|
}
|
|
536
549
|
|
|
@@ -560,22 +573,64 @@ extension PointrApp: PTRSiteManagerDelegate {
|
|
|
560
573
|
}
|
|
561
574
|
}
|
|
562
575
|
|
|
563
|
-
extension PointrApp: PTRDataManagerDelegate {
|
|
564
|
-
public func onDataManagerCompleteAll(for site: PTRSite, isSuccessful: Bool, dataFromOnline isOnlineData: Bool, errorMessages: [NSNumber : String]) {
|
|
565
|
-
if (!isOnlineData) {
|
|
566
|
-
return
|
|
567
|
-
}
|
|
568
|
-
while(self.mapDispatchGroupDataManager[site.internalIdentifier]?.isEmpty == false) {
|
|
569
|
-
if let dispatchGroup = self.mapDispatchGroupDataManager[site.internalIdentifier]?.removeLast() {
|
|
570
|
-
dispatchGroup.leave()
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
576
|
// TODO: remove below code when we have parameter to hide whole pathFindingViewController
|
|
577
577
|
extension PointrApp: PTRMapWidgetEventsListener {
|
|
578
578
|
public func mapWidgetWillPresentPathFinding(_ mapWidget: PTRMapWidgetViewController, pathFinding: PTRPathFindingViewController) {
|
|
579
579
|
pathFinding.view.isHidden = !isRouteFooterViewEnabled && !mapWidget.configuration.isRouteHeaderViewEnabled
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
+
|
|
583
|
+
extension PointrApp: PTRPermissionManagerDelegate {
|
|
584
|
+
public func permissionManagerShouldRequestBluetoothServicesPermission(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
585
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
586
|
+
}
|
|
587
|
+
public func permissionManagerShouldRequestBluetoothAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
588
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
589
|
+
}
|
|
590
|
+
public func permissionManagerShouldRequestCoreMotionAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
591
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
592
|
+
}
|
|
593
|
+
public func permissionManagerShouldRequestLocationAuthorizationPermissionForWhenInUse(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
594
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
595
|
+
}
|
|
596
|
+
public func permissionManagerShouldRequestLocationAuthorizationPermissionForAlways(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
597
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
598
|
+
}
|
|
599
|
+
public func permissionManagerShouldRequestUserNotificationAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
600
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
class DataManagerListener: NSObject, PTRDataManagerDelegate {
|
|
605
|
+
let dispatchGroup = DispatchGroup()
|
|
606
|
+
let site: PTRSite
|
|
607
|
+
init(site: PTRSite) {
|
|
608
|
+
self.site = site
|
|
609
|
+
super.init()
|
|
610
|
+
dispatchGroup.enter()
|
|
611
|
+
}
|
|
612
|
+
func onDataManagerCompleteAll(for site: PTRSite, isSuccessful: Bool, dataFromOnline isOnlineData: Bool, errorMessages: [NSNumber : String]) {
|
|
613
|
+
guard isOnlineData else {return}
|
|
614
|
+
dispatchGroup.leave()
|
|
615
|
+
}
|
|
616
|
+
func wait(_ seconds: Int = 15) {
|
|
617
|
+
_ = dispatchGroup.wait(wallTimeout: .now() + DispatchTimeInterval.seconds(seconds))
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
class ThemeManagerListener: NSObject, PTRMapWidgetThemeManagerListener {
|
|
622
|
+
let dispatchGroup = DispatchGroup()
|
|
623
|
+
|
|
624
|
+
override init() {
|
|
625
|
+
super.init()
|
|
626
|
+
dispatchGroup.enter()
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
func themeManagerConfigurationReady() {
|
|
630
|
+
dispatchGroup.leave()
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
func wait(_ seconds: Int = 5) {
|
|
634
|
+
_ = dispatchGroup.wait(wallTimeout: .now() + DispatchTimeInterval.seconds(seconds))
|
|
635
|
+
}
|
|
636
|
+
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
|
-
s.dependency
|
|
19
|
+
s.dependency 'PointrKit', '8.15.0'
|
|
20
20
|
|
|
21
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command types supported by the Pointr SDK
|
|
3
|
+
*/
|
|
4
|
+
export enum PTRCommandType {
|
|
5
|
+
SITE = "site",
|
|
6
|
+
BUILDING = "building",
|
|
7
|
+
LEVEL = "level",
|
|
8
|
+
POI = "poi",
|
|
9
|
+
PATH = "path",
|
|
10
|
+
STATIC_PATH = "staticPath",
|
|
11
|
+
MARK_MY_CAR_LEVEL = "markMyCarForLevel",
|
|
12
|
+
MARK_MY_CAR_SITE = "markMyCarForSite",
|
|
13
|
+
MY_CAR_SITE = "myCarForSite"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Base class for all Pointr SDK commands
|
|
17
|
+
* @param type - the command type
|
|
18
|
+
*/
|
|
19
|
+
export abstract class PTRCommand {
|
|
20
|
+
constructor(public type: PTRCommandType = PTRCommandType.SITE) { }
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Command to show a site
|
|
24
|
+
* @param site - the site to show
|
|
25
|
+
*/
|
|
26
|
+
export class PTRSiteCommand extends PTRCommand {
|
|
27
|
+
constructor(public site: string) {
|
|
28
|
+
super(PTRCommandType.SITE);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Command to show a building
|
|
33
|
+
* @param site - the site to show
|
|
34
|
+
* @param building - the building to show
|
|
35
|
+
*/
|
|
36
|
+
export class PTRBuildingCommand extends PTRCommand {
|
|
37
|
+
constructor(public site: string, public building: string) {
|
|
38
|
+
super(PTRCommandType.BUILDING);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Command to show a level
|
|
43
|
+
* @param site - the site to show
|
|
44
|
+
* @param building - the building to show
|
|
45
|
+
* @param level - the level to show
|
|
46
|
+
*/
|
|
47
|
+
export class PTRLevelCommand extends PTRCommand {
|
|
48
|
+
constructor(public site: string, public building: string, public level: number) {
|
|
49
|
+
super(PTRCommandType.LEVEL);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Command to show a POI
|
|
54
|
+
* @param site - the site that has the POI
|
|
55
|
+
* @param poi - the POI to show
|
|
56
|
+
*/
|
|
57
|
+
export class PTRPoiCommand extends PTRCommand {
|
|
58
|
+
constructor(public site: string, public poi: string) {
|
|
59
|
+
super(PTRCommandType.POI);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Command to show a path
|
|
64
|
+
* @param site - the site that has the POI
|
|
65
|
+
* @param poi - the POI to show the path to from the current location
|
|
66
|
+
*/
|
|
67
|
+
export class PTRPathCommand extends PTRCommand {
|
|
68
|
+
constructor(public site: string, public poi: string) {
|
|
69
|
+
super(PTRCommandType.PATH);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Command to show a static path
|
|
74
|
+
* @param site - the site that has the POIs
|
|
75
|
+
* @param fromPoi - the POI to start the path from
|
|
76
|
+
* @param toPoi - the POI to end the path at
|
|
77
|
+
*/
|
|
78
|
+
export class PTRStaticPathCommand extends PTRCommand {
|
|
79
|
+
constructor(public site: string, public fromPoi: string, public toPoi: string) {
|
|
80
|
+
super(PTRCommandType.STATIC_PATH);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Command to show mark my car details
|
|
86
|
+
* @param site - the site to show mark my car details
|
|
87
|
+
* @param building - the building to show mark my car details
|
|
88
|
+
* @param level - the level to show mark my car details
|
|
89
|
+
* @param shouldShowPopup - flag to show popup or not
|
|
90
|
+
* @param animationType - animation type to show map loading
|
|
91
|
+
*/
|
|
92
|
+
export class PTRMarkMyCarLevelCommand extends PTRCommand {
|
|
93
|
+
constructor(public site: string, public building: string, public level: number, public shouldShowPopup: boolean = true, public animationType: number = 1) {
|
|
94
|
+
super(PTRCommandType.MARK_MY_CAR_LEVEL);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Command to show mark my car details
|
|
100
|
+
* @param site - the site to show mark my car details
|
|
101
|
+
* @param shouldShowPopup - flag to show popup or not
|
|
102
|
+
* @param animationType - animation type to show map loading
|
|
103
|
+
*/
|
|
104
|
+
export class PTRMarkMyCarSiteCommand extends PTRCommand {
|
|
105
|
+
constructor(public site: string, public shouldShowPopup: boolean = true, public animationType: number = 1) {
|
|
106
|
+
super(PTRCommandType.MARK_MY_CAR_SITE);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Command to show my car details
|
|
112
|
+
* @param site - the site to show my car details
|
|
113
|
+
* @param animationType - animation type to show map loading
|
|
114
|
+
*/
|
|
115
|
+
export class PTRMyCarSiteCommand extends PTRCommand {
|
|
116
|
+
constructor(public site: string, public animationType: number = 1) {
|
|
117
|
+
super(PTRCommandType.MY_CAR_SITE);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { UIManager } from 'react-native';
|
|
2
|
+
import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRCommand, PTRCommandType, PTRMarkMyCarLevelCommand, PTRMarkMyCarSiteCommand, PTRMyCarSiteCommand } from 'react-native-pointr/src/PTRCommand';
|
|
3
|
+
/**
|
|
4
|
+
* Show the map widget with the given command
|
|
5
|
+
* @param reactTag view tag of the map widget
|
|
6
|
+
* @param ptrCommand command to show the map widget
|
|
7
|
+
*/
|
|
8
|
+
export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
9
|
+
console.log(`Showing map widget with command: ${ptrCommand.type}`);
|
|
10
|
+
switch (ptrCommand.type) {
|
|
11
|
+
case PTRCommandType.SITE: {
|
|
12
|
+
const siteCommand = ptrCommand as PTRSiteCommand;
|
|
13
|
+
UIManager.dispatchViewManagerCommand(
|
|
14
|
+
reactTag,
|
|
15
|
+
ptrCommand.type,
|
|
16
|
+
[siteCommand.site],
|
|
17
|
+
);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
case PTRCommandType.BUILDING: {
|
|
21
|
+
const buildingCommand = ptrCommand as PTRBuildingCommand;
|
|
22
|
+
UIManager.dispatchViewManagerCommand(
|
|
23
|
+
reactTag,
|
|
24
|
+
ptrCommand.type,
|
|
25
|
+
[buildingCommand.site, buildingCommand.building],
|
|
26
|
+
);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case PTRCommandType.LEVEL: {
|
|
30
|
+
const levelCommand = ptrCommand as PTRLevelCommand;
|
|
31
|
+
UIManager.dispatchViewManagerCommand(
|
|
32
|
+
reactTag,
|
|
33
|
+
ptrCommand.type,
|
|
34
|
+
[levelCommand.site, levelCommand.building, levelCommand.level],
|
|
35
|
+
);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case PTRCommandType.POI: {
|
|
39
|
+
const poiCommand = ptrCommand as PTRPoiCommand;
|
|
40
|
+
UIManager.dispatchViewManagerCommand(
|
|
41
|
+
reactTag,
|
|
42
|
+
ptrCommand.type,
|
|
43
|
+
[poiCommand.site, poiCommand.poi],
|
|
44
|
+
);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case PTRCommandType.PATH: {
|
|
48
|
+
const pathCommand = ptrCommand as PTRPathCommand;
|
|
49
|
+
UIManager.dispatchViewManagerCommand(
|
|
50
|
+
reactTag,
|
|
51
|
+
ptrCommand.type,
|
|
52
|
+
[pathCommand.site, pathCommand.poi],
|
|
53
|
+
);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case PTRCommandType.STATIC_PATH: {
|
|
57
|
+
const staticPathCommand = ptrCommand as PTRStaticPathCommand;
|
|
58
|
+
UIManager.dispatchViewManagerCommand(
|
|
59
|
+
reactTag,
|
|
60
|
+
ptrCommand.type,
|
|
61
|
+
[staticPathCommand.site, staticPathCommand.fromPoi, staticPathCommand.toPoi],
|
|
62
|
+
);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case PTRCommandType.MARK_MY_CAR_LEVEL: {
|
|
66
|
+
const markMyCarCommand = ptrCommand as PTRMarkMyCarLevelCommand;
|
|
67
|
+
UIManager.dispatchViewManagerCommand(
|
|
68
|
+
reactTag,
|
|
69
|
+
ptrCommand.type,
|
|
70
|
+
[markMyCarCommand.site, markMyCarCommand.building, markMyCarCommand.level, markMyCarCommand.shouldShowPopup, markMyCarCommand.animationType],
|
|
71
|
+
);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case PTRCommandType.MARK_MY_CAR_SITE: {
|
|
75
|
+
const markMyCarCommand = ptrCommand as PTRMarkMyCarSiteCommand;
|
|
76
|
+
UIManager.dispatchViewManagerCommand(
|
|
77
|
+
reactTag,
|
|
78
|
+
ptrCommand.type,
|
|
79
|
+
[markMyCarCommand.site, markMyCarCommand.shouldShowPopup, markMyCarCommand.animationType],
|
|
80
|
+
);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case PTRCommandType.MY_CAR_SITE: {
|
|
84
|
+
const myCarCommand = ptrCommand as PTRMyCarSiteCommand;
|
|
85
|
+
UIManager.dispatchViewManagerCommand(
|
|
86
|
+
reactTag,
|
|
87
|
+
ptrCommand.type,
|
|
88
|
+
[myCarCommand.site, myCarCommand.animationType],
|
|
89
|
+
);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|