react-native-navigation的迁移库

BottomTabsSideMenu.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import React, {Component, PropTypes} from 'react';
  2. import {
  3. Text,
  4. View,
  5. ScrollView,
  6. TouchableOpacity,
  7. StyleSheet,
  8. Alert
  9. } from 'react-native';
  10. import {connect} from 'react-redux';
  11. import * as counterActions from '../reducers/counter/actions';
  12. import _ from 'lodash';
  13. class SideMenu extends Component {
  14. constructor(props) {
  15. super(props);
  16. // if you want to listen on navigator events, set this up
  17. this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
  18. }
  19. onNavigatorEvent(event) {
  20. console.log('SideMenu', 'Unhandled event ' + event.id);
  21. }
  22. render() {
  23. return (
  24. <View style={styles.sideMenu}>
  25. <Text style={styles.title}>{this.props.title}</Text>
  26. <TouchableOpacity onPress={ this.onShowModalPress.bind(this) }>
  27. <Text style={styles.button}>Show modal</Text>
  28. </TouchableOpacity>
  29. <TouchableOpacity onPress={ this.onPushScreenToFirstTab.bind(this) }>
  30. <Text style={styles.button}>Push screen to first tab</Text>
  31. </TouchableOpacity>
  32. <TouchableOpacity onPress={ this.onPushScreenToSecondTab.bind(this) }>
  33. <Text style={styles.button}>Push screen to second tab</Text>
  34. </TouchableOpacity>
  35. </View>
  36. );
  37. }
  38. onShowModalPress() {
  39. this.props.navigator.showModal({
  40. title: "Modal Screen from SideMenu",
  41. screen: "example.PushedScreen",
  42. passProps: {
  43. str: 'This is a prop passed in \'navigator.showModal()\'!',
  44. obj: {
  45. str: 'This is a prop passed in an object!',
  46. arr: [
  47. {
  48. str: 'This is a prop in an object in an array in an object!'
  49. }
  50. ]
  51. },
  52. num: 1234
  53. }
  54. });
  55. }
  56. onPushScreenToFirstTab() {
  57. this.props.navigator.handleDeepLink({
  58. link: 'tab1/pushScreen/example.PushedScreen'
  59. });
  60. }
  61. onPushScreenToSecondTab() {
  62. this.props.navigator.handleDeepLink({
  63. link: 'tab2/pushScreen/example.PushedScreen'
  64. });
  65. }
  66. }
  67. const styles = StyleSheet.create({
  68. sideMenu: {
  69. flex: 1,
  70. width: 260,
  71. backgroundColor: '#efefef',
  72. padding: 20
  73. },
  74. title: {
  75. textAlign: 'center',
  76. marginBottom: 15
  77. },
  78. button: {
  79. textAlign: 'center',
  80. fontSize: 18,
  81. borderBottomWidth: 1,
  82. borderColor: 'grey',
  83. marginBottom: 10,
  84. marginTop:10,
  85. color: 'black'
  86. }
  87. });
  88. export default connect()(SideMenu);