Guest User

Untitled

a guest
Jun 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import React from 'react';
  2. import { ScrollView, TouchableOpacity } from 'react-native';
  3. import { createStackNavigator } from 'react-navigation';
  4. import { ListItem, Text } from 'react-native-elements';
  5.  
  6. // USAGE COMPONENTS
  7. import Avatar from './components/stories/Avatar.usage';
  8.  
  9. const List = ({ navigation }) => (
  10. <ScrollView>
  11. {Object.keys(Routes)
  12. .filter(e => e !== 'STORYBOOK')
  13. .map((title, i) => (
  14. <ListItem
  15. key={`list-item-${i}`}
  16. title={title}
  17. chevron
  18. leftElement={<Text>ยท</Text>}
  19. onPress={() => navigation.navigate(title)}
  20. />
  21. ))}
  22. </ScrollView>
  23. );
  24.  
  25. const Exit = ({ navigation }) => (
  26. <TouchableOpacity
  27. onPress={() => {
  28. navigation.goBack(null);
  29. }}
  30. style={{ margin: 10 }}
  31. >
  32. <Text>Exit</Text>
  33. </TouchableOpacity>
  34. );
  35.  
  36. const navigationOptions = ({ navigation }) => ({
  37. headerRight: <Exit navigation={navigation} />,
  38. })
  39.  
  40. const Routes = {
  41. STORYBOOK: {
  42. screen: List,
  43. navigationOptions,
  44. },
  45. // ADD YOUR USAGE COMPONENTS HERE
  46. Avatar: {
  47. screen: Avatar,
  48. }
  49. };
  50.  
  51. export default createStackNavigator(Routes);
Add Comment
Please, Sign In to add comment