-
-
Notifications
You must be signed in to change notification settings - Fork 31
ScreenWithCallback for tabs navigators #34
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
MoOx
merged 1 commit into
rescript-react-native:master
from
Freddy03h:screencallback-tabs
Jul 8, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,31 +64,57 @@ 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here (not sure it's doable for some reason) |
||
}), | ||
), | ||
children: option(renderCallbackProp => React.element), | ||
}; | ||
|
||
[@bs.module "@react-navigation/material-bottom-tabs"] | ||
external make: | ||
unit => | ||
{ | ||
. | ||
"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"; | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be declared as a standard record?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, I copied the way it was done on the Stack 😅
https://github.com/reason-react-native/reason-react-navigation/blob/a7d40f04e6785ed0c4525ad2b5f63a287282cf7f/src/Stack.re#L127
https://github.com/reason-react-native/reason-react-navigation/blob/a7d40f04e6785ed0c4525ad2b5f63a287282cf7f/src/Stack.re#L269-L282
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so we could change that later in all places