diff --git a/types/react-native-vector-icons/FontAwesome5.d.ts b/types/react-native-vector-icons/FontAwesome5.d.ts new file mode 100644 index 0000000000..79c77ff0e2 --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome5.d.ts @@ -0,0 +1,43 @@ +import { Component } from "react"; +import { Icon, IconProps, ImageSource } from "./Icon"; + +export const FA5Style: { + regular: 0; + light: 1; + solid: 2; + brand: 3; +}; + +export type ValueOf = T[keyof T]; + +// borrowed from +// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html +export type Omit = Pick>; + +export type FontAwesome5IconVariants = keyof Omit; + +// modified from https://stackoverflow.com/a/49725198/1105281 +export type AllowOnlyOne = Omit & + { + [K in Keys]-?: Partial> & + Partial, undefined>> + }[Keys]; + +export type FontAwesome5IconProps = AllowOnlyOne< + { [K in FontAwesome5IconVariants]?: boolean } & IconProps, + FontAwesome5IconVariants +>; + +export default class FontAwesome5Icon extends Component< + FontAwesome5IconProps, + any +> { + static getImageSource( + name: string, + size?: number, + color?: string, + fa5Style?: ValueOf + ): Promise; + static loadFont(file?: string): Promise; + static hasIcon(name: string): boolean; +} diff --git a/types/react-native-vector-icons/FontAwesome5Pro.d.ts b/types/react-native-vector-icons/FontAwesome5Pro.d.ts new file mode 100644 index 0000000000..f8233abce5 --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome5Pro.d.ts @@ -0,0 +1,6 @@ +import { Component } from "react"; +import FontAwesome5Icon, { FontAwesome5IconProps } from "./FontAwesome5"; + +export type FontAwesome5ProIconProps = FontAwesome5IconProps; +export { FA5Style } from "./FontAwesome5"; +export default FontAwesome5Icon; diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index 51cb1eee81..18b03edcaa 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -3,6 +3,8 @@ import { View, Text, TabBarIOS } from 'react-native'; import { createIconSet } from 'react-native-vector-icons'; import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; +import FontAwesome5Icon from 'react-native-vector-icons/FontAwesome5'; +import FontAwesome5ProIcon from 'react-native-vector-icons/FontAwesome5Pro'; import Ionicon from 'react-native-vector-icons/Ionicons'; const glyphMap = { @@ -27,6 +29,9 @@ class Example extends React.Component { {/* Normal Icon */} + + + {/* Icon button */}