Add defintions for react-native-tab-navigator

This commit is contained in:
Kyle
2017-08-22 19:54:17 -04:00
parent 516ed213ca
commit 376149f73c
4 changed files with 167 additions and 0 deletions

View File

@@ -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 <https://github.com/iRoachie>
// 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<TabNavigatorProps, any> {}
export namespace TabNavigator {
class Item extends React.Component<TabNavigatorItemProps, any> {}
}
export default TabNavigator;

View File

@@ -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<any, TabTestState> {
constructor() {
super();
this.state = {
selectedTab: 'home'
};
}
render() {
return (
<TabNavigator>
<TabNavigator.Item
selected={this.state.selectedTab === 'home'}
title="Home"
renderIcon={() => <Image source={{uri: tabBarImage }} />}
renderSelectedIcon={() => <Image source={{uri: tabBarImage}} />}
badgeText="1"
onPress={() => this.setState({ selectedTab: 'home' })}>
<View />
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'profile'}
title="Profile"
renderIcon={() => <Image source={{uri: tabBarImage }} />}
renderSelectedIcon={() => <Image source={{uri: tabBarImage}} />}
renderBadge={() => <View />}
onPress={() => this.setState({ selectedTab: 'profile' })}>
<View />
</TabNavigator.Item>
</TabNavigator>
);
}
}

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }