Skip to content

Commit

Permalink
Replace Style.pt with Style.dp (facebook#535)
Browse files Browse the repository at this point in the history
To avoid brutal breaking change, I used `[@deprecated]` for pt. We can remove it  a bit later, because we know some people rely on this bindings already :)

Closes facebook#530
  • Loading branch information
MoOx authored Jun 2, 2019
1 parent e866c02 commit 958cd4e
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 111 deletions.
12 changes: 6 additions & 6 deletions react-native-template-reason/src/App.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions react-native-template-reason/src/App.re
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ let styles =
(),
),
"welcome":
style(~fontSize=20., ~textAlign=`center, ~margin=pt(10.), ()),
style(~fontSize=20., ~textAlign=`center, ~margin=10.->dp, ()),
"instructions":
style(
~textAlign=`center,
~color="#333333",
~marginBottom=pt(5.),
(),
),
style(~textAlign=`center, ~color="#333333", ~marginBottom=5.->dp, ()),
})
);

Expand Down
24 changes: 12 additions & 12 deletions reason-react-native/src/apis/CameraRoll.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,28 +162,28 @@ let styles = Style.(
),
"getPhotosExample":
style(
~height=pt(0.25 *. windowHeight),
~height=(0.25 *. windowHeight)->dp,
~justifyContent=`spaceBetween,
(),
),
"saveToCameraRollExample":
style(
~width=pt(0.8 *. windowWidth),
~height=pt(0.6 *. windowHeight),
~margin=pt(0.1 *. windowWidth),
~width=(0.8 *. windowWidth)->dp,
~height=(0.6 *. windowHeight)->dp,
~margin=(0.1 *. windowWidth)->dp,
~justifyContent=`spaceAround,
(),
),
"image":
style(
~width=pt(0.8 *. windowWidth),
~height=pt(0.56 *. windowWidth),
~width=(0.8 *. windowWidth)->dp,
~height=(0.56 *. windowWidth)->dp,
(),
),
"imageContainer":
style(
~width=pt(0.8 *. windowWidth),
~height=pt(0.56 *. windowWidth),
~width=(0.8 *. windowWidth)->dp,
~height=(0.56 *. windowWidth)->dp,
~borderWidth=1.,
~justifyContent=`center,
(),
Expand All @@ -193,20 +193,20 @@ let styles = Style.(
style(
~textAlign=`center,
~borderRadius=8.,
~padding=pt(4.),
~padding=4.->dp,
~borderWidth=1.,
~backgroundColor=Color.linen,
(),
),
"thumbnail":
style(
~width=pt(0.21 *. windowHeight),
~height=pt(0.15 *. windowHeight),
~width=(0.21 *. windowHeight)->dp,
~height=(0.15 *. windowHeight)->dp,
(),
),
"thumbnails":
style(
~height=pt(0.15 *. windowHeight),
~height=(0.15 *. windowHeight)->dp,
(),
),
})
Expand Down
8 changes: 4 additions & 4 deletions reason-react-native/src/apis/ImageEditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ let styles =
StyleSheet.create({
"container":
style(
~width=windowWidth->pt,
~height=windowHeight->pt,
~width=windowWidth->dp,
~height=windowHeight->dp,
~flexDirection=`column,
~alignItems=`center,
~justifyContent=`center,
(),
),
"frame":
style(
~width=displayWidth->pt,
~height=displayHeight->pt,
~width=displayWidth->dp,
~height=displayHeight->dp,
~alignItems=`center,
~justifyContent=`center,
~borderWidth=StyleSheet.hairlineWidth,
Expand Down
13 changes: 3 additions & 10 deletions reason-react-native/src/apis/LayoutAnimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ let styles =
Style.(
StyleSheet.create({
"container": style(~flex=1., ~flexDirection=`column, ()),
"screen": style(~width=pt(windowWidth), ()),
"screen": style(~width=windowWidth->dp, ()),
})
);
Expand Down Expand Up @@ -164,15 +164,8 @@ let make = () => {
style=Style.(
{style(
~flex=1.,
~width=pt(2.0 *. windowWidth),
~left=
pt(
if (state.register) {
0.;
} else {
0. -. windowWidth;
},
),
~width=(2.0 *. windowWidth)->dp,
~left= (state.register ? 0. : 0. -. windowWidth)->dp,
~flexDirection=`row,
(),
)}
Expand Down
4 changes: 2 additions & 2 deletions reason-react-native/src/apis/Linking.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ let windowWidth = Dimensions.get(`window)##width;
let containerStyle =
Style.(
style(
~width=windowWidth->pt,
~height=windowHeight->pt,
~width=windowWidth->dp,
~height=windowHeight->dp,
~justifyContent=`center,
~alignItems=`center,
(),
Expand Down
52 changes: 36 additions & 16 deletions reason-react-native/src/apis/PanResponder.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ handlers are extended to also depend upon the `gestureState`.
## Types

### `Event.pressEvent`

see [`Event`](../Event/#pressevent)

### `gestureState`

`gestureState` contains additional information on the state of the \_Gesture
Responder System\_

Expand All @@ -37,12 +39,14 @@ type gestureState = {
```

### `t`
`t` is the abstract type for a `PanResponder`, which can be created by means
of the `create` method, given a `config` object

`t` is the abstract type for a `PanResponder`, which can be created by means of
the `create` method, given a `config` object

### `config`
`config` is the abstract type for a custom `PanResponder` configuration; it
can be created by means of the `config` constructor

`config` is the abstract type for a custom `PanResponder` configuration; it can
be created by means of the `config` constructor

```reason
config:
Expand Down Expand Up @@ -70,10 +74,12 @@ config:
```

### `panHandlers`
`panHandlers` is the abstract type for `panHandlers` of a `PanResponder`,
which can be accessed by means of the getter method `panHandlers`

`panHandlers` is the abstract type for `panHandlers` of a `PanResponder`, which
can be accessed by means of the getter method `panHandlers`

### `callback('a)`

`callback('a)` is the type of the usual callback function specified for each
_Gesture Responder System_ handler defined as

Expand All @@ -86,20 +92,23 @@ where `'a` is either `bool` or `unit`
## Methods

### `create`

`create` allows creation of a `PanResponder` given a `config`

```reason
create: config => t
```

### `panHandlers`

`panHandlers` is a getter method to access `panHandlers` within a `PanResponder`

```reason
panHandlers: t => panHandlers
```

### `onMoveShouldSetResponder`

`onMoveShouldSetResponder` is a getter method to access the
`onMoveShouldSetResponder` callback of a `panHandlers` object

Expand All @@ -108,6 +117,7 @@ onMoveShouldSetResponder: panHandlers => callback(bool)
```

### `onMoveShouldSetResponderCapture`

`onMoveShouldSetResponderCapture` is a getter method to access the
`onMoveShouldSetResponderCapture` callback of a `panHandlers` object

Expand All @@ -116,6 +126,7 @@ onMoveShouldSetResponderCapture: panHandlers => callback(bool)
```

### `onStartShouldSetResponder`

`onStartShouldSetResponder` is a getter method to access the
`onStartShouldSetResponder` callback of a `panHandlers` object

Expand All @@ -124,6 +135,7 @@ onStartShouldSetResponder: panHandlers => callback(bool)
```

### `onStartShouldSetResponderCapture`

`onStartShouldSetResponderCapture` is a getter method to access the
`onStartShouldSetResponderCapture` callback of a `panHandlers` object

Expand All @@ -132,6 +144,7 @@ onStartShouldSetResponderCapture: panHandlers => callback(bool)
```

### `onResponderReject`

`onResponderReject` is a getter method to access the `onResponderReject`
callback of a `panHandlers` object

Expand All @@ -140,14 +153,16 @@ onResponderReject: panHandlers => callback(unit)
```

### `onResponderGrant`
`onResponderGrant` is a getter method to access the `onResponderGrant`
callback of a `panHandlers` object

`onResponderGrant` is a getter method to access the `onResponderGrant` callback
of a `panHandlers` object

```reason
onResponderGrant: panHandlers => callback(unit)
```

### `onResponderRelease`

`onResponderRelease` is a getter method to access the `onResponderRelease`
callback of a `panHandlers` object

Expand All @@ -156,14 +171,16 @@ onResponderRelease: panHandlers => callback(unit)
```

### `onResponderMove`
`onResponderMove` is a getter method to access the `onResponderMove` callback
of a `panHandlers` object

`onResponderMove` is a getter method to access the `onResponderMove` callback of
a `panHandlers` object

```reason
onResponderMove: panHandlers => callback(unit)
```

### `onResponderTerminate`

`onResponderTerminate` is a getter method to access the `onResponderTerminate`
callback of a `panHandlers` object

Expand All @@ -172,14 +189,16 @@ onResponderTerminate: panHandlers => callback(unit)
```

### `onResponderStart`
`onResponderStart` is a getter method to access the `onResponderStart`
callback of a `panHandlers` object

`onResponderStart` is a getter method to access the `onResponderStart` callback
of a `panHandlers` object

```reason
onResponderStart: panHandlers => callback(unit)
```

### `onResponderTerminationRequest`

`onResponderTerminationRequest` is a getter method to access the
`onResponderTerminationRequest` callback of a `panHandlers` object

Expand All @@ -188,8 +207,9 @@ onResponderTerminationRequest: panHandlers => callback(bool)
```

### `onResponderEnd`
`onResponderEnd` is a getter method to access the `onResponderEnd` callback of
a `panHandlers` object

`onResponderEnd` is a getter method to access the `onResponderEnd` callback of a
`panHandlers` object

```reason
onResponderEnd: panHandlers => callback(unit)
Expand Down Expand Up @@ -240,8 +260,8 @@ let windowWidth = Dimensions.get(`window)##width;
let containerStyle =
Style.(
style(
~width=windowWidth->pt,
~height=windowHeight->pt,
~width=windowWidth->dp,
~height=windowHeight->dp,
~justifyContent=`center,
~alignItems=`center,
(),
Expand Down
Loading

0 comments on commit 958cd4e

Please sign in to comment.