Skip to content

Commit c3f176b

Browse files
authored
v5 WIP (#20)
* First run at v5 bindings * fix: add missing Interop.js * fix: add route to navigation component props * fix: add route type to functor
1 parent f147eb8 commit c3f176b

17 files changed

+1708
-0
lines changed

src/BottomTabs.bs.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
var Core$ReactNavigation = require("./Core.bs.js");
4+
var BottomTabs = require("@react-navigation/bottom-tabs");
5+
6+
function BottomTabNavigationProp(M) {
7+
var include = Core$ReactNavigation.NavigationScreenProp(M);
8+
return {
9+
navigateByKey: include.navigateByKey,
10+
navigateByName: include.navigateByName
11+
};
12+
}
13+
14+
function Make(M) {
15+
var M$1 = { };
16+
var include = Core$ReactNavigation.NavigationScreenProp(M$1);
17+
var Navigation_navigateByKey = include.navigateByKey;
18+
var Navigation_navigateByName = include.navigateByName;
19+
var Navigation = {
20+
navigateByKey: Navigation_navigateByKey,
21+
navigateByName: Navigation_navigateByName
22+
};
23+
var stack = BottomTabs.createBottomTabNavigator();
24+
var make = stack.Screen;
25+
var $$Screen = {
26+
make: make
27+
};
28+
var make$1 = stack.Navigator;
29+
var $$Navigator = {
30+
make: make$1
31+
};
32+
return {
33+
Navigation: Navigation,
34+
stack: stack,
35+
Screen: $$Screen,
36+
Navigator: $$Navigator
37+
};
38+
}
39+
40+
exports.BottomTabNavigationProp = BottomTabNavigationProp;
41+
exports.Make = Make;
42+
/* @react-navigation/bottom-tabs Not a pure module */

src/BottomTabs.re

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
open Core;
2+
3+
type options;
4+
5+
module BottomTabNavigationProp = (M: {
6+
type params;
7+
type options;
8+
}) => {
9+
include NavigationScreenProp(M);
10+
11+
type t = navigation;
12+
13+
[@bs.send] external jumpTo: (t, string) => unit = "jumpTo";
14+
[@bs.send]
15+
external jumpToWithParams: (t, string, M.params) => unit = "jumpTo";
16+
};
17+
18+
module Make = (M: {type params;}) => {
19+
module Navigation =
20+
BottomTabNavigationProp({
21+
include M;
22+
type nonrec options = options;
23+
});
24+
25+
type animatedNode = ReactNative.Animated.Value.t;
26+
27+
type scene = {
28+
.
29+
"index": int,
30+
"focused": bool,
31+
"tintColor": string,
32+
};
33+
34+
class type virtual baseBottomTabBarOptions = {
35+
pub keyboardHidesTabBar: option(bool);
36+
pub activeBackgroundColor: option(string);
37+
pub inactiveBackgroundColor: option(string);
38+
pub allowFontScaling: option(bool);
39+
pub showLabel: option(bool);
40+
pub showIcon: option(bool);
41+
pub labelStyle: option(ReactNative.Style.t);
42+
pub tabStyle: option(ReactNative.Style.t);
43+
pub labelPosition: option({. "deviceOrientation": string} => string);
44+
pub adaptive: option(bool);
45+
pub style: option(ReactNative.Style.t);
46+
};
47+
48+
class type virtual bottomTabBarOptions = {
49+
as 'self;
50+
constraint 'self = #baseBottomTabBarOptions;
51+
pub activeTintColor: option(string);
52+
pub inactiveTintColor: option(string);
53+
};
54+
55+
type accessibilityRole = string;
56+
type accessibilityStates = array(string);
57+
class type virtual bottomTabBarProps = {
58+
as 'self;
59+
constraint 'self = #baseBottomTabBarOptions;
60+
pub state: navigationState(M.params);
61+
pub navigation: navigation;
62+
pub onTabPress: {. "route": route(M.params)} => unit;
63+
pub onTabLongPress: {. "route": route(M.params)} => unit;
64+
pub getAccessibilityLabel:
65+
{. "route": route(M.params)} => Js.nullable(string);
66+
pub getAccessibilityRole:
67+
{. "route": route(M.params)} => Js.nullable(accessibilityRole);
68+
pub getAccessibilityStates:
69+
{. "route": route(M.params)} => Js.nullable(accessibilityStates);
70+
pub getButtonComponent:
71+
{. "route": route(M.params)} => Js.nullable(React.element);
72+
//pub getLabelText: {. "route": route(M.params)} => ...;
73+
pub getTestID: {. "route": route(M.params)} => Js.nullable(string);
74+
pub renderIcon:
75+
{
76+
.
77+
"route": route(M.params),
78+
"focused": bool,
79+
"tintColor": string,
80+
"horizontal": bool,
81+
} =>
82+
React.element;
83+
pub activeTintColor: string;
84+
pub inactiveTintColor: string;
85+
};
86+
87+
[@bs.obj]
88+
external bottomTabBarOptions:
89+
(
90+
~keyboardHidesTabBar: bool=?,
91+
~activeTintColor: string=?,
92+
~inactiveTintColor: string=?,
93+
~activeBackgroundColor: string=?,
94+
~inactiveBackgroundColor: string=?,
95+
~allowFontScaling: bool=?,
96+
~showLabel: bool=?,
97+
~showIcon: bool=?,
98+
~labelStyle: ReactNative.Style.t=?,
99+
~tabStyle: ReactNative.Style.t=?,
100+
~labelPosition: {. "deviceOrientation": string} => string=?,
101+
~adaptive: bool=?,
102+
~style: ReactNative.Style.t=?
103+
) =>
104+
bottomTabBarOptions =
105+
"";
106+
107+
[@bs.obj]
108+
external options:
109+
(
110+
~title: string=?,
111+
//TODO: dynamic, missing static option: React.ReactNode
112+
~tabBarLabel: scene => React.element=?,
113+
//TODO: dynamic, missing static option: React.ReactNode
114+
~tabBarIcon: scene => React.element=?,
115+
~tabBarAccessibilityLabel: string=?,
116+
~tabBarTestID: string=?,
117+
~tabBarVisible: bool=?,
118+
~tabBarButtonComponent: React.element=?,
119+
unit
120+
) =>
121+
options =
122+
"";
123+
124+
type optionsProps =
125+
{
126+
.
127+
"navigation": navigation,
128+
"route": route(M.params),
129+
} =>
130+
options;
131+
132+
type navigatorProps;
133+
134+
type screenProps;
135+
136+
[@bs.module "@react-navigation/bottom-tabs"]
137+
external make:
138+
unit =>
139+
{
140+
.
141+
"Navigator": navigatorProps => React.element,
142+
"Screen": screenProps => React.element,
143+
} =
144+
"createBottomTabNavigator";
145+
146+
let stack = make();
147+
148+
module Screen = {
149+
[@bs.obj]
150+
external makeProps:
151+
(
152+
~name: string,
153+
~options: optionsProps=?,
154+
~initialParams: M.params=?,
155+
~component: React.component({. "navigation": navigation}),
156+
unit
157+
) =>
158+
screenProps =
159+
"";
160+
let make = stack##"Screen";
161+
};
162+
163+
module Navigator = {
164+
[@bs.obj]
165+
external makeProps:
166+
(
167+
~initialRouteName: string=?,
168+
~screenOptions: optionsProps=?,
169+
~children: React.element,
170+
~_lazy: bool=?,
171+
~tabBarComponent: React.component(Js.t(bottomTabBarProps))=?,
172+
~tabBarOptions: bottomTabBarOptions=?,
173+
unit
174+
) =>
175+
navigatorProps =
176+
"";
177+
178+
let make = stack##"Navigator";
179+
};
180+
};

src/Core.bs.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
'use strict';
2+
3+
var Caml_option = require("bs-platform/lib/js/caml_option.js");
4+
5+
function NavigationHelpersCommon(M) {
6+
var navigateByKey = function (key, params, unit) {
7+
var tmp = {
8+
key: key
9+
};
10+
if (params !== undefined) {
11+
tmp.params = Caml_option.valFromOption(params);
12+
}
13+
tmp.navigate();
14+
return /* () */0;
15+
};
16+
var navigateByName = function (name, key, params, unit) {
17+
var tmp = {
18+
name: name
19+
};
20+
if (key !== undefined) {
21+
tmp.key = Caml_option.valFromOption(key);
22+
}
23+
if (params !== undefined) {
24+
tmp.params = Caml_option.valFromOption(params);
25+
}
26+
tmp.navigate();
27+
return /* () */0;
28+
};
29+
return {
30+
navigateByKey: navigateByKey,
31+
navigateByName: navigateByName
32+
};
33+
}
34+
35+
function EventConsumer(M) {
36+
return { };
37+
}
38+
39+
function NavigationScreenProp(M) {
40+
var navigateByKey = function (key, params, unit) {
41+
var tmp = {
42+
key: key
43+
};
44+
if (params !== undefined) {
45+
tmp.params = Caml_option.valFromOption(params);
46+
}
47+
tmp.navigate();
48+
return /* () */0;
49+
};
50+
var navigateByName = function (name, key, params, unit) {
51+
var tmp = {
52+
name: name
53+
};
54+
if (key !== undefined) {
55+
tmp.key = Caml_option.valFromOption(key);
56+
}
57+
if (params !== undefined) {
58+
tmp.params = Caml_option.valFromOption(params);
59+
}
60+
tmp.navigate();
61+
return /* () */0;
62+
};
63+
return {
64+
navigateByKey: navigateByKey,
65+
navigateByName: navigateByName
66+
};
67+
}
68+
69+
exports.NavigationHelpersCommon = NavigationHelpersCommon;
70+
exports.EventConsumer = EventConsumer;
71+
exports.NavigationScreenProp = NavigationScreenProp;
72+
/* No side effect */

0 commit comments

Comments
 (0)