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.
- package/lib/components/popup/Popup.d.ts +39 -0
- package/lib/components/popup/Popup.js +110 -0
- package/lib/components/popup/PopupBody.d.ts +16 -0
- package/lib/components/popup/PopupBody.js +31 -0
- package/lib/components/popup/PopupFlatList.d.ts +10 -0
- package/lib/components/popup/PopupFlatList.js +11 -0
- package/lib/components/popup/PopupFooter.d.ts +15 -0
- package/lib/components/popup/PopupFooter.js +18 -0
- package/lib/components/popup/PopupHeader.d.ts +17 -0
- package/lib/components/popup/PopupHeader.js +48 -0
- package/lib/components/popup/PopupItem.d.ts +13 -0
- package/lib/components/popup/PopupItem.js +38 -0
- package/lib/components/popup/PopupSeparator.d.ts +8 -0
- package/lib/components/popup/PopupSeparator.js +19 -0
- package/lib/constants.d.ts +15 -0
- package/lib/constants.js +97 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +116 -0
- package/lib/type.d.ts +92 -0
- package/lib/type.js +2 -0
- package/lib/utils.d.ts +44 -0
- package/lib/utils.js +307 -0
- package/package.json +52 -20
- package/index.d.ts +0 -128
- package/index.js +0 -8
- package/src/components/Popup.js +0 -298
- package/src/constants.js +0 -95
- package/src/images/apple-maps.png +0 -0
- package/src/images/citymapper.png +0 -0
- package/src/images/dgis.png +0 -0
- package/src/images/gett.png +0 -0
- package/src/images/google-maps.png +0 -0
- package/src/images/kakao-map.png +0 -0
- package/src/images/liftago.png +0 -0
- package/src/images/lyft.png +0 -0
- package/src/images/maps-me.png +0 -0
- package/src/images/mapycz.png +0 -0
- package/src/images/moovit.png +0 -0
- package/src/images/naver-map.png +0 -0
- package/src/images/osmand.png +0 -0
- package/src/images/petalmaps.png +0 -0
- package/src/images/tmap.png +0 -0
- package/src/images/transit.png +0 -0
- package/src/images/truckmap.png +0 -0
- package/src/images/uber.png +0 -0
- package/src/images/waze.png +0 -0
- package/src/images/yandex-maps.png +0 -0
- package/src/images/yandex-taxi.png +0 -0
- package/src/images/yandex.png +0 -0
- package/src/index.js +0 -345
- package/src/utils.js +0 -252
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ModalProps, ViewStyle, TextStyle, ImageStyle } from 'react-native';
|
|
3
|
+
interface PopupProps {
|
|
4
|
+
isVisible: boolean;
|
|
5
|
+
showHeader?: boolean;
|
|
6
|
+
customHeader?: JSX.Element;
|
|
7
|
+
customFooter?: JSX.Element;
|
|
8
|
+
onAppPressed: (app: string) => void;
|
|
9
|
+
onCancelPressed: () => void;
|
|
10
|
+
style?: {
|
|
11
|
+
container?: ViewStyle;
|
|
12
|
+
itemContainer?: ViewStyle;
|
|
13
|
+
image?: ImageStyle;
|
|
14
|
+
itemText?: TextStyle;
|
|
15
|
+
headerContainer?: ViewStyle;
|
|
16
|
+
titleText?: TextStyle;
|
|
17
|
+
subtitleText?: TextStyle;
|
|
18
|
+
cancelButtonContainer?: ViewStyle;
|
|
19
|
+
cancelButtonText?: TextStyle;
|
|
20
|
+
separatorStyle?: ViewStyle;
|
|
21
|
+
activityIndicatorContainer?: ViewStyle;
|
|
22
|
+
};
|
|
23
|
+
modalProps?: ModalProps;
|
|
24
|
+
options: {
|
|
25
|
+
dialogTitle?: string;
|
|
26
|
+
dialogMessage?: string;
|
|
27
|
+
cancelText?: string;
|
|
28
|
+
appTitles?: Record<string, string>;
|
|
29
|
+
alwaysIncludeGoogle?: boolean;
|
|
30
|
+
naverCallerName?: string;
|
|
31
|
+
latitude: number;
|
|
32
|
+
longitude: number;
|
|
33
|
+
title?: string;
|
|
34
|
+
};
|
|
35
|
+
appsWhiteList?: string[];
|
|
36
|
+
setIsVisible: (isVisible: boolean) => void;
|
|
37
|
+
}
|
|
38
|
+
declare const Popup: React.FC<PopupProps>;
|
|
39
|
+
export default Popup;
|
|
@@ -0,0 +1,110 @@
|
|
|
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 utils_1 = require("../../utils");
|
|
32
|
+
const constants_1 = require("../../constants");
|
|
33
|
+
const PopupFooter_1 = __importDefault(require("./PopupFooter"));
|
|
34
|
+
const PopupHeader_1 = __importDefault(require("./PopupHeader"));
|
|
35
|
+
const PopupBody_1 = __importDefault(require("./PopupBody"));
|
|
36
|
+
const __1 = require("../..");
|
|
37
|
+
const SCREEN_HEIGHT = react_native_1.Dimensions.get('screen').height;
|
|
38
|
+
const Popup = ({ isVisible, showHeader = true, customHeader, customFooter, onAppPressed, onCancelPressed, style = {}, modalProps, options, appsWhiteList, setIsVisible, }) => {
|
|
39
|
+
const [apps, setApps] = (0, react_1.useState)([]);
|
|
40
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
41
|
+
const [titles, setTitles] = (0, react_1.useState)({});
|
|
42
|
+
(0, react_1.useEffect)(() => {
|
|
43
|
+
const loadApps = async () => {
|
|
44
|
+
let appsData = await (0, utils_1.getAvailableApps)((0, constants_1.generatePrefixes)({
|
|
45
|
+
alwaysIncludeGoogle: options.alwaysIncludeGoogle,
|
|
46
|
+
naverCallerName: options.naverCallerName,
|
|
47
|
+
}));
|
|
48
|
+
if (appsWhiteList && appsWhiteList.length) {
|
|
49
|
+
(0, utils_1.checkNotSupportedApps)(appsWhiteList);
|
|
50
|
+
appsData = appsData.filter((appName) => appsWhiteList.includes(appName));
|
|
51
|
+
}
|
|
52
|
+
setApps(appsData);
|
|
53
|
+
setIsLoading(false);
|
|
54
|
+
};
|
|
55
|
+
loadApps();
|
|
56
|
+
setTitles((0, constants_1.generateTitles)(options.appTitles));
|
|
57
|
+
}, [
|
|
58
|
+
appsWhiteList,
|
|
59
|
+
options.alwaysIncludeGoogle,
|
|
60
|
+
options.appTitles,
|
|
61
|
+
options.naverCallerName,
|
|
62
|
+
]);
|
|
63
|
+
const _onAppPressed = (app) => {
|
|
64
|
+
(0, __1.showLocation)({
|
|
65
|
+
...options,
|
|
66
|
+
app,
|
|
67
|
+
});
|
|
68
|
+
onAppPressed(app);
|
|
69
|
+
};
|
|
70
|
+
return (<react_native_1.Modal visible={isVisible} animationType="slide" onRequestClose={() => {
|
|
71
|
+
setIsVisible(false);
|
|
72
|
+
}} {...modalProps}>
|
|
73
|
+
<react_native_1.View style={[styles.container, style.container]}>
|
|
74
|
+
<react_native_1.View style={styles.modalView}>
|
|
75
|
+
<PopupHeader_1.default showHeader={showHeader} customHeader={customHeader} style={style} options={options}/>
|
|
76
|
+
<PopupBody_1.default apps={apps} isLoading={isLoading} style={style} titles={titles} onAppPressed={_onAppPressed}/>
|
|
77
|
+
<PopupFooter_1.default customFooter={customFooter} onCancelPressed={onCancelPressed} style={{
|
|
78
|
+
cancelButtonContainer: style.cancelButtonContainer,
|
|
79
|
+
cancelButtonText: style.cancelButtonText,
|
|
80
|
+
}} options={options}/>
|
|
81
|
+
</react_native_1.View>
|
|
82
|
+
</react_native_1.View>
|
|
83
|
+
</react_native_1.Modal>);
|
|
84
|
+
};
|
|
85
|
+
const styles = react_native_1.StyleSheet.create({
|
|
86
|
+
container: {
|
|
87
|
+
backgroundColor: 'white',
|
|
88
|
+
borderRadius: 10,
|
|
89
|
+
maxHeight: SCREEN_HEIGHT * 0.6,
|
|
90
|
+
flex: 1,
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
},
|
|
94
|
+
modalView: {
|
|
95
|
+
margin: 20,
|
|
96
|
+
backgroundColor: 'white',
|
|
97
|
+
borderRadius: 20,
|
|
98
|
+
padding: 35,
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
shadowColor: '#000',
|
|
101
|
+
shadowOffset: {
|
|
102
|
+
width: 0,
|
|
103
|
+
height: 2,
|
|
104
|
+
},
|
|
105
|
+
shadowOpacity: 0.25,
|
|
106
|
+
shadowRadius: 4,
|
|
107
|
+
elevation: 5,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
exports.default = Popup;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewStyle, TextStyle, ImageStyle } from 'react-native';
|
|
3
|
+
declare const PopupBody: ({ isLoading, style: { activityIndicatorContainer: styleActivityIndicatorContainer, separatorStyle: styleSeparatorStyle, itemContainer: styleItemContainer, image: styleImage, itemText: styleItemText, }, apps, onAppPressed, titles, }: {
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
style: {
|
|
6
|
+
activityIndicatorContainer?: ViewStyle;
|
|
7
|
+
separatorStyle?: ViewStyle;
|
|
8
|
+
itemContainer?: ViewStyle;
|
|
9
|
+
image?: ImageStyle;
|
|
10
|
+
itemText?: TextStyle;
|
|
11
|
+
};
|
|
12
|
+
apps: string[];
|
|
13
|
+
onAppPressed: (app: string) => void;
|
|
14
|
+
titles: Record<string, string>;
|
|
15
|
+
}) => React.JSX.Element;
|
|
16
|
+
export default PopupBody;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const PopupItem_1 = __importDefault(require("./PopupItem"));
|
|
9
|
+
const PopupSeparator_1 = __importDefault(require("./PopupSeparator"));
|
|
10
|
+
const PopupFlatList_1 = __importDefault(require("./PopupFlatList"));
|
|
11
|
+
const PopupBody = ({ isLoading, style: { activityIndicatorContainer: styleActivityIndicatorContainer, separatorStyle: styleSeparatorStyle, itemContainer: styleItemContainer, image: styleImage, itemText: styleItemText, }, apps, onAppPressed, titles, }) => {
|
|
12
|
+
if (isLoading) {
|
|
13
|
+
return (<react_native_1.ActivityIndicator style={[
|
|
14
|
+
styles.activityIndicatorContainer,
|
|
15
|
+
styleActivityIndicatorContainer,
|
|
16
|
+
]}/>);
|
|
17
|
+
}
|
|
18
|
+
return (<PopupFlatList_1.default separator={<PopupSeparator_1.default style={{ separatorStyle: styleSeparatorStyle }}/>} data={apps} renderItem={({ item }) => (<PopupItem_1.default style={{
|
|
19
|
+
itemContainer: styleItemContainer,
|
|
20
|
+
image: styleImage,
|
|
21
|
+
itemText: styleItemText,
|
|
22
|
+
}} item={item} onAppPressed={onAppPressed} titles={titles}/>)} keyExtractor={(item) => item}/>);
|
|
23
|
+
};
|
|
24
|
+
exports.default = PopupBody;
|
|
25
|
+
const styles = react_native_1.StyleSheet.create({
|
|
26
|
+
activityIndicatorContainer: {
|
|
27
|
+
height: 70,
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const PopupFlatList: ({ separator, data, renderItem, keyExtractor, }: {
|
|
3
|
+
separator: JSX.Element;
|
|
4
|
+
data: string[];
|
|
5
|
+
renderItem: ({ item }: {
|
|
6
|
+
item: string;
|
|
7
|
+
}) => JSX.Element;
|
|
8
|
+
keyExtractor: (item: string) => string;
|
|
9
|
+
}) => React.JSX.Element;
|
|
10
|
+
export default PopupFlatList;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const PopupFlatList = ({ separator, data, renderItem, keyExtractor, }) => {
|
|
9
|
+
return (<react_native_1.FlatList ItemSeparatorComponent={() => separator} data={data} renderItem={renderItem} keyExtractor={keyExtractor}/>);
|
|
10
|
+
};
|
|
11
|
+
exports.default = PopupFlatList;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import { ViewStyle, TextStyle } from 'react-native';
|
|
4
|
+
declare const PopupFooter: ({ customFooter, onCancelPressed, style: { cancelButtonContainer: styleCancelButtonContainer, cancelButtonText: styleCancelButtonText, }, options, }: {
|
|
5
|
+
customFooter?: JSX.Element | undefined;
|
|
6
|
+
onCancelPressed: () => void;
|
|
7
|
+
style: {
|
|
8
|
+
cancelButtonContainer?: ViewStyle;
|
|
9
|
+
cancelButtonText?: TextStyle;
|
|
10
|
+
};
|
|
11
|
+
options: {
|
|
12
|
+
cancelText?: string;
|
|
13
|
+
};
|
|
14
|
+
}) => JSX.Element;
|
|
15
|
+
export default PopupFooter;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const PopupFooter = ({ customFooter, onCancelPressed, style: { cancelButtonContainer: styleCancelButtonContainer, cancelButtonText: styleCancelButtonText, }, options, }) => {
|
|
9
|
+
if (customFooter) {
|
|
10
|
+
return customFooter;
|
|
11
|
+
}
|
|
12
|
+
return (<react_native_1.TouchableOpacity style={styleCancelButtonContainer} onPress={onCancelPressed}>
|
|
13
|
+
<react_native_1.Text style={styleCancelButtonText}>
|
|
14
|
+
{options.cancelText ? options.cancelText : 'Cancel'}
|
|
15
|
+
</react_native_1.Text>
|
|
16
|
+
</react_native_1.TouchableOpacity>);
|
|
17
|
+
};
|
|
18
|
+
exports.default = PopupFooter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import { ViewStyle, TextStyle } from 'react-native';
|
|
4
|
+
declare const PopupHeader: ({ showHeader, customHeader, style: { headerContainer: styleHeaderContainer, titleText: styleTitleText, subtitleText: styleSubtitleText, }, options, }: {
|
|
5
|
+
showHeader: boolean;
|
|
6
|
+
customHeader?: JSX.Element | undefined;
|
|
7
|
+
style: {
|
|
8
|
+
headerContainer?: ViewStyle;
|
|
9
|
+
titleText?: TextStyle;
|
|
10
|
+
subtitleText?: TextStyle;
|
|
11
|
+
};
|
|
12
|
+
options: {
|
|
13
|
+
dialogTitle?: string;
|
|
14
|
+
dialogMessage?: string;
|
|
15
|
+
};
|
|
16
|
+
}) => JSX.Element | null;
|
|
17
|
+
export default PopupHeader;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
const PopupHeader = ({ showHeader = true, customHeader, style: { headerContainer: styleHeaderContainer, titleText: styleTitleText, subtitleText: styleSubtitleText, }, options, }) => {
|
|
10
|
+
if (!showHeader) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (customHeader) {
|
|
14
|
+
return customHeader;
|
|
15
|
+
}
|
|
16
|
+
const dialogTitle = options.dialogTitle
|
|
17
|
+
? options.dialogTitle
|
|
18
|
+
: 'Open in Maps';
|
|
19
|
+
const dialogMessage = options.dialogMessage
|
|
20
|
+
? options.dialogMessage
|
|
21
|
+
: 'What app would you like to use?';
|
|
22
|
+
return (<react_native_1.View style={[styles.headerContainer, styleHeaderContainer]}>
|
|
23
|
+
<react_native_1.Text style={[styles.titleText, styleTitleText]}>{dialogTitle}</react_native_1.Text>
|
|
24
|
+
{dialogMessage ? (<react_native_1.Text style={[styles.subtitleText, styleSubtitleText]}>
|
|
25
|
+
{dialogMessage}
|
|
26
|
+
</react_native_1.Text>) : null}
|
|
27
|
+
</react_native_1.View>);
|
|
28
|
+
};
|
|
29
|
+
exports.default = PopupHeader;
|
|
30
|
+
const styles = react_native_1.StyleSheet.create({
|
|
31
|
+
headerContainer: {
|
|
32
|
+
borderWidth: 1,
|
|
33
|
+
borderColor: 'transparent',
|
|
34
|
+
borderBottomColor: constants_1.colorsPopup.lightBlue,
|
|
35
|
+
padding: 15,
|
|
36
|
+
},
|
|
37
|
+
titleText: {
|
|
38
|
+
fontSize: 16,
|
|
39
|
+
textAlign: 'center',
|
|
40
|
+
color: constants_1.colorsPopup.black,
|
|
41
|
+
},
|
|
42
|
+
subtitleText: {
|
|
43
|
+
fontSize: 12,
|
|
44
|
+
color: constants_1.colorsPopup.lightGray,
|
|
45
|
+
textAlign: 'center',
|
|
46
|
+
marginTop: 10,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewStyle, TextStyle, ImageStyle } from 'react-native';
|
|
3
|
+
declare const PopupItem: ({ item, style: { itemContainer: styleItemContainer, image: styleImage, itemText: styleItemText, }, onAppPressed, titles, }: {
|
|
4
|
+
item: string;
|
|
5
|
+
style: {
|
|
6
|
+
itemContainer?: ViewStyle;
|
|
7
|
+
image?: ImageStyle;
|
|
8
|
+
itemText?: TextStyle;
|
|
9
|
+
};
|
|
10
|
+
onAppPressed: (app: string) => void;
|
|
11
|
+
titles: Record<string, string>;
|
|
12
|
+
}) => React.JSX.Element;
|
|
13
|
+
export default PopupItem;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
const PopupItem = ({ item, style: { itemContainer: styleItemContainer, image: styleImage, itemText: styleItemText, }, onAppPressed, titles, }) => {
|
|
10
|
+
return (<react_native_1.TouchableOpacity key={item} style={[styles.itemContainer, styleItemContainer]} onPress={() => onAppPressed(item)}>
|
|
11
|
+
<react_native_1.View>
|
|
12
|
+
<react_native_1.Image style={[styles.image, styleImage]} source={constants_1.icons[item]}/>
|
|
13
|
+
</react_native_1.View>
|
|
14
|
+
<react_native_1.Text style={[styles.itemText, styleItemText]}>{titles[item]}</react_native_1.Text>
|
|
15
|
+
</react_native_1.TouchableOpacity>);
|
|
16
|
+
};
|
|
17
|
+
exports.default = PopupItem;
|
|
18
|
+
const styles = react_native_1.StyleSheet.create({
|
|
19
|
+
itemContainer: {
|
|
20
|
+
flexDirection: 'row',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
paddingTop: 10,
|
|
23
|
+
paddingBottom: 10,
|
|
24
|
+
paddingLeft: 20,
|
|
25
|
+
paddingRight: 20,
|
|
26
|
+
},
|
|
27
|
+
image: {
|
|
28
|
+
width: 50,
|
|
29
|
+
height: 50,
|
|
30
|
+
borderRadius: 25,
|
|
31
|
+
},
|
|
32
|
+
itemText: {
|
|
33
|
+
fontSize: 16,
|
|
34
|
+
fontWeight: 'bold',
|
|
35
|
+
color: constants_1.colorsPopup.black,
|
|
36
|
+
marginLeft: 15,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
const PopupSeparator = ({ style: { separatorStyle: styleSeparator }, }) => {
|
|
10
|
+
return <react_native_1.View style={[styles.separatorStyle, styleSeparator]}/>;
|
|
11
|
+
};
|
|
12
|
+
exports.default = PopupSeparator;
|
|
13
|
+
const styles = react_native_1.StyleSheet.create({
|
|
14
|
+
separatorStyle: {
|
|
15
|
+
flex: 1,
|
|
16
|
+
height: 1,
|
|
17
|
+
backgroundColor: constants_1.colorsPopup.lightBlue,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const isIOS: boolean;
|
|
2
|
+
export declare const generatePrefixes: ({ alwaysIncludeGoogle, naverCallerName, }: {
|
|
3
|
+
alwaysIncludeGoogle?: boolean | undefined;
|
|
4
|
+
naverCallerName?: string | undefined;
|
|
5
|
+
}) => Record<string, string>;
|
|
6
|
+
export declare const prefixForGoogleMaps: (alwaysIncludeGoogle?: boolean) => string;
|
|
7
|
+
export declare const generateTitles: (titles?: Record<string, string>) => Record<string, string>;
|
|
8
|
+
export declare const icons: Record<string, number>;
|
|
9
|
+
export declare const appKeys: string[];
|
|
10
|
+
export declare const colorsPopup: {
|
|
11
|
+
black: string;
|
|
12
|
+
gray: string;
|
|
13
|
+
lightGray: string;
|
|
14
|
+
lightBlue: string;
|
|
15
|
+
};
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.colorsPopup = exports.appKeys = exports.icons = exports.generateTitles = exports.prefixForGoogleMaps = exports.generatePrefixes = exports.isIOS = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
exports.isIOS = react_native_1.Platform.OS === 'ios';
|
|
6
|
+
const generatePrefixes = ({ alwaysIncludeGoogle, naverCallerName, }) => {
|
|
7
|
+
return {
|
|
8
|
+
'apple-maps': exports.isIOS ? 'maps://' : 'applemaps://',
|
|
9
|
+
'google-maps': (0, exports.prefixForGoogleMaps)(alwaysIncludeGoogle),
|
|
10
|
+
citymapper: 'citymapper://',
|
|
11
|
+
uber: 'uber://',
|
|
12
|
+
lyft: 'lyft://',
|
|
13
|
+
transit: 'transit://',
|
|
14
|
+
truckmap: 'truckmap://',
|
|
15
|
+
waze: 'waze://',
|
|
16
|
+
yandex: 'yandexnavi://',
|
|
17
|
+
moovit: 'moovit://directions',
|
|
18
|
+
'yandex-maps': 'yandexmaps://maps.yandex.ru/',
|
|
19
|
+
'yandex-taxi': 'yandextaxi://',
|
|
20
|
+
kakaomap: 'kakaomap://',
|
|
21
|
+
tmap: 'tmap://',
|
|
22
|
+
mapycz: exports.isIOS ? 'szn-mapy://' : 'mapycz://',
|
|
23
|
+
'maps-me': 'mapsme://',
|
|
24
|
+
osmand: exports.isIOS ? 'osmandmaps://' : 'osmand.geo://',
|
|
25
|
+
gett: 'gett://',
|
|
26
|
+
navermap: naverCallerName ? 'nmap://' : 'nmap-disabled://',
|
|
27
|
+
dgis: 'dgis://2gis.ru/',
|
|
28
|
+
liftago: 'lftgpas://',
|
|
29
|
+
petalmaps: 'petalmaps://',
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.generatePrefixes = generatePrefixes;
|
|
33
|
+
const prefixForGoogleMaps = (alwaysIncludeGoogle) => {
|
|
34
|
+
return exports.isIOS && !alwaysIncludeGoogle
|
|
35
|
+
? 'comgooglemaps://'
|
|
36
|
+
: 'https://www.google.com/maps/';
|
|
37
|
+
};
|
|
38
|
+
exports.prefixForGoogleMaps = prefixForGoogleMaps;
|
|
39
|
+
const generateTitles = (titles) => {
|
|
40
|
+
return {
|
|
41
|
+
'apple-maps': 'Apple Maps',
|
|
42
|
+
'google-maps': 'Google Maps',
|
|
43
|
+
citymapper: 'Citymapper',
|
|
44
|
+
uber: 'Uber',
|
|
45
|
+
lyft: 'Lyft',
|
|
46
|
+
transit: 'The Transit App',
|
|
47
|
+
truckmap: 'TruckMap',
|
|
48
|
+
waze: 'Waze',
|
|
49
|
+
yandex: 'Yandex.Navi',
|
|
50
|
+
moovit: 'Moovit',
|
|
51
|
+
'yandex-taxi': 'Yandex Taxi',
|
|
52
|
+
'yandex-maps': 'Yandex Maps',
|
|
53
|
+
kakaomap: 'Kakao Maps',
|
|
54
|
+
tmap: 'TMAP',
|
|
55
|
+
mapycz: 'Mapy.cz',
|
|
56
|
+
'maps-me': 'Maps Me',
|
|
57
|
+
osmand: 'OsmAnd',
|
|
58
|
+
gett: 'Gett',
|
|
59
|
+
navermap: 'Naver Map',
|
|
60
|
+
dgis: '2GIS',
|
|
61
|
+
liftago: 'Liftago',
|
|
62
|
+
petalmaps: 'Petal Maps',
|
|
63
|
+
...(titles || {}),
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.generateTitles = generateTitles;
|
|
67
|
+
exports.icons = {
|
|
68
|
+
'apple-maps': require('./images/apple-maps.png'),
|
|
69
|
+
'google-maps': require('./images/google-maps.png'),
|
|
70
|
+
citymapper: require('./images/citymapper.png'),
|
|
71
|
+
uber: require('./images/uber.png'),
|
|
72
|
+
lyft: require('./images/lyft.png'),
|
|
73
|
+
transit: require('./images/transit.png'),
|
|
74
|
+
truckmap: require('./images/truckmap.png'),
|
|
75
|
+
waze: require('./images/waze.png'),
|
|
76
|
+
yandex: require('./images/yandex.png'),
|
|
77
|
+
moovit: require('./images/moovit.png'),
|
|
78
|
+
'yandex-taxi': require('./images/yandex-taxi.png'),
|
|
79
|
+
'yandex-maps': require('./images/yandex-maps.png'),
|
|
80
|
+
kakaomap: require('./images/kakao-map.png'),
|
|
81
|
+
tmap: require('./images/tmap.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
|
+
exports.appKeys = Object.keys(exports.icons);
|
|
92
|
+
exports.colorsPopup = {
|
|
93
|
+
black: '#464646',
|
|
94
|
+
gray: '#BBC4CC',
|
|
95
|
+
lightGray: '#ACBBCB',
|
|
96
|
+
lightBlue: '#ECF2F8',
|
|
97
|
+
};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GetAppsProps, GetAppsResponse, ShowLocationProps } from './type';
|
|
2
|
+
export declare const showLocation: ({ latitude, longitude, sourceLatitude, sourceLongitude, appleIgnoreLatLon, alwaysIncludeGoogle, googleForceLatLon, googlePlaceId, title: customTitle, app: customApp, dialogTitle: customDialogTitle, dialogMessage: customDialogMessage, cancelText: customCancelText, appsWhiteList: customAppsWhiteList, appTitles, naverCallerName, directionsMode, }: ShowLocationProps) => Promise<string | null | undefined>;
|
|
3
|
+
export declare function getApps({ alwaysIncludeGoogle, appsWhiteList, appTitles, naverCallerName, ...rest }: GetAppsProps): Promise<GetAppsResponse[]>;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getApps = exports.showLocation = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const showLocation = async ({ latitude, longitude, sourceLatitude, sourceLongitude, appleIgnoreLatLon, alwaysIncludeGoogle, googleForceLatLon, googlePlaceId, title: customTitle, app: customApp, dialogTitle: customDialogTitle, dialogMessage: customDialogMessage, cancelText: customCancelText, appsWhiteList: customAppsWhiteList, appTitles, naverCallerName, directionsMode, }) => {
|
|
8
|
+
const prefixes = (0, constants_1.generatePrefixes)({
|
|
9
|
+
alwaysIncludeGoogle,
|
|
10
|
+
naverCallerName,
|
|
11
|
+
});
|
|
12
|
+
(0, utils_1.checkOptions)({
|
|
13
|
+
latitude,
|
|
14
|
+
longitude,
|
|
15
|
+
googleForceLatLon,
|
|
16
|
+
googlePlaceId,
|
|
17
|
+
title: customTitle,
|
|
18
|
+
app: customApp,
|
|
19
|
+
prefixes,
|
|
20
|
+
appTitles,
|
|
21
|
+
appsWhiteList: customAppsWhiteList,
|
|
22
|
+
});
|
|
23
|
+
let useSourceDestiny = false;
|
|
24
|
+
let sourceLat;
|
|
25
|
+
let sourceLng;
|
|
26
|
+
let sourceLatLng;
|
|
27
|
+
if (sourceLatitude != null && sourceLongitude != null) {
|
|
28
|
+
useSourceDestiny = true;
|
|
29
|
+
sourceLat =
|
|
30
|
+
typeof sourceLatitude === 'string'
|
|
31
|
+
? parseFloat(sourceLatitude)
|
|
32
|
+
: sourceLatitude;
|
|
33
|
+
sourceLng =
|
|
34
|
+
typeof sourceLongitude === 'string'
|
|
35
|
+
? parseFloat(sourceLongitude)
|
|
36
|
+
: sourceLongitude;
|
|
37
|
+
sourceLatLng = `${sourceLat},${sourceLng}`;
|
|
38
|
+
}
|
|
39
|
+
const lat = typeof latitude === 'string' ? parseFloat(latitude) : latitude;
|
|
40
|
+
const lng = typeof longitude === 'string' ? parseFloat(longitude) : longitude;
|
|
41
|
+
const latlng = `${lat},${lng}`;
|
|
42
|
+
const title = customTitle && customTitle.length ? customTitle : null;
|
|
43
|
+
const encodedTitle = encodeURIComponent(title ?? '');
|
|
44
|
+
let app = customApp && customApp.length ? customApp : null;
|
|
45
|
+
const dialogTitle = customDialogTitle && customDialogTitle.length
|
|
46
|
+
? customDialogTitle
|
|
47
|
+
: 'Open in Maps';
|
|
48
|
+
const dialogMessage = customDialogMessage && customDialogMessage.length
|
|
49
|
+
? customDialogMessage
|
|
50
|
+
: 'What app would you like to use?';
|
|
51
|
+
const cancelText = customCancelText && customCancelText.length ? customCancelText : 'Cancel';
|
|
52
|
+
const appsWhiteList = customAppsWhiteList && customAppsWhiteList.length
|
|
53
|
+
? customAppsWhiteList
|
|
54
|
+
: null;
|
|
55
|
+
if (!app) {
|
|
56
|
+
app = await (0, utils_1.askAppChoice)({
|
|
57
|
+
dialogTitle,
|
|
58
|
+
dialogMessage,
|
|
59
|
+
cancelText,
|
|
60
|
+
appsWhiteList,
|
|
61
|
+
prefixes,
|
|
62
|
+
appTitles: (0, constants_1.generateTitles)(appTitles),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const url = (0, utils_1.generateMapUrl)({
|
|
66
|
+
app,
|
|
67
|
+
directionsMode,
|
|
68
|
+
appleIgnoreLatLon,
|
|
69
|
+
googleForceLatLon,
|
|
70
|
+
googlePlaceId,
|
|
71
|
+
naverCallerName,
|
|
72
|
+
lat,
|
|
73
|
+
lng,
|
|
74
|
+
latlng,
|
|
75
|
+
sourceLat,
|
|
76
|
+
sourceLng,
|
|
77
|
+
sourceLatLng,
|
|
78
|
+
title,
|
|
79
|
+
encodedTitle,
|
|
80
|
+
prefixes,
|
|
81
|
+
useSourceDestiny,
|
|
82
|
+
});
|
|
83
|
+
if (url !== '') {
|
|
84
|
+
return react_native_1.Linking.openURL(url).then(() => Promise.resolve(app));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.showLocation = showLocation;
|
|
88
|
+
async function getApps({ alwaysIncludeGoogle, appsWhiteList, appTitles, naverCallerName, ...rest }) {
|
|
89
|
+
let apps = await (0, utils_1.getAvailableApps)((0, constants_1.generatePrefixes)({ alwaysIncludeGoogle, naverCallerName }));
|
|
90
|
+
if (appsWhiteList && appsWhiteList.length) {
|
|
91
|
+
(0, utils_1.checkNotSupportedApps)(appsWhiteList);
|
|
92
|
+
apps = apps.filter((appName) => appsWhiteList.includes(appName));
|
|
93
|
+
}
|
|
94
|
+
const titles = (0, constants_1.generateTitles)({ ...appTitles });
|
|
95
|
+
async function open(app) {
|
|
96
|
+
return (0, exports.showLocation)({
|
|
97
|
+
...rest,
|
|
98
|
+
app,
|
|
99
|
+
alwaysIncludeGoogle,
|
|
100
|
+
appsWhiteList,
|
|
101
|
+
appTitles,
|
|
102
|
+
naverCallerName,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const list = [];
|
|
106
|
+
for (const app of apps) {
|
|
107
|
+
list.push({
|
|
108
|
+
id: app,
|
|
109
|
+
name: titles[app],
|
|
110
|
+
icon: constants_1.icons[app],
|
|
111
|
+
open: () => open(app),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return list;
|
|
115
|
+
}
|
|
116
|
+
exports.getApps = getApps;
|