ListViewV2.js 5.9 KB

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