Skip to content

Commit a653b7d

Browse files
authored
Merge pull request #2 from Naturalclar/feat/initial
Add view pager bindings
2 parents 3d47b83 + aee2f09 commit a653b7d

12 files changed

+181
-35
lines changed

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
**How to use this template**
22

3-
- Put your bindings in `src/ReactNativeSomething` & rename accordingly or use
3+
- Put your bindings in `src/ReactNativeViewPager` & rename accordingly or use
44
`bsconfig.json` `"namespace"` field (more on this below),
55
- Update all occurences of
66

7-
- `@reason-react-native/__template__`
8-
- `https://github.com/reason-react-native/__template__`
9-
- `__template__`
10-
- `@react-native-community/something`
11-
- `https://github.com/react-native-community/something`
12-
- `ReactNativeSomething`. If you have more than a file exposed, you should
7+
- `@reason-react-native/viewpager`
8+
- `https://github.com/reason-react-native/viewpager`
9+
- `viewpager`
10+
- `@react-native-community/viewpager`
11+
- `https://github.com/react-native-community/react-native-viewpager`
12+
- `ReactNativeViewPager`. If you have more than a file exposed, you should
1313
consider using BuckleScript custom namespace by adjusting `bsconfig.json`
1414
and adding a `"namespace": "react-native-something"` (note that it will be
15-
converted to `ReactNativeSomething`)
15+
converted to `ReactNativeViewPager`)
1616

17-
- Add your `@react-native-community/something` (adjusted) in `peerDependencies`
17+
- Add your `@react-native-community/viewpager` (adjusted) in `peerDependencies`
1818
& `devDependencies` section
1919
- Adjust the changelog (and/or clean it)
2020
- Remove this part ⬆ & keep everything below ⬇
2121

2222
---
2323

24-
# `@reason-react-native/__template__`
24+
# `@reason-react-native/viewpager`
2525

26-
[![Build Status](https://github.com/reason-react-native/__template__/workflows/Build/badge.svg)](https://github.com/reason-react-native/__template__/actions)
27-
[![Version](https://img.shields.io/npm/v/@reason-react-native/__template__.svg)](https://www.npmjs.com/@reason-react-native/__template__)
26+
[![Build Status](https://github.com/reason-react-native/viewpager/workflows/Build/badge.svg)](https://github.com/reason-react-native/viewpager/actions)
27+
[![Version](https://img.shields.io/npm/v/@reason-react-native/viewpager.svg)](https://www.npmjs.com/@reason-react-native/viewpager)
2828
[![Chat](https://img.shields.io/discord/235176658175262720.svg?logo=discord&colorb=blue)](https://reasonml-community.github.io/reason-react-native/discord/)
2929

3030
[ReasonML](https://reasonml.github.io) /
3131
[BuckleScript](https://bucklescript.github.io) bindings for
32-
[`@react-native-community/something`](https://github.com/react-native-community/something).
32+
[`@react-native-community/viewpager`](https://github.com/react-native-community/react-native-viewpager).
3333

34-
Exposed as `ReactNativeSomething` module.
34+
Exposed as `ReactNativeViewPager` module.
3535

36-
`@reason-react-native/__template__` X.y._ means it's compatible with
37-
`@react-native-community/something` X.y._
36+
`@reason-react-native/viewpager` X.y._ means it's compatible with
37+
`@react-native-community/viewpager` X.y._
3838

3939
## Installation
4040

4141
When
42-
[`@react-native-community/something`](https://github.com/react-native-community/something)
42+
[`@react-native-community/viewpager`](https://github.com/react-native-community/react-native-viewpager)
4343
is properly installed & configured by following their installation instructions,
4444
you can install the bindings:
4545

4646
```console
47-
npm install @reason-react-native/__template__
47+
npm install @reason-react-native/viewpager
4848
# or
49-
yarn add @reason-react-native/__template__
49+
yarn add @reason-react-native/viewpager
5050
```
5151

52-
`@reason-react-native/__template__` should be added to `bs-dependencies` in your
52+
`@reason-react-native/viewpager` should be added to `bs-dependencies` in your
5353
`bsconfig.json`. Something like
5454

5555
```diff
@@ -59,7 +59,7 @@ yarn add @reason-react-native/__template__
5959
"reason-react",
6060
"reason-react-native",
6161
// ...
62-
+ "@reason-react-native/__template__"
62+
+ "@reason-react-native/viewpager"
6363
],
6464
//...
6565
}
@@ -69,13 +69,13 @@ yarn add @reason-react-native/__template__
6969

7070
### Types
7171

72-
#### `ReactNativeSomething.t`
72+
#### `ReactNativeViewPager.t`
7373

7474
...
7575

7676
### Methods
7777

78-
#### `ReactNativeSomething.method`
78+
#### `ReactNativeViewPager.method`
7979

8080
...
8181

bsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@reason-react-native/__template__",
2+
"name": "@reason-react-native/viewpager",
33
"refmt": 3,
44
"reason": {
55
"react-jsx": 3
@@ -16,5 +16,5 @@
1616
}
1717
],
1818
"bsc-flags": ["-bs-no-version-header", "-warn-error @a"],
19-
"bs-dependencies": []
19+
"bs-dependencies": ["reason-react", "reason-react-native"]
2020
}

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"name": "@reason-react-native/__template__",
3-
"version": "0.0.0",
2+
"name": "@reason-react-native/viewpager",
3+
"version": "3.3.0",
44
"publishConfig": {
55
"access": "public"
66
},
77
"peerDependencies": {
8+
"react-native-linear-gradient": "~3.3.0"
89
},
9-
"repository": "https://github.com/reason-react-native/__template__.git",
10+
"repository": "https://github.com/reason-react-native/viewpager.git",
1011
"license": "MIT",
1112
"keywords": [
1213
"reason",
@@ -35,11 +36,14 @@
3536
"release": "npmpub"
3637
},
3738
"devDependencies": {
39+
"@react-native-community/viewpager":"~3.3.0",
3840
"bs-platform": "^5.2.0",
3941
"husky": "^1.3.0",
4042
"lint-staged": "^8.1.0",
4143
"npmpub": "^5.0.0",
42-
"prettier": "^1.18.0"
44+
"prettier": "^1.18.0",
45+
"reason-react": "0.7.0",
46+
"reason-react-native": "0.60.1"
4347
},
4448
"prettier": {
4549
"trailingComma": "all",

src/ReactNativeSomething.bs.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/ReactNativeSomething.re

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/ReactNativeViewPager.bs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
3+
var ViewPagerElement = require("./ViewPagerElement.bs.js");
4+
5+
6+
/* ViewPagerElement Not a pure module */

src/ReactNativeViewPager.re

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
include ViewPagerElement;
2+
3+
type scrollEvent;
4+
type selectedEvent;
5+
type scrollStateChangedEvent;
6+
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+
"";
17+
18+
[@bs.module "@react-native-community/viewpager"] [@react.component]
19+
external make:
20+
(
21+
~ref: ref=?,
22+
~initialPage: int=?,
23+
~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+
=?,
31+
~keyboardDismissMode: [@bs.string] [ | `none | [@bs.as "on-drag"] `onDrag]
32+
=?,
33+
~pageMargin: int=?,
34+
~onMoveShouldSetResponderCapture: ReactNative.Event.pressEvent => bool=?,
35+
~style: ReactNative.Style.t=?,
36+
~children: React.element=?,
37+
~orientation: [@bs.string] [ | `horizontal | `vertical]=?,
38+
~transitionStyle: [@bs.string] [ | `scroll | `curl]=?,
39+
~showPageIndicator: bool=?
40+
) =>
41+
React.element =
42+
"default";

src/ViewPagerElement.bs.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
var ViewPagerMethods = require("./ViewPagerMethods.bs.js");
4+
5+
ViewPagerMethods.Make({ });
6+
7+
/* Not a pure module */

src/ViewPagerElement.re

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type element;
2+
type ref = React.Ref.t(Js.nullable(element));
3+
4+
include ViewPagerMethods.Make({
5+
type t = element;
6+
});

src/ViewPagerMethods.bs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
4+
function Make(T) {
5+
return { };
6+
}
7+
8+
exports.Make = Make;
9+
/* No side effect */

0 commit comments

Comments
 (0)