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

Commit 816a664

Browse files
Freddy03hcknitt
andauthored
upgrade to react-navigation 7 (#72)
* upgrade to react-navigation 7 * fix : rescript.json instead of bsconfig.json for files release config * preload * layout navigator prop * new options for bottom tabs * change headerTruncatedBackTitle to headerBackTruncatedTitle * update Elements bindings * use header options on stack and native-stack * back to explicit option type instead of optionnal fields * fix Element HeaderButton Co-authored-by: Christoph Knittel <ck@cca.io> * update to rescript 11.1 * deprecate WithParams functions * remove unnecessary trailing unit --------- Co-authored-by: Christoph Knittel <ck@cca.io>
1 parent fd1d0e7 commit 816a664

18 files changed

+3058
-5119
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ yarn add rescript-react-navigation
3131
```
3232

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

3636
```diff
3737
{

‎package-lock.json‎

Lines changed: 2768 additions & 4958 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
"access": "public"
77
},
88
"peerDependencies": {
9-
"@react-navigation/bottom-tabs": ">=6.1.0",
10-
"@react-navigation/drawer": ">=6.1.0",
11-
"@react-navigation/material-bottom-tabs": ">=6.1.0",
12-
"@react-navigation/material-top-tabs": ">=6.1.0",
13-
"@react-navigation/native": ">=6.1.0",
14-
"@react-navigation/stack": ">=6.1.0",
15-
"@rescript/react": ">=0.11.0",
16-
"rescript-react-native": ">=0.71.0"
9+
"@react-navigation/bottom-tabs": ">=7.0.0",
10+
"@react-navigation/drawer": ">=7.0.0",
11+
"@react-navigation/material-top-tabs": ">=7.0.0",
12+
"@react-navigation/native": ">=7.0.0",
13+
"@react-navigation/stack": ">=7.0.0",
14+
"@rescript/react": ">=0.12.0",
15+
"rescript-react-native": ">=0.73.1"
16+
},
17+
"overrides": {
18+
"react": "^18.0.0"
1719
},
1820
"repository": "https://github.com/rescript-react-native/react-navigation.git",
1921
"license": "MIT",
@@ -24,7 +26,7 @@
2426
],
2527
"files": [
2628
"*.md",
27-
"bsconfig.json",
29+
"rescript.json",
2830
"src/**/*.res",
2931
"src/**/*.resi",
3032
"src/**/*.js",
@@ -43,13 +45,13 @@
4345
"release": "npmpub"
4446
},
4547
"devDependencies": {
46-
"@rescript/react": "^0.11.0",
48+
"@rescript/react": "^0.12.2",
4749
"husky": "^4.0.0",
4850
"lint-staged": "^10.0.0",
4951
"npmpub": "^5.0.0",
5052
"prettier": "^2.0.0",
51-
"rescript": "^11.0.0",
52-
"rescript-react-native": ">=0.71.1"
53+
"rescript": "^11.1.0",
54+
"rescript-react-native": "^0.73.1"
5355
},
5456
"prettier": {
5557
"trailingComma": "all"

‎bsconfig.json‎ renamed to ‎rescript.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"name": "rescript-react-navigation",
33
"namespace": "react-navigation",
44
"jsx": {
5-
"version": 4,
6-
"mode": "classic"
5+
"version": 4
76
},
87
"package-specs": {
98
"module": "commonjs",

‎src/BottomTabs.res‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ open ReactNative
66

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

9+
type tabBarPosition = [#bottom | #top | #left | #right]
10+
11+
type tabBarVariant = [#uikit | #material]
12+
13+
type animation = [
14+
| #fade
15+
| #shift
16+
| #none
17+
]
18+
919
type tabBarIconOptions = {
1020
focused: bool,
1121
color: string,
@@ -29,9 +39,8 @@ type rec options = {
2939
tabBarBadge?: string,
3040
tabBarBadgeStyle?: Style.t,
3141
tabBarAccessibilityLabel?: string,
32-
tabBarTestID?: string,
42+
tabBarButtonTestID?: string,
3343
tabBarButton?: unit => React.element, // TODO: props
34-
tabBarColor?: Color.t,
3544
tabBarActiveTintColor?: string,
3645
tabBarInactiveTintColor?: string,
3746
tabBarActiveBackgroundColor?: string,
@@ -40,11 +49,15 @@ type rec options = {
4049
tabBarItemStyle?: Style.t,
4150
tabBarStyle?: Style.t,
4251
tabBarBackground?: unit => React.element,
52+
tabBarPosition?: tabBarPosition,
53+
tabBarVariant?: tabBarVariant,
54+
sceneStyle?: Style.t,
4355
\"lazy"?: bool,
44-
unmountOnBlur?: bool,
56+
popToTopOnBlur?: bool,
4557
freezeOnBlur?: bool,
4658
header?: headerParams => React.element,
4759
headerShown?: bool,
60+
animation?: animation,
4861
// Header props from https://reactnavigation.org/docs/elements#header
4962
headerTitle?: Header.headerTitle,
5063
headerTitleAlign?: Header.headerTitleAlign,
@@ -82,8 +95,8 @@ module type NavigatorModule = {
8295
~screenOptions: screenOptionsParams => options=?,
8396
~backBehavior: backBehavior=?,
8497
~detachInactiveScreens: bool=?,
85-
~sceneContainerStyle: Style.t=?,
8698
~tabBar: unit => React.element=?,
99+
~layout: layoutNavigatorParams => React.element=?,
87100
~children: React.element,
88101
) => React.element
89102
}
@@ -124,8 +137,8 @@ type navigatorModule
124137
module Make = () => unpack(createBottomTabNavigator()->adaptNavigatorModule)
125138

126139
module Navigation = {
127-
@send external jumpTo: (navigation, string) => unit = "jumpTo"
128-
@send
140+
@send external jumpTo: (navigation, string, ~params: 'params=?) => unit = "jumpTo"
141+
@deprecated("Use `jumpTo` with `~params` instead") @send
129142
external jumpToWithParams: (navigation, string, 'params) => unit = "jumpTo"
130143

131144
@send

‎src/Core.res‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,35 @@ type stateEventData = {state: navigationState}
5454

5555
type action
5656

57+
type layoutNavigatorParams = {
58+
state: navigationState,
59+
navigation: navigation,
60+
descriptors: descriptors,
61+
children: React.element,
62+
}
63+
5764
module Navigation = {
5865
type t = navigation
5966

60-
@send external navigate: (t, string) => unit = "navigate"
61-
@send
67+
@send external navigate: (t, string, ~params: 'params=?) => unit = "navigate"
68+
@deprecated("Use `navigate` with `~params` instead") @send
6269
external navigateWithParams: (t, string, 'params) => unit = "navigate"
6370

64-
@send external goBack: (navigation, unit) => unit = "goBack"
71+
@send external navigateDeprecated: (t, string, ~params: 'params=?) => unit = "navigateDeprecated"
72+
73+
@send external goBack: navigation => unit = "goBack"
6574

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

69-
@send external isFocused: (navigation, unit) => bool = "isFocused"
78+
@send external preload: (t, string, ~params: 'params=?) => unit = "preload"
79+
80+
@send external isFocused: navigation => bool = "isFocused"
7081

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

74-
@send external canGoBack: (navigation, unit) => bool = "canGoBack"
85+
@send external canGoBack: navigation => bool = "canGoBack"
7586

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

‎src/Drawer.res‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ type rec options = {
4545
drawerHideStatusBarOnOpen?: bool,
4646
drawerStatusBarAnimation?: drawerStatusBarAnimation,
4747
overlayColor?: Color.t,
48-
sceneContainerStyle?: Style.t,
48+
sceneStyle?: Style.t,
4949
gestureEnabled?: bool,
5050
gestureHandlerProps?: gestureHandlerProps,
5151
swipeEnabled?: bool,
5252
swipeEdgeWidth?: float,
5353
swipeMinDistance?: float,
5454
keyboardDismissMode?: keyboardDismissMode,
55-
unmountOnBlur?: bool,
55+
popToTopOnBlur?: bool,
5656
freezeOnBlur?: bool,
5757
headerShown?: bool,
5858
header?: headerProps => React.element,
@@ -104,6 +104,7 @@ module type NavigatorModule = {
104104
~detachInactiveScreens: bool=?,
105105
~useLegacyImplementation: bool=?,
106106
~drawerContent: React.component<contentComponentProps>=?,
107+
~layout: layoutNavigatorParams => React.element=?,
107108
~children: React.element=?,
108109
) => React.element
109110
}
@@ -147,7 +148,7 @@ module Navigation = {
147148
@send
148149
external setOptions: (navigation, options) => unit = "setOptions"
149150

150-
@send external jumpTo: (navigation, ~name: string, ~params: 'params=?, unit) => unit = "jumpTo"
151+
@send external jumpTo: (navigation, ~name: string, ~params: 'params=?) => unit = "jumpTo"
151152
@send external openDrawer: navigation => unit = "openDrawer"
152153
@send external closeDrawer: navigation => unit = "closeDrawer"
153154
@send external toggleDrawer: navigation => unit = "toggleDrawer"

‎src/Elements.bs.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ var Header = {};
55

66
var HeaderBackground = {};
77

8+
var HeaderTitle = {};
9+
10+
var HeaderButton = {};
11+
812
var HeaderBackButton = {};
913

1014
exports.Header = Header;
1115
exports.HeaderBackground = HeaderBackground;
16+
exports.HeaderTitle = HeaderTitle;
17+
exports.HeaderButton = HeaderButton;
1218
exports.HeaderBackButton = HeaderBackButton;
1319
/* No side effect */

0 commit comments

Comments
(0)

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