Skip to content

Instantly share code, notes, and snippets.

@joegaudet
Created July 13, 2018 16:16
Show Gist options
  • Select an option

  • Save joegaudet/f9749381ca6cce762372c47ba8b6da51 to your computer and use it in GitHub Desktop.

Select an option

Save joegaudet/f9749381ca6cce762372c47ba8b6da51 to your computer and use it in GitHub Desktop.
export default class Main extends Component {
// currentUser stuff is in the state...
render() {
const AppNavigator = createRootNavigator();
return (
<SessionContext.Provider value={this.state}>
<AppNavigator persistenceKey="NavigationState" />
</SessionContext.Provider>
);
}
}
export function backNavigation(title, options = {}) {
return ({navigation}) => {
const params = navigation.state.params || {};
return {
title: title || `${params.title}`,
headerStyle: {
backgroundColor: params.toolbarColor || options.color || Colors.FOODEE_RED,
},
headerTitleStyle: {
color: 'white'
},
headerLeft: (
<View style={{marginLeft: 10}}>
<Icon
name='chevron-left'
size={20}
color="white"
type='font-awesome'
style={{paddingLeft: 20}}
onPress={() => navigation.pop()}
/>
</View>
)
}
};
}
export class VehicleTypeScreen extends Component {
static navigationOptions = backNavigation('Vehicle Type');
render() {
// some stuff
}
static propTypes = {
navigation: PropTypes.object
};
}
export default function VehicleType(props) {
return (
<SessionContext.Consumer>
{({currentUser}) => (
<VehicleTypeScreen
{...props}
currentUser={currentUser}
/>
)}
</SessionContext.Consumer>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment