diff --git a/example/src/RootNavigator.js b/example/src/RootNavigator.js
index 91291ef..226d2d3 100644
--- a/example/src/RootNavigator.js
+++ b/example/src/RootNavigator.js
@@ -1,21 +1,47 @@
/* @flow */
import React from 'react';
-import Expo from 'expo';
import { StackNavigator } from 'react-navigation';
-import { Colors } from 'react-native-paper';
+import { Platform, StatusBar } from 'react-native';
+import { Toolbar } from 'react-native-paper';
import ExampleList, { examples } from './ExampleList';
+const MORE_ICON = Platform.OS === 'ios' ? 'more-horiz' : 'more-vert';
+
const routes = Object.keys(examples)
.map(id => ({ id, item: examples[id] }))
.reduce((acc, { id, item }) => {
const Comp = item;
const Screen = props => ;
- Screen.navigationOptions = {
- title: Comp.title,
- /* $FlowFixMe */
- ...Comp.navigationOptions,
+ Screen.navigationOptions = ({ navigation }) => {
+ const { params = {} } = navigation.state;
+ return {
+ header: (
+
+ {!params.showLeftIcon && (
+ navigation.goBack()} />
+ )}
+
+ {params.showSearchIcon && (
+ {}} />
+ )}
+ {!params.showMoreIcon && (
+ {}} />
+ )}
+
+ ),
+ /* $FlowFixMe */
+ ...Comp.navigationOptions,
+ };
};
return {
@@ -31,12 +57,14 @@ export default StackNavigator(
},
{
navigationOptions: {
- headerTintColor: Colors.white,
- headerStyle: {
- backgroundColor: Colors.indigo500,
- paddingTop: Expo.Constants.statusBarHeight,
- height: 56 + Expo.Constants.statusBarHeight,
- },
+ header: (
+
+
+
+ ),
},
}
);
diff --git a/example/src/ToolbarExample.js b/example/src/ToolbarExample.js
index bb0c553..830113b 100644
--- a/example/src/ToolbarExample.js
+++ b/example/src/ToolbarExample.js
@@ -8,15 +8,38 @@ const MORE_ICON = Platform.OS === 'ios' ? 'more-horiz' : 'more-vert';
export default class ToolbarExample extends Component {
static title = 'Toolbar';
- static navigationOptions = {
- header: null,
+ static navigationOptions = ({ navigation }) => {
+ return {
+ header: (
+
+ {navigation.params.showLeftIcon && (
+ this.props.navigation.goBack()}
+ />
+ )}
+
+ {navigation.params.showSearchIcon && (
+ {}} />
+ )}
+ {navigation.params.showMoreIcon && (
+ {}} />
+ )}
+
+ ),
+ };
};
state = {
showLeftIcon: true,
- showSearchIcon: Platform.OS !== 'ios',
+ showSearchIcon: false,
showMoreIcon: true,
- showSubtitle: Platform.OS !== 'ios',
+ showSubtitle: false,
};
render() {
@@ -26,59 +49,54 @@ export default class ToolbarExample extends Component {
showMoreIcon,
showSubtitle,
} = this.state;
-
return (
-
- {showLeftIcon && (
- this.props.navigation.goBack()}
- />
- )}
-
- {showSearchIcon && (
- {}} />
- )}
- {showMoreIcon && (
- {}} />
- )}
-