react-native-navigation的迁移库

FirstTabScreen.ios.js 2.5KB

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