Skip to content

Commit 53dc7f9

Browse files
authored
reason-react-navigation: split WIP (#563)
* ReactNavigation WIP This is just a start that going to help us to see where we wanna go. (Just to let you know, I only used react-navigation once with js, and it was v1 - but I think it didn't changed that much from what I saw on docs) One question I have: how are we supposed to define screenProps per screen? I was using js+flow when using react-navigation 1 & here are things that I disliked - no way to validate that your are going to navigate to a screen that exist (string to navigate) - no way to know if the screenProps you are going to pass are valid Not sure how we can address that with reason-react-navigation as I only see on screenProps passed to main functor. Did I miss something? * reason-react-navigation: meta update * Delete yarn.lock * remove bs header
1 parent 5c3ab4b commit 53dc7f9

21 files changed

+281
-4827
lines changed
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
{
22
"name": "reason-react-navigation",
3-
"sources": [
4-
{
5-
"dir": "src",
6-
"subdirs": true
7-
}
8-
],
3+
"namespace": "react-navigation",
4+
"refmt": 3,
5+
"reason": {
6+
"react-jsx": 3
7+
},
98
"package-specs": {
109
"module": "commonjs",
1110
"in-source": true
1211
},
1312
"suffix": ".bs.js",
14-
"bs-dependencies": [
15-
"reason-react",
16-
"reason-react-native"
13+
"sources": [
14+
{
15+
"dir": "src",
16+
"subdirs": true
17+
}
1718
],
19+
"bsc-flags": ["-bs-no-version-header"],
1820
"warnings": {
1921
"number": "+102"
2022
},
21-
"reason": {
22-
"react-jsx": 3
23-
},
24-
"refmt": 3
25-
}
23+
"bs-dependencies": ["reason-react", "reason-react-native"]
24+
}

reason-react-navigation/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "reason-react-navigation",
3-
"version": "0.2.0",
3+
"namespace": "react-navigation",
4+
"version": "3.11.0",
45
"description": "Reason bindings for react-navigation",
56
"scripts": {
67
"re:clean": "bsb -clean-world",
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(S) {
5+
return /* module */[];
6+
}
7+
8+
exports.Make = Make;
9+
/* No side effect */
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
module Make = (S: {type screenProps;}) => {
2+
type screenProps = S.screenProps;
3+
4+
type contentComponentProps = {
5+
.
6+
"navigation": Navigation.t,
7+
"screenProps": screenProps,
8+
};
9+
10+
type contentComponent = React.component(contentComponentProps);
11+
12+
[@bs.module "react-navigation"]
13+
external drawerItems: contentComponent = "DrawerItems";
14+
15+
type contentOptions;
16+
17+
[@bs.obj]
18+
external contentOptions:
19+
(
20+
~activeTintColor: string=?,
21+
~activeBackgroundColor: string=?,
22+
~inactiveTintColor: string=?,
23+
~inactiveBackgroundColor: string=?,
24+
~itemsContainerStyle: ReactNative.Style.t=?,
25+
~itemStyle: ReactNative.Style.t=?,
26+
~labelStyle: ReactNative.Style.t=?,
27+
~activeLabelStyle: ReactNative.Style.t=?,
28+
~inactiveLabelStyle: ReactNative.Style.t=?,
29+
~iconContainerStyle: ReactNative.Style.t=?,
30+
// TODO: more props
31+
unit
32+
) =>
33+
contentOptions =
34+
"";
35+
36+
type config;
37+
38+
[@bs.obj]
39+
external config:
40+
(
41+
~mode: [@bs.string] [ | `card | `modal]=?,
42+
~drawerWidth: float=?,
43+
~drawerPosition: [@bs.string] [ | `left | `right]=?,
44+
~contentComponent: contentComponent=?,
45+
~contentOptions: contentOptions=?,
46+
~useNativeAnimations: bool=?,
47+
~drawerBackgroundColor: string=?,
48+
~initialRouteName: string=?,
49+
~backBehavior: [@bs.string] [ | `initialRoute | `none]=?,
50+
~hideStatusBar: bool=?,
51+
// TODO: more props
52+
unit
53+
) =>
54+
config =
55+
"";
56+
57+
[@bs.module "react-navigation"]
58+
external make: Js.t('a) => Types.navigator = "createDrawerNavigator";
59+
60+
[@bs.module "react-navigation"]
61+
external makeWithConfig: (Js.t('a), config) => Types.navigator =
62+
"createDrawerNavigator";
63+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
type t;
2+
3+
[@bs.get] external state: t => Types.navigationState = "";
4+
5+
[@bs.send] external navigate: (t, string) => unit = "";
6+
[@bs.send]
7+
external navigateWithParams: (t, string, Js.t({..})) => unit = "navigate";
8+
[@bs.send] external goBack: t => unit = "";
9+
[@bs.send] external goBackToRoute: (t, string) => unit = "";
10+
[@bs.send] external getParam: (t, string, 'a) => 'a = "";
11+
// TODO: addListener, setParams, ...
12+
// Stack Actions
13+
// TODO: push, replace, ...
14+
[@bs.send] external pop: t => unit = "";
15+
[@bs.send] external popN: (t, int) => unit = "";
16+
[@bs.send] external popToTop: t => unit = "";
17+
// Drawer navigator only
18+
[@bs.send] external openDrawer: t => unit = "";
19+
[@bs.send] external closeDrawer: t => unit = "";
20+
[@bs.send] external toggleDrawer: t => unit = "";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
type action;
2+
3+
type navigateParams;
4+
5+
[@bs.obj]
6+
external navigateParams:
7+
(~routeName: string, ~params: Js.t({..})=?, unit) => navigateParams =
8+
"";
9+
10+
type backParams;
11+
12+
[@bs.obj]
13+
external backParams:
14+
(~key: string=?, ~immediate: bool=?, unit) => navigateParams =
15+
"";
16+
17+
[@bs.module "react-navigation"] [@bs.scope "NavigationActions"]
18+
external navigate: navigateParams => action = "";
19+
20+
[@bs.module "react-navigation"] [@bs.scope "NavigationActions"]
21+
external back: backParams => action = "";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type t;
2+
[@bs.send] external dispatch: (t, NavigationActions.action) => unit = "";

0 commit comments

Comments
 (0)