react-native-navigation的迁移库

SideMenu.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import React, {
  2. Component,
  3. Text,
  4. View,
  5. ScrollView,
  6. TouchableOpacity,
  7. StyleSheet,
  8. AlertIOS
  9. } from 'react-native';
  10. export default class SideMenu extends Component {
  11. constructor(props) {
  12. super(props);
  13. }
  14. render() {
  15. return (
  16. <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
  17. <Text style={styles.title}>Side Menu</Text>
  18. <TouchableOpacity onPress={ this.onReplaceTab2Press.bind(this) }>
  19. <Text style={styles.button}>Replace Tab#2 Root</Text>
  20. </TouchableOpacity>
  21. <TouchableOpacity onPress={ this.onModalPress.bind(this) }>
  22. <Text style={styles.button}>Show Modal Screen</Text>
  23. </TouchableOpacity>
  24. </View>
  25. );
  26. }
  27. onReplaceTab2Press() {
  28. this.props.navigator.toggleDrawer({
  29. to: 'closed',
  30. side: 'left',
  31. animated: true
  32. });
  33. this.props.navigator.handleDeepLink({
  34. link: "tab2/example.PushedScreen"
  35. });
  36. }
  37. onModalPress() {
  38. this.props.navigator.showModal({
  39. title: "Modal",
  40. screen: "example.ModalScreen"
  41. });
  42. }
  43. }
  44. const styles = StyleSheet.create({
  45. title: {
  46. textAlign: 'center',
  47. fontSize: 18,
  48. marginBottom: 10,
  49. marginTop:10,
  50. fontWeight: '500'
  51. },
  52. button: {
  53. textAlign: 'center',
  54. fontSize: 18,
  55. marginBottom: 10,
  56. marginTop:10,
  57. color: 'blue'
  58. }
  59. });