Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Linking#71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Freddy03h merged 2 commits intomainfromlinking
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletionssrc/Example.bs.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
'use strict';

varReact=require("react");
varJs_dict=require("rescript/lib/js/js_dict.js");
varCaml_option=require("rescript/lib/js/caml_option.js");
varReactNative=require("react-native");
varStack$ReactNavigation=require("./Stack.bs.js");
Expand DownExpand Up@@ -71,8 +72,49 @@ var $$Navigator$1 = include$1.$$Navigator;

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

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

varlinking_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"
}
]])
}
]
])
}
]])
};

varlinking={
prefixes:linking_prefixes,
config:linking_config
};

functionExample$RootStackScreen(props){
returnReact.createElement(Native.NavigationContainer,{
linking:linking,
children:React.createElement($$Navigator$1.make,{
screenOptions:(function(param){
return{
Expand DownExpand 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 deletionsrc/Example.res
View file
Open in desktop
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletionssrc/Native.bs.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
'use strict';


varLinking={};

varNavigationContainer={};

varServerContainer={};
Expand All@@ -9,6 +11,7 @@ var CommonActions = {};

varLink={};

exports.Linking=Linking;
exports.NavigationContainer=NavigationContainer;
exports.ServerContainer=ServerContainer;
exports.CommonActions=CommonActions;
Expand Down
17 changes: 17 additions & 0 deletionssrc/Native.res
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,22 @@ external darkTheme: theme = "DarkTheme"
@module("@react-navigation/native")
external useTheme: unit => theme = "useTheme"

module Linking = {
type rec config = {
path?: string,
exact?: bool,
initialRouteName?: string,
screens?: screens,
}
and screens = dict<config>

type t = {
enabled?: bool,
prefixes: array<string>,
config?: config,
}
}

module NavigationContainer = {
type state = Js.Json.t
type navigationState = state => unit
Expand All@@ -30,6 +46,7 @@ module NavigationContainer = {
~onStateChange: navigationState=?,
~onReady: unit => unit=?,
~theme: theme=?,
~linking: Linking.t=?,
~children: React.element,
~independent: bool=?,
) => React.element = "NavigationContainer"
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp