react-native-navigation的迁移库

ThirdTabScreen.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 ThirdTabScreen extends Component {
  10. static navigatorStyle = {
  11. drawUnderTabBar: true
  12. };
  13. constructor(props) {
  14. super(props);
  15. this.state = {
  16. navBarVisability: 'shown'
  17. }
  18. }
  19. render() {
  20. return (
  21. <View style={{flex: 1, padding: 20}}>
  22. <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
  23. <Text style={styles.button}>Push Plain Screen</Text>
  24. </TouchableOpacity>
  25. <TouchableOpacity onPress={ this.onPushStyledPress.bind(this) }>
  26. <Text style={styles.button}>Push Styled Screen</Text>
  27. </TouchableOpacity>
  28. <TouchableOpacity onPress={ this.onPushStyled2Press.bind(this) }>
  29. <Text style={styles.button}>Push Styled Screen 2</Text>
  30. </TouchableOpacity>
  31. <TouchableOpacity onPress={ this.onModalPress.bind(this) }>
  32. <Text style={styles.button}>Show Modal Screen</Text>
  33. </TouchableOpacity>
  34. <TouchableOpacity onPress={ this.onToggleNavBarPressed.bind(this) }>
  35. <Text style={styles.button}>Toggle Navigation Bar</Text>
  36. </TouchableOpacity>
  37. </View>
  38. );
  39. }
  40. onPushPress() {
  41. this.props.navigator.push({
  42. title: "More",
  43. screen: "example.PushedScreen"
  44. });
  45. }
  46. onPushStyledPress() {
  47. this.props.navigator.push({
  48. title: "Styled",
  49. screen: "example.StyledScreen"
  50. });
  51. }
  52. onPushStyled2Press () {
  53. this.props.navigator.push({
  54. title: "Styled",
  55. titleImage: require('../../img/two.png'),
  56. screen: "example.StyledScreen"
  57. });
  58. }
  59. onModalPress() {
  60. this.props.navigator.showModal({
  61. title: "Modal",
  62. screen: "example.ModalScreen"
  63. });
  64. }
  65. onToggleNavBarPressed() {
  66. this.state.navBarVisability = (this.state.navBarVisability === 'shown') ? 'hidden' : 'shown';
  67. this.props.navigator.toggleNavBar({
  68. to: this.state.navBarVisability,
  69. animated: true // true is default
  70. });
  71. }
  72. componentDidUpdate() {
  73. console.error('this is an error: ' + Math.random());
  74. this.state.navBarState = 'shown';
  75. }
  76. }
  77. const styles = StyleSheet.create({
  78. button: {
  79. textAlign: 'center',
  80. fontSize: 18,
  81. marginBottom: 10,
  82. marginTop:10,
  83. color: 'blue'
  84. }
  85. });