react-native-pointr 8.16.1 → 9.2.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/android/build.gradle +6 -9
- package/android/gradle.properties +3 -3
- package/android/src/main/AndroidManifestNew.xml +2 -9
- package/android/src/main/java/com/pointr/PTRMapWidgetCommandType.kt +3 -4
- package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +265 -394
- package/android/src/main/java/com/pointr/PointrModule.kt +36 -177
- package/ios/PTRMapWidgetContainerView.swift +248 -0
- package/ios/PTRMapWidgetManager-Bridging.m +116 -0
- package/ios/PTRMapWidgetManager.swift +255 -0
- package/ios/PTRNativeLibrary-Bridging.m +34 -0
- package/ios/PTRNativeLibrary.swift +357 -0
- package/ios/react-native-pointr-Bridging-Header.h +5 -0
- package/package.json +1 -1
- package/react-native-pointr.podspec +1 -1
- package/src/PTRCommand.ts +25 -4
- package/src/PTRMapWidgetUtils.ts +107 -16
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
- package/android/src/main/AndroidManifest.xml +0 -12
- package/android/src/main/java/com/pointr/PointrMapWidgetActivity.kt +0 -485
- package/android/src/main/res/layout/pointr_map_widget_activity_layout.xml +0 -16
- package/ios/PTRMapWidgetContainerView.h +0 -19
- package/ios/PTRMapWidgetContainerView.m +0 -281
- package/ios/PTRMapWidgetManager.m +0 -256
- package/ios/PTRNativeLibrary.h +0 -11
- package/ios/PTRNativeLibrary.m +0 -164
- package/ios/PointrApp.swift +0 -636
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import PointrKit
|
|
3
|
+
import React
|
|
4
|
+
|
|
5
|
+
@objc public protocol PTREventManagerDelegate {
|
|
6
|
+
func onPositionManagerCalculatedLocation(location: [String: Any])
|
|
7
|
+
func onBuildingClicked(_ building: [String: Any])
|
|
8
|
+
func onSiteClicked(_ site: [String: Any])
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc(PTRNativePointrLibrary)
|
|
12
|
+
class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
13
|
+
|
|
14
|
+
private var hasListeners = false
|
|
15
|
+
|
|
16
|
+
// PointrApp functionality moved here
|
|
17
|
+
@objc public weak var eventManagerDelegate: PTREventManagerDelegate?
|
|
18
|
+
@objc public static var shouldRequestPermissionsAtStartup: Bool = true
|
|
19
|
+
@objc public static let params = PTRParams()
|
|
20
|
+
|
|
21
|
+
let dispatchGroup = DispatchGroup()
|
|
22
|
+
var ptrMapWidget: PTRMapWidgetViewController? = nil
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
static var configuration: Dictionary<String,Any>? = nil {
|
|
26
|
+
didSet {
|
|
27
|
+
guard let configuration else {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
let mirror = Mirror(reflecting: mapWidgetConfiguration)
|
|
31
|
+
for attr in mirror.children {
|
|
32
|
+
guard let key = attr.label else {
|
|
33
|
+
continue
|
|
34
|
+
}
|
|
35
|
+
// only set boolean values
|
|
36
|
+
guard let value = configuration[key] as? Bool, attr.value is Bool else {
|
|
37
|
+
continue
|
|
38
|
+
}
|
|
39
|
+
mapWidgetConfiguration.setValue(value, forKey: key)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@objc public
|
|
45
|
+
static var mapWidgetConfiguration: PTRMapWidgetConfiguration = PTRMapWidgetConfiguration.defaultConfiguration()
|
|
46
|
+
|
|
47
|
+
private var dispatchGroupSiteManager = [DispatchGroup]()
|
|
48
|
+
var rootViewController: UIViewController? = nil
|
|
49
|
+
var isRouteFooterViewEnabled = true
|
|
50
|
+
|
|
51
|
+
override init() {
|
|
52
|
+
super.init()
|
|
53
|
+
self.eventManagerDelegate = self
|
|
54
|
+
guard let permissionManager = Pointr.shared.permissionManager else {
|
|
55
|
+
print("EDIP - Pointr permission manager not available")
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
permissionManager.delegate = self
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override func supportedEvents() -> [String]! {
|
|
66
|
+
return ["OnPositionManagerCalculatedLocation", "OnBuildingClicked", "OnSiteClicked"]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override func startObserving() {
|
|
70
|
+
hasListeners = true
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override func stopObserving() {
|
|
74
|
+
hasListeners = false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// MARK: - Utility Methods (from PointrApp)
|
|
78
|
+
|
|
79
|
+
func covertToDictionary(_ location: PTRCalculatedPosition) -> [String: Any] {
|
|
80
|
+
var dictionary = [String: Any]()
|
|
81
|
+
if let siteInternalIdentifier = location.site?.internalIdentifier {
|
|
82
|
+
dictionary.updateValue(siteInternalIdentifier, forKey: "siteInternalIdentifier")
|
|
83
|
+
}
|
|
84
|
+
if let buildingInternalIdentifier = location.building?.internalIdentifier {
|
|
85
|
+
dictionary.updateValue(buildingInternalIdentifier, forKey: "buildingInternalIdentifier")
|
|
86
|
+
}
|
|
87
|
+
if let siteExternalIdentifier = location.site?.externalIdentifier {
|
|
88
|
+
dictionary.updateValue(siteExternalIdentifier, forKey: "siteExternalIdentifier")
|
|
89
|
+
}
|
|
90
|
+
if let buildingExternalIdentifier = location.building?.externalIdentifier {
|
|
91
|
+
dictionary.updateValue(buildingExternalIdentifier, forKey: "buildingExternalIdentifier")
|
|
92
|
+
}
|
|
93
|
+
if let levelIndex = location.level?.index {
|
|
94
|
+
dictionary.updateValue(levelIndex, forKey: "levelIndex")
|
|
95
|
+
}
|
|
96
|
+
if location.coordinate.latitude != CLLocationDegrees(PTRPositioningTypes.invalidFloat()) && location.coordinate.longitude != CLLocationDegrees(PTRPositioningTypes.invalidFloat()) {
|
|
97
|
+
dictionary.updateValue(location.coordinate.latitude, forKey: "latitude")
|
|
98
|
+
dictionary.updateValue(location.coordinate.longitude, forKey: "longitude")
|
|
99
|
+
}
|
|
100
|
+
if location.accuracy != Double(PTRPositioningTypes.invalidFloat()) {
|
|
101
|
+
dictionary.updateValue(location.accuracy, forKey: "accuracy")
|
|
102
|
+
}
|
|
103
|
+
if (location.headingAccuracyClass == .high) {
|
|
104
|
+
dictionary.updateValue(location.heading, forKey: "heading")
|
|
105
|
+
}
|
|
106
|
+
return dictionary
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
func getAnimationTypeFromInt(value: Int) -> PTRMapAnimationType {
|
|
110
|
+
switch value {
|
|
111
|
+
case 0:
|
|
112
|
+
return .none
|
|
113
|
+
case 1:
|
|
114
|
+
return .standard
|
|
115
|
+
case 2:
|
|
116
|
+
return .flyOver
|
|
117
|
+
default:
|
|
118
|
+
return .none
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
func getErrorStringFromMapWidgetError(error: PTRMapWidgetError?) -> String? {
|
|
123
|
+
guard let error = error else {
|
|
124
|
+
return nil
|
|
125
|
+
}
|
|
126
|
+
return "\(error.errorCode ?? "")"
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
func getPointrStateStringFromPointrState(state: PointrState) -> String {
|
|
130
|
+
switch (state) {
|
|
131
|
+
case .running:
|
|
132
|
+
return "running"
|
|
133
|
+
case .failedRegistration:
|
|
134
|
+
return "failed registration"
|
|
135
|
+
case .failedValidation:
|
|
136
|
+
return "failed validation"
|
|
137
|
+
case .failedInvalidDeepLinkUrl:
|
|
138
|
+
return "failed invalid deep link url"
|
|
139
|
+
case .failedNoInternet:
|
|
140
|
+
return "failed no internet"
|
|
141
|
+
default:
|
|
142
|
+
return "off"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// MARK: - Core Methods
|
|
147
|
+
|
|
148
|
+
@objc func shouldRequestPermissionsAtStartup(_ shouldRequestPermissionsAtStartup: Bool) {
|
|
149
|
+
PTRNativeLibrary.shouldRequestPermissionsAtStartup = shouldRequestPermissionsAtStartup
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@objc func initialize(_ clientIdentifier: String,
|
|
153
|
+
licenseKey: String,
|
|
154
|
+
baseUrl: String,
|
|
155
|
+
logLevel: Int) {
|
|
156
|
+
guard let presentedViewController = RCTPresentedViewController() else { return }
|
|
157
|
+
self.rootViewController = presentedViewController
|
|
158
|
+
PTRNativeLibrary.params.mode = PointrDebugMode()
|
|
159
|
+
PTRNativeLibrary.params.loggerLevel = PTRLoggerLevel.init(rawValue: Int32(logLevel)) ?? .error
|
|
160
|
+
PTRNativeLibrary.params.licenseKey = licenseKey
|
|
161
|
+
PTRNativeLibrary.params.baseUrl = baseUrl
|
|
162
|
+
PTRNativeLibrary.params.clientIdentifier = clientIdentifier
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@objc func start(_ callback: @escaping RCTResponseSenderBlock) {
|
|
166
|
+
if Pointr.shared.state == .running {
|
|
167
|
+
callback(["Pointr is already running"])
|
|
168
|
+
} else {
|
|
169
|
+
let dispatchGroup = DispatchGroup()
|
|
170
|
+
dispatchGroup.enter()
|
|
171
|
+
Pointr.shared.start(with: PTRNativeLibrary.params) { state in
|
|
172
|
+
if (state == .running || state.rawValue <= 0) {
|
|
173
|
+
dispatchGroup.leave()
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
dispatchGroup.wait()
|
|
177
|
+
if Pointr.shared.state == .running {
|
|
178
|
+
Pointr.shared.positioningManager?.addListener(self)
|
|
179
|
+
}
|
|
180
|
+
callback([getPointrStateStringFromPointrState(state: Pointr.shared.state)])
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@objc func stop() {
|
|
185
|
+
Pointr.shared.positioningManager?.removeListener(self)
|
|
186
|
+
Pointr.shared.stop()
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@objc func requestPermissions() {
|
|
190
|
+
guard let permissionManager = Pointr.shared.permissionManager else { return }
|
|
191
|
+
if (!permissionManager.hasLocationAuthorizationWhenInUseOrAlways) {
|
|
192
|
+
permissionManager.requestLocationAuthorizationPermissionForWhenInUse()
|
|
193
|
+
}
|
|
194
|
+
if #available(iOS 17.4, *) {
|
|
195
|
+
if (!permissionManager.hasCoreMotionAuthorization) {
|
|
196
|
+
permissionManager.requestCoreMotionAuthorizationPermission()
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// MARK: - Map Widget Methods
|
|
202
|
+
|
|
203
|
+
func initializeMapWidget() {
|
|
204
|
+
if ptrMapWidget == nil {
|
|
205
|
+
ptrMapWidget = PTRMapWidgetViewController(location: PTRMapWidgetSiteLocation(siteIdentifier: ""), configuration: PTRNativeLibrary.mapWidgetConfiguration)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
func presentMapWidgetIfNotPresented() {
|
|
210
|
+
guard let ptrMapWidget = ptrMapWidget,
|
|
211
|
+
let rootViewController = rootViewController else { return }
|
|
212
|
+
|
|
213
|
+
if ptrMapWidget.view.superview == nil {
|
|
214
|
+
rootViewController.view.addSubview(ptrMapWidget.view)
|
|
215
|
+
ptrMapWidget.view.translatesAutoresizingMaskIntoConstraints = false
|
|
216
|
+
NSLayoutConstraint.activate([
|
|
217
|
+
ptrMapWidget.view.topAnchor.constraint(equalTo: rootViewController.view.safeAreaLayoutGuide.topAnchor),
|
|
218
|
+
ptrMapWidget.view.leadingAnchor.constraint(equalTo: rootViewController.view.leadingAnchor),
|
|
219
|
+
ptrMapWidget.view.trailingAnchor.constraint(equalTo: rootViewController.view.trailingAnchor),
|
|
220
|
+
ptrMapWidget.view.bottomAnchor.constraint(equalTo: rootViewController.view.bottomAnchor)
|
|
221
|
+
])
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@objc func getCurrentLocation(_ callback: @escaping RCTResponseSenderBlock) {
|
|
226
|
+
guard let positionManager = Pointr.shared.positioningManager else {
|
|
227
|
+
callback(["Position manager not available"])
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if let lastLocation = positionManager.lastValidCalculatedPosition {
|
|
232
|
+
let locationDict = covertToDictionary(lastLocation)
|
|
233
|
+
if let latitude = locationDict["latitude"] as? Double, latitude != -999999 {
|
|
234
|
+
callback([locationDict])
|
|
235
|
+
} else {
|
|
236
|
+
callback(["There is no location"])
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
callback(["There is no location"])
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@objc func setPointrMapWidgetConfiguration(_ string: String) {
|
|
244
|
+
guard let data = string.data(using: .utf8) else {
|
|
245
|
+
print("String does not have valid data")
|
|
246
|
+
return
|
|
247
|
+
}
|
|
248
|
+
do {
|
|
249
|
+
guard let jsonObject = try JSONSerialization.jsonObject(with: data) as? Dictionary<String,Any> else {
|
|
250
|
+
print("Bad json")
|
|
251
|
+
return
|
|
252
|
+
}
|
|
253
|
+
PTRNativeLibrary.configuration = jsonObject
|
|
254
|
+
} catch let error as NSError {
|
|
255
|
+
print("Error parsing json: \(string)\n\(error)")
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@objc func isMyCarMarked(_ callback: @escaping RCTResponseSenderBlock) {
|
|
260
|
+
let feature = Pointr.shared.getMyCarFeature()
|
|
261
|
+
if feature == nil {
|
|
262
|
+
callback(["No saved location"])
|
|
263
|
+
return
|
|
264
|
+
}
|
|
265
|
+
callback([])
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// MARK: - Event Manager Delegate
|
|
269
|
+
|
|
270
|
+
func onPositionManagerCalculatedLocation(location: [String : Any]) {
|
|
271
|
+
guard hasListeners else { return }
|
|
272
|
+
sendEvent(withName: "OnPositionManagerCalculatedLocation", body: location)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
func onBuildingClicked(_ building: [String : Any]) {
|
|
276
|
+
guard hasListeners else { return }
|
|
277
|
+
sendEvent(withName: "OnBuildingClicked", body: building)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
func onSiteClicked(_ site: [String : Any]) {
|
|
281
|
+
guard hasListeners else { return }
|
|
282
|
+
sendEvent(withName: "OnSiteClicked", body: site)
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// MARK: - PTRPositionManagerDelegate
|
|
287
|
+
extension PTRNativeLibrary: PTRPositioningManagerDelegate {
|
|
288
|
+
func onPositioningManagerCalculatedPosition(_ calculatedPosition: PTRCalculatedPosition) {
|
|
289
|
+
eventManagerDelegate?.onPositionManagerCalculatedLocation(location: self.covertToDictionary(calculatedPosition))
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// MARK: - PTRExitButtonEventsListener
|
|
294
|
+
extension PTRNativeLibrary: PTRExitButtonEventsListener {
|
|
295
|
+
func exitButtonDidTap() {
|
|
296
|
+
self.ptrMapWidget?.view.removeFromSuperview()
|
|
297
|
+
self.ptrMapWidget = nil
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// MARK: - PTRMapEventsListener
|
|
302
|
+
extension PTRNativeLibrary: PTRMapEventsListener {
|
|
303
|
+
public func map(_ map: PTRMapViewController, didReceiveTapOnFeature feature: PTRFeature) {
|
|
304
|
+
// Handle feature tap if needed
|
|
305
|
+
if (feature.typeCode == "building-outline") {
|
|
306
|
+
eventManagerDelegate?.onBuildingClicked([
|
|
307
|
+
"internalIdentifier": feature.identifier,
|
|
308
|
+
"externalIdentifier": feature.externalIdentifier,
|
|
309
|
+
"title": feature.name
|
|
310
|
+
])
|
|
311
|
+
} else if (feature.typeCode == "site-outline") {
|
|
312
|
+
eventManagerDelegate?.onSiteClicked([
|
|
313
|
+
"internalIdentifier": feature.identifier,
|
|
314
|
+
"externalIdentifier": feature.externalIdentifier,
|
|
315
|
+
"title": feature.name
|
|
316
|
+
])
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// MARK: - PTRSiteManagerDelegate
|
|
322
|
+
extension PTRNativeLibrary: PTRSiteManagerDelegate {
|
|
323
|
+
public func onSiteManagerDataChanged() {
|
|
324
|
+
while(!dispatchGroupSiteManager.isEmpty) {
|
|
325
|
+
let dispatchGroup = dispatchGroupSiteManager.removeLast()
|
|
326
|
+
dispatchGroup.leave()
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// MARK: - PTRPermissionManagerDelegate
|
|
332
|
+
extension PTRNativeLibrary: PTRPermissionManagerDelegate {
|
|
333
|
+
public func permissionManagerShouldRequestLocationAuthorizationPermission() -> Bool {
|
|
334
|
+
Plogv("Should request location permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
335
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
public func permissionManagerShouldRequestBluetoothServicesPermission() -> Bool {
|
|
339
|
+
Plogv("Should request bluetooth permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
340
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
public func permissionManagerShouldRequestUserNotificationAuthorizationPermission() -> Bool {
|
|
344
|
+
Plogv("Should request notification permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
345
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
public func permissionManagerShouldRequestCoreMotionAuthorizationPermission(_ permissionManager: any PTRPermissionManagerInterface) -> Bool {
|
|
349
|
+
Plogv("Should request core motion permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
350
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
func permissionManagerShouldRequestLocationAuthorizationPermissionForWhenInUse(_ permissionManager: any PTRPermissionManagerInterface) -> Bool {
|
|
354
|
+
Plogv("Should request location when in use permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
355
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
356
|
+
}
|
|
357
|
+
}
|
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 'PointrKit', '
|
|
19
|
+
s.dependency 'PointrKit', '9.2.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.
|
package/src/PTRCommand.ts
CHANGED
|
@@ -10,7 +10,8 @@ export enum PTRCommandType {
|
|
|
10
10
|
STATIC_PATH = "staticPath",
|
|
11
11
|
MARK_MY_CAR_LEVEL = "markMyCarForLevel",
|
|
12
12
|
MARK_MY_CAR_SITE = "markMyCarForSite",
|
|
13
|
-
|
|
13
|
+
SHOW_MY_CAR_SITE = "showMyCarForSite",
|
|
14
|
+
START_AND_FOCUS = "startAndFocus"
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* Base class for all Pointr SDK commands
|
|
@@ -110,10 +111,30 @@ export class PTRMarkMyCarSiteCommand extends PTRCommand {
|
|
|
110
111
|
/**
|
|
111
112
|
* Command to show my car details
|
|
112
113
|
* @param site - the site to show my car details
|
|
114
|
+
* @param shouldShowPopup - flag to show popup or not
|
|
113
115
|
* @param animationType - animation type to show map loading
|
|
114
116
|
*/
|
|
115
|
-
export class
|
|
116
|
-
constructor(public site: string, public animationType: number = 1) {
|
|
117
|
-
super(PTRCommandType.
|
|
117
|
+
export class PTRShowMyCarSiteCommand extends PTRCommand {
|
|
118
|
+
constructor(public site: string, public shouldShowPopup: boolean = true, public animationType: number = 1) {
|
|
119
|
+
super(PTRCommandType.SHOW_MY_CAR_SITE);
|
|
118
120
|
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Command to start the SDK and focus on a location using an existing PTR command
|
|
125
|
+
* This command is not a PTRCommand itself, but wraps SDK initialization with a focus command
|
|
126
|
+
* @param clientId - the client ID for SDK initialization
|
|
127
|
+
* @param licenseKey - the license key for SDK initialization
|
|
128
|
+
* @param baseUrl - the base URL for SDK initialization
|
|
129
|
+
* @param logLevel - the log level for SDK initialization
|
|
130
|
+
* @param command - the PTR command to execute after SDK initialization (PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, or PTRPoiCommand)
|
|
131
|
+
*/
|
|
132
|
+
export class PTRStartAndFocusCommand {
|
|
133
|
+
constructor(
|
|
134
|
+
public clientId: string,
|
|
135
|
+
public licenseKey: string,
|
|
136
|
+
public baseUrl: string,
|
|
137
|
+
public logLevel: number = 4,
|
|
138
|
+
public command: PTRSiteCommand | PTRBuildingCommand | PTRLevelCommand | PTRPoiCommand
|
|
139
|
+
) {}
|
|
119
140
|
}
|
package/src/PTRMapWidgetUtils.ts
CHANGED
|
@@ -1,18 +1,109 @@
|
|
|
1
1
|
import { UIManager } from 'react-native';
|
|
2
|
-
import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRCommand, PTRCommandType, PTRMarkMyCarLevelCommand, PTRMarkMyCarSiteCommand,
|
|
2
|
+
import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRCommand, PTRCommandType, PTRMarkMyCarLevelCommand, PTRMarkMyCarSiteCommand, PTRShowMyCarSiteCommand, PTRStartAndFocusCommand } from 'react-native-pointr/src/PTRCommand';
|
|
3
|
+
/**
|
|
4
|
+
* Handle PTRStartAndFocusCommand specifically
|
|
5
|
+
* @param reactTag view tag of the map widget
|
|
6
|
+
* @param startAndFocusCommand the start and focus command
|
|
7
|
+
*/
|
|
8
|
+
const handleStartAndFocusCommand = (reactTag: number, startAndFocusCommand: PTRStartAndFocusCommand) => {
|
|
9
|
+
const innerCommand = startAndFocusCommand.command;
|
|
10
|
+
console.info('Handling PTRStartAndFocusCommand with type:', innerCommand.type);
|
|
11
|
+
// Build arguments based on the inner command type
|
|
12
|
+
let args: any[];
|
|
13
|
+
console.info('Inner command details:', innerCommand);
|
|
14
|
+
|
|
15
|
+
switch (innerCommand.type) {
|
|
16
|
+
case PTRCommandType.SITE: {
|
|
17
|
+
const siteCommand = innerCommand as PTRSiteCommand;
|
|
18
|
+
args = [
|
|
19
|
+
startAndFocusCommand.clientId,
|
|
20
|
+
startAndFocusCommand.licenseKey,
|
|
21
|
+
startAndFocusCommand.baseUrl,
|
|
22
|
+
startAndFocusCommand.logLevel,
|
|
23
|
+
innerCommand.type,
|
|
24
|
+
siteCommand.site,
|
|
25
|
+
"",
|
|
26
|
+
0
|
|
27
|
+
];
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case PTRCommandType.BUILDING: {
|
|
31
|
+
const buildingCommand = innerCommand as PTRBuildingCommand;
|
|
32
|
+
args = [
|
|
33
|
+
startAndFocusCommand.clientId,
|
|
34
|
+
startAndFocusCommand.licenseKey,
|
|
35
|
+
startAndFocusCommand.baseUrl,
|
|
36
|
+
startAndFocusCommand.logLevel,
|
|
37
|
+
innerCommand.type,
|
|
38
|
+
buildingCommand.site,
|
|
39
|
+
buildingCommand.building,
|
|
40
|
+
0
|
|
41
|
+
];
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case PTRCommandType.LEVEL: {
|
|
45
|
+
const levelCommand = innerCommand as PTRLevelCommand;
|
|
46
|
+
args = [
|
|
47
|
+
startAndFocusCommand.clientId,
|
|
48
|
+
startAndFocusCommand.licenseKey,
|
|
49
|
+
startAndFocusCommand.baseUrl,
|
|
50
|
+
startAndFocusCommand.logLevel,
|
|
51
|
+
innerCommand.type,
|
|
52
|
+
levelCommand.site,
|
|
53
|
+
levelCommand.building,
|
|
54
|
+
levelCommand.level
|
|
55
|
+
];
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case PTRCommandType.POI: {
|
|
59
|
+
const poiCommand = innerCommand as PTRPoiCommand;
|
|
60
|
+
args = [
|
|
61
|
+
startAndFocusCommand.clientId,
|
|
62
|
+
startAndFocusCommand.licenseKey,
|
|
63
|
+
startAndFocusCommand.baseUrl,
|
|
64
|
+
startAndFocusCommand.logLevel,
|
|
65
|
+
innerCommand.type,
|
|
66
|
+
poiCommand.site,
|
|
67
|
+
poiCommand.poi,
|
|
68
|
+
0
|
|
69
|
+
];
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
console.error('Unsupported command type in PTRStartAndFocusCommand:', innerCommand.type);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
console.info('Dispatching startAndFocus with args:', args);
|
|
77
|
+
UIManager.dispatchViewManagerCommand(
|
|
78
|
+
reactTag,
|
|
79
|
+
'startAndFocus',
|
|
80
|
+
args,
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
3
84
|
/**
|
|
4
85
|
* Show the map widget with the given command
|
|
5
86
|
* @param reactTag view tag of the map widget
|
|
6
|
-
* @param ptrCommand command to show the map widget
|
|
87
|
+
* @param ptrCommand command to show the map widget (PTRCommand or PTRStartAndFocusCommand)
|
|
7
88
|
*/
|
|
8
|
-
export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
9
|
-
|
|
10
|
-
|
|
89
|
+
export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand | PTRStartAndFocusCommand) => {
|
|
90
|
+
// Check if it's a PTRStartAndFocusCommand (which doesn't have a 'type' property)
|
|
91
|
+
if ('command' in ptrCommand) {
|
|
92
|
+
const startAndFocusCommand = ptrCommand as PTRStartAndFocusCommand;
|
|
93
|
+
console.log(`Showing map widget with start and focus command: ${startAndFocusCommand.command.type} and reactTag: ${reactTag}`);
|
|
94
|
+
handleStartAndFocusCommand(reactTag, startAndFocusCommand);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Handle regular PTRCommand
|
|
99
|
+
const command = ptrCommand as PTRCommand;
|
|
100
|
+
console.log(`Showing map widget with command: ${command.type} and reactTag: ${reactTag}`);
|
|
101
|
+
switch (command.type) {
|
|
11
102
|
case PTRCommandType.SITE: {
|
|
12
103
|
const siteCommand = ptrCommand as PTRSiteCommand;
|
|
13
104
|
UIManager.dispatchViewManagerCommand(
|
|
14
105
|
reactTag,
|
|
15
|
-
|
|
106
|
+
'site',
|
|
16
107
|
[siteCommand.site],
|
|
17
108
|
);
|
|
18
109
|
break;
|
|
@@ -21,7 +112,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
21
112
|
const buildingCommand = ptrCommand as PTRBuildingCommand;
|
|
22
113
|
UIManager.dispatchViewManagerCommand(
|
|
23
114
|
reactTag,
|
|
24
|
-
|
|
115
|
+
'building',
|
|
25
116
|
[buildingCommand.site, buildingCommand.building],
|
|
26
117
|
);
|
|
27
118
|
break;
|
|
@@ -30,7 +121,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
30
121
|
const levelCommand = ptrCommand as PTRLevelCommand;
|
|
31
122
|
UIManager.dispatchViewManagerCommand(
|
|
32
123
|
reactTag,
|
|
33
|
-
|
|
124
|
+
'level',
|
|
34
125
|
[levelCommand.site, levelCommand.building, levelCommand.level],
|
|
35
126
|
);
|
|
36
127
|
break;
|
|
@@ -39,7 +130,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
39
130
|
const poiCommand = ptrCommand as PTRPoiCommand;
|
|
40
131
|
UIManager.dispatchViewManagerCommand(
|
|
41
132
|
reactTag,
|
|
42
|
-
|
|
133
|
+
'poi',
|
|
43
134
|
[poiCommand.site, poiCommand.poi],
|
|
44
135
|
);
|
|
45
136
|
break;
|
|
@@ -48,7 +139,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
48
139
|
const pathCommand = ptrCommand as PTRPathCommand;
|
|
49
140
|
UIManager.dispatchViewManagerCommand(
|
|
50
141
|
reactTag,
|
|
51
|
-
|
|
142
|
+
'path',
|
|
52
143
|
[pathCommand.site, pathCommand.poi],
|
|
53
144
|
);
|
|
54
145
|
break;
|
|
@@ -57,7 +148,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
57
148
|
const staticPathCommand = ptrCommand as PTRStaticPathCommand;
|
|
58
149
|
UIManager.dispatchViewManagerCommand(
|
|
59
150
|
reactTag,
|
|
60
|
-
|
|
151
|
+
'staticPath',
|
|
61
152
|
[staticPathCommand.site, staticPathCommand.fromPoi, staticPathCommand.toPoi],
|
|
62
153
|
);
|
|
63
154
|
break;
|
|
@@ -66,7 +157,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
66
157
|
const markMyCarCommand = ptrCommand as PTRMarkMyCarLevelCommand;
|
|
67
158
|
UIManager.dispatchViewManagerCommand(
|
|
68
159
|
reactTag,
|
|
69
|
-
|
|
160
|
+
'markMyCarForLevel',
|
|
70
161
|
[markMyCarCommand.site, markMyCarCommand.building, markMyCarCommand.level, markMyCarCommand.shouldShowPopup, markMyCarCommand.animationType],
|
|
71
162
|
);
|
|
72
163
|
break;
|
|
@@ -75,16 +166,16 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
75
166
|
const markMyCarCommand = ptrCommand as PTRMarkMyCarSiteCommand;
|
|
76
167
|
UIManager.dispatchViewManagerCommand(
|
|
77
168
|
reactTag,
|
|
78
|
-
|
|
169
|
+
'markMyCarForSite',
|
|
79
170
|
[markMyCarCommand.site, markMyCarCommand.shouldShowPopup, markMyCarCommand.animationType],
|
|
80
171
|
);
|
|
81
172
|
break;
|
|
82
173
|
}
|
|
83
|
-
case PTRCommandType.
|
|
84
|
-
const myCarCommand = ptrCommand as
|
|
174
|
+
case PTRCommandType.SHOW_MY_CAR_SITE: {
|
|
175
|
+
const myCarCommand = ptrCommand as PTRShowMyCarSiteCommand;
|
|
85
176
|
UIManager.dispatchViewManagerCommand(
|
|
86
177
|
reactTag,
|
|
87
|
-
|
|
178
|
+
'myCarForSite',
|
|
88
179
|
[myCarCommand.site, myCarCommand.animationType],
|
|
89
180
|
);
|
|
90
181
|
break;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
package="com.pointr">
|
|
4
|
-
<application>
|
|
5
|
-
<activity
|
|
6
|
-
android:name="com.pointr.PointrMapWidgetActivity"
|
|
7
|
-
android:exported="true"
|
|
8
|
-
android:launchMode="singleTask"
|
|
9
|
-
android:screenOrientation="portrait">
|
|
10
|
-
</activity>
|
|
11
|
-
</application>
|
|
12
|
-
</manifest>
|