Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. var NavigationBarRouteMapper = {
  2. LeftButton(route, navigator, index, navState) {
  3. if (index >= 0) {
  4. return (
  5. <View style={styles.navContainer}>
  6. <TouchableHighlight
  7. underlayColor="transparent"
  8. onPress={() => { if (index > 0) { navigator.pop() } }}>
  9. <Text style={ styles.leftNavButton }>
  10. <Icon name="arrow-left" size={25} color="#900" />
  11. </Text>
  12. </TouchableHighlight>
  13. </View>
  14. )
  15. }
  16. else { return null }
  17. },
  18. RightButton(route, navigator, index, navState) {
  19. if (route.onPress) {
  20. return (
  21. <View style={styles.navContainer}>
  22. <TouchableHighlight
  23. underlayColor="transparent"
  24. onPress={ () => route.onPress() }>
  25. <Text style={ styles.rightNavButton }>
  26. { route.rightText || <Icon name="arrow-right" size={25} color="#900" /> }
  27. </Text>
  28. </TouchableHighlight>
  29. </View>
  30. )
  31. }
  32. else { return null }
  33. },
  34. Title(route, navigator, index, navState) {
  35. return (
  36. <View style={styles.navContainer}>
  37. <Text style={ styles.title }>{route.title}</Text>
  38. </View>
  39. )
  40. }
  41. };
  42.  
  43. // Main component description
  44. class App extends Component {
  45.  
  46. // not important stuff here
  47.  
  48. render() {
  49. return (
  50. <Provider store={store}>
  51. <Navigator
  52. configureScene={this.configureScene}
  53. initialRoute={{ component: Index, title: 'HOME', display: true}}
  54. renderScene={ this.renderScene }
  55. style={{backgroundColor: '#FFD800'}}
  56. navigationBar={
  57. <Navigator.NavigationBar
  58. style={ styles.navigator }
  59. routeMapper={ NavigationBarRouteMapper }
  60. />
  61. }
  62.  
  63. />
  64. </Provider>
  65. )
  66. }
  67. }
  68.  
  69. var styles = StyleSheet.create({
  70. navigator: {
  71. flex: 1,
  72. backgroundColor: '#FFD800',
  73. justifyContent: 'center',
  74. alignItems: 'center',
  75. // height: 64,
  76. },
  77. navContainer: {
  78. flex: 1,
  79. flexDirection: 'column',
  80. justifyContent: 'center',
  81. alignItems: 'center',
  82. borderWidth: 1,
  83. borderColor: 'red',
  84. },
  85. title: {
  86. alignItems: 'center',
  87. },
  88. leftNavButton: {
  89. marginLeft: 12,
  90. },
  91. rightNavButton: {
  92. marginRight: 12,
  93. },
  94. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement