UNPKG

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