UNPKG

3.46 kBTypeScriptView Raw
1import * as React from 'react';
2import {
3 TextStyle,
4 ViewStyle,
5 TextProps,
6 TouchableHighlightProps,
7 TouchableNativeFeedbackProps,
8 TabBarIOSItemProps,
9 ToolbarAndroidProps as ReactNativeToolbarAndroidProps
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;
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?: string;
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?: string;
43
44 /**
45 * Border radius of the button
46 * Set to 0 to disable.
47 *
48 * @default 5
49 */
50 borderRadius?: number;
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;
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;
66
67 /**
68 * Background color of the button
69 *
70 * @default '#007AFF'
71 */
72 backgroundColor?: string;
73}
74
75export type ImageSource = any;
76
77export interface ToolbarAndroidProps extends ReactNativeToolbarAndroidProps {
78 /**
79 * Name of the navigation logo icon
80 * (similar to ToolbarAndroid logo)
81 *
82 */
83 logoName: string;
84
85 /**
86 * Name of the navigation icon
87 * (similar to ToolbarAndroid navIcon)
88 *
89 */
90 navIconName: string;
91
92 /**
93 * Name of the overflow icon
94 * (similar to ToolbarAndroid overflowIcon)
95 *
96 */
97 overflowIconName: string;
98
99 /**
100 * Size of the icons
101 *
102 * @default 24
103 */
104 iconSize: number;
105
106 /**
107 * Color of the icons
108 *
109 * @default 'black'
110 */
111 iconColor: string;
112}
113
114export interface TabBarItemIOSProps extends TabBarIOSItemProps {
115 /**
116 * Name of the default icon (similar to TabBarIOS.Item icon)
117 *
118 */
119 iconName: string;
120
121 /**
122 * Name of the selected icon (similar to TabBarIOS.Item selectedIcon)
123 *
124 * Defaults to iconName
125 *
126 */
127 selectedIconName?: string;
128
129 /**
130 * Size of the icon
131 *
132 * @default 30
133 */
134 iconSize?: number;
135
136 /**
137 * Color of the icon
138 *
139 */
140 iconColor?: string;
141
142 /**
143 * Color of the selected icon.
144 *
145 * Defaults to iconColor
146 *
147 */
148 selectedIconColor?: string;
149}
150
151export class Icon extends React.Component<IconProps, any> {
152 static getImageSource(
153 name: string,
154 size?: number,
155 color?: string,
156 ): Promise<ImageSource>;
157 static getImageSourceSync(
158 name: string,
159 size?: number,
160 color?: string,
161 ): ImageSource;
162 static getRawGlyphMap(): { [name: string]: number };
163 static loadFont(
164 file?: string
165 ): Promise<void>;
166 static hasIcon(
167 name: string,
168 ): boolean;
169}
170
171export namespace Icon {
172 class ToolbarAndroid extends React.Component<ToolbarAndroidProps, any> {}
173 class TabBarItem extends React.Component<TabBarItemIOSProps, any> {}
174 class TabBarItemIOS extends React.Component<TabBarItemIOSProps, any> {}
175 class Button extends React.Component<IconButtonProps, any> {}
176}