ItemArticle.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * 文章渲染项目组件
  3. * @邠心vbe on 2023/10/24
  4. */
  5. import React from 'react';
  6. import { Image, Pressable, StyleSheet, View } from 'react-native';
  7. import TextView from '../../components/TextView';
  8. import utils from '../../utils/utils';
  9. export default ItemArticle = ({item, index, separators, onPress}) => {
  10. return (
  11. <Pressable
  12. style={item.readStatus ? styles.notyItemView : styles.unotyItemView}
  13. onPress={onPress}
  14. android_ripple={ripple}>
  15. <View style={ui.center}>
  16. <Image
  17. source={{uri: utils.getImageUrl(item.articleImages[0].articleImagePath)}}
  18. resizeMode="cover"
  19. style={styles.articleImage}/>
  20. <View style={ui.flexc}>
  21. <MaterialCommunityIcons
  22. name="eye-check-outline"
  23. size={13}
  24. color={textPrimary}/>
  25. <TextView
  26. style={styles.textView}
  27. numberOfLines={1}>
  28. {item.articleViews}
  29. </TextView>
  30. </View>
  31. </View>
  32. <View style={styles.itemContent}>
  33. <TextView
  34. style={styles.textTitle}
  35. numberOfLines={1}
  36. ellipsizeMode="tail">
  37. {item.articleTitle}
  38. </TextView>
  39. <TextView
  40. style={styles.textDate}
  41. numberOfLines={1}>
  42. <MaterialCommunityIcons
  43. name="clock-time-four-outline"
  44. size={10}
  45. style={styles.textDate}/>
  46. {" " + item.createTime}
  47. </TextView>
  48. <View style={ui.flex}>
  49. <TextView
  50. style={styles.labelTypeText}
  51. numberOfLines={1}>
  52. {item.articleTypeName}
  53. </TextView>
  54. </View>
  55. <TextView
  56. style={styles.textMessage}
  57. numberOfLines={4}>
  58. {item.articleContent}
  59. </TextView>
  60. </View>
  61. </Pressable>
  62. )
  63. }
  64. const styles = StyleSheet.create({
  65. notyItemView: {
  66. padding: 16,
  67. flexDirection: 'row'
  68. },
  69. unotyItemView: {
  70. padding: 16,
  71. flexDirection: 'row',
  72. backgroundColor: "#F0F0F0"
  73. },
  74. articleImage: {
  75. width: 85,
  76. height: 85,
  77. borderRadius: 6,
  78. marginRight: 16,
  79. marginBottom: 8
  80. },
  81. readIcon: {
  82. top: 2,
  83. left: -5,
  84. width: 7,
  85. height: 6,
  86. position: 'absolute'
  87. },
  88. itemContent: {
  89. flex: 1
  90. },
  91. textTitle: {
  92. color: textPrimary,
  93. fontSize: 15,
  94. fontWeight: 'bold',
  95. paddingBottom: 4
  96. },
  97. textDate: {
  98. color: textSecondary,
  99. fontSize: 10,
  100. lineHeight: 10,
  101. paddingBottom: 4
  102. },
  103. textView: {
  104. color: textPrimary,
  105. fontSize: 11,
  106. lineHeight: 12,
  107. paddingLeft: 4,
  108. paddingRight: 16
  109. },
  110. labelTypeText: {
  111. fontSize: 10,
  112. borderWidth: 1,
  113. borderRadius: 4,
  114. borderColor: colorPrimary,
  115. ...$padding(2, 6)
  116. },
  117. unread: {
  118. fontWeight: 'bold'
  119. },
  120. textMessage: {
  121. color: textPrimary,
  122. fontSize: 12,
  123. paddingTop: 2
  124. }
  125. })