@situm/react-native 3.0.7 → 3.1.0-beta.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/src/main/java/com/situm/plugin/PluginHelper.java +3 -2
- package/android/src/main/java/com/situm/plugin/SitumMapper.java +38 -59
- package/android/src/main/java/com/situm/plugin/SitumPlugin.java +1 -0
- package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +1 -1
- package/ios/SitumPlugin.m +8 -2
- package/lib/commonjs/sdk/index.js +509 -251
- package/lib/commonjs/sdk/index.js.map +1 -1
- package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
- package/lib/commonjs/sdk/types/constants.js +31 -4
- package/lib/commonjs/sdk/types/constants.js.map +1 -1
- package/lib/commonjs/sdk/utils.js +103 -0
- package/lib/commonjs/sdk/utils.js.map +1 -0
- package/lib/commonjs/utils/requestPermission.js +9 -16
- package/lib/commonjs/utils/requestPermission.js.map +1 -1
- package/lib/commonjs/wayfinding/components/MapView.js +78 -134
- package/lib/commonjs/wayfinding/components/MapView.js.map +1 -1
- package/lib/commonjs/wayfinding/hooks/index.js +118 -278
- package/lib/commonjs/wayfinding/hooks/index.js.map +1 -1
- package/lib/commonjs/wayfinding/store/index.js +17 -6
- package/lib/commonjs/wayfinding/store/index.js.map +1 -1
- package/lib/commonjs/wayfinding/types/index.js +1 -3
- package/lib/commonjs/wayfinding/types/index.js.map +1 -1
- package/lib/commonjs/wayfinding/utils/mapper.js +128 -71
- package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
- package/lib/module/sdk/index.js +509 -249
- package/lib/module/sdk/index.js.map +1 -1
- package/lib/module/sdk/nativeInterface.js.map +1 -1
- package/lib/module/sdk/types/constants.js +27 -3
- package/lib/module/sdk/types/constants.js.map +1 -1
- package/lib/module/sdk/utils.js +94 -0
- package/lib/module/sdk/utils.js.map +1 -0
- package/lib/module/utils/requestPermission.js +9 -16
- package/lib/module/utils/requestPermission.js.map +1 -1
- package/lib/module/wayfinding/components/MapView.js +77 -133
- package/lib/module/wayfinding/components/MapView.js.map +1 -1
- package/lib/module/wayfinding/hooks/index.js +119 -278
- package/lib/module/wayfinding/hooks/index.js.map +1 -1
- package/lib/module/wayfinding/store/index.js +15 -6
- package/lib/module/wayfinding/store/index.js.map +1 -1
- package/lib/module/wayfinding/types/index.js +1 -1
- package/lib/module/wayfinding/types/index.js.map +1 -1
- package/lib/module/wayfinding/utils/mapper.js +123 -72
- package/lib/module/wayfinding/utils/mapper.js.map +1 -1
- package/lib/typescript/src/sdk/index.d.ts +183 -145
- package/lib/typescript/src/sdk/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/nativeInterface.d.ts +59 -0
- package/lib/typescript/src/sdk/nativeInterface.d.ts.map +1 -1
- package/lib/typescript/src/sdk/types/constants.d.ts +24 -3
- package/lib/typescript/src/sdk/types/constants.d.ts.map +1 -1
- package/lib/typescript/src/sdk/types/index.d.ts +91 -146
- package/lib/typescript/src/sdk/types/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/utils.d.ts +53 -0
- package/lib/typescript/src/sdk/utils.d.ts.map +1 -0
- package/lib/typescript/src/utils/requestPermission.d.ts +1 -1
- package/lib/typescript/src/utils/requestPermission.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/components/MapView.d.ts +16 -28
- package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/hooks/index.d.ts +3 -34
- package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/store/index.d.ts +8 -6
- package/lib/typescript/src/wayfinding/store/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/types/index.d.ts +36 -17
- package/lib/typescript/src/wayfinding/types/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts +16 -11
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/sdk/index.ts +467 -476
- package/src/sdk/nativeInterface.ts +149 -1
- package/src/sdk/types/constants.ts +27 -3
- package/src/sdk/types/index.ts +98 -158
- package/src/sdk/utils.ts +129 -0
- package/src/utils/requestPermission.ts +18 -23
- package/src/wayfinding/components/MapView.tsx +145 -215
- package/src/wayfinding/hooks/index.ts +155 -385
- package/src/wayfinding/store/index.tsx +19 -9
- package/src/wayfinding/types/index.ts +49 -15
- package/src/wayfinding/utils/mapper.ts +145 -104
|
@@ -60,6 +60,7 @@ import es.situm.sdk.location.GeofenceListener;
|
|
|
60
60
|
import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_CHANGED;
|
|
61
61
|
import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_ERROR;
|
|
62
62
|
import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_STATUS_CHANGED;
|
|
63
|
+
import static com.situm.plugin.SitumPlugin.EVENT_LOCATION_STOPPED;
|
|
63
64
|
import static com.situm.plugin.SitumPlugin.EVENT_NAVIGATION_ERROR;
|
|
64
65
|
import static com.situm.plugin.SitumPlugin.EVENT_NAVIGATION_UPDATE;
|
|
65
66
|
import static com.situm.plugin.SitumPlugin.EVENT_REALTIME_ERROR;
|
|
@@ -402,13 +403,14 @@ public class PluginHelper {
|
|
|
402
403
|
}
|
|
403
404
|
}
|
|
404
405
|
|
|
405
|
-
public void stopPositioning(Callback callback) {
|
|
406
|
+
public void stopPositioning(Callback callback, DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter) {
|
|
406
407
|
try {
|
|
407
408
|
SitumSdk.locationManager().removeUpdates();
|
|
408
409
|
WritableMap map = Arguments.createMap();
|
|
409
410
|
map.putBoolean("success", true);
|
|
410
411
|
map.putString("message", "Stopped Successfully");
|
|
411
412
|
invokeCallback(callback, map);
|
|
413
|
+
eventEmitter.emit(EVENT_LOCATION_STOPPED, null);
|
|
412
414
|
} catch (Exception e) {
|
|
413
415
|
invokeCallback(callback, e.getMessage());
|
|
414
416
|
}
|
|
@@ -427,7 +429,6 @@ public class PluginHelper {
|
|
|
427
429
|
|
|
428
430
|
DirectionsRequest directionRequest = SitumMapper.jsonObjectToDirectionsRequest(jsonBuilding, jsonFrom,
|
|
429
431
|
jsonTo, jsonOptions);
|
|
430
|
-
|
|
431
432
|
SitumSdk.directionsManager().requestDirections(directionRequest, new Handler<Route>() {
|
|
432
433
|
@Override
|
|
433
434
|
public void onSuccess(Route route) {
|
|
@@ -7,12 +7,12 @@ import android.util.Log;
|
|
|
7
7
|
|
|
8
8
|
import androidx.annotation.Nullable;
|
|
9
9
|
|
|
10
|
+
import com.facebook.react.bridge.Arguments;
|
|
10
11
|
import com.facebook.react.bridge.ReadableArray;
|
|
11
12
|
import com.facebook.react.bridge.ReadableMap;
|
|
12
13
|
import com.facebook.react.bridge.WritableArray;
|
|
13
14
|
import com.facebook.react.bridge.WritableMap;
|
|
14
15
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
15
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
16
16
|
|
|
17
17
|
import org.json.JSONArray;
|
|
18
18
|
import org.json.JSONException;
|
|
@@ -29,7 +29,6 @@ import java.util.Iterator;
|
|
|
29
29
|
import java.util.List;
|
|
30
30
|
import java.util.Locale;
|
|
31
31
|
import java.util.Map;
|
|
32
|
-
import java.util.Stack;
|
|
33
32
|
|
|
34
33
|
import es.situm.sdk.directions.DirectionsRequest;
|
|
35
34
|
import es.situm.sdk.location.LocationRequest;
|
|
@@ -1100,9 +1099,12 @@ class SitumMapper {
|
|
|
1100
1099
|
DirectionsRequest.AccessibilityMode accessibilityMode = DirectionsRequest.AccessibilityMode.CHOOSE_SHORTEST;
|
|
1101
1100
|
Boolean minimizeFloorChanges = false;
|
|
1102
1101
|
double startingAngle = 0.0;
|
|
1103
|
-
|
|
1102
|
+
|
|
1104
1103
|
if (joOptions != null) {
|
|
1104
|
+
|
|
1105
|
+
|
|
1105
1106
|
if (joOptions.has(SitumMapper.ACCESSIBILITY_MODE)) {
|
|
1107
|
+
|
|
1106
1108
|
String mode = joOptions.getString(SitumMapper.ACCESSIBILITY_MODE);
|
|
1107
1109
|
if (mode.equals(DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE.name())) {
|
|
1108
1110
|
accessibilityMode = DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE;
|
|
@@ -1127,6 +1129,7 @@ class SitumMapper {
|
|
|
1127
1129
|
}
|
|
1128
1130
|
|
|
1129
1131
|
static ReadableArray mapList(List<? extends MapperInterface> modelObjects) {
|
|
1132
|
+
|
|
1130
1133
|
WritableArray mappedList = new WritableNativeArray();
|
|
1131
1134
|
for (MapperInterface modelObject : modelObjects) {
|
|
1132
1135
|
ReadableMap modelMap = convertMapToReadableMap(modelObject.toMap());
|
|
@@ -1136,37 +1139,25 @@ class SitumMapper {
|
|
|
1136
1139
|
}
|
|
1137
1140
|
|
|
1138
1141
|
public static ReadableMap convertMapToReadableMap(Map<String, Object> map) {
|
|
1139
|
-
WritableMap response =
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
currentTarget.putDouble(key, (Double) value);
|
|
1159
|
-
} else if (value instanceof Boolean) {
|
|
1160
|
-
currentTarget.putBoolean(key, (Boolean) value);
|
|
1161
|
-
} else if (value instanceof List) {
|
|
1162
|
-
// Warning: #convertMapToReadableMap maybe called here:
|
|
1163
|
-
currentTarget.putArray(key, convertListToReadableArray((List<Object>) value));
|
|
1164
|
-
} else if (value instanceof Map) {
|
|
1165
|
-
sourcesStack.push((Map) value);
|
|
1166
|
-
WritableMap nextMap = new WritableNativeMap();
|
|
1167
|
-
responseStack.push(nextMap);
|
|
1168
|
-
currentTarget.putMap(key, nextMap);
|
|
1169
|
-
}
|
|
1142
|
+
WritableMap response = Arguments.createMap();
|
|
1143
|
+
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
1144
|
+
String key = entry.getKey();
|
|
1145
|
+
Object value = entry.getValue();
|
|
1146
|
+
if (value instanceof String) {
|
|
1147
|
+
response.putString(key, (String) value);
|
|
1148
|
+
} else if (value instanceof Integer) {
|
|
1149
|
+
response.putInt(key, (Integer) value);
|
|
1150
|
+
} else if (value instanceof Double) {
|
|
1151
|
+
response.putDouble(key, (Double) value);
|
|
1152
|
+
} else if (value instanceof Boolean) {
|
|
1153
|
+
response.putBoolean(key, (Boolean) value);
|
|
1154
|
+
} else if (value instanceof List) {
|
|
1155
|
+
// Warning: #convertMapToReadableMap maybe called here:
|
|
1156
|
+
response.putArray(key, convertListToReadableArray((List<Object>) value));
|
|
1157
|
+
} else if (value instanceof Map) {
|
|
1158
|
+
// TODO: avoid recursive calls using a stack throws ObjectAlreadyConsumedException while
|
|
1159
|
+
// processing nested WritableMaps. Is there a way to avoid recursion?
|
|
1160
|
+
response.putMap(key, convertMapToReadableMap((Map) value));
|
|
1170
1161
|
}
|
|
1171
1162
|
}
|
|
1172
1163
|
return response;
|
|
@@ -1174,31 +1165,19 @@ class SitumMapper {
|
|
|
1174
1165
|
|
|
1175
1166
|
public static ReadableArray convertListToReadableArray(List<Object> list) {
|
|
1176
1167
|
WritableArray response = new WritableNativeArray();
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
} else if (value instanceof Double) {
|
|
1191
|
-
currentTarget.pushDouble((Double) value);
|
|
1192
|
-
} else if (value instanceof Boolean) {
|
|
1193
|
-
currentTarget.pushBoolean((Boolean) value);
|
|
1194
|
-
} else if (value instanceof Map) {
|
|
1195
|
-
currentTarget.pushMap(convertMapToReadableMap((Map) value));
|
|
1196
|
-
} else if (value instanceof List) {
|
|
1197
|
-
sourcesStack.push((List) value);
|
|
1198
|
-
WritableArray nextList = new WritableNativeArray();
|
|
1199
|
-
responseStack.push(nextList);
|
|
1200
|
-
currentTarget.pushArray(nextList);
|
|
1201
|
-
}
|
|
1168
|
+
for (Object value : list) {
|
|
1169
|
+
if (value instanceof String) {
|
|
1170
|
+
response.pushString((String) value);
|
|
1171
|
+
} else if (value instanceof Integer) {
|
|
1172
|
+
response.pushInt((Integer) value);
|
|
1173
|
+
} else if (value instanceof Double) {
|
|
1174
|
+
response.pushDouble((Double) value);
|
|
1175
|
+
} else if (value instanceof Boolean) {
|
|
1176
|
+
response.pushBoolean((Boolean) value);
|
|
1177
|
+
} else if (value instanceof Map) {
|
|
1178
|
+
response.pushMap(convertMapToReadableMap((Map) value));
|
|
1179
|
+
} else if (value instanceof List) {
|
|
1180
|
+
response.pushArray(convertListToReadableArray((List) value));
|
|
1202
1181
|
}
|
|
1203
1182
|
}
|
|
1204
1183
|
return response;
|
|
@@ -8,6 +8,7 @@ public interface SitumPlugin {
|
|
|
8
8
|
String EVENT_LOCATION_CHANGED = "locationChanged";
|
|
9
9
|
String EVENT_LOCATION_ERROR = "locationError";
|
|
10
10
|
String EVENT_LOCATION_STATUS_CHANGED = "statusChanged";
|
|
11
|
+
String EVENT_LOCATION_STOPPED = "locationStopped";
|
|
11
12
|
|
|
12
13
|
String EVENT_NAVIGATION_UPDATE = "navigationUpdated";
|
|
13
14
|
String EVENT_NAVIGATION_ERROR = "navigationError";
|
|
@@ -181,7 +181,7 @@ public class SitumPluginImpl extends ReactContextBaseJavaModule implements Situm
|
|
|
181
181
|
@Override
|
|
182
182
|
@ReactMethod
|
|
183
183
|
public void stopPositioning(Callback callback) {
|
|
184
|
-
|
|
184
|
+
getPluginInstance().stopPositioning(callback, getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class));
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
@Override
|
package/ios/SitumPlugin.m
CHANGED
|
@@ -84,7 +84,7 @@ RCT_EXPORT_MODULE(RNCSitumPlugin);
|
|
|
84
84
|
|
|
85
85
|
- (NSArray<NSString *> *)supportedEvents
|
|
86
86
|
{
|
|
87
|
-
return @[@"locationChanged", @"statusChanged", @"locationError", @"navigationUpdated", @"navigationError", @"realtimeUpdated", @"realtimeError", @"onEnterGeofences", @"onExitGeofences"];
|
|
87
|
+
return @[@"locationChanged", @"statusChanged", @"locationError", @"locationStopped", @"navigationUpdated", @"navigationError", @"realtimeUpdated", @"realtimeError", @"onEnterGeofences", @"onExitGeofences"];
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
@synthesize computedRoute = _computedRoute;
|
|
@@ -359,6 +359,11 @@ RCT_EXPORT_METHOD(stopPositioning:(RCTResponseSenderBlock)callback)
|
|
|
359
359
|
_positioningUpdates = NO;
|
|
360
360
|
[[SITLocationManager sharedInstance] removeUpdates];
|
|
361
361
|
[[SITLocationManager sharedInstance] removeDelegate:self];
|
|
362
|
+
|
|
363
|
+
NSDictionary *response = @{@"success": @YES, @"message": @"Stopped Successfully"};
|
|
364
|
+
callback(@[response]);
|
|
365
|
+
|
|
366
|
+
[self sendEventWithName:@"locationStopped" body:@{}];
|
|
362
367
|
}
|
|
363
368
|
|
|
364
369
|
RCT_EXPORT_METHOD(requestDirections: (NSArray *)requestArray withSuccessCallback:(RCTResponseSenderBlock)successBlock errorCallback:(RCTResponseSenderBlock)errorBlock)
|
|
@@ -897,13 +902,14 @@ destinationReachedOnRoute:(SITRoute *)route {
|
|
|
897
902
|
|
|
898
903
|
|
|
899
904
|
- (void)didEnteredGeofences:(NSArray<SITGeofence *> *)geofences {
|
|
905
|
+
|
|
900
906
|
NSArray *geofencesJO = [SitumLocationWrapper.shared geofencesToJsonArray:geofences];
|
|
901
907
|
|
|
902
908
|
[self sendEventWithName:@"onEnterGeofences" body:geofencesJO];
|
|
903
909
|
}
|
|
904
910
|
|
|
905
911
|
- (void)didExitedGeofences:(NSArray<SITGeofence *> *)geofences {
|
|
906
|
-
|
|
912
|
+
|
|
907
913
|
NSArray *geofencesJO = [SitumLocationWrapper.shared geofencesToJsonArray:geofences];
|
|
908
914
|
|
|
909
915
|
[self sendEventWithName:@"onExitGeofences" body:geofencesJO];
|