react-native-radar 3.9.0 → 3.10.0-beta.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.
- package/android/build.gradle +2 -2
- package/dist/package.json +79 -0
- package/dist/src/@types/RadarNativeInterface.d.ts +51 -0
- package/dist/src/@types/RadarNativeInterface.js +2 -0
- package/dist/src/@types/types.d.ts +379 -0
- package/dist/src/@types/types.js +16 -0
- package/dist/src/helpers.d.ts +2 -0
- package/dist/src/helpers.js +11 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.native.d.ts +3 -0
- package/dist/src/index.native.js +136 -0
- package/dist/src/index.web.d.ts +73 -0
- package/dist/src/index.web.js +385 -0
- package/dist/src/ui/autocomplete.d.ts +4 -0
- package/dist/src/ui/autocomplete.js +213 -0
- package/dist/src/ui/images.d.ts +5 -0
- package/dist/src/ui/images.js +8 -0
- package/dist/src/ui/map.d.ts +5 -0
- package/dist/src/ui/map.js +112 -0
- package/dist/src/ui/styles.d.ts +2 -0
- package/dist/src/ui/styles.js +125 -0
- package/ios/Cartfile.resolved +1 -1
- package/package.json +14 -8
- package/react-native-radar.podspec +1 -1
- package/src/@types/RadarNativeInterface.ts +96 -0
- package/src/@types/types.ts +489 -0
- package/src/index.native.ts +272 -0
- package/src/index.ts +21 -0
- package/{js → src}/index.web.js +1 -1
- package/{js → src}/ui/autocomplete.jsx +3 -3
- package/js/index.js +0 -12
- package/js/index.native.js +0 -263
- /package/{js → src}/helpers.js +0 -0
- /package/{js → src}/ui/back.png +0 -0
- /package/{js → src}/ui/close.png +0 -0
- /package/{js → src}/ui/images.js +0 -0
- /package/{js → src}/ui/map-logo.png +0 -0
- /package/{js → src}/ui/map.jsx +0 -0
- /package/{js → src}/ui/marker.png +0 -0
- /package/{js → src}/ui/radar-logo.png +0 -0
- /package/{js → src}/ui/search.png +0 -0
- /package/{js → src}/ui/styles.js +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
// Autocomplete.js
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const react_native_1 = require("react-native");
|
|
32
|
+
const index_native_1 = __importDefault(require("../index.native"));
|
|
33
|
+
const images_1 = require("./images");
|
|
34
|
+
const styles_1 = __importDefault(require("./styles"));
|
|
35
|
+
const defaultAutocompleteOptions = {
|
|
36
|
+
debounceMS: 200, // Debounce time in milliseconds
|
|
37
|
+
minCharacters: 3, // Minimum number of characters to trigger autocomplete
|
|
38
|
+
limit: 8, // Maximum number of results to return
|
|
39
|
+
placeholder: "Search address", // Placeholder text for the input field
|
|
40
|
+
showMarkers: true,
|
|
41
|
+
disabled: false,
|
|
42
|
+
};
|
|
43
|
+
const autocompleteUI = ({ options = {} }) => {
|
|
44
|
+
const [query, setQuery] = (0, react_1.useState)("");
|
|
45
|
+
const [results, setResults] = (0, react_1.useState)([]);
|
|
46
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
47
|
+
const animationValue = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current; // animation value
|
|
48
|
+
const timerRef = (0, react_1.useRef)(null);
|
|
49
|
+
const textInputRef = (0, react_1.useRef)(null);
|
|
50
|
+
const config = { ...defaultAutocompleteOptions, ...options };
|
|
51
|
+
const style = config.style || {};
|
|
52
|
+
const fetchResults = (0, react_1.useCallback)(async (searchQuery) => {
|
|
53
|
+
if (searchQuery.length < config.minCharacters)
|
|
54
|
+
return;
|
|
55
|
+
const { limit, layers, countryCode } = config;
|
|
56
|
+
const params = { query: searchQuery, limit, layers, countryCode };
|
|
57
|
+
if (config.near && config.near.latitude && config.near.longitude) {
|
|
58
|
+
params.near = config.near;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const result = await index_native_1.default.autocomplete(params);
|
|
62
|
+
if (config.onResults && typeof config.onResults === "function") {
|
|
63
|
+
config.onResults(result.addresses);
|
|
64
|
+
}
|
|
65
|
+
setResults(result.addresses);
|
|
66
|
+
setIsOpen(true);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (config.onError && typeof config.onError === "function") {
|
|
70
|
+
config.onError(error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [config]);
|
|
74
|
+
const handleInput = (0, react_1.useCallback)((text) => {
|
|
75
|
+
setQuery(text);
|
|
76
|
+
// Clear the existing timer
|
|
77
|
+
if (timerRef.current) {
|
|
78
|
+
clearTimeout(timerRef.current);
|
|
79
|
+
}
|
|
80
|
+
if (text.length < config.minCharacters) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Set the new timer
|
|
84
|
+
timerRef.current = setTimeout(() => {
|
|
85
|
+
fetchResults(text);
|
|
86
|
+
}, config.debounceMS);
|
|
87
|
+
}, [config, fetchResults]);
|
|
88
|
+
const handleSelect = (item) => {
|
|
89
|
+
setQuery(item.formattedAddress);
|
|
90
|
+
setIsOpen(false);
|
|
91
|
+
if (typeof config.onSelection === "function") {
|
|
92
|
+
config.onSelection(item);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const renderFooter = () => {
|
|
96
|
+
if (results.length === 0)
|
|
97
|
+
return null;
|
|
98
|
+
return (<react_native_1.View style={styles.footerContainer}>
|
|
99
|
+
<react_native_1.View style={{ flexDirection: "row", alignItems: "center" }}>
|
|
100
|
+
<react_native_1.Text style={styles.footerText}>Powered by</react_native_1.Text>
|
|
101
|
+
<react_native_1.Image source={images_1.RADAR_LOGO} resizeMode="contain" style={styles_1.default.logo}/>
|
|
102
|
+
</react_native_1.View>
|
|
103
|
+
</react_native_1.View>);
|
|
104
|
+
};
|
|
105
|
+
const renderItem = ({ item }) => (<react_native_1.Pressable style={({ pressed }) => [
|
|
106
|
+
{
|
|
107
|
+
...styles.resultItem,
|
|
108
|
+
backgroundColor: pressed
|
|
109
|
+
? styles.resultItem.pressedBackgroundColor
|
|
110
|
+
: styles.resultItem.backgroundColor,
|
|
111
|
+
},
|
|
112
|
+
]} onPress={() => handleSelect(item)}>
|
|
113
|
+
<react_native_1.View style={styles.addressContainer}>
|
|
114
|
+
<react_native_1.View style={styles.pinIconContainer}>
|
|
115
|
+
{config.showMarkers ? (<react_native_1.Image source={images_1.MARKER_ICON} style={styles.pinIcon}/>) : null}
|
|
116
|
+
</react_native_1.View>
|
|
117
|
+
<react_native_1.View style={styles.addressTextContainer}>
|
|
118
|
+
<react_native_1.Text numberOfLines={1} style={styles.addressText}>
|
|
119
|
+
{item.addressLabel || item?.placeLabel}
|
|
120
|
+
</react_native_1.Text>
|
|
121
|
+
{item?.formattedAddress.length > 0 && (<react_native_1.Text numberOfLines={1} style={styles.addressSubtext}>
|
|
122
|
+
{item?.formattedAddress?.replace(`${item?.addressLabel || item?.placeLabel}, `, "")}
|
|
123
|
+
</react_native_1.Text>)}
|
|
124
|
+
</react_native_1.View>
|
|
125
|
+
</react_native_1.View>
|
|
126
|
+
</react_native_1.Pressable>);
|
|
127
|
+
const styles = {
|
|
128
|
+
...styles_1.default,
|
|
129
|
+
container: react_native_1.StyleSheet.compose(styles_1.default.container, style.container),
|
|
130
|
+
input: react_native_1.StyleSheet.compose(styles_1.default.input, style.input),
|
|
131
|
+
inputContainer: react_native_1.StyleSheet.compose(styles_1.default.inputContainer, style.inputContainer),
|
|
132
|
+
modalInputContainer: react_native_1.StyleSheet.compose(styles_1.default.modalInputContainer, style.modalInputContainer),
|
|
133
|
+
resultList: react_native_1.StyleSheet.compose(styles_1.default.resultList, style.resultList),
|
|
134
|
+
resultItem: react_native_1.StyleSheet.compose({ ...styles_1.default.resultItem, pressedBackgroundColor: '#F6FAFC' }, style.resultItem),
|
|
135
|
+
addressContainer: react_native_1.StyleSheet.compose(styles_1.default.addressContainer, style.addressContainer),
|
|
136
|
+
pinIconContainer: react_native_1.StyleSheet.compose(styles_1.default.pinIconContainer, style.pinIconContainer),
|
|
137
|
+
pinIcon: react_native_1.StyleSheet.compose(styles_1.default.pinIcon, style.pinIcon),
|
|
138
|
+
addressTextContainer: react_native_1.StyleSheet.compose(styles_1.default.addressTextContainer, style.addressTextContainer),
|
|
139
|
+
addressText: react_native_1.StyleSheet.compose(styles_1.default.addressText, style.addressText),
|
|
140
|
+
addressSubtext: react_native_1.StyleSheet.compose(styles_1.default.addressSubtext, style.addressSubtext),
|
|
141
|
+
footerContainer: react_native_1.StyleSheet.compose(styles_1.default.footerContainer, style.footerContainer),
|
|
142
|
+
footerText: react_native_1.StyleSheet.compose(styles_1.default.footerText, style.footerText),
|
|
143
|
+
};
|
|
144
|
+
(0, react_1.useEffect)(() => {
|
|
145
|
+
react_native_1.Animated.timing(animationValue, {
|
|
146
|
+
toValue: isOpen ? 1 : 0,
|
|
147
|
+
duration: 300,
|
|
148
|
+
easing: react_native_1.Easing.inOut(react_native_1.Easing.ease),
|
|
149
|
+
useNativeDriver: false,
|
|
150
|
+
}).start();
|
|
151
|
+
}, [isOpen]);
|
|
152
|
+
const screenHeight = react_native_1.Dimensions.get("window").height;
|
|
153
|
+
const inputHeight = animationValue.interpolate({
|
|
154
|
+
inputRange: [0, 1],
|
|
155
|
+
outputRange: [40, screenHeight],
|
|
156
|
+
});
|
|
157
|
+
const modalOpacity = animationValue.interpolate({
|
|
158
|
+
inputRange: [0, 0.5, 1],
|
|
159
|
+
outputRange: [0, 0, 1],
|
|
160
|
+
});
|
|
161
|
+
return (<react_native_1.View style={styles.container}>
|
|
162
|
+
<react_native_1.Animated.View style={{ height: inputHeight }}>
|
|
163
|
+
<react_native_1.TouchableOpacity style={styles.inputContainer} onPress={() => {
|
|
164
|
+
if (config.disabled)
|
|
165
|
+
return;
|
|
166
|
+
setIsOpen(true);
|
|
167
|
+
// Set the focus on the other textinput after it opens
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
textInputRef.current.focus();
|
|
170
|
+
}, 100);
|
|
171
|
+
}}>
|
|
172
|
+
<react_native_1.Image source={images_1.SEARCH_ICON} style={styles.inputIcon}/>
|
|
173
|
+
<react_native_1.TextInput style={styles.input} onFocus={() => {
|
|
174
|
+
setIsOpen(true);
|
|
175
|
+
setTimeout(() => {
|
|
176
|
+
textInputRef.current.focus();
|
|
177
|
+
}, 100);
|
|
178
|
+
}} value={query} returnKeyType="done" placeholder={config.placeholder} placeholderTextColor="#acbdc8"/>
|
|
179
|
+
</react_native_1.TouchableOpacity>
|
|
180
|
+
</react_native_1.Animated.View>
|
|
181
|
+
<react_native_1.Modal animationType="slide" transparent={false} visible={isOpen} onRequestClose={() => setIsOpen(false)}>
|
|
182
|
+
<react_native_1.Animated.View style={{ flex: 1, opacity: modalOpacity }}>
|
|
183
|
+
<react_native_1.SafeAreaView>
|
|
184
|
+
<react_native_1.KeyboardAvoidingView behavior={Platform.OS === "ios" ? "padding" : "height"} keyboardVerticalOffset={50} style={styles.container}>
|
|
185
|
+
<react_native_1.View style={styles.modalInputContainer}>
|
|
186
|
+
<react_native_1.TouchableOpacity onPress={() => {
|
|
187
|
+
setIsOpen(false);
|
|
188
|
+
}}>
|
|
189
|
+
<react_native_1.Image source={images_1.BACK_ICON} style={styles.inputIcon}/>
|
|
190
|
+
</react_native_1.TouchableOpacity>
|
|
191
|
+
<react_native_1.TextInput ref={textInputRef} style={styles.input} onChangeText={handleInput} value={query} placeholder={config.placeholder} returnKeyType="done" onSubmitEditing={() => {
|
|
192
|
+
setIsOpen(false);
|
|
193
|
+
}} placeholderTextColor="#acbdc8"/>
|
|
194
|
+
<react_native_1.TouchableOpacity onPress={() => {
|
|
195
|
+
setQuery("");
|
|
196
|
+
}}>
|
|
197
|
+
<react_native_1.Image source={images_1.CLOSE_ICON} style={styles.closeIcon}/>
|
|
198
|
+
</react_native_1.TouchableOpacity>
|
|
199
|
+
</react_native_1.View>
|
|
200
|
+
{results.length > 0 && (<react_native_1.View style={styles.resultListWrapper}>
|
|
201
|
+
<react_native_1.FlatList style={styles.resultList} data={results} onScroll={() => {
|
|
202
|
+
textInputRef.current.blur();
|
|
203
|
+
react_native_1.Keyboard.dismiss();
|
|
204
|
+
}} keyboardShouldPersistTaps="handled" renderItem={renderItem} keyExtractor={(item) => item.formattedAddress + item.postalCode}/>
|
|
205
|
+
{renderFooter()}
|
|
206
|
+
</react_native_1.View>)}
|
|
207
|
+
</react_native_1.KeyboardAvoidingView>
|
|
208
|
+
</react_native_1.SafeAreaView>
|
|
209
|
+
</react_native_1.Animated.View>
|
|
210
|
+
</react_native_1.Modal>
|
|
211
|
+
</react_native_1.View>);
|
|
212
|
+
};
|
|
213
|
+
exports.default = autocompleteUI;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLOSE_ICON = exports.MARKER_ICON = exports.RADAR_LOGO = exports.SEARCH_ICON = exports.BACK_ICON = void 0;
|
|
4
|
+
exports.BACK_ICON = require('./back.png');
|
|
5
|
+
exports.SEARCH_ICON = require('./search.png');
|
|
6
|
+
exports.RADAR_LOGO = require('./radar-logo.png');
|
|
7
|
+
exports.MARKER_ICON = require('./marker.png');
|
|
8
|
+
exports.CLOSE_ICON = require('./close.png');
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const react_native_1 = require("react-native");
|
|
31
|
+
const index_native_1 = __importDefault(require("../index.native"));
|
|
32
|
+
const helpers_1 = require("../helpers");
|
|
33
|
+
const styles_1 = __importDefault(require("./styles"));
|
|
34
|
+
let MapLibreGL;
|
|
35
|
+
try {
|
|
36
|
+
MapLibreGL = require('@maplibre/maplibre-react-native');
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
MapLibreGL = null;
|
|
40
|
+
}
|
|
41
|
+
const DEFAULT_STYLE = 'radar-default-v1';
|
|
42
|
+
const createStyleURL = async (style = DEFAULT_STYLE) => {
|
|
43
|
+
const host = await (0, helpers_1.getHost)();
|
|
44
|
+
const publishableKey = await (0, helpers_1.getPublishableKey)();
|
|
45
|
+
return `${host}/maps/styles/${style}?publishableKey=${publishableKey}`;
|
|
46
|
+
};
|
|
47
|
+
const RadarMap = ({ mapOptions, children }) => {
|
|
48
|
+
const [styleURL, setStyleURL] = (0, react_1.useState)(null);
|
|
49
|
+
const [userLocation, setUserLocation] = (0, react_1.useState)(null);
|
|
50
|
+
(0, react_1.useEffect)(() => {
|
|
51
|
+
createStyleURL(mapOptions?.mapStyle || DEFAULT_STYLE).then((result) => {
|
|
52
|
+
setStyleURL(result);
|
|
53
|
+
});
|
|
54
|
+
}, [mapOptions]);
|
|
55
|
+
(0, react_1.useEffect)(() => {
|
|
56
|
+
index_native_1.default.getLocation().then((result) => {
|
|
57
|
+
if (result?.location?.latitude && result?.location?.longitude) {
|
|
58
|
+
setUserLocation({
|
|
59
|
+
latitude: result.location.latitude,
|
|
60
|
+
longitude: result.location.longitude,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}).catch((err) => {
|
|
64
|
+
// eslint-disable-next-line no-console
|
|
65
|
+
console.warn(`Radar SDK: Failed to get location: ${err}`);
|
|
66
|
+
});
|
|
67
|
+
}, [mapOptions]);
|
|
68
|
+
if (!styleURL) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
if (!MapLibreGL) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const geoJSONUserLocation = {
|
|
75
|
+
type: 'FeatureCollection',
|
|
76
|
+
features: userLocation?.longitude !== undefined ? [
|
|
77
|
+
{
|
|
78
|
+
type: 'Feature',
|
|
79
|
+
geometry: {
|
|
80
|
+
type: 'Point',
|
|
81
|
+
coordinates: [userLocation.longitude, userLocation.latitude],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
] : [],
|
|
85
|
+
};
|
|
86
|
+
const userLocationMapIndicator = (<MapLibreGL.ShapeSource id="user-location" shape={geoJSONUserLocation}>
|
|
87
|
+
<MapLibreGL.CircleLayer id="user-location-inner" style={{
|
|
88
|
+
circleRadius: 15,
|
|
89
|
+
circleColor: '#000257',
|
|
90
|
+
circleOpacity: 0.2,
|
|
91
|
+
circlePitchAlignment: 'map',
|
|
92
|
+
}}/>
|
|
93
|
+
<MapLibreGL.CircleLayer id="user-location-middle" style={{
|
|
94
|
+
circleRadius: 9,
|
|
95
|
+
circleColor: '#fff',
|
|
96
|
+
circlePitchAlignment: 'map',
|
|
97
|
+
}}/>
|
|
98
|
+
<MapLibreGL.CircleLayer id="user-location-outer" style={{
|
|
99
|
+
circleRadius: 6,
|
|
100
|
+
circleColor: '#000257',
|
|
101
|
+
circlePitchAlignment: 'map',
|
|
102
|
+
}}/>
|
|
103
|
+
</MapLibreGL.ShapeSource>);
|
|
104
|
+
return (<react_native_1.View style={styles_1.default.mapContainer}>
|
|
105
|
+
<MapLibreGL.MapView style={styles_1.default.map} pitchEnabled={false} compassEnabled={false} logoEnabled={false} attributionEnabled onRegionDidChange={mapOptions?.onRegionDidChange ? mapOptions.onRegionDidChange : null} styleURL={styleURL}>
|
|
106
|
+
{userLocationMapIndicator}
|
|
107
|
+
{children}
|
|
108
|
+
</MapLibreGL.MapView>
|
|
109
|
+
<react_native_1.Image source={require('./map-logo.png')} style={styles_1.default.mapLogo}/>
|
|
110
|
+
</react_native_1.View>);
|
|
111
|
+
};
|
|
112
|
+
exports.default = RadarMap;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_native_1 = require("react-native");
|
|
4
|
+
const styles = react_native_1.StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: '100%',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
paddingTop: 8,
|
|
10
|
+
},
|
|
11
|
+
inputContainer: {
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
marginHorizontal: 16,
|
|
15
|
+
backgroundColor: 'white',
|
|
16
|
+
borderRadius: 5,
|
|
17
|
+
borderColor: '#DBE5EB',
|
|
18
|
+
borderWidth: 1,
|
|
19
|
+
width: '95%', // only difference between this and the modalInputContainer
|
|
20
|
+
},
|
|
21
|
+
modalInputContainer: {
|
|
22
|
+
flexDirection: 'row',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
marginHorizontal: 16,
|
|
25
|
+
backgroundColor: 'white',
|
|
26
|
+
borderRadius: 5,
|
|
27
|
+
borderColor: '#DBE5EB',
|
|
28
|
+
borderWidth: 1,
|
|
29
|
+
},
|
|
30
|
+
inputIcon: {
|
|
31
|
+
marginLeft: 10,
|
|
32
|
+
height: 18,
|
|
33
|
+
width: 18,
|
|
34
|
+
backgroundColor: 'white',
|
|
35
|
+
},
|
|
36
|
+
closeIcon: {
|
|
37
|
+
marginRight: 10,
|
|
38
|
+
height: 18,
|
|
39
|
+
width: 18,
|
|
40
|
+
backgroundColor: 'white',
|
|
41
|
+
},
|
|
42
|
+
input: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
backgroundColor: 'white',
|
|
45
|
+
height: 40,
|
|
46
|
+
fontSize: 14,
|
|
47
|
+
paddingHorizontal: 8,
|
|
48
|
+
borderRadius: 5,
|
|
49
|
+
},
|
|
50
|
+
resultListWrapper: {
|
|
51
|
+
width: '100%',
|
|
52
|
+
marginBottom: 30,
|
|
53
|
+
backgroundColor: 'white',
|
|
54
|
+
borderRadius: 5,
|
|
55
|
+
paddingVertical: 8,
|
|
56
|
+
},
|
|
57
|
+
resultList: {
|
|
58
|
+
width: '100%',
|
|
59
|
+
},
|
|
60
|
+
resultItem: {
|
|
61
|
+
paddingRight: 16,
|
|
62
|
+
paddingVertical: 8,
|
|
63
|
+
paddingHorizontal: 16,
|
|
64
|
+
fontSize: 12,
|
|
65
|
+
backgroundColor: 'white',
|
|
66
|
+
},
|
|
67
|
+
addressContainer: {
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
},
|
|
71
|
+
pinIconContainer: {
|
|
72
|
+
width: 28,
|
|
73
|
+
marginRight: 8,
|
|
74
|
+
},
|
|
75
|
+
pinIcon: {
|
|
76
|
+
height: 26,
|
|
77
|
+
width: 26,
|
|
78
|
+
},
|
|
79
|
+
addressTextContainer: {
|
|
80
|
+
flex: 1,
|
|
81
|
+
},
|
|
82
|
+
addressText: {
|
|
83
|
+
fontSize: 14,
|
|
84
|
+
lineHeight: 24,
|
|
85
|
+
color: '#000',
|
|
86
|
+
fontWeight: '600',
|
|
87
|
+
},
|
|
88
|
+
addressSubtext: {
|
|
89
|
+
fontSize: 14,
|
|
90
|
+
color: '#5A6872',
|
|
91
|
+
},
|
|
92
|
+
footerContainer: {
|
|
93
|
+
flexDirection: 'row',
|
|
94
|
+
alignItems: 'center',
|
|
95
|
+
paddingVertical: 10,
|
|
96
|
+
marginRight: 16,
|
|
97
|
+
alignSelf: 'flex-end',
|
|
98
|
+
},
|
|
99
|
+
footerText: {
|
|
100
|
+
marginTop: 2,
|
|
101
|
+
marginRight: 4,
|
|
102
|
+
fontSize: 10,
|
|
103
|
+
color: '#5A6872',
|
|
104
|
+
},
|
|
105
|
+
logo: {
|
|
106
|
+
width: 50,
|
|
107
|
+
height: 15,
|
|
108
|
+
resizeMode: 'contain',
|
|
109
|
+
},
|
|
110
|
+
mapContainer: {
|
|
111
|
+
flex: 1,
|
|
112
|
+
},
|
|
113
|
+
map: {
|
|
114
|
+
flex: 1,
|
|
115
|
+
},
|
|
116
|
+
mapLogo: {
|
|
117
|
+
position: 'absolute',
|
|
118
|
+
bottom: -10,
|
|
119
|
+
left: 5,
|
|
120
|
+
width: 50,
|
|
121
|
+
height: 50,
|
|
122
|
+
resizeMode: 'contain',
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
exports.default = styles;
|
package/ios/Cartfile.resolved
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "radarlabs/radar-sdk-ios" "3.9.
|
|
1
|
+
github "radarlabs/radar-sdk-ios" "3.9.3"
|
package/package.json
CHANGED
|
@@ -3,19 +3,22 @@
|
|
|
3
3
|
"description": "React Native module for Radar, the leading geofencing and location tracking platform",
|
|
4
4
|
"homepage": "https://radar.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "3.
|
|
7
|
-
"main": "
|
|
6
|
+
"version": "3.10.0-beta.1",
|
|
7
|
+
"main": "dist/src/index.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"android",
|
|
10
10
|
"ios",
|
|
11
|
-
"
|
|
11
|
+
"src",
|
|
12
12
|
"README.md",
|
|
13
|
-
"react-native-radar.podspec"
|
|
13
|
+
"react-native-radar.podspec",
|
|
14
|
+
"/dist"
|
|
14
15
|
],
|
|
16
|
+
"types":"dist/src/index.d.ts",
|
|
15
17
|
"scripts": {
|
|
16
18
|
"test": "jest ./test/*.test.js",
|
|
17
19
|
"check-latest-tag": "node ./scripts/check-latest-tag.cjs",
|
|
18
|
-
"check-beta-tag": "node ./scripts/check-beta-tag.cjs"
|
|
20
|
+
"check-beta-tag": "node ./scripts/check-beta-tag.cjs",
|
|
21
|
+
"build": "tsc"
|
|
19
22
|
},
|
|
20
23
|
"jest": {
|
|
21
24
|
"preset": "react-native",
|
|
@@ -26,9 +29,9 @@
|
|
|
26
29
|
]
|
|
27
30
|
},
|
|
28
31
|
"peerDependencies": {
|
|
32
|
+
"@maplibre/maplibre-react-native": "^9.0.1",
|
|
29
33
|
"react": ">= 16.8.6",
|
|
30
|
-
"react-native": ">= 0.60.0"
|
|
31
|
-
"@maplibre/maplibre-react-native": "^9.0.1"
|
|
34
|
+
"react-native": ">= 0.60.0"
|
|
32
35
|
},
|
|
33
36
|
"peerDependenciesMeta": {
|
|
34
37
|
"@maplibre/maplibre-react-native": {
|
|
@@ -40,6 +43,8 @@
|
|
|
40
43
|
"@babel/preset-env": "^7.2.3",
|
|
41
44
|
"@babel/preset-react": "^7.0.0",
|
|
42
45
|
"@babel/register": "^7.0.0",
|
|
46
|
+
"@types/node": "^20.11.7",
|
|
47
|
+
"@types/react-native": "^0.73.0",
|
|
43
48
|
"babel-core": "^7.0.0-bridge.0",
|
|
44
49
|
"babel-eslint": "^10.0.1",
|
|
45
50
|
"babel-jest": "^23.4.2",
|
|
@@ -56,7 +61,8 @@
|
|
|
56
61
|
"metro-react-native-babel-preset": "^0.51.1",
|
|
57
62
|
"npm-run-all": "^4.1.5",
|
|
58
63
|
"react": "16.8.6",
|
|
59
|
-
"react-native": "0.60.0"
|
|
64
|
+
"react-native": "0.60.0",
|
|
65
|
+
"typescript": "^5.3.3"
|
|
60
66
|
},
|
|
61
67
|
"bugs": {
|
|
62
68
|
"url": "https://github.com/radarlabs/react-native-radar/issues"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Location,
|
|
3
|
+
RadarAutocompleteOptions,
|
|
4
|
+
RadarContextCallback,
|
|
5
|
+
RadarGeocodeCallback,
|
|
6
|
+
RadarGetDistanceOptions,
|
|
7
|
+
RadarLocationCallback,
|
|
8
|
+
RadarLogConversionCallback,
|
|
9
|
+
RadarLogConversionOptions,
|
|
10
|
+
RadarLogLevel,
|
|
11
|
+
RadarMockTrackingOptions,
|
|
12
|
+
RadarNotificationOptions,
|
|
13
|
+
RadarPermissionsStatus,
|
|
14
|
+
RadarRouteCallback,
|
|
15
|
+
RadarRouteMatrix,
|
|
16
|
+
RadarSearchGeofencesCallback,
|
|
17
|
+
RadarSearchGeofencesOptions,
|
|
18
|
+
RadarSearchPlacesCallback,
|
|
19
|
+
RadarSearchPlacesOptions,
|
|
20
|
+
RadarStartTripOptions,
|
|
21
|
+
RadarTrackCallback,
|
|
22
|
+
RadarTrackOnceOptions,
|
|
23
|
+
RadarTrackTokenCallback,
|
|
24
|
+
RadarTrackingOptions,
|
|
25
|
+
RadarTrackingOptionsDesiredAccuracy,
|
|
26
|
+
RadarTrackingOptionsForegroundService,
|
|
27
|
+
RadarTripCallback,
|
|
28
|
+
RadarTripOptions,
|
|
29
|
+
RadarUpdateTripOptions,
|
|
30
|
+
Event,
|
|
31
|
+
} from "./types";
|
|
32
|
+
|
|
33
|
+
export interface RadarNativeInterface {
|
|
34
|
+
initialize: (publishableKey: string, fraud: boolean) => void;
|
|
35
|
+
setLogLevel: (level: RadarLogLevel) => void;
|
|
36
|
+
setUserId: (userId: string) => void;
|
|
37
|
+
getUserId: () => Promise<string>;
|
|
38
|
+
setDescription: (description: string) => void;
|
|
39
|
+
getDescription: () => Promise<string>;
|
|
40
|
+
setMetadata: (metadata: object) => void;
|
|
41
|
+
getMetadata: () => Promise<object>;
|
|
42
|
+
setAnonymousTrackingEnabled: (enabled: boolean) => void;
|
|
43
|
+
getPermissionsStatus: () => Promise<RadarPermissionsStatus>;
|
|
44
|
+
requestPermissions: (background: boolean) => Promise<RadarPermissionsStatus>;
|
|
45
|
+
getLocation: (
|
|
46
|
+
desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy
|
|
47
|
+
) => Promise<RadarLocationCallback>;
|
|
48
|
+
trackOnce: (
|
|
49
|
+
options?: RadarTrackOnceOptions | Location
|
|
50
|
+
) => Promise<RadarTrackCallback>;
|
|
51
|
+
trackVerifiedToken: () => Promise<RadarTrackTokenCallback>;
|
|
52
|
+
trackVerified: () => Promise<RadarTrackCallback>;
|
|
53
|
+
startTrackingEfficient: () => void;
|
|
54
|
+
startTrackingResponsive: () => void;
|
|
55
|
+
startTrackingContinuous: () => void;
|
|
56
|
+
startTrackingCustom: (options: RadarTrackingOptions) => void;
|
|
57
|
+
mockTracking: (options: RadarMockTrackingOptions) => void;
|
|
58
|
+
stopTracking: () => void;
|
|
59
|
+
getTrackingOptions: () => Promise<RadarTrackingOptions>;
|
|
60
|
+
isUsingRemoteTrackingOptions: () => Promise<boolean>;
|
|
61
|
+
isTracking: () => boolean;
|
|
62
|
+
setForegroundServiceOptions: (
|
|
63
|
+
options: RadarTrackingOptionsForegroundService
|
|
64
|
+
) => void;
|
|
65
|
+
setNotificationOptions: (options: RadarNotificationOptions) => void;
|
|
66
|
+
getTripOptions: () => Promise<RadarTripOptions>;
|
|
67
|
+
startTrip: (options: RadarStartTripOptions) => Promise<RadarTripCallback>;
|
|
68
|
+
completeTrip: () => Promise<RadarTripCallback>;
|
|
69
|
+
cancelTrip: () => Promise<RadarTripCallback>;
|
|
70
|
+
updateTrip: (options: RadarUpdateTripOptions) => Promise<RadarTripCallback>;
|
|
71
|
+
acceptEvent: (eventId: string, verifiedPlaceId: string) => void;
|
|
72
|
+
rejectEvent: (eventId: string) => void;
|
|
73
|
+
getContext: (location?: Location) => Promise<RadarContextCallback>;
|
|
74
|
+
searchPlaces: (
|
|
75
|
+
options: RadarSearchPlacesOptions
|
|
76
|
+
) => Promise<RadarSearchPlacesCallback>;
|
|
77
|
+
searchGeofences: (
|
|
78
|
+
options: RadarSearchGeofencesOptions
|
|
79
|
+
) => Promise<RadarSearchGeofencesCallback>;
|
|
80
|
+
autocomplete: (
|
|
81
|
+
options: RadarAutocompleteOptions
|
|
82
|
+
) => Promise<RadarGeocodeCallback>;
|
|
83
|
+
geocode: (address: string) => Promise<RadarGeocodeCallback>;
|
|
84
|
+
reverseGeocode: (location: any) => Promise<RadarGeocodeCallback>;
|
|
85
|
+
ipGeocode: () => Promise<RadarGeocodeCallback>;
|
|
86
|
+
getDistance: (option: RadarGetDistanceOptions) => Promise<RadarRouteCallback>;
|
|
87
|
+
getMatrix: (option: RadarGetDistanceOptions) => Promise<RadarRouteMatrix>;
|
|
88
|
+
logConversion: (
|
|
89
|
+
options: RadarLogConversionOptions
|
|
90
|
+
) => Promise<RadarLogConversionCallback>;
|
|
91
|
+
sendEvent: (name: string, metadata: Object) => void;
|
|
92
|
+
on: (event: Event, callback: Function | undefined) => void;
|
|
93
|
+
off: (event: Event, callback: Function | undefined) => void;
|
|
94
|
+
nativeSdkVersion: () => Promise<string>;
|
|
95
|
+
rnSdkVersion: () => string;
|
|
96
|
+
}
|