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

upgrade to react-navigation 7 #72

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Freddy03h merged 13 commits into main from upgrade-to-react-navigation-7
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
7dfb18f
upgrade to react-navigation 7
Freddy03h Dec 26, 2024
1aa581d
fix : rescript.json instead of bsconfig.json for files release config
Freddy03h Dec 26, 2024
08799fa
preload
Freddy03h Dec 27, 2024
da948e0
layout navigator prop
Freddy03h Dec 27, 2024
70e87c3
new options for bottom tabs
Freddy03h Dec 27, 2024
fc0ac66
change headerTruncatedBackTitle to headerBackTruncatedTitle
Freddy03h Dec 30, 2024
33601ed
update Elements bindings
Freddy03h Jan 15, 2025
2b69eda
use header options on stack and native-stack
Freddy03h Jan 15, 2025
6278321
back to explicit option type instead of optionnal fields
Freddy03h Jan 15, 2025
4a07e1c
fix Element HeaderButton
Freddy03h Jan 18, 2025
f780064
update to rescript 11.1
Freddy03h Jan 18, 2025
923ff7f
deprecate WithParams functions
Freddy03h Jan 18, 2025
4d8df45
remove unnecessary trailing unit
Freddy03h Jan 18, 2025
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
2 changes: 1 addition & 1 deletion README.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ yarn add rescript-react-navigation
```

`rescript-react-navigation` should be added to `bs-dependencies` in your
`bsconfig.json`:
`rescript.json`:

```diff
{
Expand Down
7,726 changes: 2,768 additions & 4,958 deletions package-lock.json
View file Open in desktop

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions package.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"access": "public"
},
"peerDependencies": {
"@react-navigation/bottom-tabs": ">=6.1.0",
"@react-navigation/drawer": ">=6.1.0",
"@react-navigation/material-bottom-tabs": ">=6.1.0",
"@react-navigation/material-top-tabs": ">=6.1.0",
"@react-navigation/native": ">=6.1.0",
"@react-navigation/stack": ">=6.1.0",
"@rescript/react": ">=0.11.0",
"rescript-react-native": ">=0.71.0"
"@react-navigation/bottom-tabs": ">=7.0.0",
"@react-navigation/drawer": ">=7.0.0",
"@react-navigation/material-top-tabs": ">=7.0.0",
"@react-navigation/native": ">=7.0.0",
"@react-navigation/stack": ">=7.0.0",
"@rescript/react": ">=0.12.0",
"rescript-react-native": ">=0.73.1"
},
"overrides": {
"react": "^18.0.0"
},
"repository": "https://github.com/rescript-react-native/react-navigation.git",
"license": "MIT",
Expand All @@ -24,7 +26,7 @@
],
"files": [
"*.md",
"bsconfig.json",
"rescript.json",
"src/**/*.res",
"src/**/*.resi",
"src/**/*.js",
Expand All @@ -43,13 +45,13 @@
"release": "npmpub"
},
"devDependencies": {
"@rescript/react": "^0.11.0",
"@rescript/react": "^0.12.2",
"husky": "^4.0.0",
"lint-staged": "^10.0.0",
"npmpub": "^5.0.0",
"prettier": "^2.0.0",
"rescript": "^11.0.0",
"rescript-react-native": ">=0.71.1"
"rescript": "^11.1.0",
"rescript-react-native": "^0.73.1"
},
"prettier": {
"trailingComma": "all"
Expand Down
3 changes: 1 addition & 2 deletions bsconfig.json → rescript.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"name": "rescript-react-navigation",
"namespace": "react-navigation",
"jsx": {
"version": 4,
"mode": "classic"
"version": 4
},
"package-specs": {
"module": "commonjs",
Expand Down
25 changes: 19 additions & 6 deletions src/BottomTabs.res
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ open ReactNative

type tabBarLabelPosition = [#"below-icon" | #"beside-icon"]

type tabBarPosition = [#bottom | #top | #left | #right]

type tabBarVariant = [#uikit | #material]

type animation = [
| #fade
| #shift
| #none
]

type tabBarIconOptions = {
focused: bool,
color: string,
Expand All @@ -29,9 +39,8 @@ type rec options = {
tabBarBadge?: string,
tabBarBadgeStyle?: Style.t,
tabBarAccessibilityLabel?: string,
tabBarTestID?: string,
tabBarButtonTestID?: string,
tabBarButton?: unit => React.element, // TODO: props
tabBarColor?: Color.t,
tabBarActiveTintColor?: string,
tabBarInactiveTintColor?: string,
tabBarActiveBackgroundColor?: string,
Expand All @@ -40,11 +49,15 @@ type rec options = {
tabBarItemStyle?: Style.t,
tabBarStyle?: Style.t,
tabBarBackground?: unit => React.element,
tabBarPosition?: tabBarPosition,
tabBarVariant?: tabBarVariant,
sceneStyle?: Style.t,
\"lazy"?: bool,
unmountOnBlur?: bool,
popToTopOnBlur?: bool,
freezeOnBlur?: bool,
header?: headerParams => React.element,
headerShown?: bool,
animation?: animation,
// Header props from https://reactnavigation.org/docs/elements#header
headerTitle?: Header.headerTitle,
headerTitleAlign?: Header.headerTitleAlign,
Expand Down Expand Up @@ -82,8 +95,8 @@ module type NavigatorModule = {
~screenOptions: screenOptionsParams => options=?,
~backBehavior: backBehavior=?,
~detachInactiveScreens: bool=?,
~sceneContainerStyle: Style.t=?,
~tabBar: unit => React.element=?,
~layout: layoutNavigatorParams => React.element=?,
~children: React.element,
) => React.element
}
Expand Down Expand Up @@ -124,8 +137,8 @@ type navigatorModule
module Make = () => unpack(createBottomTabNavigator()->adaptNavigatorModule)

module Navigation = {
@send external jumpTo: (navigation, string) => unit = "jumpTo"
@send
@send external jumpTo: (navigation, string, ~params: 'params=?) => unit = "jumpTo"
@deprecated("Use `jumpTo` with `~params` instead") @send
external jumpToWithParams: (navigation, string, 'params) => unit = "jumpTo"

@send
Expand Down
21 changes: 16 additions & 5 deletions src/Core.res
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,35 @@ type stateEventData = {state: navigationState}

type action

type layoutNavigatorParams = {
state: navigationState,
navigation: navigation,
descriptors: descriptors,
children: React.element,
}

module Navigation = {
type t = navigation

@send external navigate: (t, string) => unit = "navigate"
@send
@send external navigate: (t, string, ~params: 'params=?) => unit = "navigate"
@deprecated("Use `navigate` with `~params` instead") @send
external navigateWithParams: (t, string, 'params) => unit = "navigate"

@send external goBack: (navigation, unit) => unit = "goBack"
@send external navigateDeprecated: (t, string, ~params: 'params=?) => unit = "navigateDeprecated"

@send external goBack: navigation => unit = "goBack"

@send
external reset: (navigation, navigationState) => unit = "reset"

@send external isFocused: (navigation, unit) => bool = "isFocused"
@send external preload: (t, string, ~params: 'params=?) => unit = "preload"

@send external isFocused: navigation => bool = "isFocused"

@send
external dispatch: (t, action) => unit = "dispatch"

@send external canGoBack: (navigation, unit) => bool = "canGoBack"
@send external canGoBack: navigation => bool = "canGoBack"

@send external setParams: (navigation, 'params) => unit = "setParams"

Expand Down
7 changes: 4 additions & 3 deletions src/Drawer.res
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ type rec options = {
drawerHideStatusBarOnOpen?: bool,
drawerStatusBarAnimation?: drawerStatusBarAnimation,
overlayColor?: Color.t,
sceneContainerStyle?: Style.t,
sceneStyle?: Style.t,
gestureEnabled?: bool,
gestureHandlerProps?: gestureHandlerProps,
swipeEnabled?: bool,
swipeEdgeWidth?: float,
swipeMinDistance?: float,
keyboardDismissMode?: keyboardDismissMode,
unmountOnBlur?: bool,
popToTopOnBlur?: bool,
freezeOnBlur?: bool,
headerShown?: bool,
header?: headerProps => React.element,
Expand Down Expand Up @@ -104,6 +104,7 @@ module type NavigatorModule = {
~detachInactiveScreens: bool=?,
~useLegacyImplementation: bool=?,
~drawerContent: React.component<contentComponentProps>=?,
~layout: layoutNavigatorParams => React.element=?,
~children: React.element=?,
) => React.element
}
Expand Down Expand Up @@ -147,7 +148,7 @@ module Navigation = {
@send
external setOptions: (navigation, options) => unit = "setOptions"

@send external jumpTo: (navigation, ~name: string, ~params: 'params=?, unit) => unit = "jumpTo"
@send external jumpTo: (navigation, ~name: string, ~params: 'params=?) => unit = "jumpTo"
@send external openDrawer: navigation => unit = "openDrawer"
@send external closeDrawer: navigation => unit = "closeDrawer"
@send external toggleDrawer: navigation => unit = "toggleDrawer"
Expand Down
6 changes: 6 additions & 0 deletions src/Elements.bs.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ var Header = {};

var HeaderBackground = {};

var HeaderTitle = {};

var HeaderButton = {};

var HeaderBackButton = {};

exports.Header = Header;
exports.HeaderBackground = HeaderBackground;
exports.HeaderTitle = HeaderTitle;
exports.HeaderButton = HeaderButton;
exports.HeaderBackButton = HeaderBackButton;
/* No side effect */
Loading
Loading

AltStyle によって変換されたページ (->オリジナル) /