ListViewV2.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. import Button from '../../components/Button';
  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 style={ui.flexc}>
  38. <TextView style={[styles.infoStatus, styles.available]}>{item.distance}</TextView>
  39. {item.allConnector && item.allConnector.available > 0 &&
  40. <TextView style={[styles.infoStatus, styles.available]}>{$t('charging.statusAvailable')}</TextView>
  41. }
  42. {item.siteType == "Private" &&
  43. <TextView style={[styles.infoStatus, styles.private]}>{$t('home.statusPrivate')}</TextView>
  44. }
  45. </View>
  46. </View>
  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. </View>
  80. </View>
  81. </Button>
  82. );
  83. } else {
  84. return <></>;
  85. }
  86. }
  87. const styles = StyleSheet.create({
  88. itemView: {
  89. borderRadius: 0,
  90. flexDirection: 'row',
  91. borderBottomWidth: 1,
  92. borderBottomColor: '#eee',
  93. backgroundColor: pageBackground
  94. },
  95. itemContent: {
  96. flex: 1,
  97. padding: 16,
  98. flexDirection: 'row'
  99. },
  100. stationInfo: {
  101. flex: 1,
  102. paddingLeft: 0
  103. },
  104. nameView: {
  105. paddingTop: 3,
  106. alignItems: 'center',
  107. flexDirection: 'row'
  108. },
  109. stationName: {
  110. color: textPrimary,
  111. fontSize: 16,
  112. fontWeight: 'bold'
  113. },
  114. stationAddress: {
  115. color: textCancel,
  116. fontSize: 14,
  117. paddingTop: 4,
  118. paddingBottom: 4
  119. },
  120. infoStatus: {
  121. fontSize: 12,
  122. borderRadius: 3,
  123. marginRight: 5,
  124. borderWidth: 1,
  125. ...$padding(3, 8, 2)
  126. },
  127. selected: {
  128. color: textPrimary,
  129. borderColor: colorAccent
  130. },
  131. available: {
  132. color: '#90DB0A',
  133. borderColor: '#90DB0A'
  134. },
  135. unavailable: {
  136. color: '#999',
  137. fontSize: 10.5,
  138. paddingTop: 7,
  139. paddingLeft: 9,
  140. paddingRight: 9,
  141. paddingBottom: 7,
  142. backgroundColor: '#CCC'
  143. },
  144. private: {
  145. color: '#FDB702',
  146. borderColor: '#FDB702'
  147. },
  148. connectView: {
  149. paddingTop: 4,
  150. paddingBottom: 8,
  151. alignItems: 'center',
  152. flexDirection: 'row'
  153. },
  154. connectType: {
  155. borderWidth: 1,
  156. borderColor: textPrimary,
  157. borderRadius: 3,
  158. marginRight: 16,
  159. alignItems: 'center',
  160. flexDirection: 'row',
  161. },
  162. directView: {
  163. zIndex: 1,
  164. width: 32,
  165. height: 32,
  166. marginTop: 4,
  167. marginLeft: 8,
  168. alignItems: 'center'
  169. },
  170. distanceText: {
  171. color: textPrimary,
  172. fontSize: 12,
  173. paddingTop: 2
  174. },
  175. directIconView: {
  176. zIndex: 1,
  177. width: 32,
  178. height: 32,
  179. marginTop: 4,
  180. marginLeft: 16,
  181. borderRadius: 45,
  182. alignItems: 'center',
  183. justifyContent: 'center',
  184. backgroundColor: colorAccent
  185. },
  186. })