TopicTitle.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * @param:
  3. * title: 标题
  4. * summary: 标题下的灰字简介
  5. * background: 背景色
  6. * tubeColor: 左边小长条背景色
  7. * ifTubeShow: 左侧icon是否显示,默认不显示 boolean
  8. */
  9. import React, { Component } from "react";
  10. import {
  11. StyleSheet,
  12. Text,
  13. View,
  14. } from "react-native";
  15. import Dimensions from '../utils/dimensions'
  16. const styles = StyleSheet.create({
  17. wrapper: {
  18. width: Dimensions.width,
  19. height: 45,
  20. paddingLeft: 14,
  21. justifyContent: "center",
  22. flexDirection: 'column',
  23. backgroundColor: 'yellow'
  24. },
  25. line1: {
  26. flex: 1,
  27. alignItems: "center",
  28. flexDirection: 'row'
  29. },
  30. line2: {
  31. // 123
  32. flex: 1
  33. },
  34. tube: {
  35. width: 4,
  36. height: 14,
  37. marginRight: 6,
  38. backgroundColor: 'red'
  39. },
  40. title: {
  41. color: '#373737',
  42. fontSize: 18
  43. },
  44. summary: {
  45. color: '#787878',
  46. fontSize: 16
  47. }
  48. })
  49. export default class TopicTitle extends Component {
  50. constructor(props) {
  51. super(props);
  52. }
  53. render() {
  54. let line2 = <View></View>;
  55. if (this.props.summary) {
  56. line2 = <View style={styles.line2}>
  57. <Text style={styles.summary}>{this.props.summary}</Text>
  58. </View>
  59. }
  60. let tube = <View></View>;
  61. if (this.props.ifTubeShow) {
  62. tube = 1
  63. }
  64. const tubeColor = this.props.tubeColor ? this.props.tubeColor : '#ffd101';
  65. return (
  66. <View
  67. style={{
  68. width: Dimensions.width,
  69. height: this.props.background ? 45 : 66,
  70. paddingLeft: 14,
  71. paddingTop: this.props.background ? 0: 20,
  72. // justifyContent: "center",
  73. flexDirection: 'column',
  74. backgroundColor: this.props.background ? this.props.background : '#fff'
  75. }}>
  76. <View
  77. style={styles.line1}>
  78. <View
  79. style={this.props.ifTubeShow ? {
  80. width: 4,
  81. height: 14,
  82. marginRight: 6,
  83. backgroundColor: tubeColor
  84. } : null}></View>
  85. <Text style={styles.title}>{this.props.title}</Text>
  86. </View>
  87. {line2}
  88. </View>
  89. );
  90. }
  91. }