Skip to content

Commit 9394860

Browse files
sgnyMoOx
authored andcommitted
Event.layoutEvent for View components (#390)
1 parent 4ac1437 commit 9394860

43 files changed

Lines changed: 69 additions & 102 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1 @@
1-
'use strict';
2-
3-
4-
function layout(t) {
5-
var l = t.nativeEvent.layout;
6-
return /* record */[
7-
/* x */l.x,
8-
/* y */l.y,
9-
/* width */l.width,
10-
/* height */l.height
11-
];
12-
}
13-
14-
var NativeLayoutEvent = /* module */[/* layout */layout];
15-
16-
exports.NativeLayoutEvent = NativeLayoutEvent;
17-
/* No side effect */
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

‎bs-react-native-next/src/apis/Event.md‎

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ type pressEvent = event(pressEventPayload);
2828
type position = {
2929
.
3030
"y": float,
31-
"x": float
31+
"x": float,
3232
};
3333
3434
type dimensions = {
3535
.
3636
"height": float,
37-
"width": float
37+
"width": float,
3838
};
3939
4040
type scrollEvent =
@@ -45,31 +45,23 @@ type scrollEvent =
4545
"bottom": float,
4646
"left": float,
4747
"right": float,
48-
"top": float
48+
"top": float,
4949
},
5050
"contentOffset": position,
5151
"contentSize": dimensions,
52-
"layoutMeasurement": dimensions
52+
"layoutMeasurement": dimensions,
5353
});
5454
55-
type t;
56-
57-
module NativeLayoutEvent = {
58-
type t;
59-
type layout = {
60-
x: float,
61-
y: float,
62-
width: float,
63-
height: float,
64-
};
65-
[@bs.get] external _layout: t => Js.t('a) = "nativeEvent";
66-
let layout = (t: t) => {
67-
let l = _layout(t)##layout;
68-
{x: l##x, y: l##y, width: l##width, height: l##height};
69-
};
70-
};
71-
72-
[@bs.get] external nativeLayoutEvent: t => NativeLayoutEvent.t = "nativeEvent";
73-
74-
55+
type layoutEvent =
56+
event({
57+
.
58+
"layout": {
59+
.
60+
"x": float,
61+
"y": float,
62+
"width": float,
63+
"height": float,
64+
},
65+
});
66+
7567
```

‎bs-react-native-next/src/apis/Event.re‎

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/*
2-
see https://github.com/facebook/react-native/blob/master/Libraries/Types/CoreEventTypes.js
3-
*/
1+
// see https://github.com/facebook/react-native/blob/master/Libraries/Types/CoreEventTypes.js
42

53
type event('a) = {. "nativeEvent": 'a};
64

@@ -47,21 +45,14 @@ type scrollEvent =
4745
"layoutMeasurement": dimensions,
4846
});
4947

50-
type t;
51-
52-
module NativeLayoutEvent = {
53-
type t;
54-
type layout = {
55-
x: float,
56-
y: float,
57-
width: float,
58-
height: float,
59-
};
60-
[@bs.get] external _layout: t => Js.t('a) = "nativeEvent";
61-
let layout = (t: t) => {
62-
let l = _layout(t)##layout;
63-
{x: l##x, y: l##y, width: l##width, height: l##height};
64-
};
65-
};
66-
67-
[@bs.get] external nativeLayoutEvent: t => NativeLayoutEvent.t = "nativeEvent";
48+
type layoutEvent =
49+
event({
50+
.
51+
"layout": {
52+
.
53+
"x": float,
54+
"y": float,
55+
"width": float,
56+
"height": float,
57+
},
58+
});

‎bs-react-native-next/src/components/ActivityIndicator.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ external make:
6262
~nativeID: string=?,
6363
~needsOffscreenAlphaCompositing: bool=?,
6464
~onAccessibilityTap: unit => unit=?,
65-
~onLayout: Event.NativeLayoutEvent.t => unit=?,
65+
~onLayout: Event.layoutEvent => unit=?,
6666
~onMagicTap: unit => unit=?,
6767
// Gesture Responder props
6868
~onMoveShouldSetResponder: Event.pressEvent => bool=?,

‎bs-react-native-next/src/components/ActivityIndicator.re‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ external make:
5555
~nativeID: string=?,
5656
~needsOffscreenAlphaCompositing: bool=?,
5757
~onAccessibilityTap: unit => unit=?,
58-
~onLayout: Event.NativeLayoutEvent.t => unit=?,
58+
~onLayout: Event.layoutEvent => unit=?,
5959
~onMagicTap: unit => unit=?,
6060
// Gesture Responder props
6161
~onMoveShouldSetResponder: Event.pressEvent => bool=?,

‎bs-react-native-next/src/components/FlatList.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ external make:
156156
~nativeID: string=?,
157157
~needsOffscreenAlphaCompositing: bool=?,
158158
~onAccessibilityTap: unit => unit=?,
159-
~onLayout: Event.NativeLayoutEvent.t => unit=?,
159+
~onLayout: Event.layoutEvent => unit=?,
160160
~onMagicTap: unit => unit=?,
161161
// Gesture Responder props
162162
~onMoveShouldSetResponder: Event.pressEvent => bool=?,

‎bs-react-native-next/src/components/FlatList.re‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ external make:
149149
~nativeID: string=?,
150150
~needsOffscreenAlphaCompositing: bool=?,
151151
~onAccessibilityTap: unit => unit=?,
152-
~onLayout: Event.NativeLayoutEvent.t => unit=?,
152+
~onLayout: Event.layoutEvent => unit=?,
153153
~onMagicTap: unit => unit=?,
154154
// Gesture Responder props
155155
~onMoveShouldSetResponder: Event.pressEvent => bool=?,

‎bs-react-native-next/src/components/Image.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type progress = {
5959
[@react.component] [@bs.module "react-native"]
6060
external make:
6161
(
62-
~onLayout: Event.NativeLayoutEvent.t => unit=?,
62+
~onLayout: Event.layoutEvent => unit=?,
6363
~onLoad: unit => unit=?,
6464
~onLoadEnd: unit => unit=?,
6565
~onLoadStart: unit => unit=?,

‎bs-react-native-next/src/components/Image.re‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type progress = {
5252
[@react.component] [@bs.module "react-native"]
5353
external make:
5454
(
55-
~onLayout: Event.NativeLayoutEvent.t => unit=?,
55+
~onLayout: Event.layoutEvent => unit=?,
5656
~onLoad: unit => unit=?,
5757
~onLoadEnd: unit => unit=?,
5858
~onLoadStart: unit => unit=?,

‎bs-react-native-next/src/components/ImageBackground.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ external imageStyle:
4343
external make:
4444
(
4545
~imageRef: ref=?,
46-
~onLayout: Event.NativeLayoutEvent.t => unit=?,
46+
~onLayout: Event.layoutEvent => unit=?,
4747
~onLoad: unit => unit=?,
4848
~onLoadEnd: unit => unit=?,
4949
~onLoadStart: unit => unit=?,

0 commit comments

Comments
 (0)