Skip to content

Commit

Permalink
Add flow definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
David Narbutovich committed Sep 20, 2018
1 parent 008ed8b commit 7afcdd7
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions index.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// @flow strict

// eslint-disable-next-line
import type { Component, Node } from 'react';

declare module 'react-native-swiper' {
// eslint-disable-next-line no-undef
declare export type SwiperProps = $ReadOnly<{|
// Basic
// If true, the scroll view's children are arranged horizontally in a row instead of vertically in a column.
horizontal?: ?boolean,
// If no specify default enable fullscreen mode by flex: 1.
loop?: ?boolean,
// Index number of initial slide.
index?: ?number,
// Set to true make control buttons visible.
showsButtons?: ?boolean,
// Set to false to disable continuous loop mode.
autoplay?: ?boolean,
// Called with the new index when the user swiped
onIndexChanged?: ?(index?: number) => void,

// Custom basic style & content
// Set to true enable auto play mode.
width?: ?number,
// If no specify default fullscreen mode by flex: 1.
height?: ?number,
// See default style in source.
style?: ?Object,
// Only load current index slide , loadMinimalSize slides before and after.
loadMinimal?: ?boolean,
// see loadMinimal
loadMinimalSize?: ?boolean,
// Custom loader to display when slides aren't loaded
loadMinimalLoader?: ?boolean,

// Pagination
// Set to true make pagination visible.
showsPagination?: ?boolean,
// Custom styles will merge with the default styles.
paginationStyle?: ?Object,
// Complete control how to render pagination with three params (index, total, context) ref to this.state.index / this.state.total / this, For example: show numbers instead of dots.
renderPagination?: ?(index: number, total: number, context: any) => Node,
// Allow custom the dot element.
dot?: ?Node,
// Allow custom the active-dot element.
activeDot?: ?Node,
// Allow custom the active-dot element.
dotStyle?: ?Object,
// Allow custom the active-dot element.
dotColor?: ?string,
// Allow custom the active-dot element.
activeDotColor?: ?string,
// Allow custom the active-dot element.
activeDotStyle?: ?Object,

// Autoplay
// Delay between auto play transitions (in second).
autoplayTimeout?: ?number,
// Cycle direction control.
autoplayDirection?: ?boolean,

// Control buttons
// Set to true make control buttons visible.
buttonWrapperStyle?: ?Object,
// Allow custom the next button.
nextButton?: ?Node,
// Allow custom the prev button.
prevButton?: ?Node,

// Supported ScrollResponder
// When animation begins after letting up
onScrollBeginDrag?: ?(event?: any, state?: any, context?: any) => void,
// Makes no sense why this occurs first during bounce
onMomentumScrollEnd?: ?(event?: any, state?: any, context?: any) => void,
// Immediately after onMomentumScrollEnd
onTouchStartCapture?: ?(event?: any, state?: any, context?: any) => void,
// Same, but bubble phase
onTouchStart?: ?(event?: any, state?: any, context?: any) => void,
// You could hold the touch start for a long time
onTouchEnd?: ?(event?: any, state?: any, context?: any) => void,
// When lifting up - you could pause forever before * lifting
onResponderRelease?: ?(event?: any, state?: any, context?: any) => void,

// If true, the scroll view stops on multiples of the scroll view's size when scrolling. This can be used for
// horizontal pagination.
pagingEnabled?: ?boolean,
// Set to true if you want to show horizontal scroll bar.
showsHorizontalScrollIndicator?: ?boolean,
// Set to true if you want to show vertical scroll bar.
showsVerticalScrollIndicator?: ?boolean,
// If true, the scroll view bounces when it reaches the end of the content if the content is larger then the
// scroll view along the axis of the scroll direction. If false, it disables all bouncing even if the
// alwaysBounce* props are true.
bounces?: ?boolean,
// If true, the scroll view scrolls to top when the status bar is tapped.
scrollsToTop?: ?boolean,
// If true, offscreen child views (whose overflow value is hidden) are removed from their native backing
// superview when offscreen. This canimprove scrolling performance on long lists.
removeClippedSubviews?: ?boolean,
// Set to true if you need adjust content insets automation.
automaticallyAdjustContentInsets?: ?boolean,
// Enables/Disables swiping
scrollEnabled?: ?boolean
|}>;

// eslint-disable-next-line no-undef
declare export default class Swiper extends Component<SwiperProps> {
scrollBy(index: number, animated?: boolean): void;
}
}

0 comments on commit 7afcdd7

Please sign in to comment.