@@ -16,6 +16,7 @@ module BottomTabNavigationProp = (M: {
|
16 | 16 | };
|
17 | 17 |
|
18 | 18 | module Make = (M: {type params;}) => {
|
| 19 | +type nonrec route = route(M.params); |
19 | 20 | module Navigation =
|
20 | 21 | BottomTabNavigationProp({
|
21 | 22 | include M;
|
@@ -55,9 +56,9 @@ module Make = (M: {type params;}) => {
|
55 | 56 |
|
56 | 57 | type accessibilityRole = string;
|
57 | 58 | type accessibilityStates = array(string);
|
58 |
| -type routeArgs = {route: route(M.params)}; |
| 59 | +type routeArgs = {route}; |
59 | 60 | type renderIconArgs = {
|
60 |
| -route: route(M.params), |
| 61 | +route, |
61 | 62 | focused: bool,
|
62 | 63 | tintColor: string,
|
63 | 64 | horizontal: bool,
|
@@ -98,8 +99,7 @@ module Make = (M: {type params;}) => {
|
98 | 99 | ~style: ReactNative.Style.t=?,
|
99 | 100 | unit
|
100 | 101 | ) =>
|
101 |
| -bottomTabBarOptions = |
102 |
| -""; |
| 102 | +bottomTabBarOptions; |
103 | 103 |
|
104 | 104 | type tabBarLabelArgs = {
|
105 | 105 | focused: bool,
|
@@ -123,27 +123,50 @@ module Make = (M: {type params;}) => {
|
123 | 123 | ~tabBarButtonComponent: React.element=?,
|
124 | 124 | unit
|
125 | 125 | ) =>
|
126 |
| -options = |
127 |
| -""; |
| 126 | +options; |
128 | 127 |
|
129 | 128 | type optionsProps = {
|
130 | 129 | navigation,
|
131 |
| -route: route(M.params), |
| 130 | +route, |
132 | 131 | };
|
133 | 132 |
|
134 | 133 | type optionsCallback = optionsProps => options;
|
135 | 134 |
|
136 |
| -type navigatorProps; |
| 135 | +type navigatorProps = { |
| 136 | +initialRouteName: option(string), |
| 137 | +screenOptions: option(optionsCallback), |
| 138 | +_lazy: option(bool), |
| 139 | +tabBar: option(React.component(Js.t(bottomTabBarProps))), |
| 140 | +tabBarOptions: option(bottomTabBarOptions), |
| 141 | +}; |
| 142 | + |
| 143 | +type renderCallbackProp = { |
| 144 | +navigation, |
| 145 | +route, |
| 146 | +}; |
137 | 147 |
|
138 |
| -type screenProps; |
| 148 | +type screenProps('params) = { |
| 149 | +name: string, |
| 150 | +options: option(optionsCallback), |
| 151 | +initialParams: option('params), |
| 152 | +component: |
| 153 | +option( |
| 154 | +React.component({ |
| 155 | +. |
| 156 | +"navigation": navigation, |
| 157 | +"route": route, |
| 158 | +}), |
| 159 | +), |
| 160 | +children: option(renderCallbackProp => React.element), |
| 161 | +}; |
139 | 162 |
|
140 | 163 | [@bs.module "@react-navigation/bottom-tabs"]
|
141 | 164 | external make:
|
142 | 165 | unit =>
|
143 | 166 | {
|
144 | 167 | .
|
145 | 168 | "Navigator": navigatorProps => React.element,
|
146 |
| -"Screen": screenProps => React.element, |
| 169 | +"Screen": screenProps(M.params) => React.element, |
147 | 170 | } =
|
148 | 171 | "createBottomTabNavigator";
|
149 | 172 |
|
@@ -159,12 +182,25 @@ module Make = (M: {type params;}) => {
|
159 | 182 | ~component: React.component({
|
160 | 183 | .
|
161 | 184 | "navigation": navigation,
|
162 |
| -"route": route(M.params), |
| 185 | +"route": route, |
163 | 186 | }),
|
164 | 187 | unit
|
165 | 188 | ) =>
|
166 |
| -screenProps = |
167 |
| -""; |
| 189 | +screenProps(M.params); |
| 190 | +let make = bottomTabs##"Screen"; |
| 191 | +}; |
| 192 | + |
| 193 | +module ScreenWithCallback = { |
| 194 | +[@bs.obj] |
| 195 | +external makeProps: |
| 196 | +( |
| 197 | +~name: string, |
| 198 | +~options: optionsCallback=?, |
| 199 | +~initialParams: M.params=?, |
| 200 | +~children: renderCallbackProp => React.element, |
| 201 | +unit |
| 202 | +) => |
| 203 | +screenProps(M.params); |
168 | 204 | let make = bottomTabs##"Screen";
|
169 | 205 | };
|
170 | 206 |
|
@@ -180,8 +216,7 @@ module Make = (M: {type params;}) => {
|
180 | 216 | ~tabBarOptions: bottomTabBarOptions=?,
|
181 | 217 | unit
|
182 | 218 | ) =>
|
183 |
| -navigatorProps = |
184 |
| -""; |
| 219 | +navigatorProps; |
185 | 220 |
|
186 | 221 | let make = bottomTabs##"Navigator";
|
187 | 222 | };
|
|
0 commit comments