Skip to content

Commit bf5a0e0

Browse files
committed
init commit
1 parent a05bd47 commit bf5a0e0

File tree

7 files changed

+155
-67
lines changed

7 files changed

+155
-67
lines changed

CHANGELOG.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1 @@
1-
# Changelog of `@reason-react-native/__template__`
2-
3-
## X.Y.Z - 20YY-MM-DD
4-
5-
Short & concise description
6-
7-
### 💥 Breaking changes
8-
9-
- Something, in [1234567](<link to commit on github>) by @<usename>
10-
11-
### 🐛 Fixes
12-
13-
- Something else, in [1234567](<link to commit on github>) by @<usename>
14-
15-
### Internal changes
16-
17-
(If worth mentioning)
1+
# Changelog of `@reason-react-native/inappbrowser`

README.md

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,29 @@
1-
## How to use this template
2-
3-
- ⚠️ **Don't fork this repository.** Use the "Use this template" green GitHub
4-
button.
5-
- Put your bindings in `src/ReactNativeXxxxxxxxxx` & rename accordingly or use
6-
`bsconfig.json` `"namespace"` field (more on this below),
7-
- Update all occurences of
8-
9-
- `@reason-react-native/__template__`
10-
- `https://github.com/reason-react-native/__template__`
11-
- `__template__`
12-
- `react-native-XXXXXXXXXX`
13-
- `https://github.com/OWNER/react-native-XXXXXXXXXX`
14-
- `ReactNativeXxxxxxxxxx`. If you have more than a file exposed, you should
15-
consider using ReScript custom namespace by adjusting `bsconfig.json`
16-
and adding a `"namespace": "react-native-something"` (note that it will be
17-
converted to `ReactNativeXxxxxxxxxx`)
18-
19-
- Add your `react-native-XXXXXXXXXX` (adjusted) in `peerDependencies`
20-
& `devDependencies` section
21-
- Adjust the changelog (and/or clean it)
22-
- Remove this part ⬆ & keep everything below ⬇
1+
# `@reason-react-native/inappbrowser`
232

24-
---
25-
26-
# `@reason-react-native/__template__`
27-
28-
[![Build Status](https://github.com/reason-react-native/__template__/workflows/Build/badge.svg)](https://github.com/reason-react-native/__template__/actions)
29-
[![Version](https://img.shields.io/npm/v/@reason-react-native/__template__.svg)](https://www.npmjs.com/@reason-react-native/__template__)
303
[![Chat](https://img.shields.io/discord/235176658175262720.svg?logo=discord&colorb=blue)](https://reason-react-native.github.io/discord/)
314

325
[ReScript](https://rescript-lang.org) / [Reason](https://reasonml.github.io) bindings for
33-
[`react-native-XXXXXXXXXX`](https://github.com/OWNER/react-native-XXXXXXXXXX).
6+
[`react-native-inappbrowser-reborn`](https://github.com/proyecto26/react-native-inappbrowser).
347

35-
Exposed as `ReactNativeXxxxxxxxxx` module.
8+
Exposed as `ReactNativeInAppBrowser` module.
369

37-
`@reason-react-native/__template__` X.y.\* means it's compatible with
38-
`react-native-XXXXXXXXXX` X.y.\*
10+
`@reason-react-native/inappbrowser` X.y.\* means it's compatible with
11+
`react-native-inappbrowser-reborn` X.y.\*
3912

4013
## Installation
4114

4215
When
43-
[`react-native-XXXXXXXXXX`](https://github.com/OWNER/react-native-XXXXXXXXXX)
16+
[`react-native-inappbrowser-reborn`](https://github.com/proyecto26/react-native-inappbrowser)
4417
is properly installed & configured by following their installation instructions,
4518
you can install the bindings:
4619

4720
```console
48-
npm install @reason-react-native/__template__
21+
npm install @reason-react-native/inappbrowser
4922
# or
50-
yarn add @reason-react-native/__template__
23+
yarn add @reason-react-native/inappbrowser
5124
```
5225

53-
`@reason-react-native/__template__` should be added to `bs-dependencies` in your
26+
`@reason-react-native/inappbrowser` should be added to `bs-dependencies` in your
5427
`bsconfig.json`:
5528

5629
```diff
@@ -60,23 +33,51 @@ yarn add @reason-react-native/__template__
6033
"reason-react",
6134
"reason-react-native",
6235
// ...
63-
+ "@reason-react-native/__template__"
36+
+ "@reason-react-native/inappbrowser"
6437
],
6538
//...
6639
}
6740
```
6841

6942
## Usage
7043

44+
### Examples
45+
46+
```reason
47+
open Js.Promise;
48+
49+
let opts = iosOptions(~preferredBarTintColor="#ff0000", ());
50+
openBrowserIos("https://rescript-lang.org", opts)
51+
|> Js.Promise.then_((result: browserResult) => {
52+
Js.log(result.resultType);
53+
resolve();
54+
})
55+
|> ignore;
56+
```
57+
58+
```reason
59+
open Js.Promise;
60+
61+
openAuthIos("https://example.com/auth", "myschema://auth", iosOptions())
62+
|> Js.Promise.then_((result: authResult) => {
63+
switch (result.url) {
64+
| Some(url) => Js.log(url)
65+
| None => Js.log("Something went wrong")
66+
};
67+
resolve();
68+
})
69+
|> ignore;
70+
```
71+
7172
### Types
7273

73-
#### `ReactNativeXxxxxxxxxx.t`
74+
#### `ReactNativeInAppBrowser.t`
7475

7576
...
7677

7778
### Methods
7879

79-
#### `ReactNativeXxxxxxxxxx.method`
80+
#### `ReactNativeInAppBrowser.method`
8081

8182
...
8283

bsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@reason-react-native/__template__",
2+
"name": "@reason-react-native/inappbrowser",
33
"refmt": 3,
44
"reason": {
55
"react-jsx": 3

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
2-
"name": "@reason-react-native/__template__",
3-
"description": "ReScript bindings for react-native-XXXXXXXXXX",
4-
"version": "0.0.0",
2+
"name": "@reason-react-native/inappbrowser",
3+
"description": "ReScript bindings for react-native-inappbrowser",
4+
"version": "3.5.0",
55
"publishConfig": {
66
"access": "public"
77
},
8-
"peerDependencies": {},
9-
"repository": "https://github.com/reason-react-native/__template__.git",
8+
"peerDependencies": {
9+
"react-native-inappbrowser-reborn": "^3.5.1"
10+
},
11+
"repository": "https://github.com/reason-react-native/react-native-inappbrowser.git",
1012
"license": "MIT",
1113
"keywords": [
1214
"rescript",
@@ -56,5 +58,6 @@
5658
"hooks": {
5759
"pre-commit": "lint-staged"
5860
}
59-
}
61+
},
62+
"dependencies": {}
6063
}

src/ReactNativeInAppBrowser.re

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
type authResult = {
2+
[@bs.as "type"]
3+
resultType: [ | `cancel | `dismiss | `success],
4+
url: option(string),
5+
};
6+
7+
type browserResult = {
8+
[@bs.as "type"]
9+
resultType: [ | `cancel | `dismiss],
10+
};
11+
12+
type iosOptions;
13+
[@bs.obj]
14+
external iosOptions:
15+
(
16+
~dismissButtonStyle: [@bs.string] [
17+
| [@bs.as "done"] `doneButton
18+
| [@bs.as "close"] `closeButton
19+
| [@bs.as "cancel"] `cancelButton
20+
]
21+
=?,
22+
~preferredBarTintColor: string=?,
23+
~preferredControlTintColor: string=?,
24+
~readerMode: bool=?,
25+
~animated: bool=?,
26+
~modalPresentationStyle: [
27+
| `automatic
28+
| `fullScreen
29+
| `pageSheet
30+
| `formSheet
31+
| `currentContext
32+
| `ustom
33+
| `overFullScreen
34+
| `overCurrentContext
35+
| `popover
36+
| `none
37+
]
38+
=?,
39+
~modalTransitionStyle: [
40+
| `coverVertical
41+
| `flipHorizontal
42+
| `crossDissolve
43+
| `partialCurl
44+
]
45+
=?,
46+
~modalEnabled: bool=?,
47+
~enableBarCollapsing: bool=?,
48+
~ephemeralWebSession: bool=?,
49+
unit
50+
) =>
51+
iosOptions;
52+
53+
type androidAnimationOptions = {
54+
startEnter: string,
55+
startExit: string,
56+
endEnter: string,
57+
endExit: string,
58+
};
59+
60+
type androidOptions;
61+
[@bs.obj]
62+
external androidOptions:
63+
(
64+
~showTitle: bool=?,
65+
~toolbarColor: string=?,
66+
~secondaryToolbarColor: string=?,
67+
~enableUrlBarHiding: bool=?,
68+
~enableDefaultShare: bool=?,
69+
~forceCloseOnRedirection: bool=?,
70+
~animations: androidAnimationOptions=?,
71+
~headers: Js.t('a)=?,
72+
~hasBackButton: bool=?,
73+
~browserPackage: string=?,
74+
~showInRecents: bool=?,
75+
unit
76+
) =>
77+
androidOptions;
78+
79+
[@bs.module "react-native-inappbrowser-reborn"] [@bs.scope "InAppBrowser"]
80+
external isAvailable: unit => Js.Promise.t(bool) = "isAvailable";
81+
82+
[@bs.module "react-native-inappbrowser-reborn"] [@bs.scope "InAppBrowser"]
83+
external openBrowserIos: (string, iosOptions) => Js.Promise.t(browserResult) =
84+
"open";
85+
86+
[@bs.module "react-native-inappbrowser-reborn"] [@bs.scope "InAppBrowser"]
87+
external openBrowserAndroid:
88+
(string, androidOptions) => Js.Promise.t(browserResult) =
89+
"open";
90+
91+
[@bs.module "react-native-inappbrowser-reborn"] [@bs.scope "InAppBrowser"]
92+
external close: unit => unit = "close";
93+
94+
[@bs.module "react-native-inappbrowser-reborn"] [@bs.scope "InAppBrowser"]
95+
external openAuthIos: (string, string, iosOptions) => Js.Promise.t(authResult) =
96+
"openAuth";
97+
98+
[@bs.module "react-native-inappbrowser-reborn"] [@bs.scope "InAppBrowser"]
99+
external openAuthAndroid:
100+
(string, string, androidOptions) => Js.Promise.t(authResult) =
101+
"openAuth";
102+
103+
[@bs.module "react-native-inappbrowser-reborn"] [@bs.scope "InAppBrowser"]
104+
external closeAuth: unit => unit = "closeAuth";

src/ReactNativeXxxxxxxxxx.re

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

0 commit comments

Comments
 (0)