Add type definition for react-native-navbar (#27412)

This commit is contained in:
Ryokik 2018-07-24 03:39:06 +09:00 committed by Andy
parent f109e22895
commit 642a64efbf
4 changed files with 85 additions and 0 deletions

41
types/react-native-navbar/index.d.ts vendored Normal file
View File

@ -0,0 +1,41 @@
// Type definitions for react-native-navbar 2.1
// Project: https://github.com/react-native-community/react-native-navbar
// Definitions by: Ryo Kikuchi <https://github.com/ryokik>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
import * as React from 'react';
import { ViewStyle, TextProps } from 'react-native';
export interface NavigationBarButton {
title: string;
style?: ViewStyle;
handler?: () => void;
disable?: boolean;
}
export interface NavigationBarTitle {
title: string;
tintColor?: string;
ellipsizeMode?: TextProps["ellipsizeMode"];
numberOfLines?: number;
}
export interface StatusBar {
style?: 'light-content' | 'default';
hidden?: boolean;
tintColor?: string;
hideAnimation?: 'fade' | 'slide' | 'none';
showAnimation?: 'fade' | 'slide' | 'none';
}
export interface NavigationBarProps {
style?: ViewStyle;
tintColor?: string;
statusBar?: StatusBar;
leftButton?: NavigationBarButton | React.ReactElement<any> | null;
rightButton?: NavigationBarButton | React.ReactElement<any> | null;
title?: NavigationBarTitle | React.ReactElement<any> | null;
}
export default class NavigationBar extends React.Component<NavigationBarProps> {}

View File

@ -0,0 +1,19 @@
import * as React from "react";
import { View, Text } from "react-native";
import NavigationBar from "react-native-navbar";
class NavigationBarTest extends React.Component {
render() {
return (
<View>
<NavigationBar tintColor={'red'} leftButton={{
title: "Back",
handler: () => { console.log("Back"); },
}}
rightButton={<Text>Next</Text>}
title={null}
/>
</View>
);
}
}

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"jsx": "react-native",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"react-native-navbar-tests.tsx"
]
}

View File

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