@@ -2,6 +2,8 @@ open Core
2
2
3
3
type options
4
4
5
+ type layoutChangeEvent
6
+
5
7
module DrawerNavigationProp = (
6
8
M : {
7
9
type params
@@ -27,32 +29,69 @@ module Make = (
27
29
type options = options
28
30
})
29
31
32
+ module HeaderTitle = {
33
+ type t
34
+
35
+ type headerTitleProps = {
36
+ children : option <string >,
37
+ allowFontScaling : option <bool >,
38
+ tintColor : option <ReactNative .Color .t >,
39
+ onLayout : layoutChangeEvent => unit ,
40
+ style : option <ReactNative .Style .t >, //textStyle
41
+ }
42
+
43
+ @val @module ("./Interop" )
44
+ external t : @unwrap
45
+ [
46
+ | #String (string )
47
+ | #Render (headerTitleProps => React .element )
48
+ ] => t = "identity"
49
+
50
+ let string = s => t (#String (s ))
51
+ let render = x => t (#Render (x ))
52
+ }
53
+
54
+ module DrawerLabel = {
55
+ type t
56
+
57
+ type drawerLabelProps = {
58
+ focused : bool ,
59
+ color : string ,
60
+ }
61
+
62
+ @val @module ("./Interop" )
63
+ external t : @unwrap
64
+ [
65
+ | #String (string )
66
+ | #Render (drawerLabelProps => React .element )
67
+ ] => t = "identity"
68
+
69
+ let string = s => t (#String (s ))
70
+ let render = x => t (#Render (x ))
71
+ }
72
+
30
73
type animatedNode = ReactNative .Animated .Value .t
31
74
32
75
type scene = {
33
76
route : route <M .params >,
34
77
index : int ,
35
78
focused : bool ,
36
- tintColor : option <string >,
79
+ tintColor : option <ReactNative . Color . t >,
37
80
}
38
81
39
- type drawerLabelProps = {
40
- focused : bool ,
41
- color : string ,
42
- }
43
82
type drawerIconProps = {
44
83
focused : bool ,
45
- color : string ,
84
+ color : ReactNative . Color . t ,
46
85
size : float ,
47
86
}
48
87
49
88
type contentOptions = {
50
89
"items" : array <route <M .params >>,
51
90
"activeItemKey" : option <Js .nullable <string >>,
52
- "activeTintColor" : option <string >,
53
- "activeBackgroundColor" : option <string >,
54
- "inactiveTintColor" : option <string >,
55
- "inactiveBackgroundColor" : option <string >,
91
+ "activeTintColor" : option <ReactNative . Color . t >,
92
+ "activeBackgroundColor" : option <ReactNative . Color . t >,
93
+ "inactiveTintColor" : option <ReactNative . Color . t >,
94
+ "inactiveBackgroundColor" : option <ReactNative . Color . t >,
56
95
"itemsContainerStyle" : option <ReactNative .Style .t >,
57
96
"itemStyle" : option <ReactNative .Style .t >,
58
97
"labelStyle" : option <ReactNative .Style .t >,
@@ -75,16 +114,31 @@ module Make = (
75
114
"drawerOpenProgress" : animatedNode ,
76
115
}
77
116
117
+ type headerRightOptions = {
118
+ tintColor : option <ReactNative .Color .t >,
119
+ pressColor : option <ReactNative .Color .t >,
120
+ pressOpacity : option <float >,
121
+ }
122
+
123
+ type headerLeftOptions = {
124
+ tintColor : option <ReactNative .Color .t >,
125
+ pressColor : option <ReactNative .Color .t >,
126
+ pressOpacity : option <float >,
127
+ labelVisible : option <bool >,
128
+ }
129
+
130
+ type headerBackgroundOptions = {style : option <ReactNative .Style .t >}
131
+
78
132
@obj
79
133
external options : (
80
134
~title : string = ?,
81
135
~_lazy : bool = ?,
82
- ~drawerLabel : drawerLabelProps => React . element = ?,
136
+ ~drawerLabel : DrawerLabel . t = ?,
83
137
~drawerIcon : drawerIconProps => React .element = ?,
84
- ~drawerActiveTintColor : string = ?,
85
- ~drawerActiveBackgroundColor : string = ?,
86
- ~drawerInactiveTintColor : string = ?,
87
- ~drawerInactiveBackgroundColor : string = ?,
138
+ ~drawerActiveTintColor : ReactNative . Color . t = ?,
139
+ ~drawerActiveBackgroundColor : ReactNative . Color . t = ?,
140
+ ~drawerInactiveTintColor : ReactNative . Color . t = ?,
141
+ ~drawerInactiveBackgroundColor : ReactNative . Color . t = ?,
88
142
~drawerItemStyle : ReactNative .Style .t = ?,
89
143
~drawerLabelStyle : ReactNative .Style .t = ?,
90
144
~drawerContentContainerStyle : ReactNative .Style .t = ?,
@@ -94,7 +148,7 @@ module Make = (
94
148
~drawerType : [#front | #back | #slide | #permanent ]= ?,
95
149
~drawerHideStatusBarOnOpen : bool = ?,
96
150
~drawerStatusBarAnimation : [#slide | #fade | #none ]= ?,
97
- ~overlayColor : string = ?,
151
+ ~overlayColor : ReactNative . Color . t = ?,
98
152
~sceneContainerStyle : ReactNative .Style .t = ?,
99
153
~gestureEnabled : bool = ?,
100
154
~gestureHandlerProps : 'gestureHandlerProps = ?,
@@ -108,9 +162,28 @@ module Make = (
108
162
]= ?,
109
163
~unmountOnBlur : bool = ?,
110
164
~headerShown : bool = ?,
165
+ // ~header: Header.t=?,
166
+ ~headerTitle : HeaderTitle .t = ?,
167
+ ~headerTitleAlign : [#left | #center ]= ?,
168
+ ~headerTitleStyle : ReactNative .Style .t = ?,
169
+ ~headerTitleContainerStyle : ReactNative .Style .t = ?,
170
+ ~headerTitleAllowFontScaling : bool = ?,
171
+ ~headerLeft : headerLeftOptions => React .element = ?,
172
+ ~headerLeftLabelVisible : bool = ?,
173
+ ~headerLeftContainerStyle : ReactNative .Style .t = ?,
174
+ ~headerRight : headerRightOptions => React .element = ?,
175
+ ~headerRightContainerStyle : ReactNative .Style .t = ?,
176
+ ~headerPressColor : ReactNative .Color .t = ?,
177
+ ~headerPressOpacity : float = ?,
178
+ ~headerTintColor : ReactNative .Color .t = ?,
179
+ ~headerBackground : headerBackgroundOptions => React .element = ?,
180
+ ~headerBackgroundContainerStyle : ReactNative .Style .t = ?,
181
+ ~headerTransparent : bool = ?,
182
+ ~headerStyle : ReactNative .Style .t = ?,
183
+ ~headerShadowVisible : bool = ?,
184
+ ~headerStatusBarHeight : ReactNative .Style .size = ?,
111
185
unit ,
112
186
) => options = ""
113
- // TODO Header options: https://reactnavigation.org/docs/drawer-navigator/#header-related-options
114
187
// ~drawerLockMode: [@bs.string] [
115
188
// | `unlocked
116
189
// | [@bs.as "locked-closed"] `lockedClosed
@@ -127,19 +200,43 @@ module Make = (
127
200
128
201
type navigatorProps
129
202
130
- type screenProps
203
+ type groupProps = { screenOptions : option < optionsCallback >}
131
204
132
- type groupProps
205
+ type renderCallbackProp = {
206
+ navigation : navigation ,
207
+ route : route <M .params >,
208
+ }
209
+
210
+ type screenProps <'params > = {
211
+ name : string ,
212
+ options : option <optionsCallback >,
213
+ initialParams : option <'params >,
214
+ component : option <React .component <{"navigation" : navigation , "route" : route <M .params >}>>,
215
+ children : option <renderCallbackProp => React .element >,
216
+ }
133
217
134
218
@module ("@react-navigation/drawer" )
135
219
external make : unit => {
136
220
"Navigator" : navigatorProps => React .element ,
137
- "Screen" : screenProps => React .element ,
221
+ "Screen" : screenProps < M . params > => React .element ,
138
222
"Group" : groupProps => React .element ,
139
223
} = "createDrawerNavigator"
140
224
141
225
let stack = make ()
142
226
227
+ module ScreenWithCallback = {
228
+ @obj
229
+ external makeProps : (
230
+ ~name : string ,
231
+ ~options : optionsCallback = ?,
232
+ ~initialParams : M .params = ?,
233
+ ~children : renderCallbackProp => React .element ,
234
+ ~key : string = ?,
235
+ unit ,
236
+ ) => screenProps <M .params > = ""
237
+ let make = stack ["Screen" ]
238
+ }
239
+
143
240
module Screen = {
144
241
@obj
145
242
external makeProps : (
@@ -149,7 +246,7 @@ module Make = (
149
246
~component : React .component <{"navigation" : navigation , "route" : route <M .params >}>,
150
247
~key : string = ?,
151
248
unit ,
152
- ) => screenProps = ""
249
+ ) => screenProps < M . params > = ""
153
250
let make = stack ["Screen" ]
154
251
}
155
252
@@ -190,7 +287,7 @@ module Make = (
190
287
~children : React .element ,
191
288
~key : string = ?,
192
289
unit ,
193
- ) => screenProps = ""
290
+ ) => groupProps = ""
194
291
let make = stack ["Group" ]
195
292
}
196
293
}
0 commit comments