From 376149f73ce471e24b67af14d36af4dc30b5af89 Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 22 Aug 2017 19:54:17 -0400 Subject: [PATCH] Add defintions for react-native-tab-navigator --- types/react-native-tab-navigator/index.d.ts | 97 +++++++++++++++++++ .../react-native-tab-navigator-tests.tsx | 45 +++++++++ .../react-native-tab-navigator/tsconfig.json | 24 +++++ types/react-native-tab-navigator/tslint.json | 1 + 4 files changed, 167 insertions(+) create mode 100644 types/react-native-tab-navigator/index.d.ts create mode 100644 types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx create mode 100644 types/react-native-tab-navigator/tsconfig.json create mode 100644 types/react-native-tab-navigator/tslint.json diff --git a/types/react-native-tab-navigator/index.d.ts b/types/react-native-tab-navigator/index.d.ts new file mode 100644 index 0000000000..9c2beb5108 --- /dev/null +++ b/types/react-native-tab-navigator/index.d.ts @@ -0,0 +1,97 @@ +// Type definitions for react-native-tab-navigator 0.3 +// Project: https://github.com/exponentjs/react-native-tab-navigator#readme +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import * as React from 'react'; +import { ViewStyle, TextStyle } from 'react-native'; + +export interface TabNavigatorProps { + /** + * Define for rendered scene + */ + sceneStyle?: ViewStyle; + + /** + * Define style for TabBar + */ + tabBarStyle?: ViewStyle; + + /** + * Define shadow style for tabBar + */ + tabBarShadowStyle?: ViewStyle; + + /** + * Disable onPress opacity for Tab + * + * @default false + */ + hidesTabTouch?: boolean; +} + +interface TabNavigatorItemProps { + /** + * Allow font scaling for title + */ + allowFontScaling?: boolean; + + /** + * Text for Item badge + */ + badgeText?: string | number; + + /** + * Return whether the item is selected + */ + selected?: boolean; + + /** + * Styling for selected Item title + */ + selectedTitleStyle?: TextStyle; + + /** + * Styling for tab + */ + tabStyle?: ViewStyle; + + /** + * Item title + */ + title?: string; + + /** + * Styling for Item title + */ + titleStyle?: TextStyle; + + /** + * onPress method for Item + */ + onPress?(): void; + + /** + * Returns Item badge + */ + renderBadge?(): JSX.Element; + + /** + * Returns Item icon + */ + renderIcon?(): JSX.Element; + + /** + * Returns selected Item icon + */ + renderSelectedIcon?(): JSX.Element; +} + +export class TabNavigator extends React.Component {} + +export namespace TabNavigator { + class Item extends React.Component {} +} + +export default TabNavigator; diff --git a/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx b/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx new file mode 100644 index 0000000000..d343a7b84e --- /dev/null +++ b/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx @@ -0,0 +1,45 @@ +import * as React from 'react'; +import { View, Image } from 'react-native'; +import TabNavigator from 'react-native-tab-navigator'; + +interface TabTestState { + selectedTab: string; +} + +const tabBarImage = 'https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png'; + +class TabTest extends React.Component { + constructor() { + super(); + + this.state = { + selectedTab: 'home' + }; + } + + render() { + return ( + + } + renderSelectedIcon={() => } + badgeText="1" + onPress={() => this.setState({ selectedTab: 'home' })}> + + + + } + renderSelectedIcon={() => } + renderBadge={() => } + onPress={() => this.setState({ selectedTab: 'profile' })}> + + + + ); + } +} diff --git a/types/react-native-tab-navigator/tsconfig.json b/types/react-native-tab-navigator/tsconfig.json new file mode 100644 index 0000000000..1506f1471c --- /dev/null +++ b/types/react-native-tab-navigator/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-native-tab-navigator-tests.tsx" + ] +} diff --git a/types/react-native-tab-navigator/tslint.json b/types/react-native-tab-navigator/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-tab-navigator/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }