Skip to content

Commit 3b8c11b

Browse files
committed
bs-react-native-next: add apis BackHandler, Clipboard, Keyboard, Vibration
1 parent c4e791a commit 3b8c11b

10 files changed

Lines changed: 130 additions & 0 deletions

File tree

‎bs-react-native-next/src/BackHandler.bs.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[@bs.scope "BackHandler"] [@bs.module "react-native"]
2+
external exitApp: unit => unit = "";
3+
4+
[@bs.scope "BackHandler"] [@bs.module "react-native"]
5+
external addEventListener: (string, unit => bool) => EventSubscription.t = "";
6+
7+
[@bs.scope "BackHandler"] [@bs.module "react-native"]
8+
external removeEventListener: (string, unit => bool) => unit = "";

‎bs-react-native-next/src/Clipboard.bs.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[@bs.module "react-native"] [@bs.scope "Clipboard"]
2+
external getString: unit => Js.Promise.t(string) = "";
3+
4+
[@bs.module "react-native"] [@bs.scope "Clipboard"]
5+
external setString: string => unit = "";

‎bs-react-native-next/src/EventSubscription.bs.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type t;
2+
3+
[@bs.send] external remove: t => unit = "";

‎bs-react-native-next/src/Keyboard.bs.js‎

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
module Easing = {
2+
type t;
3+
4+
external fromString: string => t = "%identity";
5+
6+
let easeIn = "easeIn"->fromString;
7+
let easeInEaseOut = "easeInEaseOut"->fromString;
8+
let easeOut = "easeOut"->fromString;
9+
let linear = "linear"->fromString;
10+
let keyboard = "keyboard"->fromString;
11+
};
12+
13+
type screenRect = {
14+
.
15+
"screenX": float,
16+
"screenY": float,
17+
"width": float,
18+
"height": float,
19+
};
20+
21+
type keyboardEvent = {
22+
.
23+
"duration": float,
24+
"easing": Easing.t,
25+
"endCoordinates": screenRect,
26+
"startCoordinates": screenRect,
27+
"isEventFromThisApp": bool,
28+
};
29+
30+
type listener = keyboardEvent => unit;
31+
32+
[@bs.module "react-native"] [@bs.scope "Keyboard"]
33+
external addListener:
34+
(
35+
[@bs.string] [
36+
| `keyboardWillShow
37+
| `keyboardDidShow
38+
| `keyboardWillHide
39+
| `keyboardDidHide
40+
| `keyboardWillChangeFrame
41+
| `keyboardDidChangeFrame
42+
],
43+
listener
44+
) =>
45+
EventSubscription.t =
46+
"addListener";
47+
48+
[@bs.module "react-native"] [@bs.scope "Keyboard"]
49+
external removeAllListeners:
50+
(
51+
[@bs.string]
52+
[
53+
| `keyboardWillShow
54+
| `keyboardDidShow
55+
| `keyboardWillHide
56+
| `keyboardDidHide
57+
| `keyboardWillChangeFrame
58+
| `keyboardDidChangeFrame
59+
]
60+
) =>
61+
unit =
62+
"removeAllListeners";
63+
64+
[@bs.module "react-native"] [@bs.scope "Keyboard"]
65+
external removeListener:
66+
(
67+
[@bs.string] [
68+
| `keyboardWillShow
69+
| `keyboardDidShow
70+
| `keyboardWillHide
71+
| `keyboardDidHide
72+
| `keyboardWillChangeFrame
73+
| `keyboardDidChangeFrame
74+
],
75+
listener
76+
) =>
77+
unit =
78+
"removeListener";
79+
80+
[@bs.module "react-native"] [@bs.scope "Keyboard"]
81+
external dismiss: unit => unit = "";

‎bs-react-native-next/src/Vibration.bs.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[@bs.scope "Vibration"] [@bs.module "react-native"]
2+
external vibrateWithDuration: (int, ~repeat: bool=?, unit) => unit = "vibrate";
3+
4+
[@bs.scope "Vibration"] [@bs.module "react-native"]
5+
external vibrateWithPattern: (array(int), ~repeat: bool=?, unit) => unit =
6+
"vibrate";
7+
8+
[@bs.scope "Vibration"] [@bs.module "react-native"]
9+
external cancel: unit => unit = "";

0 commit comments

Comments
 (0)