react-native-navigation的迁移库

PushedScreen.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 PushedScreen extends Component {
  10. static navigatorStyle = {
  11. drawUnderTabBar: true
  12. };
  13. constructor(props) {
  14. super(props);
  15. }
  16. render() {
  17. return (
  18. <View style={styles.container}>
  19. <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
  20. <Text style={styles.button}>Push Plain Screen</Text>
  21. </TouchableOpacity>
  22. <TouchableOpacity onPress={ this.onPushStyledPress.bind(this) }>
  23. <Text style={styles.button}>Push Styled Screen</Text>
  24. </TouchableOpacity>
  25. <TouchableOpacity onPress={ this.onPopPress.bind(this) }>
  26. <Text style={styles.button}>Pop Screen</Text>
  27. </TouchableOpacity>
  28. <TouchableOpacity onPress={ this.onPopToRootPress.bind(this) }>
  29. <Text style={styles.button}>Pop To Root</Text>
  30. </TouchableOpacity>
  31. <TouchableOpacity onPress={ this.onResetToPress.bind(this) }>
  32. <Text style={styles.button}>Reset To</Text>
  33. </TouchableOpacity>
  34. </View>
  35. );
  36. }
  37. onPushPress() {
  38. this.props.navigator.push({
  39. title: "More",
  40. container: "example.PushedScreen"
  41. });
  42. }
  43. onPushStyledPress() {
  44. this.props.navigator.push({
  45. title: "More",
  46. container: "com.example.StyledScreen"
  47. });
  48. }
  49. onPopPress() {
  50. this.props.navigator.pop();
  51. }
  52. onPopToRootPress() {
  53. this.props.navigator.popToRoot();
  54. }
  55. onResetToPress() {
  56. this.props.navigator.resetTo({
  57. title: "New Root",
  58. container: "com.example.ThirdTabScreen"
  59. });
  60. }
  61. }
  62. const styles = StyleSheet.create({
  63. container: {
  64. flex: 1,
  65. padding: 20,
  66. backgroundColor: 'white'
  67. },
  68. button: {
  69. textAlign: 'center',
  70. fontSize: 18,
  71. marginBottom: 10,
  72. marginTop:10,
  73. color: 'blue'
  74. }
  75. });