-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathExample.res
More file actions
61 lines (58 loc) · 1.71 KB
/
Example.res
File metadata and controls
61 lines (58 loc) · 1.71 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
// Uncomment this to compile this example outside of this repo
// in this example it's not necessary (since we are running it in the module repo itself)
// open ReactNavigation;
module HomeScreen = {
open ReactNative
@react.component
let make = (~navigation as _, ~route as _) =>
<Text> {j`Hello Reasonable Person!`->React.string} </Text>
}
module ModalScreen = {
open ReactNative
@react.component
let make = (~navigation as _, ~route as _) => <Text> {j`Hello From Modal`->React.string} </Text>
}
module MainStackScreen = {
open ReactNative
module StakeParams = {
type params = {name: string}
}
include Stack.Make(StakeParams)
@react.component
let make = (~navigation as _, ~route as _) =>
<Navigator>
<Screen
name="Home"
component=HomeScreen.make
options={props =>
options(
~headerRight=_ =>
<Button
onPress={_ => props.navigation->Navigation.navigate("MyModal")}
title="Info"
color="#f00"
/>,
~title=switch props.route.params {
| Some(params) => params.name
| None => "Reason"
},
(),
)}
/>
</Navigator>
}
module RootStackScreen = {
include Stack.Make({
type params = unit
})
@react.component
let make = () =>
<Native.NavigationContainer>
<Navigator screenOptions={_optionsProps => options(~presentation=#modal, ())}>
<Screen name="Main" component=MainStackScreen.make />
<ScreenWithCallback name="MyModal">
{({navigation, route}) => <ModalScreen navigation route />}
</ScreenWithCallback>
</Navigator>
</Native.NavigationContainer>
}