react-native-map-link 2.11.3 → 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/README.md +10 -4
  2. package/lib/components/popup/Popup.d.ts +39 -0
  3. package/lib/components/popup/Popup.js +110 -0
  4. package/lib/components/popup/PopupBody.d.ts +16 -0
  5. package/lib/components/popup/PopupBody.js +31 -0
  6. package/lib/components/popup/PopupFlatList.d.ts +10 -0
  7. package/lib/components/popup/PopupFlatList.js +11 -0
  8. package/lib/components/popup/PopupFooter.d.ts +15 -0
  9. package/lib/components/popup/PopupFooter.js +18 -0
  10. package/lib/components/popup/PopupHeader.d.ts +17 -0
  11. package/lib/components/popup/PopupHeader.js +48 -0
  12. package/lib/components/popup/PopupItem.d.ts +13 -0
  13. package/lib/components/popup/PopupItem.js +38 -0
  14. package/lib/components/popup/PopupSeparator.d.ts +8 -0
  15. package/lib/components/popup/PopupSeparator.js +19 -0
  16. package/lib/constants.d.ts +15 -0
  17. package/lib/constants.js +97 -0
  18. package/lib/index.d.ts +3 -0
  19. package/lib/index.js +116 -0
  20. package/lib/type.d.ts +92 -0
  21. package/lib/type.js +2 -0
  22. package/lib/utils.d.ts +44 -0
  23. package/lib/utils.js +307 -0
  24. package/package.json +52 -20
  25. package/index.d.ts +0 -127
  26. package/index.js +0 -8
  27. package/src/components/Popup.js +0 -298
  28. package/src/constants.js +0 -92
  29. package/src/images/apple-maps.png +0 -0
  30. package/src/images/citymapper.png +0 -0
  31. package/src/images/dgis.png +0 -0
  32. package/src/images/gett.png +0 -0
  33. package/src/images/google-maps.png +0 -0
  34. package/src/images/kakao-map.png +0 -0
  35. package/src/images/liftago.png +0 -0
  36. package/src/images/lyft.png +0 -0
  37. package/src/images/maps-me.png +0 -0
  38. package/src/images/mapycz.png +0 -0
  39. package/src/images/moovit.png +0 -0
  40. package/src/images/naver-map.png +0 -0
  41. package/src/images/osmand.png +0 -0
  42. package/src/images/petalmaps.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 -338
  51. package/src/utils.js +0 -252
package/index.d.ts DELETED
@@ -1,127 +0,0 @@
1
- import * as React from 'react';
2
- import {
3
- ViewStyle,
4
- StyleProp,
5
- ImageStyle,
6
- TextStyle,
7
- ImageSourcePropType,
8
- } from 'react-native';
9
-
10
- /** id for map application. this is the id that is passed to the `app` option */
11
- export type MapId =
12
- | 'apple-maps'
13
- | 'google-maps'
14
- | 'citymapper'
15
- | 'uber'
16
- | 'lyft'
17
- | 'transit'
18
- | 'truckmap'
19
- | 'waze'
20
- | 'yandex'
21
- | 'moovit'
22
- | 'yandex-maps'
23
- | 'yandex-taxi'
24
- | 'kakaomap'
25
- | 'mapycz'
26
- | 'maps-me'
27
- | 'osmand'
28
- | 'gett'
29
- | 'navermap'
30
- | 'dgis'
31
- | 'liftago'
32
- | 'petalmaps';
33
-
34
- /** options shared across different types */
35
- interface SharedOptions {
36
- /** optionally you can set which apps to show (default: will show all supported apps installed on device) */
37
- appsWhiteList?: MapId[];
38
- /** custom titles to display for each app instead of using default titles. */
39
- appTitles?: Partial<Record<MapId, string>>;
40
- }
41
-
42
- interface Options extends SharedOptions {
43
- latitude: number | string;
44
- longitude: number | string;
45
- /** optionally specify starting location for directions */
46
- sourceLatitude?: number;
47
- /** not optional if `sourceLatitude` is specified */
48
- sourceLongitude?: number;
49
- /** optional, true will always add Google Maps to iOS and open in Safari, even if app is not installed (default: false) */
50
- alwaysIncludeGoogle?: boolean;
51
- googleForceLatLon?: boolean;
52
- appleIgnoreLatLon?: boolean;
53
- googlePlaceId?: string;
54
- title?: string;
55
- /** optionally specify specific app to use */
56
- app?: MapId;
57
- /** optional (default: 'Open in Maps') */
58
- dialogTitle?: string;
59
- /** optional (default: 'What app would you like to use?') */
60
- dialogMessage?: string;
61
- cancelText?: string;
62
- /** to link into Naver Map You should provide your appname which is the bundle ID in iOS and applicationId in android. */
63
- naverCallerName?: string;
64
- directionsMode?: 'car' | 'walk' | 'public-transport' | 'bike';
65
- }
66
-
67
- interface PopupStyleProp {
68
- container?: StyleProp<ViewStyle>;
69
- itemContainer?: StyleProp<ViewStyle>;
70
- image?: StyleProp<ImageStyle>;
71
- itemText?: StyleProp<TextStyle>;
72
- headerContainer?: StyleProp<ViewStyle>;
73
- titleText?: StyleProp<TextStyle>;
74
- subtitleText?: StyleProp<TextStyle>;
75
- cancelButtonContainer?: StyleProp<ViewStyle>;
76
- cancelButtonText?: StyleProp<TextStyle>;
77
- separatorStyle?: StyleProp<ViewStyle>;
78
- activityIndicatorContainer?: StyleProp<ViewStyle>;
79
- }
80
-
81
- interface PopupProps extends SharedOptions {
82
- isVisible: boolean;
83
- showHeader?: boolean;
84
- customHeader?: React.ReactNode;
85
- customFooter?: React.ReactNode;
86
- onCancelPressed: () => void;
87
- onBackButtonPressed: () => void;
88
- onAppPressed: (appName: MapId) => void;
89
- style?: PopupStyleProp;
90
- modalProps?: object;
91
- options: Options;
92
- }
93
-
94
- /**
95
- * Link users to their desired map app.
96
- *
97
- * If an `app` option is passed, it will directly link to that map app,
98
- * else it will prompt user to select map app.
99
- *
100
- * Prompts via `ActionSheetIOS` on iOS & `Alert.alert` on Android.
101
- *
102
- * If these prompts don't meet your UI use case, checkout the `Popup` component,
103
- * or use the `getApps` function to build a custom UI.
104
- */
105
- export function showLocation(
106
- options: Options,
107
- ): Promise<string | undefined | null>;
108
-
109
- export type GetAppResult = {
110
- id: MapId;
111
- name: string;
112
- icon: ImageSourcePropType;
113
- /** function to link user to map app */
114
- open: () => Promise<void>;
115
- };
116
-
117
- /**
118
- * Get array of map apps on users device.
119
- *
120
- * Useful for building custom UIs.
121
- */
122
- export function getApps(options: Options): Promise<GetAppResult[]>;
123
-
124
- /**
125
- * A styled popup component that displays icons in the app list
126
- */
127
- export class Popup extends React.Component<PopupProps> {}
package/index.js DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * React Native Map Link
3
- */
4
-
5
- import Popup from './src/components/Popup';
6
- import {showLocation, getApps} from './src';
7
-
8
- export {showLocation, getApps, Popup};
@@ -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,92 +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
- mapycz: isIOS ? 'szn-mapy://' : 'mapycz://',
25
- 'maps-me': 'mapsme://',
26
- osmand: isIOS ? 'osmandmaps://' : 'osmand.geo://',
27
- gett: 'gett://',
28
- navermap: options.naverCallerName ? 'nmap://' : 'nmap-disabled://',
29
- dgis: 'dgis://2gis.ru/',
30
- liftago: 'lftgpas://',
31
- petalmaps: 'petalmaps://',
32
- };
33
- }
34
-
35
- export function prefixForGoogleMaps(alwaysIncludeGoogle) {
36
- return isIOS && !alwaysIncludeGoogle
37
- ? 'comgooglemaps://'
38
- : 'https://www.google.com/maps/';
39
- }
40
-
41
- export function generateTitles(titles) {
42
- return {
43
- 'apple-maps': 'Apple Maps',
44
- 'google-maps': 'Google Maps',
45
- citymapper: 'Citymapper',
46
- uber: 'Uber',
47
- lyft: 'Lyft',
48
- transit: 'The Transit App',
49
- truckmap: 'TruckMap',
50
- waze: 'Waze',
51
- yandex: 'Yandex.Navi',
52
- moovit: 'Moovit',
53
- 'yandex-taxi': 'Yandex Taxi',
54
- 'yandex-maps': 'Yandex Maps',
55
- kakaomap: 'Kakao Maps',
56
- mapycz: 'Mapy.cz',
57
- 'maps-me': 'Maps Me',
58
- osmand: 'OsmAnd',
59
- gett: 'Gett',
60
- navermap: 'Naver Map',
61
- dgis: '2GIS',
62
- liftago: 'Liftago',
63
- petalmaps: 'Petal Maps',
64
- ...(titles || {}),
65
- };
66
- }
67
-
68
- export const icons = {
69
- 'apple-maps': require('./images/apple-maps.png'),
70
- 'google-maps': require('./images/google-maps.png'),
71
- citymapper: require('./images/citymapper.png'),
72
- uber: require('./images/uber.png'),
73
- lyft: require('./images/lyft.png'),
74
- transit: require('./images/transit.png'),
75
- truckmap: require('./images/truckmap.png'),
76
- waze: require('./images/waze.png'),
77
- yandex: require('./images/yandex.png'),
78
- moovit: require('./images/moovit.png'),
79
- 'yandex-taxi': require('./images/yandex-taxi.png'),
80
- 'yandex-maps': require('./images/yandex-maps.png'),
81
- kakaomap: require('./images/kakao-map.png'),
82
- mapycz: require('./images/mapycz.png'),
83
- 'maps-me': require('./images/maps-me.png'),
84
- osmand: require('./images/osmand.png'),
85
- gett: require('./images/gett.png'),
86
- navermap: require('./images/naver-map.png'),
87
- dgis: require('./images/dgis.png'),
88
- liftago: require('./images/liftago.png'),
89
- petalmaps: require('./images/petalmaps.png'),
90
- };
91
-
92
- 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