@@ -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 ))=?,
0 commit comments