Skip to content

Commit

Permalink
add example linking config
Browse files Browse the repository at this point in the history
  • Loading branch information
Freddy03h committed Dec 12, 2024
1 parent 45faa70 commit b1a2ef5
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/Example.bs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var React = require("react");
var Js_dict = require("rescript/lib/js/js_dict.js");
var Caml_option = require("rescript/lib/js/caml_option.js");
var ReactNative = require("react-native");
var Stack$ReactNavigation = require("./Stack.bs.js");
Expand Down Expand Up @@ -71,8 +72,49 @@ var $$Navigator$1 = include$1.$$Navigator;

var $$Screen$1 = include$1.$$Screen;

var linking_prefixes = ["https://www.example.com"];

var linking_config = {
initialRouteName: "app",
screens: Js_dict.fromArray([[
"app",
{
screens: Js_dict.fromArray([
[
"tab1",
{
screens: Js_dict.fromArray([[
"home",
{
path: ""
}
]])
}
],
[
"tab2",
{
screens: Js_dict.fromArray([[
"config",
{
path: "/config"
}
]])
}
]
])
}
]])
};

var linking = {
prefixes: linking_prefixes,
config: linking_config
};

function Example$RootStackScreen(props) {
return React.createElement(Native.NavigationContainer, {
linking: linking,
children: React.createElement($$Navigator$1.make, {
screenOptions: (function (param) {
return {
Expand Down Expand Up @@ -101,6 +143,7 @@ var RootStackScreen = {
$$Navigator: $$Navigator$1,
$$Screen: $$Screen$1,
Group: RootStackScreen_Group,
linking: linking,
make: Example$RootStackScreen
};

Expand Down
33 changes: 32 additions & 1 deletion src/Example.res
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,40 @@ module MainStackScreen = {
module RootStackScreen = {
include Stack.Make()

let linking = {
open Native.Linking
{
prefixes: ["https://www.example.com"],
config: {
initialRouteName: "app",
screens: [
(
"app",
{
screens: [
(
"tab1",
{
screens: [("home", {path: ""})]->Js.Dict.fromArray,
},
),
(
"tab2",
{
screens: [("config", {path: "/config"})]->Js.Dict.fromArray,
},
),
]->Js.Dict.fromArray,
},
),
]->Js.Dict.fromArray,
},
}
}

@react.component
let make = () =>
<Native.NavigationContainer>
<Native.NavigationContainer linking>
<Navigator screenOptions={_ => {presentation: #modal}}>
<Screen name="Main" component=MainStackScreen.make />
<Screen name="MyModal">
Expand Down

0 comments on commit b1a2ef5

Please sign in to comment.