UNPKG

6.95 kBTypeScriptView Raw
1import * as React from 'react';
2import { ReactNode } from 'react';
3import { Animated, PanResponderGestureState, PanResponderInstance, StyleProp, ViewStyle, ViewProps } from 'react-native';
4import * as PropTypes from 'prop-types';
5import { Animation, CustomAnimation } from 'react-native-animatable';
6import { Direction, Orientation, OrNull, PresentationStyle, OnOrientationChange } from './types';
7export declare type OnSwipeCompleteParams = {
8 swipingDirection: Direction;
9};
10declare type State = {
11 showContent: boolean;
12 isVisible: boolean;
13 deviceWidth: number;
14 deviceHeight: number;
15 isSwipeable: boolean;
16 pan: OrNull<Animated.ValueXY>;
17};
18export interface ModalProps extends ViewProps {
19 children: ReactNode;
20 onSwipeStart?: () => void;
21 onSwipeMove?: (percentageShown: number) => void;
22 onSwipeComplete?: (params: OnSwipeCompleteParams) => void;
23 onSwipeCancel?: () => void;
24 style?: StyleProp<ViewStyle>;
25 swipeDirection?: Direction | Array<Direction>;
26 onDismiss?: () => void;
27 onShow?: () => void;
28 hardwareAccelerated?: boolean;
29 onOrientationChange?: OnOrientationChange;
30 presentationStyle?: PresentationStyle;
31 animationIn: Animation | CustomAnimation;
32 animationInTiming: number;
33 animationOut: Animation | CustomAnimation;
34 animationOutTiming: number;
35 avoidKeyboard: boolean;
36 coverScreen: boolean;
37 hasBackdrop: boolean;
38 backdropColor: string;
39 backdropOpacity: number;
40 backdropTransitionInTiming: number;
41 backdropTransitionOutTiming: number;
42 customBackdrop: ReactNode;
43 useNativeDriver: boolean;
44 deviceHeight: number;
45 deviceWidth: number;
46 hideModalContentWhileAnimating: boolean;
47 propagateSwipe: boolean;
48 isVisible: boolean;
49 onModalShow: () => void;
50 onModalWillShow: () => void;
51 onModalHide: () => void;
52 onModalWillHide: () => void;
53 onBackButtonPress: () => void;
54 onBackdropPress: () => void;
55 swipeThreshold: number;
56 scrollTo: OrNull<(e: any) => void>;
57 scrollOffset: number;
58 scrollOffsetMax: number;
59 scrollHorizontal: boolean;
60 supportedOrientations?: Orientation[];
61}
62export declare class ReactNativeModal extends React.Component<ModalProps, State> {
63 static propTypes: {
64 animationIn: PropTypes.Requireable<string | object>;
65 animationInTiming: PropTypes.Requireable<number>;
66 animationOut: PropTypes.Requireable<string | object>;
67 animationOutTiming: PropTypes.Requireable<number>;
68 avoidKeyboard: PropTypes.Requireable<boolean>;
69 coverScreen: PropTypes.Requireable<boolean>;
70 hasBackdrop: PropTypes.Requireable<boolean>;
71 backdropColor: PropTypes.Requireable<string>;
72 backdropOpacity: PropTypes.Requireable<number>;
73 backdropTransitionInTiming: PropTypes.Requireable<number>;
74 backdropTransitionOutTiming: PropTypes.Requireable<number>;
75 customBackdrop: PropTypes.Requireable<PropTypes.ReactNodeLike>;
76 children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
77 deviceHeight: PropTypes.Requireable<number>;
78 deviceWidth: PropTypes.Requireable<number>;
79 isVisible: PropTypes.Validator<boolean>;
80 hideModalContentWhileAnimating: PropTypes.Requireable<boolean>;
81 propagateSwipe: PropTypes.Requireable<boolean>;
82 onModalShow: PropTypes.Requireable<(...args: any[]) => any>;
83 onModalWillShow: PropTypes.Requireable<(...args: any[]) => any>;
84 onModalHide: PropTypes.Requireable<(...args: any[]) => any>;
85 onModalWillHide: PropTypes.Requireable<(...args: any[]) => any>;
86 onBackButtonPress: PropTypes.Requireable<(...args: any[]) => any>;
87 onBackdropPress: PropTypes.Requireable<(...args: any[]) => any>;
88 onSwipeStart: PropTypes.Requireable<(...args: any[]) => any>;
89 onSwipeMove: PropTypes.Requireable<(...args: any[]) => any>;
90 onSwipeComplete: PropTypes.Requireable<(...args: any[]) => any>;
91 onSwipeCancel: PropTypes.Requireable<(...args: any[]) => any>;
92 swipeThreshold: PropTypes.Requireable<number>;
93 swipeDirection: PropTypes.Requireable<string | (string | null | undefined)[]>;
94 useNativeDriver: PropTypes.Requireable<boolean>;
95 style: PropTypes.Requireable<any>;
96 scrollTo: PropTypes.Requireable<(...args: any[]) => any>;
97 scrollOffset: PropTypes.Requireable<number>;
98 scrollOffsetMax: PropTypes.Requireable<number>;
99 scrollHorizontal: PropTypes.Requireable<boolean>;
100 supportedOrientations: PropTypes.Requireable<(string | null | undefined)[]>;
101 };
102 static defaultProps: {
103 animationIn: string;
104 animationInTiming: number;
105 animationOut: string;
106 animationOutTiming: number;
107 avoidKeyboard: boolean;
108 coverScreen: boolean;
109 hasBackdrop: boolean;
110 backdropColor: string;
111 backdropOpacity: number;
112 backdropTransitionInTiming: number;
113 backdropTransitionOutTiming: number;
114 customBackdrop: null;
115 useNativeDriver: boolean;
116 deviceHeight: null;
117 deviceWidth: null;
118 hideModalContentWhileAnimating: boolean;
119 propagateSwipe: boolean;
120 isVisible: boolean;
121 onModalShow: () => null;
122 onModalWillShow: () => null;
123 onModalHide: () => null;
124 onModalWillHide: () => null;
125 onBackdropPress: () => null;
126 onBackButtonPress: () => null;
127 swipeThreshold: number;
128 scrollTo: null;
129 scrollOffset: number;
130 scrollOffsetMax: number;
131 scrollHorizontal: boolean;
132 supportedOrientations: string[];
133 };
134 state: State;
135 isTransitioning: boolean;
136 inSwipeClosingState: boolean;
137 currentSwipingDirection: OrNull<Direction>;
138 animationIn: string;
139 animationOut: string;
140 backdropRef: any;
141 contentRef: any;
142 panResponder: OrNull<PanResponderInstance>;
143 constructor(props: ModalProps);
144 static getDerivedStateFromProps(nextProps: ModalProps, state: State): {
145 isVisible: boolean;
146 showContent: boolean;
147 } | null;
148 componentDidMount(): void;
149 componentWillUnmount(): void;
150 componentDidUpdate(prevProps: ModalProps): void;
151 buildPanResponder: () => void;
152 getAccDistancePerDirection: (gestureState: PanResponderGestureState) => number;
153 getSwipingDirection: (gestureState: PanResponderGestureState) => "left" | "right" | "up" | "down";
154 calcDistancePercentage: (gestureState: PanResponderGestureState) => number;
155 createAnimationEventForSwipe: () => (...args: any[]) => void;
156 isDirectionIncluded: (direction: Direction) => boolean;
157 isSwipeDirectionAllowed: ({ dy, dx }: PanResponderGestureState) => boolean;
158 handleDimensionsUpdate: () => void;
159 open: () => void;
160 close: () => void;
161 render(): JSX.Element;
162}
163export default ReactNativeModal;