-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathDrawer.res
More file actions
293 lines (255 loc) · 8.33 KB
/
Drawer.res
File metadata and controls
293 lines (255 loc) · 8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
open Core
type options
type layoutChangeEvent
module DrawerNavigationProp = (
M: {
type params
type options
},
) => {
include NavigationScreenProp(M)
type t = navigation
@send external openDrawer: t => unit = "openDrawer"
@send external closeDrawer: t => unit = "closeDrawer"
@send external toggleDrawer: t => unit = "toggleDrawer"
@send external jumpTo: (t, ~name: string, ~params: 'params=?, unit) => unit = "jumpTo"
}
module Make = (
M: {
type params
},
) => {
module Navigation = DrawerNavigationProp({
include M
type options = options
})
module HeaderTitle = {
type t
type headerTitleProps = {
children: option<string>,
allowFontScaling: option<bool>,
tintColor: option<ReactNative.Color.t>,
onLayout: layoutChangeEvent => unit,
style: option<ReactNative.Style.t>, //textStyle
}
@val @module("./Interop")
external t: @unwrap
[
| #String(string)
| #Render(headerTitleProps => React.element)
] => t = "identity"
let string = s => t(#String(s))
let render = x => t(#Render(x))
}
module DrawerLabel = {
type t
type drawerLabelProps = {
focused: bool,
color: string,
}
@val @module("./Interop")
external t: @unwrap
[
| #String(string)
| #Render(drawerLabelProps => React.element)
] => t = "identity"
let string = s => t(#String(s))
let render = x => t(#Render(x))
}
type animatedNode = ReactNative.Animated.Value.t
type scene = {
route: route<M.params>,
index: int,
focused: bool,
tintColor: option<ReactNative.Color.t>,
}
type drawerIconProps = {
focused: bool,
color: ReactNative.Color.t,
size: float,
}
type contentOptions = {
"items": array<route<M.params>>,
"activeItemKey": option<Js.nullable<string>>,
"activeTintColor": option<ReactNative.Color.t>,
"activeBackgroundColor": option<ReactNative.Color.t>,
"inactiveTintColor": option<ReactNative.Color.t>,
"inactiveBackgroundColor": option<ReactNative.Color.t>,
"itemsContainerStyle": option<ReactNative.Style.t>,
"itemStyle": option<ReactNative.Style.t>,
"labelStyle": option<ReactNative.Style.t>,
"activeLabelStyle": option<ReactNative.Style.t>,
"inactiveLabelStyle": option<ReactNative.Style.t>,
"iconContainerStyle": option<ReactNative.Style.t>,
}
type drawerNavigationItemsProps = {
...contentOptions,
"drawerPosition": string,
"getLabel": scene => React.element,
"renderIcon": scene => React.element,
"onItemPress": scene => unit,
}
type contentComponentProps = {
...drawerNavigationItemsProps,
"navigation": navigation,
"drawerOpenProgress": animatedNode,
}
type headerRightOptions = {
tintColor: option<ReactNative.Color.t>,
pressColor: option<ReactNative.Color.t>,
pressOpacity: option<float>,
}
type headerLeftOptions = {
tintColor: option<ReactNative.Color.t>,
pressColor: option<ReactNative.Color.t>,
pressOpacity: option<float>,
labelVisible: option<bool>,
}
type headerBackgroundOptions = {style: option<ReactNative.Style.t>}
@obj
external options: (
~title: string=?,
~_lazy: bool=?,
~drawerLabel: DrawerLabel.t=?,
~drawerIcon: drawerIconProps => React.element=?,
~drawerActiveTintColor: ReactNative.Color.t=?,
~drawerActiveBackgroundColor: ReactNative.Color.t=?,
~drawerInactiveTintColor: ReactNative.Color.t=?,
~drawerInactiveBackgroundColor: ReactNative.Color.t=?,
~drawerItemStyle: ReactNative.Style.t=?,
~drawerLabelStyle: ReactNative.Style.t=?,
~drawerContentContainerStyle: ReactNative.Style.t=?,
~drawerContentStyle: ReactNative.Style.t=?,
~drawerStyle: ReactNative.Style.t=?,
~drawerPosition: [#left | #right]=?,
~drawerType: [#front | #back | #slide | #permanent]=?,
~drawerHideStatusBarOnOpen: bool=?,
~drawerStatusBarAnimation: [#slide | #fade | #none]=?,
~overlayColor: ReactNative.Color.t=?,
~sceneContainerStyle: ReactNative.Style.t=?,
~gestureEnabled: bool=?,
~gestureHandlerProps: 'gestureHandlerProps=?,
~swipeEnabled: bool=?,
~swipeEdgeWidth: float=?,
~swipeMinDistance: float=?,
~keyboardDismissMode: @string
[
| @as("on-drag") #onDrag
| #none
]=?,
~unmountOnBlur: bool=?,
~headerShown: bool=?,
// ~header: Header.t=?,
~headerTitle: HeaderTitle.t=?,
~headerTitleAlign: [#left | #center]=?,
~headerTitleStyle: ReactNative.Style.t=?,
~headerTitleContainerStyle: ReactNative.Style.t=?,
~headerTitleAllowFontScaling: bool=?,
~headerLeft: headerLeftOptions => React.element=?,
~headerLeftLabelVisible: bool=?,
~headerLeftContainerStyle: ReactNative.Style.t=?,
~headerRight: headerRightOptions => React.element=?,
~headerRightContainerStyle: ReactNative.Style.t=?,
~headerPressColor: ReactNative.Color.t=?,
~headerPressOpacity: float=?,
~headerTintColor: ReactNative.Color.t=?,
~headerBackground: headerBackgroundOptions => React.element=?,
~headerBackgroundContainerStyle: ReactNative.Style.t=?,
~headerTransparent: bool=?,
~headerStyle: ReactNative.Style.t=?,
~headerShadowVisible: bool=?,
~headerStatusBarHeight: ReactNative.Style.size=?,
unit,
) => options = ""
// ~drawerLockMode: [@bs.string] [
// | `unlocked
// | [@bs.as "locked-closed"] `lockedClosed
// | [@bs.as "locked-open"] `lockedOpen
// ]
// =?,
type optionsProps = {
navigation: navigation,
route: route<M.params>,
}
type optionsCallback = optionsProps => options
type navigatorProps
type groupProps = {screenOptions: option<optionsCallback>}
type renderCallbackProp = {
navigation: navigation,
route: route<M.params>,
}
type screenProps<'params> = {
name: string,
options: option<optionsCallback>,
initialParams: option<'params>,
component: option<React.component<{"navigation": navigation, "route": route<M.params>}>>,
children: option<renderCallbackProp => React.element>,
}
@module("@react-navigation/drawer")
external make: unit => {
"Navigator": navigatorProps => React.element,
"Screen": screenProps<M.params> => React.element,
"Group": groupProps => React.element,
} = "createDrawerNavigator"
let stack = make()
module ScreenWithCallback = {
@obj
external makeProps: (
~name: string,
~options: optionsCallback=?,
~initialParams: M.params=?,
~children: renderCallbackProp => React.element,
~key: string=?,
unit,
) => screenProps<M.params> = ""
let make = stack["Screen"]
}
module Screen = {
@obj
external makeProps: (
~name: string,
~options: optionsCallback=?,
~initialParams: M.params=?,
~component: React.component<{"navigation": navigation, "route": route<M.params>}>,
~key: string=?,
unit,
) => screenProps<M.params> = ""
let make = stack["Screen"]
}
module Navigator = {
@obj
external makeProps: (
~initialRouteName: string=?,
~screenOptions: optionsCallback=?,
~children: React.element,
~backBehavior: [#firstRoute | #initialRoute | #order | #history | #none]=?,
~defaultStatus: @string [@as("open") #open_ | #closed]=?,
~detachInactiveScreens: bool=?,
~useLegacyImplementation: bool=?,
/*
The content component receives following props by default:
state - The navigation state of the navigator.
navigation - The navigation object for the navigator.
descriptors - An descriptor object containing options for the drawer screens. The options can be accessed at descriptors[route.key].options.
progress - Reanimated Node that represents the animated position of the drawer (0 is closed; 1 is open).
*/
~drawerContent: React.component<contentComponentProps>=?,
//TODO: ~gestureHandlerProps: React.ComponentProps<typeof PanGestureHandler>;
// ~unmountInactiveRoutes: bool=?,
// ~drawerContentOptions: Js.t<contentOptions>=?,
~key: string=?,
unit,
) => navigatorProps = ""
let make = stack["Navigator"]
}
module Group = {
@obj
external makeProps: (
~screenOptions: optionsCallback=?,
~children: React.element,
~key: string=?,
unit,
) => groupProps = ""
let make = stack["Group"]
}
}