|
| 1 | +open ReactNative; |
1 | 2 | include ViewPagerElement; |
2 | 3 |
|
3 | | -type scrollEvent; |
4 | | -type selectedEvent; |
5 | | -type scrollStateChangedEvent; |
| 4 | +module PageScrollEvent = { |
| 5 | + type payload = { |
| 6 | + position: int, |
| 7 | + offset: float, |
| 8 | + }; |
| 9 | + include Event.SyntheticEvent({ |
| 10 | + type _payload = payload; |
| 11 | + }); |
| 12 | +}; |
6 | 13 |
|
7 | | -[@bs.obj] |
8 | | -external scrollEvent: (~position: float, ~offset: float, unit) => scrollEvent = |
9 | | - ""; |
10 | | -[@bs.obj] |
11 | | -external selectedEvent: (~position: float, unit) => selectedEvent = ""; |
12 | | -[@bs.obj] |
13 | | -external scrollStateChangedEvent: |
14 | | - (~pageScrollState: [@bs.string] [ | `idle | `dragging | `settling], unit) => |
15 | | - scrollStateChangedEvent = |
16 | | - ""; |
| 14 | +module PageSelectedEvent = { |
| 15 | + type payload = {position: float}; |
| 16 | + include Event.SyntheticEvent({ |
| 17 | + type _payload = payload; |
| 18 | + }); |
| 19 | +}; |
| 20 | + |
| 21 | +module PageScrollStateChangedEvent = { |
| 22 | + // new bs new polyvar encoding |
| 23 | + //type payload = {pageScrollState: [ | `idle | `dragging | `settling]}; |
| 24 | + type payload = {pageScrollState: string}; |
| 25 | + include Event.SyntheticEvent({ |
| 26 | + type _payload = payload; |
| 27 | + }); |
| 28 | +}; |
17 | 29 |
|
18 | 30 | [@bs.module "@react-native-community/viewpager"] [@react.component] |
19 | 31 | external make: |
20 | 32 | ( |
21 | 33 | ~ref: ref=?, |
22 | 34 | ~initialPage: int=?, |
23 | 35 | ~scrollEnabled: bool=?, |
24 | | - ~onPageScroll: ReactNative.Event.syntheticEvent(scrollEvent) => unit=?, |
25 | | - ~onPageSelected: ReactNative.Event.syntheticEvent(selectedEvent) => unit=?, |
26 | | - ~onPageScrollStateChanged: ReactNative.Event.syntheticEvent( |
27 | | - scrollStateChangedEvent, |
28 | | - ) => |
29 | | - unit |
30 | | - =?, |
| 36 | + ~onPageScroll: PageScrollEvent.t => unit=?, |
| 37 | + ~onPageSelected: PageSelectedEvent.t => unit=?, |
| 38 | + ~onPageScrollStateChanged: PageScrollStateChangedEvent.t => unit=?, |
31 | 39 | ~keyboardDismissMode: [@bs.string] [ | `none | [@bs.as "on-drag"] `onDrag] |
32 | 40 | =?, |
33 | 41 | ~pageMargin: int=?, |
34 | 42 | ~onMoveShouldSetResponderCapture: ReactNative.Event.pressEvent => bool=?, |
35 | 43 | ~style: ReactNative.Style.t=?, |
36 | 44 | ~children: React.element=?, |
37 | | - ~orientation: [@bs.string] [ | `horizontal | `vertical]=?, |
38 | | - ~transitionStyle: [@bs.string] [ | `scroll | `curl]=?, |
| 45 | + ~orientation: [ | `horizontal | `vertical]=?, |
| 46 | + ~transitionStyle: [ | `scroll | `curl]=?, |
39 | 47 | ~showPageIndicator: bool=? |
40 | 48 | ) => |
41 | 49 | React.element = |
|
0 commit comments