ItemCampaign.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. * 活动渲染项目组件
  3. * @邠心vbe on 2023/10/25
  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. const getColorByType = (type) => {
  10. switch (type) {
  11. case "Ended":
  12. return {
  13. backgroundColor: "#E11919"
  14. }
  15. case "Upcoming":
  16. return {
  17. backgroundColor: "#FFAA2C"
  18. }
  19. }
  20. }
  21. export default ItemCampaign = ({item, index, separators, onPress}) => {
  22. return (
  23. <Pressable
  24. style={item.readStatus ? styles.notyItemView : styles.unotyItemView}
  25. onPress={onPress}
  26. android_ripple={ripple}>
  27. <View style={ui.center}>
  28. <Image
  29. source={{uri: utils.getImageUrl(item.articleImages[0].articleImagePath)}}
  30. resizeMode="cover"
  31. style={styles.articleImage}/>
  32. <View style={ui.flexc}>
  33. <MaterialCommunityIcons
  34. name="eye-check-outline"
  35. size={13}
  36. color={textPrimary}/>
  37. <TextView
  38. style={styles.textView}
  39. numberOfLines={1}>
  40. {item.articleViews}
  41. </TextView>
  42. </View>
  43. </View>
  44. <View style={styles.itemContent}>
  45. <View>
  46. <TextView
  47. style={[styles.labelTypeText, getColorByType(item.campaignMark)]}
  48. numberOfLines={1}>
  49. {item.campaignMark}
  50. </TextView>
  51. <TextView
  52. style={styles.textTitle}
  53. numberOfLines={2}
  54. ellipsizeMode="tail">
  55. <TextView
  56. style={styles.hideText}
  57. numberOfLines={1}>
  58. {item.campaignMark}
  59. </TextView>
  60. {item.articleTitle}
  61. </TextView>
  62. </View>
  63. <TextView
  64. style={styles.textDate}
  65. numberOfLines={1}>
  66. <MaterialCommunityIcons
  67. name="calendar-clock"
  68. size={12}/>
  69. {" " + item.campaignDuration}
  70. </TextView>
  71. <TextView
  72. style={styles.textMessage}
  73. numberOfLines={4}>
  74. {item.articleContent}
  75. </TextView>
  76. </View>
  77. </Pressable>
  78. )
  79. }
  80. const styles = StyleSheet.create({
  81. notyItemView: {
  82. padding: 16,
  83. flexDirection: 'row'
  84. },
  85. unotyItemView: {
  86. padding: 16,
  87. flexDirection: 'row',
  88. backgroundColor: "#F0F0F0"
  89. },
  90. articleImage: {
  91. width: 85,
  92. height: 85,
  93. borderRadius: 6,
  94. marginRight: 16,
  95. marginBottom: 8
  96. },
  97. readIcon: {
  98. top: 2,
  99. left: -5,
  100. width: 7,
  101. height: 6,
  102. position: 'absolute'
  103. },
  104. itemContent: {
  105. flex: 1
  106. },
  107. textTitle: {
  108. color: textPrimary,
  109. fontSize: 15,
  110. lineHeight: 20,
  111. fontWeight: 'bold',
  112. paddingBottom: 4,
  113. alignItems: 'center',
  114. flexDirection: 'row'
  115. },
  116. labelTypeText: {
  117. color: textLight,
  118. height: 16,
  119. fontSize: 10,
  120. borderRadius: 4,
  121. marginTop: 2,
  122. ...$padding(0, 6),
  123. position: 'absolute',
  124. backgroundColor: "#1ABD00"
  125. },
  126. hideText: {
  127. height: 16,
  128. opacity: 0,
  129. fontSize: 10,
  130. ...$padding(2, 8),
  131. },
  132. textDate: {
  133. color: textSecondary,
  134. fontSize: 11,
  135. lineHeight: 12,
  136. fontWeight: 'bold',
  137. paddingBottom: 4,
  138. alignItems: 'center',
  139. flexDirection: 'row'
  140. },
  141. textView: {
  142. color: textPrimary,
  143. fontSize: 11,
  144. lineHeight: 12,
  145. paddingLeft: 4,
  146. paddingRight: 16
  147. },
  148. unread: {
  149. fontWeight: 'bold'
  150. },
  151. textMessage: {
  152. color: textPrimary,
  153. fontSize: 12,
  154. paddingTop: 2
  155. }
  156. })