mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
add types for react-native-swiper, fix types for react-navigation (#16552)
* add missing types which lists in the docs but not in the propTypes of src * fix types in react-navigation * fix `Definitions by` * Update index.d.ts * Update index.d.ts * stash * fix `Definitions by` * add test for react-native-swiper
This commit is contained in:
committed by
Mohamed Hegazy
parent
f7ef6b01f6
commit
a8dca3c8f5
74
types/react-native-swiper/index.d.ts
vendored
74
types/react-native-swiper/index.d.ts
vendored
@@ -1,14 +1,33 @@
|
||||
// Type definitions for react-native-swiper 1.5
|
||||
// Project: https://github.com/leecade/react-native-swiper#readme
|
||||
// Definitions by: CaiHuan <https://github.com/CaiHuan>, HuHuanming <https://github.com/huhuanming>
|
||||
// Definitions by: CaiHuan <https://github.com/CaiHuan>
|
||||
// HuHuanming <https://github.com/huhuanming>
|
||||
// mhcgrq <https://github.com/mhcgrq>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import * as React from 'react';
|
||||
import {
|
||||
ViewStyle
|
||||
ViewStyle,
|
||||
NativeSyntheticEvent,
|
||||
NativeScrollEvent,
|
||||
} from 'react-native';
|
||||
|
||||
export interface SwiperState {
|
||||
autoplayEnd: boolean;
|
||||
dir: 'x' | 'y';
|
||||
height: number;
|
||||
width: number;
|
||||
index: number;
|
||||
isScrolling: boolean;
|
||||
loopJump: boolean;
|
||||
offset: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface SwiperProperties extends React.Props<Swiper> {
|
||||
horizontal?: boolean;
|
||||
|
||||
@@ -24,6 +43,8 @@ export interface SwiperProperties extends React.Props<Swiper> {
|
||||
|
||||
scrollsToTop?: boolean;
|
||||
|
||||
scrollEnabled?: boolean;
|
||||
|
||||
removeClippedSubviews?: boolean;
|
||||
|
||||
automaticallyAdjustContentInsets?: boolean;
|
||||
@@ -54,6 +75,10 @@ export interface SwiperProperties extends React.Props<Swiper> {
|
||||
|
||||
activeDotStyle?: ViewStyle;
|
||||
|
||||
activeDot?: JSX.Element;
|
||||
|
||||
dot?: JSX.Element;
|
||||
|
||||
dotColor?: string;
|
||||
|
||||
activeDotColor?: string;
|
||||
@@ -63,7 +88,50 @@ export interface SwiperProperties extends React.Props<Swiper> {
|
||||
width?: number;
|
||||
|
||||
paginationStyle?: ViewStyle;
|
||||
|
||||
buttonWrapperStyle?: ViewStyle;
|
||||
|
||||
nextButton?: JSX.Element;
|
||||
|
||||
prevButton?: JSX.Element;
|
||||
|
||||
onScrollBeginDrag?(
|
||||
event: NativeSyntheticEvent<NativeScrollEvent>,
|
||||
state: SwiperState,
|
||||
context: Swiper
|
||||
): void;
|
||||
|
||||
onMomentumScrollEnd?(
|
||||
event: NativeSyntheticEvent<NativeScrollEvent>,
|
||||
state: SwiperState,
|
||||
context: Swiper
|
||||
): void;
|
||||
|
||||
onTouchStartCapture?(
|
||||
event: NativeSyntheticEvent<NativeScrollEvent>,
|
||||
state: SwiperState,
|
||||
context: Swiper
|
||||
): void;
|
||||
|
||||
onTouchStart?(
|
||||
event: NativeSyntheticEvent<NativeScrollEvent>,
|
||||
state: SwiperState,
|
||||
context: Swiper
|
||||
): void;
|
||||
|
||||
onTouchEnd?(
|
||||
event: NativeSyntheticEvent<NativeScrollEvent>,
|
||||
state: SwiperState,
|
||||
context: Swiper
|
||||
): void;
|
||||
|
||||
onResponderRelease?(
|
||||
event: NativeSyntheticEvent<NativeScrollEvent>,
|
||||
state: SwiperState,
|
||||
context: Swiper
|
||||
): void;
|
||||
}
|
||||
|
||||
export default class Swiper extends React.Component<SwiperProperties, {}> {
|
||||
export default class Swiper extends React.Component<SwiperProperties, SwiperState> {
|
||||
scrollBy(index: number, animated: boolean): void;
|
||||
}
|
||||
|
||||
@@ -3,18 +3,54 @@ import {
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
ViewStyle
|
||||
ViewStyle,
|
||||
NativeSyntheticEvent,
|
||||
NativeScrollEvent
|
||||
} from 'react-native';
|
||||
import Swiper from 'react-native-swiper';
|
||||
import Swiper, { SwiperState } from 'react-native-swiper';
|
||||
|
||||
class SwiperTest extends React.Component<{}, {}> {
|
||||
constructor(props: {}) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
callback = (
|
||||
event: NativeSyntheticEvent<NativeScrollEvent>,
|
||||
state: SwiperState,
|
||||
context: Swiper
|
||||
) => {
|
||||
console.log(this.callback.name, event, state, context);
|
||||
}
|
||||
render(): React.ReactElement<any> {
|
||||
return (
|
||||
<Swiper
|
||||
horizontal
|
||||
pagingEnabled
|
||||
showsHorizontalScrollIndicator
|
||||
showsVerticalScrollIndicator
|
||||
bounces
|
||||
scrollsToTop
|
||||
scrollEnabled
|
||||
removeClippedSubviews
|
||||
automaticallyAdjustContentInsets
|
||||
showsPagination
|
||||
showsButtons
|
||||
loadMinimal
|
||||
loadMinimalSize={1}
|
||||
loop
|
||||
autoplay
|
||||
autoplayTimeout={300}
|
||||
autoplayDirection
|
||||
renderPagination={() => (<View />)}
|
||||
height={100}
|
||||
width={200}
|
||||
nextButton={<View><Text>NEXT</Text></View>}
|
||||
prevButton={<View><Text>PREV</Text></View>}
|
||||
onScrollBeginDrag={this.callback}
|
||||
onMomentumScrollEnd={this.callback}
|
||||
onTouchStartCapture={this.callback}
|
||||
onTouchStart={this.callback}
|
||||
onTouchEnd={this.callback}
|
||||
onResponderRelease={this.callback}
|
||||
style={styles.wrapper}>
|
||||
<View
|
||||
style={styles.slide1}>
|
||||
|
||||
2
types/react-navigation/index.d.ts
vendored
2
types/react-navigation/index.d.ts
vendored
@@ -490,7 +490,7 @@ interface NavigationContainerState {
|
||||
export interface NavigationContainer extends React.ComponentClass<
|
||||
NavigationContainerProps
|
||||
> {
|
||||
router: any
|
||||
router: NavigationRouter
|
||||
}
|
||||
|
||||
export type StackNavigatorConfig =
|
||||
|
||||
Reference in New Issue
Block a user