ListViewV2.js 6.0 KB

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