react-native-navigation的迁移库

TopTabOptionsScreen.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 get 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: false,
  41. buttonColor: 'red',
  42. }
  43. });
  44. }
  45. }
  46. const styles = {
  47. root: {
  48. flexGrow: 1,
  49. justifyContent: 'center',
  50. alignItems: 'center',
  51. backgroundColor: '#f5fcff'
  52. },
  53. h1: {
  54. fontSize: 24,
  55. textAlign: 'center',
  56. margin: 10
  57. },
  58. h2: {
  59. fontSize: 12,
  60. textAlign: 'center',
  61. margin: 10
  62. },
  63. footer: {
  64. fontSize: 10,
  65. color: '#888',
  66. marginTop: 10
  67. }
  68. };
  69. module.exports = TopTabOptionsScreen;