react-native-navigation的迁移库

TopTabOptionsScreen.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const React = require('react');
  2. const { PureComponent } = require('react');
  3. const testIDs = require('../testIDs');
  4. const { View, Text, Button } = require('react-native');
  5. const { Navigation } = require('react-native-navigation');
  6. class TopTabOptionsScreen extends PureComponent {
  7. static options() {
  8. return {
  9. topBar: {
  10. title: {
  11. color: 'black',
  12. fontSize: 16,
  13. fontFamily: 'HelveticaNeue-Italic'
  14. }
  15. }
  16. };
  17. }
  18. constructor(props) {
  19. super(props);
  20. this.onClickDynamicOptions = this.onClickDynamicOptions.bind(this);
  21. }
  22. render() {
  23. return (
  24. <View style={styles.root}>
  25. <Text style={styles.h1}>{this.props.text || 'Top Tab Screen'}</Text>
  26. <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
  27. <Button title='Dynamic Options' testID={testIDs.DYNAMIC_OPTIONS_BUTTON} onPress={this.onClickDynamicOptions} />
  28. </View>
  29. );
  30. }
  31. onClickDynamicOptions() {
  32. Navigation.mergeOptions(this.props.componentId, {
  33. topBar: {
  34. title: {
  35. text: 'Dynamic Title',
  36. color: '#00FFFF',
  37. fontSize: 16,
  38. fontFamily: 'HelveticaNeue-CondensedBold'
  39. },
  40. largeTitle: {
  41. visible: false,
  42. },
  43. buttonColor: 'red',
  44. }
  45. });
  46. }
  47. }
  48. const styles = {
  49. root: {
  50. flexGrow: 1,
  51. justifyContent: 'center',
  52. alignItems: 'center',
  53. backgroundColor: '#f5fcff'
  54. },
  55. h1: {
  56. fontSize: 24,
  57. textAlign: 'center',
  58. margin: 10
  59. },
  60. h2: {
  61. fontSize: 12,
  62. textAlign: 'center',
  63. margin: 10
  64. },
  65. footer: {
  66. fontSize: 10,
  67. color: '#888',
  68. marginTop: 10
  69. }
  70. };
  71. module.exports = TopTabOptionsScreen;