@@ -25,12 +25,13 @@ module Make = (M: {type params;}) => {
25
25
type animatedNode = ReactNative . Animated . Value . t ;
26
26
27
27
type scene = {
28
- .
29
- "index": int ,
30
- "focused": bool ,
31
- "tintColor": string ,
28
+ index: int ,
29
+ focused: bool ,
30
+ tintColor: string ,
32
31
};
33
32
33
+ type labelPositionArgs = {deviceOrientation: string };
34
+
34
35
class type virtual baseBottomTabBarOptions = {
35
36
pub keyboardHidesTabBar: option(bool);
36
37
pub activeBackgroundColor: option(string);
@@ -40,7 +41,7 @@ module Make = (M: {type params;}) => {
40
41
pub showIcon: option(bool);
41
42
pub labelStyle: option(ReactNative.Style.t);
42
43
pub tabStyle: option(ReactNative.Style.t);
43
- pub labelPosition: option({. "deviceOrientation": string} => string);
44
+ pub labelPosition: option(labelPositionArgs => string);
44
45
pub adaptive: option(bool);
45
46
pub style: option(ReactNative.Style.t);
46
47
};
@@ -54,32 +55,27 @@ module Make = (M: {type params;}) => {
54
55
55
56
type accessibilityRole = string ;
56
57
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
+ };
57
65
class type virtual bottomTabBarProps = {
58
66
as 'self;
59
67
constraint 'self = # baseBottomTabBarOptions;
60
68
pub state: navigationState(M . params);
61
69
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;
83
79
pub activeTintColor: string;
84
80
pub inactiveTintColor: string;
85
81
};
@@ -97,34 +93,30 @@ module Make = (M: {type params;}) => {
97
93
~showIcon : bool =?,
98
94
~labelStyle : ReactNative . Style . t =?,
99
95
~tabStyle : ReactNative . Style . t =?,
100
- ~labelPosition : {. "deviceOrientation" : string } => string =?,
96
+ ~labelPosition : labelPositionArgs => string =?,
101
97
~adaptive : bool =?,
102
98
~style : ReactNative . Style . t =?,
103
99
unit
104
100
) =>
105
101
bottomTabBarOptions =
106
102
"" ;
107
103
104
+ type tabBarLabelArgs = {
105
+ focused: bool ,
106
+ color: string ,
107
+ };
108
+ type tabBarIconArgs = {
109
+ focused: bool ,
110
+ color: string ,
111
+ size: float ,
112
+ };
108
113
[@ bs . obj ]
109
114
external options :
110
115
(
111
116
~title : string =?,
112
117
// 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 =?,
128
120
~tabBarAccessibilityLabel : string =?,
129
121
~tabBarTestID : string =?,
130
122
~tabBarVisible : bool =?,
@@ -134,13 +126,12 @@ module Make = (M: {type params;}) => {
134
126
options =
135
127
"" ;
136
128
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 ;
144
135
145
136
type navigatorProps ;
146
137
@@ -163,7 +154,7 @@ module Make = (M: {type params;}) => {
163
154
external makeProps :
164
155
(
165
156
~name : string ,
166
- ~options : optionsProps =?,
157
+ ~options : optionsCallback =?,
167
158
~initialParams : M . params =?,
168
159
~component : React . component ({. "navigation": navigation }),
169
160
unit
@@ -178,7 +169,7 @@ module Make = (M: {type params;}) => {
178
169
external makeProps :
179
170
(
180
171
~initialRouteName : string =?,
181
- ~screenOptions : optionsProps =?,
172
+ ~screenOptions : optionsCallback =?,
182
173
~children : React . element ,
183
174
~_lazy : bool =?,
184
175
~tabBarComponent : React . component (Js . t (bottomTabBarProps ))=?,
0 commit comments