react-native-map-link 3.2.0 → 3.2.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/lib/components/popup/Popup.d.ts +8 -19
- package/lib/components/popup/Popup.js +5 -5
- package/lib/components/popup/PopupBody.d.ts +4 -3
- package/lib/components/popup/PopupFlatList.d.ts +6 -6
- package/lib/components/popup/PopupFooter.d.ts +5 -6
- package/lib/components/popup/PopupHeader.d.ts +6 -7
- package/lib/components/popup/PopupItem.d.ts +5 -4
- package/lib/components/popup/PopupSeparator.d.ts +1 -1
- package/lib/constants.d.ts +2 -1
- package/lib/index.d.ts +4 -3
- package/lib/type.d.ts +6 -60
- package/lib/utils.d.ts +3 -2
- package/lib/utils.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ModalProps, ViewStyle, TextStyle
|
|
3
|
-
|
|
2
|
+
import type { ImageStyle, ModalProps, ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
import type { MapId, ShowLocationProps } from '../../type';
|
|
4
|
+
export interface PopupProps {
|
|
4
5
|
isVisible: boolean;
|
|
6
|
+
setIsVisible: (isVisible: boolean) => void;
|
|
5
7
|
showHeader?: boolean;
|
|
6
|
-
customHeader?:
|
|
7
|
-
customFooter?:
|
|
8
|
-
onAppPressed: (app:
|
|
8
|
+
customHeader?: React.ReactNode;
|
|
9
|
+
customFooter?: React.ReactNode;
|
|
10
|
+
onAppPressed: (app: MapId) => void;
|
|
9
11
|
onCancelPressed: () => void;
|
|
10
12
|
style?: {
|
|
11
13
|
container?: ViewStyle;
|
|
@@ -21,19 +23,6 @@ interface PopupProps {
|
|
|
21
23
|
activityIndicatorContainer?: ViewStyle;
|
|
22
24
|
};
|
|
23
25
|
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;
|
|
26
|
+
options: ShowLocationProps;
|
|
37
27
|
}
|
|
38
28
|
export declare const Popup: React.FC<PopupProps>;
|
|
39
|
-
export {};
|
|
@@ -36,7 +36,7 @@ const PopupHeader_1 = __importDefault(require("./PopupHeader"));
|
|
|
36
36
|
const PopupBody_1 = __importDefault(require("./PopupBody"));
|
|
37
37
|
const __1 = require("../..");
|
|
38
38
|
const SCREEN_HEIGHT = react_native_1.Dimensions.get('screen').height;
|
|
39
|
-
const Popup = ({ isVisible, showHeader = true, customHeader, customFooter, onAppPressed, onCancelPressed, style = {}, modalProps, options,
|
|
39
|
+
const Popup = ({ isVisible, showHeader = true, customHeader, customFooter, onAppPressed, onCancelPressed, style = {}, modalProps, options, setIsVisible, }) => {
|
|
40
40
|
const [apps, setApps] = (0, react_1.useState)([]);
|
|
41
41
|
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
42
42
|
const [titles, setTitles] = (0, react_1.useState)({});
|
|
@@ -46,9 +46,9 @@ const Popup = ({ isVisible, showHeader = true, customHeader, customFooter, onApp
|
|
|
46
46
|
alwaysIncludeGoogle: options.alwaysIncludeGoogle,
|
|
47
47
|
naverCallerName: options.naverCallerName,
|
|
48
48
|
}));
|
|
49
|
-
if (appsWhiteList && appsWhiteList.length) {
|
|
50
|
-
(0, utils_1.checkNotSupportedApps)(appsWhiteList);
|
|
51
|
-
appsData = appsData.filter((appName) => appsWhiteList
|
|
49
|
+
if (options.appsWhiteList && options.appsWhiteList.length) {
|
|
50
|
+
(0, utils_1.checkNotSupportedApps)(options.appsWhiteList);
|
|
51
|
+
appsData = appsData.filter((appName) => options.appsWhiteList?.includes(appName));
|
|
52
52
|
}
|
|
53
53
|
setApps(appsData);
|
|
54
54
|
setIsLoading(false);
|
|
@@ -56,9 +56,9 @@ const Popup = ({ isVisible, showHeader = true, customHeader, customFooter, onApp
|
|
|
56
56
|
loadApps();
|
|
57
57
|
setTitles((0, constants_1.generateTitles)(options.appTitles));
|
|
58
58
|
}, [
|
|
59
|
-
appsWhiteList,
|
|
60
59
|
options.alwaysIncludeGoogle,
|
|
61
60
|
options.appTitles,
|
|
61
|
+
options.appsWhiteList,
|
|
62
62
|
options.naverCallerName,
|
|
63
63
|
]);
|
|
64
64
|
const _onAppPressed = (app) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import type { MapId } from '../../type';
|
|
3
4
|
declare const PopupBody: ({ isLoading, style: { activityIndicatorContainer: styleActivityIndicatorContainer, separatorStyle: styleSeparatorStyle, itemContainer: styleItemContainer, image: styleImage, itemText: styleItemText, }, apps, onAppPressed, titles, }: {
|
|
4
5
|
isLoading: boolean;
|
|
5
6
|
style: {
|
|
@@ -9,8 +10,8 @@ declare const PopupBody: ({ isLoading, style: { activityIndicatorContainer: styl
|
|
|
9
10
|
image?: ImageStyle;
|
|
10
11
|
itemText?: TextStyle;
|
|
11
12
|
};
|
|
12
|
-
apps:
|
|
13
|
-
onAppPressed: (app:
|
|
13
|
+
apps: MapId[];
|
|
14
|
+
onAppPressed: (app: MapId) => void;
|
|
14
15
|
titles: Record<string, string>;
|
|
15
16
|
}) => React.JSX.Element;
|
|
16
17
|
export default PopupBody;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { ListRenderItem } from 'react-native';
|
|
3
|
+
import type { MapId } from '../../type';
|
|
2
4
|
declare const PopupFlatList: ({ separator, data, renderItem, keyExtractor, }: {
|
|
3
|
-
separator:
|
|
4
|
-
data:
|
|
5
|
-
renderItem:
|
|
6
|
-
|
|
7
|
-
}) => JSX.Element;
|
|
8
|
-
keyExtractor: (item: string) => string;
|
|
5
|
+
separator: React.ReactNode;
|
|
6
|
+
data: MapId[];
|
|
7
|
+
renderItem: ListRenderItem<MapId>;
|
|
8
|
+
keyExtractor: (item: MapId) => string;
|
|
9
9
|
}) => React.JSX.Element;
|
|
10
10
|
export default PopupFlatList;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { ViewStyle, TextStyle } from 'react-native';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TextStyle, ViewStyle } from 'react-native';
|
|
4
3
|
declare const PopupFooter: ({ customFooter, onCancelPressed, style: { cancelButtonContainer: styleCancelButtonContainer, cancelButtonText: styleCancelButtonText, }, options, }: {
|
|
5
|
-
customFooter?:
|
|
4
|
+
customFooter?: React.ReactNode;
|
|
6
5
|
onCancelPressed: () => void;
|
|
7
6
|
style: {
|
|
8
7
|
cancelButtonContainer?: ViewStyle;
|
|
9
8
|
cancelButtonText?: TextStyle;
|
|
10
9
|
};
|
|
11
10
|
options: {
|
|
12
|
-
cancelText?: string;
|
|
11
|
+
cancelText?: string | null;
|
|
13
12
|
};
|
|
14
|
-
}) => JSX.Element;
|
|
13
|
+
}) => string | number | true | Iterable<React.ReactNode> | React.JSX.Element;
|
|
15
14
|
export default PopupFooter;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { ViewStyle, TextStyle } from 'react-native';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TextStyle, ViewStyle } from 'react-native';
|
|
4
3
|
declare const PopupHeader: ({ showHeader, customHeader, style: { headerContainer: styleHeaderContainer, titleText: styleTitleText, subtitleText: styleSubtitleText, }, options, }: {
|
|
5
4
|
showHeader: boolean;
|
|
6
|
-
customHeader?:
|
|
5
|
+
customHeader?: React.ReactNode;
|
|
7
6
|
style: {
|
|
8
7
|
headerContainer?: ViewStyle;
|
|
9
8
|
titleText?: TextStyle;
|
|
10
9
|
subtitleText?: TextStyle;
|
|
11
10
|
};
|
|
12
11
|
options: {
|
|
13
|
-
dialogTitle?: string;
|
|
14
|
-
dialogMessage?: string;
|
|
12
|
+
dialogTitle?: string | null;
|
|
13
|
+
dialogMessage?: string | null;
|
|
15
14
|
};
|
|
16
|
-
}) => JSX.Element | null;
|
|
15
|
+
}) => string | number | true | Iterable<React.ReactNode> | React.JSX.Element | null;
|
|
17
16
|
export default PopupHeader;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import type { MapId } from '../../type';
|
|
3
4
|
declare const PopupItem: ({ item, style: { itemContainer: styleItemContainer, image: styleImage, itemText: styleItemText, }, onAppPressed, titles, }: {
|
|
4
|
-
item:
|
|
5
|
+
item: MapId;
|
|
5
6
|
style: {
|
|
6
7
|
itemContainer?: ViewStyle;
|
|
7
8
|
image?: ImageStyle;
|
|
8
9
|
itemText?: TextStyle;
|
|
9
10
|
};
|
|
10
|
-
onAppPressed: (app:
|
|
11
|
-
titles: Record<
|
|
11
|
+
onAppPressed: (app: MapId) => void;
|
|
12
|
+
titles: Record<MapId, string>;
|
|
12
13
|
}) => React.JSX.Element;
|
|
13
14
|
export default PopupItem;
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { MapId } from './type';
|
|
1
2
|
export declare const isIOS: boolean;
|
|
2
3
|
export declare const generatePrefixes: ({ alwaysIncludeGoogle, naverCallerName, }: {
|
|
3
4
|
alwaysIncludeGoogle?: boolean | undefined;
|
|
4
5
|
naverCallerName?: string | undefined;
|
|
5
|
-
}) => Record<
|
|
6
|
+
}) => Record<MapId, string>;
|
|
6
7
|
export declare const prefixForGoogleMaps: (alwaysIncludeGoogle?: boolean) => string;
|
|
7
8
|
export declare const generateTitles: (titles?: Record<string, string>) => Record<string, string>;
|
|
8
9
|
export declare const icons: Record<string, number>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { GetAppsProps, GetAppsResponse, ShowLocationProps } from './type';
|
|
2
|
-
export type { DirectionMode, GetAppsProps, GetAppsResponse, MapId,
|
|
1
|
+
import { GetAppsProps, GetAppsResponse, MapId, ShowLocationProps } from './type';
|
|
2
|
+
export type { DirectionMode, GetAppsProps, GetAppsResponse, MapId, SharedOptions, ShowLocationProps, } from './type';
|
|
3
3
|
export { Popup } from './components/popup/Popup';
|
|
4
|
-
export
|
|
4
|
+
export type { PopupProps } from './components/popup/Popup';
|
|
5
|
+
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<MapId | null | undefined>;
|
|
5
6
|
export declare function getApps({ alwaysIncludeGoogle, appsWhiteList, appTitles, naverCallerName, ...rest }: GetAppsProps): Promise<GetAppsResponse[]>;
|
package/lib/type.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ViewStyle, StyleProp, ImageStyle, TextStyle, ImageSourcePropType } from 'react-native';
|
|
1
|
+
import type { ImageSourcePropType } from 'react-native';
|
|
3
2
|
/** id for map application. this is the id that is passed to the `app` option */
|
|
4
|
-
export type MapId = 'apple-maps' | 'google-maps' | 'citymapper' | 'uber' | 'lyft' | 'transit' | 'truckmap' | 'waze' | 'yandex' | 'moovit' | 'yandex-maps' | 'yandex-taxi' | 'kakaomap' | 'tmap' | 'mapycz' | 'maps-me' | 'osmand' | 'gett' | 'navermap' | 'dgis' | 'liftago' | 'petalmaps';
|
|
3
|
+
export type MapId = 'apple-maps' | 'google-maps' | 'citymapper' | 'uber' | 'lyft' | 'transit' | 'truckmap' | 'waze' | 'yandex' | 'moovit' | 'yandex-maps' | 'yandex-taxi' | 'kakaomap' | 'tmap' | 'mapycz' | 'maps-me' | 'osmand' | 'gett' | 'navermap' | 'dgis' | 'liftago' | 'petalmaps' | 'sygic';
|
|
5
4
|
export type DirectionMode = 'car' | 'walk' | 'public-transport' | 'bike';
|
|
6
5
|
/** options shared across different types */
|
|
7
6
|
export interface SharedOptions {
|
|
@@ -10,55 +9,6 @@ export interface SharedOptions {
|
|
|
10
9
|
/** custom titles to display for each app instead of using default titles. */
|
|
11
10
|
appTitles?: Partial<Record<MapId, string>>;
|
|
12
11
|
}
|
|
13
|
-
export interface MapLinkOptions extends SharedOptions {
|
|
14
|
-
latitude: number | string;
|
|
15
|
-
longitude: number | string;
|
|
16
|
-
/** optionally specify starting location for directions */
|
|
17
|
-
sourceLatitude?: number;
|
|
18
|
-
/** not optional if `sourceLatitude` is specified */
|
|
19
|
-
sourceLongitude?: number;
|
|
20
|
-
/** optional, true will always add Google Maps to iOS and open in Safari, even if app is not installed (default: false) */
|
|
21
|
-
alwaysIncludeGoogle?: boolean;
|
|
22
|
-
googleForceLatLon?: boolean;
|
|
23
|
-
appleIgnoreLatLon?: boolean;
|
|
24
|
-
googlePlaceId?: string;
|
|
25
|
-
title?: string;
|
|
26
|
-
/** optionally specify specific app to use */
|
|
27
|
-
app?: MapId;
|
|
28
|
-
/** optional (default: 'Open in Maps') */
|
|
29
|
-
dialogTitle?: string;
|
|
30
|
-
/** optional (default: 'What app would you like to use?') */
|
|
31
|
-
dialogMessage?: string;
|
|
32
|
-
cancelText?: string;
|
|
33
|
-
/** to link into Naver Map You should provide your appname which is the bundle ID in iOS and applicationId in android. */
|
|
34
|
-
naverCallerName?: string;
|
|
35
|
-
directionsMode?: DirectionMode;
|
|
36
|
-
}
|
|
37
|
-
export interface PopupStyleProp {
|
|
38
|
-
container?: StyleProp<ViewStyle>;
|
|
39
|
-
itemContainer?: StyleProp<ViewStyle>;
|
|
40
|
-
image?: StyleProp<ImageStyle>;
|
|
41
|
-
itemText?: StyleProp<TextStyle>;
|
|
42
|
-
headerContainer?: StyleProp<ViewStyle>;
|
|
43
|
-
titleText?: StyleProp<TextStyle>;
|
|
44
|
-
subtitleText?: StyleProp<TextStyle>;
|
|
45
|
-
cancelButtonContainer?: StyleProp<ViewStyle>;
|
|
46
|
-
cancelButtonText?: StyleProp<TextStyle>;
|
|
47
|
-
separatorStyle?: StyleProp<ViewStyle>;
|
|
48
|
-
activityIndicatorContainer?: StyleProp<ViewStyle>;
|
|
49
|
-
}
|
|
50
|
-
export interface PopupProps extends SharedOptions {
|
|
51
|
-
isVisible: boolean;
|
|
52
|
-
showHeader?: boolean;
|
|
53
|
-
customHeader?: React.ReactNode;
|
|
54
|
-
customFooter?: React.ReactNode;
|
|
55
|
-
onCancelPressed: () => void;
|
|
56
|
-
onBackButtonPressed: () => void;
|
|
57
|
-
onAppPressed: (appName: MapId) => void;
|
|
58
|
-
style?: PopupStyleProp;
|
|
59
|
-
modalProps?: object;
|
|
60
|
-
options: MapLinkOptions;
|
|
61
|
-
}
|
|
62
12
|
export type GetAppsResponse = {
|
|
63
13
|
id: MapId;
|
|
64
14
|
name: string;
|
|
@@ -76,17 +26,13 @@ export interface ShowLocationProps {
|
|
|
76
26
|
googleForceLatLon?: boolean;
|
|
77
27
|
googlePlaceId?: number | string;
|
|
78
28
|
title?: string | null;
|
|
79
|
-
app?:
|
|
29
|
+
app?: MapId | null;
|
|
80
30
|
dialogTitle?: string | null;
|
|
81
31
|
dialogMessage?: string | null;
|
|
82
32
|
cancelText?: string | null;
|
|
83
33
|
appsWhiteList?: string[] | null;
|
|
84
|
-
appTitles?: Record<
|
|
85
|
-
naverCallerName?: string;
|
|
86
|
-
directionsMode?: 'car' | 'walk' | 'public-transport' | 'bike' | undefined;
|
|
87
|
-
}
|
|
88
|
-
export interface GetAppsProps extends ShowLocationProps {
|
|
89
|
-
alwaysIncludeGoogle?: boolean;
|
|
90
|
-
appsWhiteList?: string[] | null;
|
|
34
|
+
appTitles?: Partial<Record<MapId, string>>;
|
|
91
35
|
naverCallerName?: string;
|
|
36
|
+
directionsMode?: DirectionMode;
|
|
92
37
|
}
|
|
38
|
+
export type GetAppsProps = ShowLocationProps;
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { MapId } from './type';
|
|
2
|
+
export declare const getAvailableApps: (prefixes: Record<string, string>) => Promise<MapId[]>;
|
|
2
3
|
export declare const isAppInstalled: (app: string, prefixes: Record<string, string>) => Promise<boolean>;
|
|
3
4
|
export declare const isSupportedApp: (app: string) => boolean;
|
|
4
5
|
export declare const getNotSupportedApps: (apps: string[]) => string[];
|
|
@@ -10,7 +11,7 @@ export declare const askAppChoice: ({ dialogTitle, dialogMessage, cancelText, ap
|
|
|
10
11
|
appsWhiteList: string[] | null | undefined;
|
|
11
12
|
prefixes: Record<string, string>;
|
|
12
13
|
appTitles: Record<string, string> | null | undefined;
|
|
13
|
-
}) => Promise<
|
|
14
|
+
}) => Promise<MapId | null>;
|
|
14
15
|
export declare const getDirectionsModeAppleMaps: (directionsMode: 'car' | 'walk' | 'public-transport' | 'bike' | undefined) => string | undefined;
|
|
15
16
|
export declare const getDirectionsModeGoogleMaps: (directionsMode: 'car' | 'walk' | 'public-transport' | 'bike' | undefined) => string | undefined;
|
|
16
17
|
export declare const getDirectionsModeSygic: (directionsMode: 'car' | 'walk' | 'public-transport' | 'bike' | undefined) => string | undefined;
|
package/lib/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ const react_native_1 = require("react-native");
|
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const getAvailableApps = async (prefixes) => {
|
|
7
7
|
const availableApps = [];
|
|
8
|
-
await Promise.all(Object.
|
|
8
|
+
await Promise.all(Object.keys(prefixes).map(async (app) => {
|
|
9
9
|
try {
|
|
10
10
|
const isInstalled = await (0, exports.isAppInstalled)(app, prefixes);
|
|
11
11
|
if (isInstalled) {
|