import type * as React from 'react'; import { codegenNativeCommands, codegenNativeComponent, type HostComponent, type ViewProps, } from 'react-native'; 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: 'idle' | 'dragging' | 'settling'; }>; export interface NativeProps extends ViewProps { scrollEnabled?: WithDefault; layoutDirection?: WithDefault<'ltr' | 'rtl', 'ltr'>; initialPage?: Int32; orientation?: WithDefault<'horizontal' | 'vertical', 'horizontal'>; offscreenPageLimit?: Int32; pageMargin?: Int32; overScrollMode?: WithDefault<'auto' | 'always' | 'never', 'auto'>; overdrag?: WithDefault; keyboardDismissMode?: WithDefault<'none' | 'on-drag', 'none'>; /** * Controls the sensitivity of scroll gestures on Android. * Higher values make scrolling less sensitive. * Valid range: 2 - 8 * @platform android */ scrollSensitivity?: Int32; /** * When true on an inner PagerView, enables gesture coordination with * a parent (outer) PagerView. At sub-tab boundaries the inner pager's * gesture recognizer will not begin, allowing the outer pager to take over. * @platform ios */ nestedScrollEnabled?: WithDefault; onPageScroll?: DirectEventHandler; onPageSelected?: DirectEventHandler; onPageScrollStateChanged?: DirectEventHandler; } type PagerViewViewType = HostComponent; export interface NativeCommands { setPage: ( viewRef: React.ElementRef, selectedPage: Int32 ) => void; setPageWithoutAnimation: ( viewRef: React.ElementRef, selectedPage: Int32 ) => void; setScrollEnabledImperatively: ( viewRef: React.ElementRef, scrollEnabled: boolean ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: [ 'setPage', 'setPageWithoutAnimation', 'setScrollEnabledImperatively', ], }); export default codegenNativeComponent( 'RNCViewPager' ) as HostComponent;