react-native-navigation的迁移库

FirstTabScreen.android.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import React, {Component} from 'react';
  2. import {
  3. Text,
  4. View,
  5. ScrollView,
  6. TouchableOpacity,
  7. StyleSheet
  8. } from 'react-native';
  9. export default class FirstTabScreen extends Component {
  10. static navigatorButtons = {
  11. leftButtons: [{
  12. icon: require('../../img/navicon_menu.png'),
  13. id: 'menu'
  14. }],
  15. rightButtons: [
  16. {
  17. title: 'Edit',
  18. id: 'edit'
  19. },
  20. {
  21. icon: require('../../img/navicon_add.png'),
  22. id: 'add'
  23. }
  24. ]
  25. };
  26. static navigatorStyle = {
  27. drawUnderTabBar: true
  28. };
  29. constructor(props) {
  30. super(props);
  31. // if you want to listen on navigator events, set this up
  32. // this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
  33. }
  34. onNavigatorEvent(event) {
  35. if (event.id == 'menu') {
  36. this.props.navigator.toggleDrawer({
  37. side: 'left',
  38. animated: true
  39. });
  40. }
  41. if (event.id == 'edit') {
  42. // AlertIOS.alert('NavBar', 'Edit button pressed');
  43. }
  44. if (event.id == 'add') {
  45. // AlertIOS.alert('NavBar', 'Add button pressed');
  46. }
  47. }
  48. render() {
  49. return (
  50. <View style={{flex: 1, padding: 20}}>
  51. <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
  52. <Text style={styles.button}>Push Plain Screen</Text>
  53. </TouchableOpacity>
  54. <TouchableOpacity onPress={ this.onPushStyledPress.bind(this) }>
  55. <Text style={styles.button}>Push Styled Screen</Text>
  56. </TouchableOpacity>
  57. <TouchableOpacity onPress={ this.onModalPress.bind(this) }>
  58. <Text style={styles.button}>Show Modal Screen</Text>
  59. </TouchableOpacity>
  60. <TouchableOpacity onPress={ this.onLightBoxPress.bind(this) }>
  61. <Text style={styles.button}>Show LightBox</Text>
  62. </TouchableOpacity>
  63. </View>
  64. );
  65. }
  66. onPushPress() {
  67. this.props.navigator.push({
  68. title: "More",
  69. screen: "example.PushedScreen"
  70. });
  71. }
  72. onPushStyledPress() {
  73. console.warn('navigator.push not implemented yet');
  74. // this.props.navigator.push({
  75. // title: "Styled",
  76. // screen: "example.StyledScreen"
  77. // });
  78. }
  79. onModalPress() {
  80. console.warn('navigator.showModal not implemented yet');
  81. // this.props.navigator.showModal({
  82. // title: "Modal",
  83. // screen: "example.ModalScreen"
  84. // });
  85. }
  86. onLightBoxPress() {
  87. console.warn('navigator.showLightBox not implemented yet');
  88. // this.props.navigator.showLightBox({
  89. // screen: "example.LightBoxScreen",
  90. // style: {
  91. // backgroundBlur: "dark"
  92. // }
  93. // });
  94. }
  95. }
  96. const styles = StyleSheet.create({
  97. button: {
  98. textAlign: 'center',
  99. fontSize: 18,
  100. marginBottom: 10,
  101. marginTop:10,
  102. color: 'blue'
  103. }
  104. });