react-native-navigation的迁移库

TopTabOptionsScreen.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. textColor: 'black',
  11. textFontSize: 16,
  12. textFontFamily: 'HelveticaNeue-Italic'
  13. }
  14. };
  15. }
  16. constructor(props) {
  17. super(props);
  18. this.onClickDynamicOptions = this.onClickDynamicOptions.bind(this);
  19. }
  20. render() {
  21. return (
  22. <View style={styles.root}>
  23. <Text style={styles.h1}>{this.props.text || 'Top Tab Screen'}</Text>
  24. <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
  25. <Button title='Dynamic Options' testID={testIDs.DYNAMIC_OPTIONS_BUTTON} onPress={this.onClickDynamicOptions} />
  26. </View>
  27. );
  28. }
  29. onClickDynamicOptions() {
  30. Navigation.setOptions(this.props.componentId, {
  31. topBar: {
  32. title: 'Dynamic Title',
  33. textColor: '#00FFFF',
  34. largeTitle: false,
  35. buttonColor: 'red',
  36. textFontSize: 20,
  37. textFontFamily: 'HelveticaNeue-CondensedBold'
  38. }
  39. });
  40. }
  41. }
  42. const styles = {
  43. root: {
  44. flexGrow: 1,
  45. justifyContent: 'center',
  46. alignItems: 'center',
  47. backgroundColor: '#f5fcff'
  48. },
  49. h1: {
  50. fontSize: 24,
  51. textAlign: 'center',
  52. margin: 10
  53. },
  54. h2: {
  55. fontSize: 12,
  56. textAlign: 'center',
  57. margin: 10
  58. },
  59. footer: {
  60. fontSize: 10,
  61. color: '#888',
  62. marginTop: 10
  63. }
  64. };
  65. module.exports = TopTabOptionsScreen;