UNPKG

2.99 kBTypeScriptView Raw
1import * as React from 'react';
2import {
3 TextStyle,
4 ViewStyle,
5 TextProps,
6 TouchableHighlightProps,
7 TouchableNativeFeedbackProps,
8 TabBarIOSItemProps,
9 ColorValue
10} from 'react-native';
11
12export interface IconProps extends TextProps {
13 /**
14 * Size of the icon, can also be passed as fontSize in the style object.
15 *
16 * @default 12
17 */
18 size?: number | undefined;
19
20 /**
21 * Name of the icon to show
22 *
23 * See Icon Explorer app
24 * {@link https://github.com/oblador/react-native-vector-icons/tree/master/Examples/IconExplorer}
25 */
26 name: string;
27
28 /**
29 * Color of the icon
30 *
31 */
32 color?: ColorValue | number | undefined;
33}
34
35export interface IconButtonProps extends IconProps, TouchableHighlightProps, TouchableNativeFeedbackProps {
36 /**
37 * Text and icon color
38 * Use iconStyle or nest a Text component if you need different colors.
39 *
40 * @default 'white'
41 */
42 color?: ColorValue | number | undefined;
43
44 /**
45 * Border radius of the button
46 * Set to 0 to disable.
47 *
48 * @default 5
49 */
50 borderRadius?: number | undefined;
51
52 /**
53 * Styles applied to the icon only
54 * Good for setting margins or a different color.
55 *
56 * @default {marginRight: 10}
57 */
58 iconStyle?: TextStyle | undefined;
59
60 /**
61 * Style prop inherited from TextProps and TouchableWithoutFeedbackProperties
62 * Only exist here so we can have ViewStyle or TextStyle
63 *
64 */
65 style?: ViewStyle | TextStyle | undefined;
66
67 /**
68 * Background color of the button
69 *
70 * @default '#007AFF'
71 */
72 backgroundColor?: ColorValue | number | undefined;
73}
74
75export type ImageSource = any;
76
77export interface TabBarItemIOSProps extends TabBarIOSItemProps {
78 /**
79 * Name of the default icon (similar to TabBarIOS.Item icon)
80 *
81 */
82 iconName: string;
83
84 /**
85 * Name of the selected icon (similar to TabBarIOS.Item selectedIcon)
86 *
87 * Defaults to iconName
88 *
89 */
90 selectedIconName?: string | undefined;
91
92 /**
93 * Size of the icon
94 *
95 * @default 30
96 */
97 iconSize?: number | undefined;
98
99 /**
100 * Color of the icon
101 *
102 */
103 iconColor?: ColorValue | number | undefined;
104
105 /**
106 * Color of the selected icon.
107 *
108 * Defaults to iconColor
109 *
110 */
111 selectedIconColor?: string | undefined;
112}
113
114export class Icon extends React.Component<IconProps, any> {
115 static getImageSource(
116 name: string,
117 size?: number,
118 color?: ColorValue | number,
119 ): Promise<ImageSource>;
120 static getImageSourceSync(
121 name: string,
122 size?: number,
123 color?: ColorValue | number,
124 ): ImageSource;
125 static getFontFamily(): string;
126 static getRawGlyphMap(): { [name: string]: number };
127 static loadFont(
128 file?: string
129 ): Promise<void>;
130 static hasIcon(
131 name: string,
132 ): boolean;
133}
134
135export namespace Icon {
136 class TabBarItem extends React.Component<TabBarItemIOSProps, any> {}
137 class TabBarItemIOS extends React.Component<TabBarItemIOSProps, any> {}
138 class Button extends React.Component<IconButtonProps, any> {}
139}