|
| 1 | +type t; |
| 2 | + |
| 3 | +module NativeEvent = { |
| 4 | + type t; |
| 5 | + [@bs.get] external changedTouches: t => array(Js.t({..})) = ""; |
| 6 | + [@bs.get] external identifier: t => int = ""; |
| 7 | + [@bs.get] external locationX: t => float = ""; |
| 8 | + [@bs.get] external locationY: t => float = ""; |
| 9 | + [@bs.get] external pageX: t => float = ""; |
| 10 | + [@bs.get] external pageY: t => float = ""; |
| 11 | + [@bs.get] external target: t => Js.t({..}) = ""; |
| 12 | + [@bs.get] external touches: t => array(Js.t({..})) = ""; |
| 13 | + [@bs.get] external timestamp: t => int = ""; |
| 14 | + [@bs.get] external data: t => string = ""; |
| 15 | +}; |
| 16 | + |
| 17 | +/* |
| 18 | + fixme rename NativeEvent to NativePressEvent when necessary |
| 19 | + see https://github.com/facebook/react-native/blob/master/Libraries/Types/CoreEventTypes.js |
| 20 | + */ |
| 21 | +module NativePressEvent = NativeEvent; |
| 22 | + |
| 23 | +module NativeLayoutEvent = { |
| 24 | + type t; |
| 25 | + type layout = { |
| 26 | + x: float, |
| 27 | + y: float, |
| 28 | + width: float, |
| 29 | + height: float, |
| 30 | + }; |
| 31 | + [@bs.get] external _layout: t => Js.t('a) = "nativeEvent"; |
| 32 | + let layout = (t: t) => { |
| 33 | + let l = _layout(t)##layout; |
| 34 | + {x: l##x, y: l##y, width: l##width, height: l##height}; |
| 35 | + }; |
| 36 | +}; |
| 37 | + |
| 38 | +module NativeScrollEvent = { |
| 39 | + type t; |
| 40 | + type point = { |
| 41 | + x: float, |
| 42 | + y: float, |
| 43 | + }; |
| 44 | + type size = { |
| 45 | + width: float, |
| 46 | + height: float, |
| 47 | + }; |
| 48 | + type contentInset = { |
| 49 | + bottom: float, |
| 50 | + top: float, |
| 51 | + left: float, |
| 52 | + right: float, |
| 53 | + }; |
| 54 | + [@bs.get] external _nativeEvent: t => Js.t('a) = "nativeEvent"; |
| 55 | + let contentOffset = (t: t) => { |
| 56 | + let co = _nativeEvent(t)##contentOffset; |
| 57 | + {x: co##x, y: co##y}; |
| 58 | + }; |
| 59 | + let contentSize = (t: t) => { |
| 60 | + let cs = _nativeEvent(t)##contentSize; |
| 61 | + {width: cs##width, height: cs##height}; |
| 62 | + }; |
| 63 | + let layoutMeasurement = (t: t) => { |
| 64 | + let lm = _nativeEvent(t)##layoutMeasurement; |
| 65 | + {width: lm##width, height: lm##height}; |
| 66 | + }; |
| 67 | + let contentInset = (t: t) => { |
| 68 | + let ci = _nativeEvent(t)##contentInset; |
| 69 | + {bottom: ci##bottom, top: ci##top, left: ci##left, right: ci##right}; |
| 70 | + }; |
| 71 | +}; |
| 72 | + |
| 73 | +[@bs.get] external nativeEvent: t => NativeEvent.t = ""; |
| 74 | + |
| 75 | +[@bs.get] external nativeLayoutEvent: t => NativeLayoutEvent.t = "nativeEvent"; |
| 76 | + |
| 77 | +[@bs.get] external nativeScrollEvent: t => NativeScrollEvent.t = "nativeEvent"; |
0 commit comments