-
Notifications
You must be signed in to change notification settings - Fork 464
Expand file tree
/
Copy pathPagerViewNativeComponent.ts
More file actions
68 lines (59 loc) · 2.06 KB
/
PagerViewNativeComponent.ts
File metadata and controls
68 lines (59 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type * as React from 'react';
import type { HostComponent, ViewProps } from 'react-native';
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type {
DirectEventHandler,
Double,
Int32,
WithDefault,
} from 'react-native/Libraries/Types/CodegenTypes';
export type OnPageScrollEventData = Readonly<{
position: Double;
offset: Double;
}>;
export type OnPageSelectedEventData = Readonly<{
position: Double;
}>;
export type OnPageScrollStateChangedEventData = Readonly<{
pageScrollState: string; //'idle' | 'dragging' | 'settling';
}>;
export interface NativeProps extends ViewProps {
scrollEnabled?: WithDefault<boolean, true>;
layoutDirection?: WithDefault<'ltr' | 'rtl', 'ltr'>;
initialPage?: Int32;
orientation?: WithDefault<'horizontal' | 'vertical', 'horizontal'>;
offscreenPageLimit?: Int32;
pageMargin?: Int32;
overScrollMode?: WithDefault<'auto' | 'always' | 'never', 'auto'>;
overdrag?: WithDefault<boolean, false>;
keyboardDismissMode?: WithDefault<'none' | 'on-drag', 'none'>;
onPageScroll?: DirectEventHandler<OnPageScrollEventData>;
onPageSelected?: DirectEventHandler<OnPageSelectedEventData>;
onPageScrollStateChanged?: DirectEventHandler<OnPageScrollStateChangedEventData>;
}
type PagerViewViewType = HostComponent<NativeProps>;
export interface NativeCommands {
setPage: (
viewRef: React.ElementRef<PagerViewViewType>,
selectedPage: Int32
) => void;
setPageWithoutAnimation: (
viewRef: React.ElementRef<PagerViewViewType>,
selectedPage: Int32
) => void;
setScrollEnabledImperatively: (
viewRef: React.ElementRef<PagerViewViewType>,
scrollEnabled: boolean
) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: [
'setPage',
'setPageWithoutAnimation',
'setScrollEnabledImperatively',
],
});
export default codegenNativeComponent<NativeProps>(
'RNCViewPager'
) as HostComponent<NativeProps>;