ListViewV3.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /**
  2. * V3版搜索列表复用组件
  3. * @邠心vbe on 2024/05/11
  4. */
  5. import React from 'react';
  6. import { Pressable, StyleSheet, View, Text } from 'react-native';
  7. import TextView from '../../components/TextView';
  8. import utils from '../../utils/utils';
  9. import ConnectType, { ConnectTypeV2 } from './ConnectType';
  10. import app from '../../../app.json';
  11. import Button from '../../components/Button';
  12. import SiteLabelView from '../../components/SiteLabelView';
  13. export default ListViewV3 = ({item, index, separators, onPress, onFavorite}) => {
  14. if (item.id) {
  15. return (
  16. <Button
  17. style={styles.itemView}
  18. viewStyle={styles.itemContent}
  19. key={index}
  20. onClick={onPress}
  21. android_ripple={ripple}>
  22. <View style={styles.stationInfo} >
  23. <TextView style={styles.stationName}>{item.name}</TextView>
  24. <View style={ui.flex}>
  25. <View style={ui.flex1}>
  26. <TextView style={styles.stationAddress}>{item.address}</TextView>
  27. <View style={ui.flexc}>
  28. <TextView style={[styles.siteTypes, item.siteType != "Public" ? styles.private : {}]}>{item.siteType}</TextView>
  29. { (item.allConnector && item.allConnector.available > 0) &&
  30. <TextView style={styles.stationAvailable}>
  31. <MaterialCommunityIcons
  32. name="circle"
  33. size={10}
  34. color={colorAccent}/>
  35. <Text> </Text>
  36. {$t("charging.statusAvailable")}
  37. </TextView>
  38. }
  39. <TextView style={styles.distance}>{item.distance}</TextView>
  40. <ConnectTypeV2 {...item?.acConnector}/>
  41. <ConnectTypeV2 {...item?.dcConnector}/>
  42. </View>
  43. </View>
  44. {/* item.upcoming
  45. ? <View style={[ui.center, $margin(0, 8)]}>
  46. <MaterialIcons
  47. name="upcoming"
  48. size={42}
  49. color={colorAccent}
  50. style={styles.upcomingIcon} />
  51. <TextView style={styles.upcomingText}>{$t("home.upcoming")}</TextView>
  52. </View>
  53. : <>
  54. { app.modules.bookmarks &&
  55. <Pressable
  56. style={[styles.directIconView, {backgroundColor: item.favorite ? colorPrimary : colorCancel}]}
  57. android_ripple={rippleLess}
  58. onPress={onFavorite}>
  59. <MaterialIcons
  60. name="star"
  61. size={22}
  62. color={colorLight}/>
  63. </Pressable>
  64. }
  65. <Pressable
  66. style={styles.directIconView}
  67. android_ripple={rippleLess}
  68. onPress={() => {
  69. utils.directMaps(item.latitude, item.longitude, item.address);
  70. }}>
  71. <MaterialCommunityIcons
  72. name="navigation-variant"
  73. size={22}
  74. color={colorLight}/>
  75. </Pressable>
  76. </> */}
  77. </View>
  78. {/* <View style={styles.labelRows}>
  79. {/* item.allConnector && item.allConnector.available > 0 &&
  80. <TextView style={[styles.infoStatus, styles.available]}>{$t('charging.statusAvailable')}</TextView>
  81. *}
  82. { utils.isNotEmpty(item?.labels) &&
  83. item?.labels.map((label, idx) =>
  84. <SiteLabelView {...label} key={idx} version={2}/>
  85. )
  86. }
  87. </View> */}
  88. </View>
  89. </Button>
  90. );
  91. } else {
  92. return <></>;
  93. }
  94. }
  95. const styles = StyleSheet.create({
  96. itemView: {
  97. borderRadius: 0,
  98. flexDirection: 'row',
  99. borderBottomWidth: 1,
  100. borderBottomColor: '#F6F6F6',
  101. backgroundColor: pageBackground
  102. },
  103. itemContent: {
  104. flex: 1,
  105. ...$padding(12, 16),
  106. flexDirection: 'row'
  107. },
  108. stationInfo: {
  109. flex: 1,
  110. paddingLeft: 12
  111. },
  112. siteIconView: {
  113. width: 38,
  114. height: 38,
  115. alignItems: 'center',
  116. justifyContent: 'center',
  117. borderWidth: 1,
  118. borderColor: colorPrimary,
  119. borderRadius: 38
  120. },
  121. nameView: {
  122. paddingTop: 3,
  123. alignItems: 'center',
  124. flexDirection: 'row'
  125. },
  126. stationName: {
  127. color: textPrimary,
  128. fontSize: 16,
  129. fontWeight: 'bold'
  130. },
  131. stationAddress: {
  132. color: textSecondary,
  133. fontSize: 14,
  134. paddingTop: 4,
  135. paddingBottom: 6
  136. },
  137. siteTypes: {
  138. color: textLight,
  139. height: 20,
  140. fontSize: 12,
  141. marginRight: 6,
  142. borderRadius: 30,
  143. ...$padding(0, 10),
  144. backgroundColor: colorAccent
  145. },
  146. stationAvailable: {
  147. color: textPrimary,
  148. height: 20,
  149. fontSize: 12,
  150. marginRight: 6,
  151. borderRadius: 30,
  152. borderWidth: 1,
  153. borderColor: colorAccent,
  154. ...$padding(0, 8, 0, 4)
  155. },
  156. labelRows: {
  157. paddingTop: 4,
  158. flexWrap: 'wrap',
  159. alignItems: 'center',
  160. flexDirection: 'row'
  161. },
  162. infoStatus: {
  163. height: 22,
  164. fontSize: 12,
  165. borderRadius: 3,
  166. marginRight: 5,
  167. marginBottom: 5,
  168. borderWidth: 1,
  169. ...$padding(0, 8)
  170. },
  171. selected: {
  172. color: textPrimary,
  173. borderColor: colorAccent
  174. },
  175. distance: {
  176. fontSize: 12,
  177. color: textLight,
  178. height: 20,
  179. fontSize: 10,
  180. marginRight: 6,
  181. borderRadius: 30,
  182. ...$padding(0, 10),
  183. backgroundColor: textPrimary
  184. },
  185. available: {
  186. color: '#90DB0A',
  187. borderColor: '#90DB0A'
  188. },
  189. unavailable: {
  190. color: '#999',
  191. fontSize: 10.5,
  192. paddingTop: 7,
  193. paddingLeft: 9,
  194. paddingRight: 9,
  195. paddingBottom: 7,
  196. backgroundColor: '#CCC'
  197. },
  198. private: {
  199. backgroundColor: '#FDB702'
  200. },
  201. connectView: {
  202. paddingTop: 4,
  203. paddingBottom: 8,
  204. alignItems: 'center',
  205. flexDirection: 'row'
  206. },
  207. connectType: {
  208. borderWidth: 1,
  209. borderColor: textPrimary,
  210. borderRadius: 3,
  211. marginRight: 16,
  212. alignItems: 'center',
  213. flexDirection: 'row',
  214. },
  215. directView: {
  216. zIndex: 1,
  217. width: 32,
  218. height: 32,
  219. marginTop: 4,
  220. marginLeft: 8,
  221. alignItems: 'center'
  222. },
  223. distanceText: {
  224. color: textPrimary,
  225. fontSize: 12,
  226. paddingTop: 2
  227. },
  228. directIconView: {
  229. zIndex: 1,
  230. width: 32,
  231. height: 32,
  232. marginTop: 4,
  233. marginLeft: 16,
  234. borderRadius: 45,
  235. alignItems: 'center',
  236. justifyContent: 'center',
  237. backgroundColor: colorAccent
  238. },
  239. upcomingIcon: {
  240. marginLeft: 8,
  241. opacity: .3
  242. },
  243. upcomingText: {
  244. color: colorAccent,
  245. fontSize: 10,
  246. opacity: .3,
  247. marginLeft: 8,
  248. marginTop: -3
  249. }
  250. })