react-native-navigation的迁移库

CollapsingTopBarScreen.android.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import React, {Component} from 'react';
  2. import {
  3. Text,
  4. View,
  5. ScrollView,
  6. TouchableOpacity,
  7. StyleSheet,
  8. } from 'react-native';
  9. // collapsingToolBarImage: require('../../img/gyro_header.jpg'),
  10. // collapsingToolBarImage: "https://static.wixstatic.com/media/ec14061b42d1dc5b809367f7cfda8eff.jpg/v1/fill/w_1002,h_499,q_80/ec14061b42d1dc5b809367f7cfda8eff.webp",
  11. export default class ThirdTabScreen extends Component {
  12. static navigatorStyle = {
  13. drawUnderTabBar: true,
  14. navBarButtonColor: '#ffffff',
  15. navBarTextColor: '#ffffff',
  16. collapsingToolBarImage: require('../../img/gyro_header.jpg'),
  17. collapsingToolBarCollapsedColor: '#0f2362',
  18. navBarBackgroundColor: '#eeeeee'
  19. };
  20. static navigatorButtons = {
  21. rightButtons: [
  22. {
  23. title: 'Edit',
  24. id: 'edit'
  25. },
  26. {
  27. icon: require('../../img/navicon_add.png'),
  28. id: 'add'
  29. }
  30. ]
  31. };
  32. constructor(props) {
  33. super(props);
  34. this.state = {
  35. navBarVisibility: 'shown'
  36. }
  37. }
  38. render() {
  39. return (
  40. <ScrollView style={styles.container}>
  41. <View style={{flex: 1, backgroundColor: '#ffffff'}}>
  42. <Text style={styles.button}>Row 0</Text>
  43. <Text style={styles.button}>Row 1</Text>
  44. <Text style={styles.button}>Row 2</Text>
  45. <Text style={styles.button}>Row 3</Text>
  46. <Text style={styles.button}>Row 4</Text>
  47. <Text style={styles.button}>Row 5</Text>
  48. <Text style={styles.button}>Row 6</Text>
  49. <Text style={styles.button}>Row 7</Text>
  50. <Text style={styles.button}>Row 8</Text>
  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.onPushStyled2Press.bind(this) }>
  58. <Text style={styles.button}>Push Styled Screen 2</Text>
  59. </TouchableOpacity>
  60. <TouchableOpacity onPress={ this.onModalPress.bind(this) }>
  61. <Text style={styles.button}>Show Modal Screen</Text>
  62. </TouchableOpacity>
  63. <TouchableOpacity onPress={ this.onToggleNavBarPressed.bind(this) }>
  64. <Text style={styles.button}>Toggle Navigation Bar</Text>
  65. </TouchableOpacity>
  66. </View>
  67. </ScrollView>
  68. );
  69. }
  70. onPushPress() {
  71. this.props.navigator.push({
  72. title: "More",
  73. screen: "example.PushedScreen"
  74. });
  75. }
  76. onPushStyledPress() {
  77. this.props.navigator.push({
  78. title: "Styled",
  79. screen: "example.StyledScreen"
  80. });
  81. }
  82. onPushStyled2Press () {
  83. this.props.navigator.push({
  84. title: "Styled",
  85. titleImage: require('../../img/two.png'),
  86. screen: "example.StyledScreen"
  87. });
  88. }
  89. onModalPress() {
  90. this.props.navigator.showModal({
  91. title: "Modal",
  92. screen: "example.ModalScreen"
  93. });
  94. }
  95. onToggleNavBarPressed() {
  96. this.state.navBarVisibility = (this.state.navBarVisibility === 'shown') ? 'hidden' : 'shown';
  97. this.props.navigator.toggleNavBar({
  98. to: this.state.navBarVisibility,
  99. animated: true // true is default
  100. });
  101. }
  102. componentDidUpdate() {
  103. console.error('this is an error: ' + Math.random());
  104. this.state.navBarState = 'shown';
  105. }
  106. }
  107. const styles = StyleSheet.create({
  108. container: {
  109. flex: 1,
  110. padding: 20,
  111. backgroundColor: '#eeeeee'
  112. },
  113. button: {
  114. textAlign: 'center',
  115. fontSize: 18,
  116. marginBottom: 10,
  117. marginTop:30,
  118. color: 'blue'
  119. }
  120. });