From feefb04e1c975ce868408d62416e5f5c49a2b9bc Mon Sep 17 00:00:00 2001 From: CaiHuan Date: Wed, 18 Jan 2017 05:57:11 +0800 Subject: [PATCH] remove style isRequire attribute and add react-native-scrollable-tab-view type define file (#14020) * remove style isRequire attribute * commit react-native-scrollable-tab-view * commit react-native-scrollable-tab-view/index.d.ts * changed file extension name * Fix test error * fix no-trailing-whitespace trailing whitespace --- react-native-scrollable-tab-view/index.d.ts | 107 ++++++++++++++++++ ...react-native-scrollable-tab-view-tests.tsx | 48 ++++++++ .../tsconfig.json | 21 ++++ react-native-scrollable-tab-view/tslint.json | 1 + react-native-swiper/index.d.ts | 2 +- 5 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 react-native-scrollable-tab-view/index.d.ts create mode 100644 react-native-scrollable-tab-view/react-native-scrollable-tab-view-tests.tsx create mode 100644 react-native-scrollable-tab-view/tsconfig.json create mode 100644 react-native-scrollable-tab-view/tslint.json diff --git a/react-native-scrollable-tab-view/index.d.ts b/react-native-scrollable-tab-view/index.d.ts new file mode 100644 index 0000000000..b2d447c23c --- /dev/null +++ b/react-native-scrollable-tab-view/index.d.ts @@ -0,0 +1,107 @@ +// Type definitions for react-native-scrollable-tab-view 0.7 +// Project: https://github.com/brentvatne/react-native-scrollable-tab-view#readme +// Definitions by: CaiHuan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from 'react'; +import { + Animated, + ViewStyle +} from 'react-native'; + +export interface onChangeTabProperties { + // currentPage + i: number; + + // currentPage object + ref: JSX.Element; + + // previousPage + from: number; +} + +export interface renderTabBarProperties { + + goToPage: (pageNumber: number) => void; + + tabs: JSX.Element; + + activeTab: number; + + scrollValue: Animated.Value; + + containerWidth: number; +} + +interface ScrollableTabViewProperties extends React.Props { + + /** + * tabBarPosition (String) Defaults to "top". + * "bottom" to position the tab bar below content. + * "overlayTop" or "overlayBottom" for a semitransparent tab bar that overlays content. Custom + * tab bars must consume a style prop on their outer element to support this feature: style={this.props.style}. + */ + tabBarPosition?: 'top' | 'bottom' | 'overlayTop' | 'overlayBottom'; + + /** + * (Integer) - the index of the initially selected tab, defaults to 0 === first tab + */ + initialPage?: number; + + /** + * (Integer) - set selected tab(can be buggy see + * https://github.com/skv-headless/react-native-scrollable-tab-view/issues/126 + */ + page?: number; + + /** + * onChangeTab (Function) - function to call when tab changes, should accept 1 argument which is + * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the + * tab that is selected + */ + onChangeTab?: (value: onChangeTabProperties) => void; + + /** + * onScroll (Function) - function to call when the pages are sliding, + * should accept 1 argument which is an Float number representing the page position in the slide frame. + */ + onScroll?: (value: number) => void; + + /** + * renderTabBar (Function:ReactComponent) - accept 1 argument props and should return a component + * to use as the tab bar. The component has goToPage, tabs, activeTab and ref added to the props, + * and should implement setAnimationValue to be able to animate itself along with the tab content. + * You can manually pass the props to the TabBar component. + */ + renderTabBar?: (value: JSX.Element) => JSX.Element; + + /** + * style (View.propTypes.style) + */ + style?: ViewStyle; + + /** + * contentProps (Object) - props that are applied to root ScrollView/ViewPagerAndroid. + * Note that overriding defaults set by the library may break functionality; see the source for details. + */ + contentProps?: React.ScrollViewProperties; + + /** + * scrollWithoutAnimation (Bool) - on tab press change tab without animation. + */ + scrollWithoutAnimation?: boolean; + + /** + * locked (Bool) - disables horizontal dragging to scroll between tabs, default is false. + */ + locked?: boolean; + + /** + * prerenderingSiblingsNumber (Integer) - pre-render nearby # sibling, Infinity === render all + * the siblings, default to 0 === render current page. + */ + prerenderingSiblingsNumber?: number; +} + +export default class ScrollableTabView extends React.Component { +} diff --git a/react-native-scrollable-tab-view/react-native-scrollable-tab-view-tests.tsx b/react-native-scrollable-tab-view/react-native-scrollable-tab-view-tests.tsx new file mode 100644 index 0000000000..be501febf9 --- /dev/null +++ b/react-native-scrollable-tab-view/react-native-scrollable-tab-view-tests.tsx @@ -0,0 +1,48 @@ +import * as React from 'react'; +import { + Text +} from 'react-native'; +import ScrollableTabView from 'react-native-scrollable-tab-view'; + +interface MyTextProperties extends React.Props { + tabLabel: string; + + text: string; +} +class MyText extends React.Component { + public constructor(props: MyTextProperties) { + super(props); + } + + public render(): JSX.Element { + return( + this.props.text + ); + } +} + +interface ScrollableTabViewDemoProperties { + +} +class ScrollableTabViewDemo extends React.Component { + + public constructor(props: ScrollableTabViewDemo) { + super(props); + } + + public render(): JSX.Element { + return ( + + + + + + ); + } + + protected componentWillMount?(): void { + } + + protected componentWillUnmount?(): void { + } +} \ No newline at end of file diff --git a/react-native-scrollable-tab-view/tsconfig.json b/react-native-scrollable-tab-view/tsconfig.json new file mode 100644 index 0000000000..a97106da78 --- /dev/null +++ b/react-native-scrollable-tab-view/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-native-scrollable-tab-view-tests.tsx" + ] +} diff --git a/react-native-scrollable-tab-view/tslint.json b/react-native-scrollable-tab-view/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-native-scrollable-tab-view/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/react-native-swiper/index.d.ts b/react-native-swiper/index.d.ts index 9b6a0f345c..f1ff914346 100644 --- a/react-native-swiper/index.d.ts +++ b/react-native-swiper/index.d.ts @@ -12,7 +12,7 @@ interface SwiperProperties extends React.Props { horizontal?: boolean; - style: ViewStyle; + style?: ViewStyle; pagingEnabled?: boolean;