react-native-navigation的迁移库

PushedScreen.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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={{flex: 1, padding: 20}}>
  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. screen: "example.PushedScreen"
  41. });
  42. }
  43. onPushStyledPress() {
  44. this.props.navigator.push({
  45. title: "More",
  46. screen: "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. screen: "example.PushedScreen"
  59. });
  60. }
  61. }
  62. const styles = StyleSheet.create({
  63. button: {
  64. textAlign: 'center',
  65. fontSize: 18,
  66. marginBottom: 10,
  67. marginTop:10,
  68. color: 'blue'
  69. }
  70. });