Skip to content

Commit 203b7e4

Browse files
committed
Upgrade "bs-platform": "^7.0.0"
1 parent ae00fdb commit 203b7e4

19 files changed

+292
-458
lines changed

README.md

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ X.y._
1818
⚠️ Work in progress. These bindings are used successfully in several apps, but
1919
are not complete yet and still subject to change.
2020

21-
## Example
22-
23-
An example project is available at
24-
[`navigation-example`](https://github.com/reason-react-native/reason-react-navigation-example).
25-
2621
## Installation
2722

2823
When
@@ -54,81 +49,7 @@ yarn add reason-react-navigation
5449

5550
## Example
5651

57-
A screen component with dynamic navigation options (Screen1.re):
58-
59-
```reason
60-
open ReactNative;
61-
open ReactNavigation;
62-
63-
[@react.component]
64-
let make = (~navigation, ~screenProps) => {
65-
<Text> {React.string("Hello world!")} </Text>;
66-
};
67-
68-
make->NavigationOptions.setDynamicNavigationOptions(params => {
69-
let navigation = params##navigation;
70-
let navigationOptions = params##navigationOptions;
71-
let screenProps = params##screenProps;
72-
73-
/* More properties can be set dynamically based on navigation, navigationOptions or screenProps. */
74-
NavigationOptions.t(~title="Screen 1", ~headerTintColor="red", ());
75-
});
76-
```
77-
78-
A stack navigator containing this screen (MyStackNavigator.re):
79-
80-
```reason
81-
open ReactNavigation;
82-
83-
let routes = {
84-
"Screen1": Screen1.make,
85-
"Screen2": Screen2.make,
86-
"Screen3": Screen3.make,
87-
};
88-
89-
let navigator = StackNavigator.make(routes);
90-
91-
navigator->NavigationOptions.setNavigationOptions(
92-
NavigationOptions.t(~gesturesEnabled=false, ()),
93-
);
94-
```
95-
96-
The main React component of the app (App.re):
97-
98-
```reason
99-
open ReactNavigation;
100-
101-
module MyAppContainer =
102-
AppContainer.Make({
103-
type screenProps = {. "someProp": int};
104-
let navigator = MyStackNavigator.navigator;
105-
});
106-
107-
[@react.component]
108-
let make = () => {
109-
let screenProps = {"someProp": 42};
110-
111-
<MyAppContainer screenProps />;
112-
};
113-
```
114-
115-
Alternatively (without a functor, but using `React.createElement`):
116-
117-
```reason
118-
open ReactNavigation;
119-
120-
let appContainer = AppContainer.makeAppContainer(MyStackNavigator.navigator);
121-
122-
[@react.component]
123-
let make = () => {
124-
let screenProps = {"someProp": 42};
125-
126-
React.createElement(
127-
appContainer,
128-
AppContainer.makeProps(~screenProps, ()),
129-
);
130-
};
131-
```
52+
See <./src/Example.re>
13253

13354
---
13455

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reason-react-navigation",
3-
"version": "4.0.0-alpha.0",
3+
"version": "5.0.0-alpha.0",
44
"peerDependencies": {
55
"@react-navigation/core": "^5.0.0",
66
"reason-react": "^0.7.0",
@@ -37,7 +37,7 @@
3737
"test": "yarn re:clean-build"
3838
},
3939
"devDependencies": {
40-
"bs-platform": "^5.2.0",
40+
"bs-platform": "^7.0.0",
4141
"husky": "^1.3.0",
4242
"lint-staged": "^8.1.0",
4343
"prettier": "^1.18.0",

src/BottomTabs.bs.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,12 @@
33
var Core$ReactNavigation = require("./Core.bs.js");
44
var BottomTabs = require("@react-navigation/bottom-tabs");
55

6-
function BottomTabNavigationProp(M) {
7-
var include = Core$ReactNavigation.NavigationScreenProp(M);
8-
return {
9-
navigateByKey: include.navigateByKey,
10-
navigateByName: include.navigateByName
11-
};
12-
}
6+
var BottomTabNavigationProp = Core$ReactNavigation.NavigationScreenProp;
137

148
function Make(M) {
159
var M$1 = { };
1610
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-
};
11+
var Navigation = include;
2312
var bottomTabs = BottomTabs.createBottomTabNavigator();
2413
var make = bottomTabs.Screen;
2514
var $$Screen = {
@@ -32,8 +21,8 @@ function Make(M) {
3221
return {
3322
Navigation: Navigation,
3423
bottomTabs: bottomTabs,
35-
Screen: $$Screen,
36-
Navigator: $$Navigator
24+
$$Screen: $$Screen,
25+
$$Navigator: $$Navigator
3726
};
3827
}
3928

src/BottomTabs.re

Lines changed: 42 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ module Make = (M: {type params;}) => {
2525
type animatedNode = ReactNative.Animated.Value.t;
2626

2727
type scene = {
28-
.
29-
"index": int,
30-
"focused": bool,
31-
"tintColor": string,
28+
index: int,
29+
focused: bool,
30+
tintColor: string,
3231
};
3332

33+
type labelPositionArgs = {deviceOrientation: string};
34+
3435
class type virtual baseBottomTabBarOptions = {
3536
pub keyboardHidesTabBar: option(bool);
3637
pub activeBackgroundColor: option(string);
@@ -40,7 +41,7 @@ module Make = (M: {type params;}) => {
4041
pub showIcon: option(bool);
4142
pub labelStyle: option(ReactNative.Style.t);
4243
pub tabStyle: option(ReactNative.Style.t);
43-
pub labelPosition: option({. "deviceOrientation": string} => string);
44+
pub labelPosition: option(labelPositionArgs => string);
4445
pub adaptive: option(bool);
4546
pub style: option(ReactNative.Style.t);
4647
};
@@ -54,32 +55,27 @@ module Make = (M: {type params;}) => {
5455

5556
type accessibilityRole = string;
5657
type accessibilityStates = array(string);
58+
type routeArgs = {route: route(M.params)};
59+
type renderIconArgs = {
60+
route: route(M.params),
61+
focused: bool,
62+
tintColor: string,
63+
horizontal: bool,
64+
};
5765
class type virtual bottomTabBarProps = {
5866
as 'self;
5967
constraint 'self = #baseBottomTabBarOptions;
6068
pub state: navigationState(M.params);
6169
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;
70+
pub onTabPress: routeArgs => unit;
71+
pub onTabLongPress: routeArgs => unit;
72+
pub getAccessibilityLabel: routeArgs => Js.nullable(string);
73+
pub getAccessibilityRole: routeArgs => Js.nullable(accessibilityRole);
74+
pub getAccessibilityStates: routeArgs => Js.nullable(accessibilityStates);
75+
pub getButtonComponent: routeArgs => Js.nullable(React.element);
76+
//pub getLabelText: routeArgs => ...;
77+
pub getTestID: routeArgs => Js.nullable(string);
78+
pub renderIcon: renderIconArgs => React.element;
8379
pub activeTintColor: string;
8480
pub inactiveTintColor: string;
8581
};
@@ -97,34 +93,30 @@ module Make = (M: {type params;}) => {
9793
~showIcon: bool=?,
9894
~labelStyle: ReactNative.Style.t=?,
9995
~tabStyle: ReactNative.Style.t=?,
100-
~labelPosition: {. "deviceOrientation": string} => string=?,
96+
~labelPosition: labelPositionArgs => string=?,
10197
~adaptive: bool=?,
10298
~style: ReactNative.Style.t=?,
10399
unit
104100
) =>
105101
bottomTabBarOptions =
106102
"";
107103

104+
type tabBarLabelArgs = {
105+
focused: bool,
106+
color: string,
107+
};
108+
type tabBarIconArgs = {
109+
focused: bool,
110+
color: string,
111+
size: float,
112+
};
108113
[@bs.obj]
109114
external options:
110115
(
111116
~title: string=?,
112117
//TODO: dynamic, missing static option: React.ReactNode
113-
~tabBarLabel: {
114-
.
115-
"focused": bool,
116-
"color": string,
117-
} =>
118-
React.element
119-
=?,
120-
~tabBarIcon: {
121-
.
122-
"focused": bool,
123-
"color": string,
124-
"size": float,
125-
} =>
126-
React.element
127-
=?,
118+
~tabBarLabel: tabBarLabelArgs => React.element=?,
119+
~tabBarIcon: tabBarIconArgs => React.element=?,
128120
~tabBarAccessibilityLabel: string=?,
129121
~tabBarTestID: string=?,
130122
~tabBarVisible: bool=?,
@@ -134,13 +126,12 @@ module Make = (M: {type params;}) => {
134126
options =
135127
"";
136128

137-
type optionsProps =
138-
{
139-
.
140-
"navigation": navigation,
141-
"route": route(M.params),
142-
} =>
143-
options;
129+
type optionsProps = {
130+
navigation,
131+
route: route(M.params),
132+
};
133+
134+
type optionsCallback = optionsProps => options;
144135

145136
type navigatorProps;
146137

@@ -163,7 +154,7 @@ module Make = (M: {type params;}) => {
163154
external makeProps:
164155
(
165156
~name: string,
166-
~options: optionsProps=?,
157+
~options: optionsCallback=?,
167158
~initialParams: M.params=?,
168159
~component: React.component({. "navigation": navigation}),
169160
unit
@@ -178,7 +169,7 @@ module Make = (M: {type params;}) => {
178169
external makeProps:
179170
(
180171
~initialRouteName: string=?,
181-
~screenOptions: optionsProps=?,
172+
~screenOptions: optionsCallback=?,
182173
~children: React.element,
183174
~_lazy: bool=?,
184175
~tabBarComponent: React.component(Js.t(bottomTabBarProps))=?,

src/Core.bs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var Caml_option = require("bs-platform/lib/js/caml_option.js");
44

55
function NavigationHelpersCommon(M) {
6-
var navigateByKey = function (key, params, unit) {
6+
var navigateByKey = function (key, params, param) {
77
var tmp = {
88
key: key
99
};
@@ -13,7 +13,7 @@ function NavigationHelpersCommon(M) {
1313
tmp.navigate();
1414
return /* () */0;
1515
};
16-
var navigateByName = function (name, key, params, unit) {
16+
var navigateByName = function (name, key, params, param) {
1717
var tmp = {
1818
name: name
1919
};
@@ -37,7 +37,7 @@ function EventConsumer(M) {
3737
}
3838

3939
function NavigationScreenProp(M) {
40-
var navigateByKey = function (key, params, unit) {
40+
var navigateByKey = function (key, params, param) {
4141
var tmp = {
4242
key: key
4343
};
@@ -47,7 +47,7 @@ function NavigationScreenProp(M) {
4747
tmp.navigate();
4848
return /* () */0;
4949
};
50-
var navigateByName = function (name, key, params, unit) {
50+
var navigateByName = function (name, key, params, param) {
5151
var tmp = {
5252
name: name
5353
};

0 commit comments

Comments
 (0)