BottomSiteInfo.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /**
  2. * 地图底部充电站信息组件
  3. * @邠心vbe on 2022/12/23
  4. */
  5. import React from 'react';
  6. import { Pressable, StyleSheet, View, Text } from 'react-native';
  7. import { ElevationObject } from '../../../components/Button';
  8. import utils from '../../../utils/utils';
  9. import { ChargeStyle } from '../../charge/Charging';
  10. import { PageList } from '../../Router';
  11. import ConnectType from '../../search/ConnectType';
  12. import app from '../../../../app.json';
  13. export default BottomSiteInfo = ({stationInfo = {}, onFavorite}) => {
  14. const getAvailable = (type) => {
  15. const all = stationInfo.allConnector;
  16. if (all) {
  17. if (type == 'box') {
  18. return all.boxAvailable + '/' + all.boxAll;
  19. } else {
  20. return all.available + '/' + all.all;
  21. }
  22. } else {
  23. return '0/0';
  24. }
  25. }
  26. const getOperatingHours = () => {
  27. if (stationInfo.endlessService) {
  28. return "24/7";
  29. } else if (stationInfo.operatingHours) {
  30. return stationInfo.operatingHours;
  31. } else {
  32. return $t('charging.toBeUpdated');
  33. }
  34. }
  35. const getParkingFee = () => {
  36. if (stationInfo.parkingFeeFree) {
  37. return $t('charging.free');
  38. } else if (stationInfo.parkingFee) {
  39. return stationInfo.parkingFee;
  40. } else {
  41. return $t('charging.toBeUpdated');
  42. }
  43. }
  44. const toChargePage = () => {
  45. startPage(PageList.chargeDetailPage, {stationInfo: stationInfo, action: 'view', from: PageList.home})
  46. }
  47. if (stationInfo.id) {
  48. return (
  49. <View style={styles.stationBarView}>
  50. <View style={ui.flexc}>
  51. <Pressable
  52. style={styles.stationInfo}
  53. //onPress={() => startPage(PageList.chargeDetail, {stationInfo: stationInfo, action: 'view'})}}
  54. onPress={toChargePage}>
  55. <Text
  56. ellipsizeMode='tail'
  57. numberOfLines={1}
  58. style={styles.stationTitle}>{stationInfo.name}</Text>
  59. <Text
  60. style={styles.stationAddress}
  61. ellipsizeMode='tail'
  62. numberOfLines={2}>{stationInfo.address}</Text>
  63. </Pressable>
  64. {/* <View style={styles.stationAvailable}>
  65. <Image
  66. style={styles.availableIcon}
  67. source={require('../../../images/charge/icon-type-stops.png')}/>
  68. <Text style={styles.availableText}>{getAvailable('box')}</Text>
  69. </View>
  70. <View style={styles.stationAvailable}>
  71. <Image
  72. style={styles.availableIcon}
  73. source={require('../../../images/charge/icon-type-interfaces.png')}/>
  74. <Text style={styles.availableText}>{getAvailable('inc')}</Text>
  75. </View> */}
  76. { app.modules.bookmarks &&
  77. <Pressable
  78. style={[styles.directIconView, {backgroundColor: stationInfo.favorite ? colorPrimary : colorCancel}]}
  79. android_ripple={rippleLess}
  80. onPress={onFavorite}>
  81. <MaterialIcons
  82. name="star"
  83. size={26}
  84. color={colorLight}/>
  85. </Pressable>
  86. }
  87. <Pressable
  88. style={styles.directIconView}
  89. android_ripple={rippleLess}
  90. onPress={() => {
  91. utils.directMaps(stationInfo.latitude, stationInfo.longitude, stationInfo.address);
  92. }}>
  93. <MaterialCommunityIcons
  94. name="navigation-variant"
  95. size={25}
  96. color={colorLight}/>
  97. {/* <MaterialIcons
  98. name='directions'
  99. size={28}
  100. color={colorAccent}/>
  101. <Text style={styles.distanceText}>{stationInfo.distance}</Text> */}
  102. </Pressable>
  103. </View>
  104. <View style={ui.flex}>
  105. <View style={styles.connectView}>
  106. <ConnectType {...stationInfo?.acConnector}/>
  107. <ConnectType {...stationInfo?.dcConnector}/>
  108. </View>
  109. <View style={styles.stationStatusView}>
  110. { (stationInfo.allConnector && stationInfo.allConnector.available > 0) &&
  111. <Text style={[ChargeStyle.infoStatus, ChargeStyle.statusAvailable, styles.stationStatus]}>{$t("charging.statusAvailable")}</Text>
  112. }
  113. <Text style={[ChargeStyle.infoStatus, stationInfo.siteType == 'Public' ? ChargeStyle.statusAvailable : ChargeStyle.statusWarning, styles.siteTypes]}>{stationInfo.siteType}</Text>
  114. </View>
  115. </View>
  116. <View style={styles.divideLine}></View>
  117. <Pressable
  118. style={styles.infoDetailsView}
  119. onPress={toChargePage}>
  120. <View style={ui.flex1}>
  121. <Text style={styles.infoTitle}>{$t("charging.operatingHours")}</Text>
  122. <View style={styles.infoView}>
  123. <Text style={styles.infoText}>{getOperatingHours()}</Text>
  124. </View>
  125. </View>
  126. <View style={{width: 4}}></View>
  127. <View style={ui.flex1}>
  128. <Text style={styles.infoTitle}>{$t("charging.parkingFees")}</Text>
  129. <View style={styles.infoView}>
  130. <Text style={styles.infoText}>{getParkingFee()}</Text>
  131. </View>
  132. </View>
  133. <View style={{width: 4}}></View>
  134. <View style={ui.flex1}>
  135. <Text style={styles.infoTitle}>{$t("charging.additionalInfo")}</Text>
  136. <View style={styles.infoView}>
  137. <Text style={styles.infoText}>{stationInfo?.additionalNotes}</Text>
  138. </View>
  139. </View>
  140. </Pressable>
  141. </View>
  142. );
  143. } else {
  144. return <></>;
  145. }
  146. }
  147. const styles = StyleSheet.create({
  148. stationBarView: {
  149. left: 16,
  150. right: 16,
  151. bottom: 48,
  152. zIndex: 10,
  153. borderRadius: 6,
  154. ...$padding(12, 9),
  155. position: 'absolute',
  156. backgroundColor: colorLight,
  157. ...ElevationObject(3)
  158. },
  159. stationInfo: {
  160. flex: 1,
  161. height: 45,
  162. paddingLeft: 4,
  163. paddingRight: 8,
  164. justifyContent: 'space-around'
  165. },
  166. stationTitle: {
  167. color: '#000',
  168. fontSize: 16,
  169. paddingBottom: 4
  170. },
  171. stationAddress: {
  172. color: '#999',
  173. fontSize: 12,
  174. },
  175. stationAvailable: {
  176. height: 45,
  177. paddingLeft: 8,
  178. paddingRight: 8,
  179. alignItems: 'center',
  180. justifyContent: 'space-between'
  181. },
  182. stationStatusView: {
  183. marginRight: 4,
  184. alignItems: 'center',
  185. flexDirection: 'row-reverse'
  186. },
  187. stationStatus: {
  188. fontSize: 10,
  189. ...$padding(2, 6)
  190. },
  191. siteTypes: {
  192. fontSize: 10,
  193. marginTop: 0,
  194. marginRight: 4,
  195. ...$padding(2, 6)
  196. },
  197. availableIcon: {
  198. width: 23,
  199. height: 23,
  200. },
  201. availableText: {
  202. color: textPrimary,
  203. fontSize: 13,
  204. textAlign: 'center'
  205. },
  206. directView: {
  207. zIndex: 1,
  208. height: 45,
  209. marginLeft: 8,
  210. marginRight: 4,
  211. alignItems: 'center',
  212. justifyContent: 'space-between'
  213. },
  214. distanceText: {
  215. color: textPrimary,
  216. fontSize: 12,
  217. },
  218. directIconView: {
  219. zIndex: 1,
  220. width: 42,
  221. height: 42,
  222. marginLeft: 8,
  223. marginRight: 8,
  224. borderRadius: 45,
  225. alignItems: 'center',
  226. justifyContent: 'center',
  227. backgroundColor: colorAccent,
  228. ...ElevationObject(2)
  229. },
  230. connectView: {
  231. flex: 1,
  232. paddingTop: 12,
  233. paddingBottom: 12,
  234. alignItems: 'center',
  235. flexDirection: 'row'
  236. },
  237. divideLine: {
  238. height: 1,
  239. backgroundColor: '#AEAEAE'
  240. },
  241. infoDetailsView: {
  242. flexDirection: 'row'
  243. },
  244. infoTitle: {
  245. color: '#000',
  246. fontSize: 12,
  247. fontWeight: 'bold',
  248. ...$padding(8, 0, 8)
  249. },
  250. infoView: {
  251. paddingBottom: 8
  252. },
  253. infoText: {
  254. color: '#444',
  255. fontSize: 10
  256. }
  257. })