diff --git a/src/BottomTabs.bs.js b/src/BottomTabs.bs.js index e0b75d4..4472458 100644 --- a/src/BottomTabs.bs.js +++ b/src/BottomTabs.bs.js @@ -14,14 +14,19 @@ function Make(M) { var $$Screen = { make: make }; - var make$1 = bottomTabs.Navigator; - var $$Navigator = { + var make$1 = bottomTabs.Screen; + var ScreenWithCallback = { make: make$1 }; + var make$2 = bottomTabs.Navigator; + var $$Navigator = { + make: make$2 + }; return { Navigation: Navigation, bottomTabs: bottomTabs, $$Screen: $$Screen, + ScreenWithCallback: ScreenWithCallback, $$Navigator: $$Navigator }; } diff --git a/src/BottomTabs.re b/src/BottomTabs.re index c388ec8..13092cf 100644 --- a/src/BottomTabs.re +++ b/src/BottomTabs.re @@ -16,6 +16,7 @@ module BottomTabNavigationProp = (M: { }; module Make = (M: {type params;}) => { + type nonrec route = route(M.params); module Navigation = BottomTabNavigationProp({ include M; @@ -55,9 +56,9 @@ module Make = (M: {type params;}) => { type accessibilityRole = string; type accessibilityStates = array(string); - type routeArgs = {route: route(M.params)}; + type routeArgs = {route}; type renderIconArgs = { - route: route(M.params), + route, focused: bool, tintColor: string, horizontal: bool, @@ -98,8 +99,7 @@ module Make = (M: {type params;}) => { ~style: ReactNative.Style.t=?, unit ) => - bottomTabBarOptions = - ""; + bottomTabBarOptions; type tabBarLabelArgs = { focused: bool, @@ -123,19 +123,42 @@ module Make = (M: {type params;}) => { ~tabBarButtonComponent: React.element=?, unit ) => - options = - ""; + options; type optionsProps = { navigation, - route: route(M.params), + route, }; type optionsCallback = optionsProps => options; - type navigatorProps; + type navigatorProps = { + initialRouteName: option(string), + screenOptions: option(optionsCallback), + _lazy: option(bool), + tabBar: option(React.component(Js.t(bottomTabBarProps))), + tabBarOptions: option(bottomTabBarOptions), + }; + + type renderCallbackProp = { + navigation, + route, + }; - type screenProps; + type screenProps('params) = { + name: string, + options: option(optionsCallback), + initialParams: option('params), + component: + option( + React.component({ + . + "navigation": navigation, + "route": route, + }), + ), + children: option(renderCallbackProp => React.element), + }; [@bs.module "@react-navigation/bottom-tabs"] external make: @@ -143,7 +166,7 @@ module Make = (M: {type params;}) => { { . "Navigator": navigatorProps => React.element, - "Screen": screenProps => React.element, + "Screen": screenProps(M.params) => React.element, } = "createBottomTabNavigator"; @@ -159,12 +182,25 @@ module Make = (M: {type params;}) => { ~component: React.component({ . "navigation": navigation, - "route": route(M.params), + "route": route, }), unit ) => - screenProps = - ""; + screenProps(M.params); + let make = bottomTabs##"Screen"; + }; + + module ScreenWithCallback = { + [@bs.obj] + external makeProps: + ( + ~name: string, + ~options: optionsCallback=?, + ~initialParams: M.params=?, + ~children: renderCallbackProp => React.element, + unit + ) => + screenProps(M.params); let make = bottomTabs##"Screen"; }; @@ -180,8 +216,7 @@ module Make = (M: {type params;}) => { ~tabBarOptions: bottomTabBarOptions=?, unit ) => - navigatorProps = - ""; + navigatorProps; let make = bottomTabs##"Navigator"; }; diff --git a/src/MaterialBottomTabs.bs.js b/src/MaterialBottomTabs.bs.js index f6aa05b..2b9eb1c 100644 --- a/src/MaterialBottomTabs.bs.js +++ b/src/MaterialBottomTabs.bs.js @@ -28,20 +28,25 @@ function Make(M) { number: number, string: string }; - var stack = MaterialBottomTabs.createMaterialBottomTabNavigator(); - var make = stack.Screen; + var materialBottomTabs = MaterialBottomTabs.createMaterialBottomTabNavigator(); + var make = materialBottomTabs.Screen; var $$Screen = { make: make }; - var make$1 = stack.Navigator; - var $$Navigator = { + var make$1 = materialBottomTabs.Screen; + var ScreenWithCallback = { make: make$1 }; + var make$2 = materialBottomTabs.Navigator; + var $$Navigator = { + make: make$2 + }; return { Navigation: Navigation, TabBarBadge: TabBarBadge, - stack: stack, + materialBottomTabs: materialBottomTabs, $$Screen: $$Screen, + ScreenWithCallback: ScreenWithCallback, $$Navigator: $$Navigator }; } diff --git a/src/MaterialBottomTabs.re b/src/MaterialBottomTabs.re index 52dc430..331ee26 100644 --- a/src/MaterialBottomTabs.re +++ b/src/MaterialBottomTabs.re @@ -20,6 +20,7 @@ module MaterialBottomTabNavigationProp = (M: { }; module Make = (M: {type params;}) => { + type nonrec route = route(M.params); module Navigation = MaterialBottomTabNavigationProp({ include M; @@ -30,7 +31,7 @@ module Make = (M: {type params;}) => { type scene = { . - "route": route(M.params), + "route": route, "focused": bool, "tintColor": string, }; @@ -63,19 +64,45 @@ module Make = (M: {type params;}) => { ~tabBarTestID: string=?, unit ) => - options = - ""; + options; type optionsProps = { navigation, - route: route(M.params), + route, }; type optionsCallback = optionsProps => options; - type navigatorProps; + type navigatorProps = { + initialRouteName: option(string), + screenOptions: option(optionsCallback), + backBehavior: option(string), + shifting: option(bool), + labeled: option(bool), + activeColor: option(string), + inactiveColor: option(string), + barStyle: option(ReactNative.Style.t), + }; + + type renderCallbackProp = { + navigation, + route, + }; - type screenProps; + type screenProps('params) = { + name: string, + options: option(optionsCallback), + initialParams: option('params), + component: + option( + React.component({ + . + "navigation": navigation, + "route": route, + }), + ), + children: option(renderCallbackProp => React.element), + }; [@bs.module "@react-navigation/material-bottom-tabs"] external make: @@ -83,11 +110,11 @@ module Make = (M: {type params;}) => { { . "Navigator": navigatorProps => React.element, - "Screen": screenProps => React.element, + "Screen": screenProps(M.params) => React.element, } = "createMaterialBottomTabNavigator"; - let stack = make(); + let materialBottomTabs = make(); module Screen = { [@bs.obj] @@ -99,9 +126,22 @@ module Make = (M: {type params;}) => { ~component: React.component({. "navigation": navigation}), unit ) => - screenProps = - ""; - let make = stack##"Screen"; + screenProps(M.params); + let make = materialBottomTabs##"Screen"; + }; + + module ScreenWithCallback = { + [@bs.obj] + external makeProps: + ( + ~name: string, + ~options: optionsCallback=?, + ~initialParams: M.params=?, + ~children: renderCallbackProp => React.element, + unit + ) => + screenProps(M.params); + let make = materialBottomTabs##"Screen"; }; module Navigator = { @@ -126,9 +166,8 @@ module Make = (M: {type params;}) => { //TODO: More? https://github.com/callstack/react-native-paper/blob/bd4296116d841ed355f3dbebb40cfbc3b87a79ff/src/components/BottomNavigation.tsx#L132-L196 unit ) => - navigatorProps = - ""; + navigatorProps; - let make = stack##"Navigator"; + let make = materialBottomTabs##"Navigator"; }; }; diff --git a/src/MaterialTopTabs.bs.js b/src/MaterialTopTabs.bs.js index 68b9859..0232bab 100644 --- a/src/MaterialTopTabs.bs.js +++ b/src/MaterialTopTabs.bs.js @@ -9,19 +9,24 @@ function Make(M) { var M$1 = { }; var include = Core$ReactNavigation.NavigationScreenProp(M$1); var Navigation = include; - var stack = MaterialTopTabs.createMaterialTopTabNavigator(); - var make = stack.Screen; + var materialTopTabs = MaterialTopTabs.createMaterialTopTabNavigator(); + var make = materialTopTabs.Screen; var $$Screen = { make: make }; - var make$1 = stack.Navigator; - var $$Navigator = { + var make$1 = materialTopTabs.Screen; + var ScreenWithCallback = { make: make$1 }; + var make$2 = materialTopTabs.Navigator; + var $$Navigator = { + make: make$2 + }; return { Navigation: Navigation, - stack: stack, + materialTopTabs: materialTopTabs, $$Screen: $$Screen, + ScreenWithCallback: ScreenWithCallback, $$Navigator: $$Navigator }; } diff --git a/src/MaterialTopTabs.re b/src/MaterialTopTabs.re index 92f9497..8894ce7 100644 --- a/src/MaterialTopTabs.re +++ b/src/MaterialTopTabs.re @@ -20,6 +20,7 @@ module MaterialTopTabNavigationProp = (M: { }; module Make = (M: {type params;}) => { + type nonrec route = route(M.params); module Navigation = MaterialTopTabNavigationProp({ include M; @@ -30,7 +31,7 @@ module Make = (M: {type params;}) => { type scene = { . - "route": route(M.params), + "route": route, "focused": bool, "tintColor": string, }; @@ -73,7 +74,7 @@ module Make = (M: {type params;}) => { type accessibilityRole = string; type accessibilityStates = array(string); - type routeOptions = {route: route(M.params)}; + type routeOptions = {route}; class type virtual materialTopTabBarProps = { as 'self; @@ -86,7 +87,7 @@ module Make = (M: {type params;}) => { pub onTabPress: { . - "route": route(M.params), + "route": route, [@bs.meth] "preventDefault": unit => unit, } => unit; @@ -120,8 +121,7 @@ module Make = (M: {type params;}) => { ~style: ReactNative.Style.t=?, unit ) => - materialTopTabBarOptions = - ""; + materialTopTabBarOptions; [@bs.obj] external options: @@ -136,19 +136,49 @@ module Make = (M: {type params;}) => { ~tabBarVisible: bool=?, unit ) => - options = - ""; + options; type optionsProps = { navigation, - route: route(M.params), + route, }; type optionsCallback = optionsProps => options; - type navigatorProps; + type navigatorProps = { + initialRouteName: option(string), + screenOptions: option(optionsCallback), + lazyPlaceholderComponent: option(React.component({. "route": route})), + tabBar: option(React.component(Js.t(materialTopTabBarProps))), + tabBarOptions: option(materialTopTabBarOptions), + tabBarPosition: option(string), + backBehavior: option(string), + shifting: option(bool), + labeled: option(bool), + activeColor: option(string), + inactiveColor: option(string), + barStyle: option(ReactNative.Style.t), + }; + + type renderCallbackProp = { + navigation, + route, + }; - type screenProps; + type screenProps('params) = { + name: string, + options: option(optionsCallback), + initialParams: option('params), + component: + option( + React.component({ + . + "navigation": navigation, + "route": route, + }), + ), + children: option(renderCallbackProp => React.element), + }; [@bs.module "@react-navigation/material-top-tabs"] external make: @@ -156,11 +186,11 @@ module Make = (M: {type params;}) => { { . "Navigator": navigatorProps => React.element, - "Screen": screenProps => React.element, + "Screen": screenProps(M.params) => React.element, } = "createMaterialTopTabNavigator"; - let stack = make(); + let materialTopTabs = make(); module Screen = { [@bs.obj] @@ -172,9 +202,22 @@ module Make = (M: {type params;}) => { ~component: React.component({. "navigation": navigation}), unit ) => - screenProps = - ""; - let make = stack##"Screen"; + screenProps(M.params); + let make = materialTopTabs##"Screen"; + }; + + module ScreenWithCallback = { + [@bs.obj] + external makeProps: + ( + ~name: string, + ~options: optionsCallback=?, + ~initialParams: M.params=?, + ~children: renderCallbackProp => React.element, + unit + ) => + screenProps(M.params); + let make = materialTopTabs##"Screen"; }; module Navigator = { @@ -184,19 +227,14 @@ module Make = (M: {type params;}) => { ~initialRouteName: string=?, ~screenOptions: optionsCallback=?, ~children: React.element, - ~lazyPlaceholderComponent: React.component({ - . - "route": route(M.params), - }) - =?, + ~lazyPlaceholderComponent: React.component({. "route": route})=?, ~tabBar: React.component(Js.t(materialTopTabBarProps))=?, ~tabBarOptions: materialTopTabBarOptions=?, ~tabBarPosition: [@bs.string] [ | `top | `bottom]=?, unit ) => - navigatorProps = - ""; + navigatorProps; - let make = stack##"Navigator"; + let make = materialTopTabs##"Navigator"; }; }; diff --git a/src/Stack.re b/src/Stack.re index 33b6c6a..2e2db72 100644 --- a/src/Stack.re +++ b/src/Stack.re @@ -253,11 +253,11 @@ module Make = (M: {type params;}) => { navigation, route, }; - type optionCallback = optionsProps => options; + type optionsCallback = optionsProps => options; type navigatorProps = { initialRouteName: option(string), - screenOptions: option(optionCallback), + screenOptions: option(optionsCallback), mode: option(string), headerMode: option(string), keyboardHandlingEnabled: option(bool), @@ -268,7 +268,7 @@ module Make = (M: {type params;}) => { }; type screenProps('params) = { name: string, - options: option(optionCallback), + options: option(optionsCallback), initialParams: option('params), component: option( @@ -297,7 +297,7 @@ module Make = (M: {type params;}) => { external makeProps: ( ~name: string, - ~options: optionCallback=?, + ~options: optionsCallback=?, ~initialParams: M.params=?, ~children: renderCallbackProp => React.element, unit @@ -311,7 +311,7 @@ module Make = (M: {type params;}) => { external makeProps: ( ~name: string, - ~options: optionCallback=?, + ~options: optionsCallback=?, ~initialParams: M.params=?, ~component: React.component({ . @@ -330,7 +330,7 @@ module Make = (M: {type params;}) => { external makeProps: ( ~initialRouteName: string=?, - ~screenOptions: optionCallback=?, + ~screenOptions: optionsCallback=?, ~mode: [@bs.string] [ | `card | `modal]=?, ~headerMode: [@bs.string] [ | `float | `screen | `none]=?, ~keyboardHandlingEnabled: bool=?,