react-native-navigation的迁移库

TopBarBackground.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const React = require('react');
  2. const { Component } = require('react');
  3. const {
  4. StyleSheet,
  5. View
  6. } = require('react-native');
  7. const { Navigation } = require('react-native-navigation');
  8. class TopBarBackground extends Component {
  9. constructor(props) {
  10. super(props);
  11. this.subscription = Navigation.events().bindComponent(this);
  12. this.state = {};
  13. this.dots = new Array(55).fill('').map((ignored, i) => <View key={'dot' + i} style={[styles.dot, {backgroundColor: this.props.color}]}/>);
  14. }
  15. componentDidAppear() {
  16. console.log('RNN', 'TBB.componentDidAppear');
  17. }
  18. componentDidDisappear() {
  19. console.log('RNN', `TBB.componentDidDisappear`);
  20. }
  21. componentDidMount() {
  22. console.log('RNN', `TBB.componentDidMount`);
  23. }
  24. componentWillUnmount() {
  25. console.log('RNN', `TBB.componentWillUnmount`);
  26. this.subscription.remove();
  27. }
  28. render() {
  29. return (
  30. <View style={styles.container}>
  31. {this.dots}
  32. </View>
  33. );
  34. }
  35. }
  36. module.exports = TopBarBackground;
  37. const styles = StyleSheet.create({
  38. container: {
  39. flex: 1,
  40. flexDirection: 'row',
  41. backgroundColor: '#EDEDED',
  42. flexWrap: 'wrap'
  43. },
  44. dot: {
  45. height: 16,
  46. width: 16,
  47. borderRadius: 8,
  48. margin: 4
  49. }
  50. });