react-native-map-link 2.11.4 → 3.0.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.
Files changed (51) hide show
  1. package/lib/components/popup/Popup.d.ts +39 -0
  2. package/lib/components/popup/Popup.js +110 -0
  3. package/lib/components/popup/PopupBody.d.ts +16 -0
  4. package/lib/components/popup/PopupBody.js +31 -0
  5. package/lib/components/popup/PopupFlatList.d.ts +10 -0
  6. package/lib/components/popup/PopupFlatList.js +11 -0
  7. package/lib/components/popup/PopupFooter.d.ts +15 -0
  8. package/lib/components/popup/PopupFooter.js +18 -0
  9. package/lib/components/popup/PopupHeader.d.ts +17 -0
  10. package/lib/components/popup/PopupHeader.js +48 -0
  11. package/lib/components/popup/PopupItem.d.ts +13 -0
  12. package/lib/components/popup/PopupItem.js +38 -0
  13. package/lib/components/popup/PopupSeparator.d.ts +8 -0
  14. package/lib/components/popup/PopupSeparator.js +19 -0
  15. package/lib/constants.d.ts +15 -0
  16. package/lib/constants.js +97 -0
  17. package/lib/index.d.ts +3 -0
  18. package/lib/index.js +116 -0
  19. package/lib/type.d.ts +92 -0
  20. package/lib/type.js +2 -0
  21. package/lib/utils.d.ts +44 -0
  22. package/lib/utils.js +307 -0
  23. package/package.json +52 -20
  24. package/index.d.ts +0 -128
  25. package/index.js +0 -8
  26. package/src/components/Popup.js +0 -298
  27. package/src/constants.js +0 -95
  28. package/src/images/apple-maps.png +0 -0
  29. package/src/images/citymapper.png +0 -0
  30. package/src/images/dgis.png +0 -0
  31. package/src/images/gett.png +0 -0
  32. package/src/images/google-maps.png +0 -0
  33. package/src/images/kakao-map.png +0 -0
  34. package/src/images/liftago.png +0 -0
  35. package/src/images/lyft.png +0 -0
  36. package/src/images/maps-me.png +0 -0
  37. package/src/images/mapycz.png +0 -0
  38. package/src/images/moovit.png +0 -0
  39. package/src/images/naver-map.png +0 -0
  40. package/src/images/osmand.png +0 -0
  41. package/src/images/petalmaps.png +0 -0
  42. package/src/images/tmap.png +0 -0
  43. package/src/images/transit.png +0 -0
  44. package/src/images/truckmap.png +0 -0
  45. package/src/images/uber.png +0 -0
  46. package/src/images/waze.png +0 -0
  47. package/src/images/yandex-maps.png +0 -0
  48. package/src/images/yandex-taxi.png +0 -0
  49. package/src/images/yandex.png +0 -0
  50. package/src/index.js +0 -345
  51. package/src/utils.js +0 -252
@@ -1,298 +0,0 @@
1
- /**
2
- * React Native Map Link
3
- */
4
-
5
- import React from 'react';
6
- import {
7
- StyleSheet,
8
- View,
9
- Text,
10
- Image,
11
- TouchableOpacity,
12
- Dimensions,
13
- FlatList,
14
- ActivityIndicator,
15
- } from 'react-native';
16
- import PropTypes from 'prop-types';
17
- import Modal from 'react-native-modal';
18
-
19
- import {getAvailableApps, checkNotSupportedApps} from '../utils';
20
- import {showLocation} from '../index';
21
- import {generateTitles, icons, generatePrefixes} from '../constants';
22
-
23
- const SCREEN_HEIGHT = Dimensions.get('screen').height;
24
-
25
- const colors = {
26
- black: '#464646',
27
- gray: '#BBC4CC',
28
- lightGray: '#ACBBCB',
29
- lightBlue: '#ECF2F8',
30
- };
31
-
32
- export default class Popup extends React.Component {
33
- constructor(props) {
34
- super(props);
35
-
36
- this.state = {
37
- apps: [],
38
- loading: true,
39
- titles: generateTitles(props.appTitles),
40
- };
41
-
42
- this._renderAppItem = this._renderAppItem.bind(this);
43
- }
44
-
45
- componentDidMount() {
46
- this.loadApps();
47
- }
48
-
49
- async loadApps() {
50
- const {appsWhiteList, options} = this.props;
51
- let apps = await getAvailableApps(generatePrefixes(options));
52
- if (appsWhiteList && appsWhiteList.length) {
53
- checkNotSupportedApps(appsWhiteList);
54
- apps = apps.filter((appName) =>
55
- this.props.appsWhiteList.includes(appName),
56
- );
57
- }
58
-
59
- this.setState({apps, loading: false});
60
- }
61
-
62
- _renderHeader() {
63
- const {showHeader, customHeader, options} = this.props;
64
- if (!showHeader) {
65
- return null;
66
- }
67
- if (customHeader) {
68
- return customHeader;
69
- }
70
-
71
- const dialogTitle =
72
- options.dialogTitle && options.dialogTitle.length
73
- ? options.dialogTitle
74
- : 'Open in Maps';
75
- const dialogMessage =
76
- options.dialogMessage && options.dialogMessage.length
77
- ? options.dialogMessage
78
- : 'What app would you like to use?';
79
-
80
- return (
81
- <View style={[styles.headerContainer, this.props.style.headerContainer]}>
82
- <Text style={[styles.titleText, this.props.style.titleText]}>
83
- {dialogTitle}
84
- </Text>
85
- {dialogMessage && dialogMessage.length ? (
86
- <Text style={[styles.subtitleText, this.props.style.subtitleText]}>
87
- {dialogMessage}
88
- </Text>
89
- ) : null}
90
- </View>
91
- );
92
- }
93
-
94
- _renderApps() {
95
- return (
96
- <FlatList
97
- ItemSeparatorComponent={() => (
98
- <View
99
- style={[styles.separatorStyle, this.props.style.separatorStyle]}
100
- />
101
- )}
102
- data={this.state.apps}
103
- renderItem={this._renderAppItem}
104
- keyExtractor={(item) => item}
105
- />
106
- );
107
- }
108
-
109
- _renderAppItem({item}) {
110
- return (
111
- <TouchableOpacity
112
- key={item}
113
- style={[styles.itemContainer, this.props.style.itemContainer]}
114
- onPress={() => this._onAppPressed({app: item})}>
115
- <View>
116
- <Image
117
- style={[styles.image, this.props.style.image]}
118
- source={icons[item]}
119
- />
120
- </View>
121
- <Text style={[styles.itemText, this.props.style.itemText]}>
122
- {this.state.titles[item]}
123
- </Text>
124
- </TouchableOpacity>
125
- );
126
- }
127
-
128
- _renderCancelButton() {
129
- const {options} = this.props;
130
- const cancelText =
131
- options.cancelText && options.cancelText.length
132
- ? options.cancelText
133
- : 'Cancel';
134
- return (
135
- <TouchableOpacity
136
- style={[
137
- styles.cancelButtonContainer,
138
- this.props.style.cancelButtonContainer,
139
- ]}
140
- onPress={this.props.onCancelPressed}>
141
- <Text
142
- style={[styles.cancelButtonText, this.props.style.cancelButtonText]}>
143
- {cancelText}
144
- </Text>
145
- </TouchableOpacity>
146
- );
147
- }
148
-
149
- _renderFooter() {
150
- const {customFooter} = this.props;
151
- if (customFooter) {
152
- return customFooter;
153
- }
154
- return this._renderCancelButton();
155
- }
156
-
157
- _onAppPressed({app}) {
158
- showLocation({...this.props.options, app});
159
- this.props.onAppPressed(app);
160
- }
161
-
162
- render() {
163
- const {loading} = this.state;
164
- return (
165
- <Modal
166
- isVisible={this.props.isVisible}
167
- backdropColor={colors.black}
168
- animationIn="slideInUp"
169
- hideModalContentWhileAnimating
170
- useNativeDriver
171
- onBackButtonPress={this.props.onBackButtonPressed}
172
- {...this.props.modalProps}>
173
- <View style={[styles.container, this.props.style.container]}>
174
- {this._renderHeader()}
175
- {loading ? (
176
- <ActivityIndicator
177
- style={[
178
- styles.activityIndicatorContainer,
179
- this.props.style.activityIndicatorContainer,
180
- ]}
181
- />
182
- ) : (
183
- this._renderApps()
184
- )}
185
- {this._renderFooter()}
186
- </View>
187
- </Modal>
188
- );
189
- }
190
- }
191
-
192
- Popup.propTypes = {
193
- isVisible: PropTypes.bool,
194
- showHeader: PropTypes.bool,
195
- customHeader: PropTypes.element,
196
- customFooter: PropTypes.element,
197
- onBackButtonPressed: PropTypes.func,
198
- onAppPressed: PropTypes.func,
199
- onCancelPressed: PropTypes.func,
200
- style: PropTypes.object,
201
- modalProps: PropTypes.object,
202
- options: PropTypes.object.isRequired,
203
- appsWhiteList: PropTypes.array,
204
- };
205
-
206
- Popup.defaultProps = {
207
- isVisible: false,
208
- showHeader: true,
209
- customHeader: null,
210
- customFooter: null,
211
- style: {
212
- container: {},
213
- itemContainer: {},
214
- image: {},
215
- itemText: {},
216
- headerContainer: {},
217
- titleText: {},
218
- subtitleText: {},
219
- cancelButtonContainer: {},
220
- cancelButtonText: {},
221
- separatorStyle: {},
222
- activityIndicatorContainer: {},
223
- },
224
- modalProps: {},
225
- options: {},
226
- appsWhiteList: null,
227
- onBackButtonPressed: () => {},
228
- onCancelPressed: () => {},
229
- onAppPressed: () => {},
230
- };
231
-
232
- const styles = StyleSheet.create({
233
- container: {
234
- backgroundColor: 'white',
235
- borderRadius: 10,
236
- overflow: 'hidden',
237
- maxHeight: SCREEN_HEIGHT * 0.6,
238
- },
239
- itemContainer: {
240
- flexDirection: 'row',
241
- alignItems: 'center',
242
- paddingTop: 10,
243
- paddingBottom: 10,
244
- paddingLeft: 20,
245
- paddingRight: 20,
246
- },
247
- image: {
248
- width: 50,
249
- height: 50,
250
- borderRadius: 25,
251
- },
252
- itemText: {
253
- fontSize: 16,
254
- fontWeight: 'bold',
255
- color: colors.black,
256
- marginLeft: 15,
257
- },
258
- headerContainer: {
259
- borderWidth: 1,
260
- borderColor: 'transparent',
261
- borderBottomColor: colors.lightBlue,
262
- padding: 15,
263
- },
264
- titleText: {
265
- fontSize: 16,
266
- textAlign: 'center',
267
- color: colors.black,
268
- },
269
- subtitleText: {
270
- fontSize: 12,
271
- color: colors.lightGray,
272
- textAlign: 'center',
273
- marginTop: 10,
274
- },
275
- cancelButtonContainer: {
276
- justifyContent: 'center',
277
- alignItems: 'center',
278
- padding: 20,
279
- borderWidth: 1,
280
- borderColor: 'transparent',
281
- borderTopColor: colors.lightBlue,
282
- },
283
- cancelButtonText: {
284
- fontSize: 16,
285
- fontWeight: 'bold',
286
- color: colors.gray,
287
- },
288
- separatorStyle: {
289
- flex: 1,
290
- height: 1,
291
- backgroundColor: colors.lightBlue,
292
- },
293
- activityIndicatorContainer: {
294
- height: 70,
295
- justifyContent: 'center',
296
- alignItems: 'center',
297
- },
298
- });
package/src/constants.js DELETED
@@ -1,95 +0,0 @@
1
- /**
2
- * React Native Map Link
3
- */
4
-
5
- import {Platform} from 'react-native';
6
-
7
- export const isIOS = Platform.OS === 'ios';
8
-
9
- export function generatePrefixes(options) {
10
- return {
11
- 'apple-maps': isIOS ? 'maps://' : 'applemaps://',
12
- 'google-maps': prefixForGoogleMaps(options.alwaysIncludeGoogle),
13
- citymapper: 'citymapper://',
14
- uber: 'uber://',
15
- lyft: 'lyft://',
16
- transit: 'transit://',
17
- truckmap: 'truckmap://',
18
- waze: 'waze://',
19
- yandex: 'yandexnavi://',
20
- moovit: 'moovit://directions',
21
- 'yandex-maps': 'yandexmaps://maps.yandex.ru/',
22
- 'yandex-taxi': 'yandextaxi://',
23
- kakaomap: 'kakaomap://',
24
- tmap: 'tmap://',
25
- mapycz: isIOS ? 'szn-mapy://' : 'mapycz://',
26
- 'maps-me': 'mapsme://',
27
- osmand: isIOS ? 'osmandmaps://' : 'osmand.geo://',
28
- gett: 'gett://',
29
- navermap: options.naverCallerName ? 'nmap://' : 'nmap-disabled://',
30
- dgis: 'dgis://2gis.ru/',
31
- liftago: 'lftgpas://',
32
- petalmaps: 'petalmaps://',
33
- };
34
- }
35
-
36
- export function prefixForGoogleMaps(alwaysIncludeGoogle) {
37
- return isIOS && !alwaysIncludeGoogle
38
- ? 'comgooglemaps://'
39
- : 'https://www.google.com/maps/';
40
- }
41
-
42
- export function generateTitles(titles) {
43
- return {
44
- 'apple-maps': 'Apple Maps',
45
- 'google-maps': 'Google Maps',
46
- citymapper: 'Citymapper',
47
- uber: 'Uber',
48
- lyft: 'Lyft',
49
- transit: 'The Transit App',
50
- truckmap: 'TruckMap',
51
- waze: 'Waze',
52
- yandex: 'Yandex.Navi',
53
- moovit: 'Moovit',
54
- 'yandex-taxi': 'Yandex Taxi',
55
- 'yandex-maps': 'Yandex Maps',
56
- kakaomap: 'Kakao Maps',
57
- tmap: 'TMAP',
58
- mapycz: 'Mapy.cz',
59
- 'maps-me': 'Maps Me',
60
- osmand: 'OsmAnd',
61
- gett: 'Gett',
62
- navermap: 'Naver Map',
63
- dgis: '2GIS',
64
- liftago: 'Liftago',
65
- petalmaps: 'Petal Maps',
66
- ...(titles || {}),
67
- };
68
- }
69
-
70
- export const icons = {
71
- 'apple-maps': require('./images/apple-maps.png'),
72
- 'google-maps': require('./images/google-maps.png'),
73
- citymapper: require('./images/citymapper.png'),
74
- uber: require('./images/uber.png'),
75
- lyft: require('./images/lyft.png'),
76
- transit: require('./images/transit.png'),
77
- truckmap: require('./images/truckmap.png'),
78
- waze: require('./images/waze.png'),
79
- yandex: require('./images/yandex.png'),
80
- moovit: require('./images/moovit.png'),
81
- 'yandex-taxi': require('./images/yandex-taxi.png'),
82
- 'yandex-maps': require('./images/yandex-maps.png'),
83
- kakaomap: require('./images/kakao-map.png'),
84
- tmap: require('./images/tmap.png'),
85
- mapycz: require('./images/mapycz.png'),
86
- 'maps-me': require('./images/maps-me.png'),
87
- osmand: require('./images/osmand.png'),
88
- gett: require('./images/gett.png'),
89
- navermap: require('./images/naver-map.png'),
90
- dgis: require('./images/dgis.png'),
91
- liftago: require('./images/liftago.png'),
92
- petalmaps: require('./images/petalmaps.png'),
93
- };
94
-
95
- export const appKeys = Object.keys(icons);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file