Skip to content

Commit

Permalink
Various fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Dec 8, 2024
1 parent 02e967f commit eb154dd
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 30 deletions.
16 changes: 9 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"lint-staged": "^10.0.0",
"npmpub": "^5.0.0",
"prettier": "^2.0.0",
"rescript": "^10.1.2",
"rescript": "^11.0.0",
"rescript-react-native": ">=0.71.1"
},
"prettier": {
Expand Down
4 changes: 2 additions & 2 deletions src/BottomTabs.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ function Make($star) {
return Interop.adaptNavigatorModule(BottomTabs.createBottomTabNavigator());
}

var Navigation = {};
var $$Navigation = {};

exports.TabBarBadge = TabBarBadge;
exports.Make = Make;
exports.Navigation = Navigation;
exports.$$Navigation = $$Navigation;
/* ./Interop Not a pure module */
2 changes: 1 addition & 1 deletion src/BottomTabs.res
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type rec options = {
header?: headerParams => React.element,
headerShown?: bool,
// Header props from https://reactnavigation.org/docs/elements#header
headerTitle?: Header.headerTitleProps => React.element,
headerTitle?: Header.headerTitle,
headerTitleAlign?: Header.headerTitleAlign,
headerTitleAllowFontScaling?: bool,
headerTitleStyle?: Style.t,
Expand Down
4 changes: 2 additions & 2 deletions src/Core.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ var Params = {};

var NavigationEvent = {};

var Navigation = {};
var $$Navigation = {};

exports.Params = Params;
exports.NavigationEvent = NavigationEvent;
exports.Navigation = Navigation;
exports.$$Navigation = $$Navigation;
/* No side effect */
4 changes: 2 additions & 2 deletions src/Drawer.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ function Make($star) {
return Interop.adaptNavigatorModule(Drawer.createDrawerNavigator());
}

var Navigation = {};
var $$Navigation = {};

exports.Make = Make;
exports.Navigation = Navigation;
exports.$$Navigation = $$Navigation;
/* ./Interop Not a pure module */
2 changes: 1 addition & 1 deletion src/Drawer.res
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type rec options = {
headerShown?: bool,
header?: headerProps => React.element,
// Header props from https://reactnavigation.org/docs/elements#header
headerTitle?: Header.headerTitleProps => React.element,
headerTitle?: Header.headerTitle,
headerTitleAlign?: Header.headerTitleAlign,
headerTitleAllowFontScaling?: bool,
headerTitleStyle?: Style.t,
Expand Down
7 changes: 6 additions & 1 deletion src/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ module Header = {
children: string,
}

@unboxed
type headerTitle =
| String(string)
| Function(headerTitleProps => React.element)

type headerLeftProps = {
tintColor: option<Color.t>,
pressColor: option<Color.t>,
Expand All @@ -28,7 +33,7 @@ module Header = {
@react.component @module("@react-navigation/elements")
external make: (
~title: string=?,
~headerTitle: headerTitleProps => React.element=?,
~headerTitle: headerTitle=?,
~headerTitleAlign: headerTitleAlign=?,
~headerTitleAllowFontScaling: bool=?,
~headerTitleStyle: Style.t=?,
Expand Down
4 changes: 2 additions & 2 deletions src/MaterialBottomTabs.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ function Make($star) {
return Interop.adaptNavigatorModule(MaterialBottomTabs.createMaterialBottomTabNavigator());
}

var Navigation = {};
var $$Navigation = {};

exports.TabBarBadge = TabBarBadge;
exports.Make = Make;
exports.Navigation = Navigation;
exports.$$Navigation = $$Navigation;
/* ./Interop Not a pure module */
3 changes: 3 additions & 0 deletions src/MaterialBottomTabs.res
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ type navigatorModule
module Make = () => unpack(createMaterialBottomTabNavigator()->adaptNavigatorModule)

module Navigation = {
@send
external setOptions: (navigation, options) => unit = "setOptions"

@send external jumpTo: (navigation, string) => unit = "jumpTo"
@send
external jumpToWithParams: (navigation, string, 'params) => unit = "jumpTo"
Expand Down
4 changes: 2 additions & 2 deletions src/MaterialTopTabs.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ function Make($star) {
return Interop.adaptNavigatorModule(MaterialTopTabs.createMaterialTopTabNavigator());
}

var Navigation = {};
var $$Navigation = {};

exports.Make = Make;
exports.Navigation = Navigation;
exports.$$Navigation = $$Navigation;
/* ./Interop Not a pure module */
3 changes: 3 additions & 0 deletions src/MaterialTopTabs.res
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ type navigatorModule
module Make = () => unpack(createMaterialTopTabNavigator()->adaptNavigatorModule)

module Navigation = {
@send
external setOptions: (navigation, options) => unit = "setOptions"

@send external jumpTo: (navigation, string) => unit = "jumpTo"
@send
external jumpToWithParams: (navigation, string, 'params) => unit = "jumpTo"
Expand Down
13 changes: 13 additions & 0 deletions src/Native.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ type themeColors = {
border: string,
notification: string,
}

type themeFonts = {
regular: ReactNative.Style.t,
medium: ReactNative.Style.t,
bold: ReactNative.Style.t,
heavy: ReactNative.Style.t,
}

type theme = {
dark: bool,
colors: themeColors,
fonts: themeFonts,
}

@module("@react-navigation/native")
external defaultTheme: theme = "DefaultTheme"
@module("@react-navigation/native")
Expand Down Expand Up @@ -122,3 +132,6 @@ module Link = {
~children: React.element,
) => React.element = "Link"
}

@module("@react-navigation/native")
external getFocusedRouteNameFromRoute: Core.route => option<string> = "getFocusedRouteNameFromRoute"
4 changes: 2 additions & 2 deletions src/NativeStack.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ function Make($star) {
return Interop.adaptNavigatorModule(NativeStack.createNativeStackNavigator());
}

var Navigation = {};
var $$Navigation = {};

exports.Make = Make;
exports.Navigation = Navigation;
exports.$$Navigation = $$Navigation;
/* ./Interop Not a pure module */
9 changes: 5 additions & 4 deletions src/NativeStack.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// https://reactnavigation.org/docs/native-stack-navigator/

open Core
open Elements
open ReactNative

@module("react-native-screens")
Expand Down Expand Up @@ -140,11 +141,11 @@ type rec options = {
headerShadowVisible?: bool,
headerTransparent?: bool,
headerBlurEffect?: blurEffect,
headerBackground?: unit => React.element,
headerBackground?: Header.headerBackgroundOptions => React.element,
headerTintColor?: Color.t,
headerLeft?: unit => React.element,
headerRight?: unit => React.element,
headerTitle?: string,
headerLeft?: Header.headerLeftProps => React.element,
headerRight?: Header.headerRightProps => React.element,
headerTitle?: Header.headerTitle,
headerTitleAlign?: headerTitleAlign,
headerTitleStyle?: headerTitleStyle,
headerSearchBarOptions?: headerSearchBarOptions,
Expand Down
4 changes: 2 additions & 2 deletions src/Stack.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Make($star) {
return Interop.adaptNavigatorModule(Stack.createStackNavigator());
}

var Navigation = {};
var $$Navigation = {};

var TransitionSpecs = {};

Expand All @@ -21,7 +21,7 @@ var TransitionPresets = {};

exports.TransitionSpec = TransitionSpec;
exports.Make = Make;
exports.Navigation = Navigation;
exports.$$Navigation = $$Navigation;
exports.TransitionSpecs = TransitionSpecs;
exports.CardStyleInterpolators = CardStyleInterpolators;
exports.HeaderStyleInterpolators = HeaderStyleInterpolators;
Expand Down
2 changes: 1 addition & 1 deletion src/Stack.res
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ type rec options = {
headerTruncatedBackTitle?: string,
headerBackTitleStyle?: Style.t,
// Header props from https://reactnavigation.org/docs/elements#header
headerTitle?: Header.headerTitleProps => React.element,
headerTitle?: Header.headerTitle,
headerTitleAlign?: Header.headerTitleAlign,
headerTitleAllowFontScaling?: bool,
headerTitleStyle?: Style.t,
Expand Down

0 comments on commit eb154dd

Please sign in to comment.