-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathAddToSiriButton.ios.js
55 lines (46 loc) · 1.32 KB
/
AddToSiriButton.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// @flow
import type { ShortcutOptions } from ".";
import * as React from "react";
import {
requireNativeComponent,
View,
Platform,
UIManager,
NativeModules,
} from "react-native";
const RNTAddToSiriButton = requireNativeComponent("RNSSAddToSiriButton");
const Constants = (
UIManager.getViewManagerConfig
? UIManager.getViewManagerConfig("RNSSAddToSiriButton")
: UIManager["RNSSAddToSiriButton"]
).Constants;
export const SiriButtonStyles = Constants.AvailableStyles;
type ViewProps = React.ElementConfig<typeof View>;
type ViewStyleProp = $PropertyType<ViewProps, "style">;
type Props = {
buttonStyle?: 0 | 1 | 2 | 3 | 4 | 5,
style?: ViewStyleProp,
shortcut: ShortcutOptions,
onPress?: () => void,
};
/** @deprecated The component itself now returns `null` when the device does not support the AddToSiriButton */
export const supportsSiriButton = Number.parseFloat(Platform.Version, 10) >= 12;
const AddToSiriButton = ({ buttonStyle, onPress, shortcut, style }: Props) => {
if (!supportsSiriButton) {
return null;
}
return (
<RNTAddToSiriButton
buttonStyle={buttonStyle}
onPress={onPress}
shortcut={shortcut}
style={[
{
height: Constants.ComponentHeight,
width: Constants.ComponentWidth,
},
style,
]}
/>
)};
export default AddToSiriButton;