ListViewV2.js 4.7 KB

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