mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-24 04:25:34 +08:00
Add React.Element support for TabBar/Drawer and fix docs (#451)
* Initial impl * Fix up some docs and support more for drawer * Fix comments * Support TabBar * Make flow more correct * Clarify even more * Rename all the things lol * Also rename renderLabel to getLabel
This commit is contained in:
committed by
Satyajit Sahoo
parent
16d57bcf40
commit
71e8c95b34
@@ -117,6 +117,34 @@ contentOptions: {
|
||||
}
|
||||
```
|
||||
|
||||
### Screen Navigation Options
|
||||
|
||||
Usually you define static `navigationOptions` on your screen component. For example:
|
||||
|
||||
```jsx
|
||||
class ProfileScreen extends React.Component {
|
||||
|
||||
static navigationOptions = {
|
||||
|
||||
title: ({ state }) => `${state.params.name}'s Profile!`,
|
||||
|
||||
drawer: {
|
||||
icon: (
|
||||
<Image src={require('./my-icon.png')} />
|
||||
),
|
||||
},
|
||||
};
|
||||
...
|
||||
```
|
||||
|
||||
All `navigationOptions` for the `DrawerNavigator`:
|
||||
|
||||
- `title` - a title (string) of the scene
|
||||
- `drawer` - a config object for the drawer:
|
||||
- `label` - String, React Element or a function that given `{ focused: boolean, tintColor: string }` returns a React.Element, to display in drawer sidebar. When undefined, scene `title` is used
|
||||
- `icon` - React Element or a function, that given `{ focused: boolean, tintColor: string }` returns a React.Element, to display in drawer sidebar
|
||||
|
||||
|
||||
### Navigator Props
|
||||
|
||||
The navigator component created by `DrawerNavigator(...)` takes the following props:
|
||||
|
||||
@@ -116,14 +116,14 @@ class ProfileScreen extends React.Component {
|
||||
|
||||
All `navigationOptions` for the `StackNavigator`:
|
||||
|
||||
- `title` - a title (string) displayed in the header
|
||||
- `title` - a title (string) of the scene
|
||||
- `header` - a config object for the header bar:
|
||||
- `visible` - Boolean toggle of header visibility. Only works when `headerMode` is `screen`.
|
||||
- `title` - Title string used by the navigation bar, or a custom React component
|
||||
- `backTitle` - Title string used by the back button or `null` to disable label. Defaults to `title` value by default
|
||||
- `right` - Custom React Element to display on the right side of the header
|
||||
- `left` - Custom React Element to display on the left side of the header
|
||||
- `style` - Style object for the navigation bar
|
||||
- `title` - String or React Element used by the header. Defaults to scene `title`
|
||||
- `backTitle` - Title string used by the back button on iOS or `null` to disable label. Defaults to scene `title`
|
||||
- `right` - React Element to display on the right side of the header
|
||||
- `left` - React Element to display on the left side of the header
|
||||
- `style` - Style object for the header
|
||||
- `titleStyle` - Style object for the title component
|
||||
- `tintColor` - Tint color for the header
|
||||
- `cardStack` - a config object for the card stack:
|
||||
|
||||
@@ -149,6 +149,34 @@ tabBarOptions: {
|
||||
}
|
||||
```
|
||||
|
||||
### Screen Navigation Options
|
||||
|
||||
Usually you define static `navigationOptions` on your screen component. For example:
|
||||
|
||||
```jsx
|
||||
class ProfileScreen extends React.Component {
|
||||
|
||||
static navigationOptions = {
|
||||
|
||||
title: ({ state }) => `${state.params.name}'s Profile!`,
|
||||
|
||||
tabBar: ({ state, setParams }) => ({
|
||||
icon: (
|
||||
<Image src={require('./my-icon.png')} />
|
||||
),
|
||||
}),
|
||||
};
|
||||
...
|
||||
```
|
||||
|
||||
All `navigationOptions` for the `TabNavigator`:
|
||||
|
||||
- `title` - a title (string) of the scene
|
||||
- `tabBar` - a config object for the tab bar:
|
||||
- `visible` - Boolean toggle of tab bar visibility
|
||||
- `icon` - React Element or a function that given `{ focused: boolean, tintColor: string }` returns a React.Element, to display in tab bar
|
||||
- `label` - Title string of a tab displayed in the tab bar. When undefined, scene `title` is used. To hide, see `tabBarOptions.showLabel` in the previous section
|
||||
|
||||
### Navigator Props
|
||||
|
||||
The navigator component created by `TabNavigator(...)` takes the following props:
|
||||
|
||||
Reference in New Issue
Block a user